From c8f16e9c718af9a7207f5e6ad5bcb5c4ab5bbecf Mon Sep 17 00:00:00 2001 From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137> Date: Sat, 18 Jul 2009 20:14:38 +0000 Subject: [PATCH] Remove CVS Id strings from '-V, --version' output. git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@2848 4ea69e1a-61f1-4043-bf83-b5c94c648137 --- smartmontools/CHANGELOG | 2 + smartmontools/smartctl.8.in | 6 +-- smartmontools/smartctl.cpp | 57 +++------------------- smartmontools/smartd.8.in | 7 ++- smartmontools/smartd.cpp | 94 +++-------------------------------- smartmontools/utility.cpp | 97 +++++++++++++------------------------ smartmontools/utility.h | 11 ++--- 7 files changed, 58 insertions(+), 216 deletions(-) diff --git a/smartmontools/CHANGELOG b/smartmontools/CHANGELOG index 92d3f1075..426341b01 100644 --- a/smartmontools/CHANGELOG +++ b/smartmontools/CHANGELOG @@ -42,6 +42,8 @@ NOTES FOR FUTURE RELEASES: see TODO file. <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE> + [CF] Remove CVS Id strings from '-V, --version' output. + [CF] Update CONTRIBUTORS section on man pages. [CF] Makefile.am: 'make maintainer-clean' now removes also files diff --git a/smartmontools/smartctl.8.in b/smartmontools/smartctl.8.in index a788be159..0d05ce8c4 100644 --- a/smartmontools/smartctl.8.in +++ b/smartmontools/smartctl.8.in @@ -154,9 +154,9 @@ to see the available options. Prints a usage message to STDOUT and exits. .TP .B \-V, \-\-version, \-\-copyright, \-\-license -Prints version, copyright, license, home page and CVS\-id information -for your copy of \fBsmartctl\fP to STDOUT and then exits. Please -include this information if you are reporting bugs or problems. +Prints version, copyright, license, home page and SVN revision +information for your copy of \fBsmartctl\fP to STDOUT and then exits. +Please include this information if you are reporting bugs or problems. .TP .B \-i, \-\-info Prints the device model number, serial number, firmware version, and diff --git a/smartmontools/smartctl.cpp b/smartmontools/smartctl.cpp index 2bc5ff5f5..c49573ba1 100644 --- a/smartmontools/smartctl.cpp +++ b/smartmontools/smartctl.cpp @@ -56,60 +56,16 @@ #include "smartctl.h" #include "utility.h" -#ifdef NEED_SOLARIS_ATA_CODE -extern const char *os_solaris_ata_s_cvsid; -#endif -#ifdef _HAVE_CCISS -extern const char *cciss_c_cvsid; -#endif -extern const char *atacmdnames_c_cvsid, *atacmds_c_cvsid, *ataprint_c_cvsid, *knowndrives_c_cvsid, *os_XXXX_c_cvsid, *scsicmds_c_cvsid, *scsiprint_c_cvsid, *utility_c_cvsid; -const char* smartctl_c_cvsid="$Id: smartctl.cpp,v 1.204 2009/07/07 19:28:29 chrfranke Exp $" -ATACMDS_H_CVSID ATAPRINT_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID KNOWNDRIVES_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; +const char * smartctl_cpp_cvsid = "$Id$" + CONFIG_H_CVSID EXTERN_H_CVSID SMARTCTL_H_CVSID; // This is a block containing all the "control variables". We declare // this globally in this file, and externally in other files. smartmonctrl *con=NULL; -void printslogan(){ - pout("%s\n", format_version_info("smartctl")); -} - -void PrintOneCVS(const char *a_cvs_id){ - char out[CVSMAXLEN]; - printone(out,a_cvs_id); - pout("%s",out); - return; -} - -void printcopy(){ - const char *configargs=strlen(SMARTMONTOOLS_CONFIGURE_ARGS)?SMARTMONTOOLS_CONFIGURE_ARGS:"[no arguments given]"; - - pout("smartctl comes with ABSOLUTELY NO WARRANTY. This\n"); - pout("is free software, and you are welcome to redistribute it\n"); - pout("under the terms of the GNU General Public License Version 2.\n"); - pout("See http://www.gnu.org for further details.\n\n"); - pout("CVS version IDs of files used to build this code are:\n"); - PrintOneCVS(atacmdnames_c_cvsid); - PrintOneCVS(atacmds_c_cvsid); - PrintOneCVS(ataprint_c_cvsid); -#ifdef _HAVE_CCISS - PrintOneCVS(cciss_c_cvsid); -#endif - PrintOneCVS(knowndrives_c_cvsid); - PrintOneCVS(os_XXXX_c_cvsid); -#ifdef NEED_SOLARIS_ATA_CODE - PrintOneCVS(os_solaris_ata_s_cvsid); -#endif - PrintOneCVS(scsicmds_c_cvsid); - PrintOneCVS(scsiprint_c_cvsid); - PrintOneCVS(smartctl_c_cvsid); - PrintOneCVS(utility_c_cvsid); - pout("\nsmartmontools release " PACKAGE_VERSION " dated " SMARTMONTOOLS_RELEASE_DATE " at " SMARTMONTOOLS_RELEASE_TIME "\n"); - pout("smartmontools build host: " SMARTMONTOOLS_BUILD_HOST "\n"); - pout("smartmontools build configured: " SMARTMONTOOLS_CONFIGURE_DATE "\n"); - pout("smartctl compile dated " __DATE__ " at "__TIME__ "\n"); - pout("smartmontools configure arguments: %s\n", configargs); - return; +static void printslogan() +{ + pout("%s\n", format_version_info("smartctl").c_str()); } void UsageSummary(){ @@ -329,8 +285,7 @@ const char * parse_options(int argc, char** argv, switch (optchar){ case 'V': con->dont_print = false; - printslogan(); - printcopy(); + pout("%s", format_version_info("smartctl", true /*full*/).c_str()); EXIT(0); break; case 'q': diff --git a/smartmontools/smartd.8.in b/smartmontools/smartd.8.in index ae2bd2e4d..4bc1eaa30 100644 --- a/smartmontools/smartd.8.in +++ b/smartmontools/smartd.8.in @@ -404,10 +404,9 @@ See NOTES below for details. .TP .B \-V, \-\-version, \-\-license, \-\-copyright -Prints license, copyright, and CVS version information onto -STDOUT and then exits. Please include this information if you are -reporting bugs, or have specific questions about the behavior of -\fBsmartd\fP. +Prints version, copyright, license, home page and SVN revision +information for your copy of \fBsmartd\fP to STDOUT and then exits. +Please include this information if you are reporting bugs or problems. .SH EXAMPLES diff --git a/smartmontools/smartd.cpp b/smartmontools/smartd.cpp index f0f693d37..4bc516ef0 100644 --- a/smartmontools/smartd.cpp +++ b/smartmontools/smartd.cpp @@ -123,42 +123,11 @@ extern "C" int getdomainname(char *, int); // no declaration in header files! #define ARGUSED(x) ((void)(x)) -// These are CVS identification information for *.cpp and *.h files -extern const char *atacmdnames_c_cvsid, *atacmds_c_cvsid, - *knowndrives_c_cvsid, *os_XXXX_c_cvsid, *scsicmds_c_cvsid, *utility_c_cvsid; - -#ifdef _HAVE_CCISS -extern const char *cciss_c_cvsid; -#endif -#ifdef NEED_SOLARIS_ATA_CODE -extern const char *os_solaris_ata_s_cvsid; -#endif -#ifdef _WIN32 -extern const char *daemon_win32_c_cvsid, *hostname_win32_c_cvsid, *syslog_win32_c_cvsid; -#endif -const char *smartd_c_cvsid="$Id: smartd.cpp,v 1.451 2009/07/10 23:01:56 chrfranke Exp $" -ATACMDS_H_CVSID CONFIG_H_CVSID -#ifdef DAEMON_WIN32_H_CVSID -DAEMON_WIN32_H_CVSID -#endif -EXTERN_H_CVSID INT64_H_CVSID -#ifdef HOSTNAME_WIN32_H_CVSID -HOSTNAME_WIN32_H_CVSID -#endif -KNOWNDRIVES_H_CVSID SCSICMDS_H_CVSID -#ifdef SYSLOG_H_CVSID -SYSLOG_H_CVSID -#endif -UTILITY_H_CVSID; +const char * smartd_cpp_cvsid = "$Id$" + CONFIG_H_CVSID EXTERN_H_CVSID; extern const char *reportbug; -// GNU copyleft statement. Needed for GPL purposes. -const char *copyleftstring="smartd comes with ABSOLUTELY NO WARRANTY. This is\n" - "free software, and you are welcome to redistribute it\n" - "under the terms of the GNU General Public License\n" - "Version 2. See http://www.gnu.org for further details.\n\n"; - extern unsigned char debugmode; // smartd exit codes @@ -707,48 +676,6 @@ static void write_all_dev_states(const dev_config_vector & configs, } } - -void PrintOneCVS(const char *a_cvs_id){ - char out[CVSMAXLEN]; - printone(out,a_cvs_id); - PrintOut(LOG_INFO,"%s",out); - return; -} - -// prints CVS identity information for the executable -void PrintCVS(void){ - const char *configargs=strlen(SMARTMONTOOLS_CONFIGURE_ARGS)?SMARTMONTOOLS_CONFIGURE_ARGS:"[no arguments given]"; - - PrintOut(LOG_INFO,"%s", (char *)copyleftstring); - PrintOut(LOG_INFO,"CVS version IDs of files used to build this code are:\n"); - PrintOneCVS(atacmdnames_c_cvsid); - PrintOneCVS(atacmds_c_cvsid); -#ifdef _HAVE_CCISS - PrintOneCVS(cciss_c_cvsid); -#endif -#ifdef _WIN32 - PrintOneCVS(daemon_win32_c_cvsid); - PrintOneCVS(hostname_win32_c_cvsid); -#endif - PrintOneCVS(knowndrives_c_cvsid); - PrintOneCVS(os_XXXX_c_cvsid); -#ifdef NEED_SOLARIS_ATA_CODE - PrintOneCVS( os_solaris_ata_s_cvsid); -#endif - PrintOneCVS(scsicmds_c_cvsid); - PrintOneCVS(smartd_c_cvsid); -#ifdef _WIN32 - PrintOneCVS(syslog_win32_c_cvsid); -#endif - PrintOneCVS(utility_c_cvsid); - PrintOut(LOG_INFO, "\nsmartmontools release " PACKAGE_VERSION " dated " SMARTMONTOOLS_RELEASE_DATE " at " SMARTMONTOOLS_RELEASE_TIME "\n"); - PrintOut(LOG_INFO, "smartmontools build host: " SMARTMONTOOLS_BUILD_HOST "\n"); - PrintOut(LOG_INFO, "smartmontools build configured: " SMARTMONTOOLS_CONFIGURE_DATE "\n"); - PrintOut(LOG_INFO, "smartd compile dated " __DATE__ " at "__TIME__ "\n"); - PrintOut(LOG_INFO, "smartmontools configure arguments: %s\n", configargs); - return; -} - // remove the PID file void RemovePidFile(){ if (!pid_file.empty()) { @@ -1400,8 +1327,9 @@ static void WritePidFile() } // Prints header identifying version of code and home -void PrintHead(){ - PrintOut(LOG_INFO, "%s\n", format_version_info("smartd")); +static void PrintHead() +{ + PrintOut(LOG_INFO, "%s\n", format_version_info("smartd").c_str()); } // prints help info for configuration file Directives @@ -3714,15 +3642,6 @@ static int ParseConfigFile(dev_config_vector & conf_entries) return entry; } - -// Prints copyright, license and version information -void PrintCopyleft(void){ - debugmode=1; - PrintHead(); - PrintCVS(); - return; -} - /* Prints the message "=======> VALID ARGUMENTS ARE: <LIST> <=======\n", where <LIST> is the list of valid arguments for option opt. */ void PrintValidArgs(char opt) { @@ -3934,7 +3853,8 @@ void ParseOpts(int argc, char **argv){ break; case 'V': // print version and CVS info - PrintCopyleft(); + debugmode = 1; + PrintOut(LOG_INFO, "%s", format_version_info("smartd", true /*full*/).c_str()); EXIT(0); break; case 'h': diff --git a/smartmontools/utility.cpp b/smartmontools/utility.cpp index 2b2d04f7d..345e1d63f 100644 --- a/smartmontools/utility.cpp +++ b/smartmontools/utility.cpp @@ -4,6 +4,7 @@ * Home page of code is: http://smartmontools.sourceforge.net * * Copyright (C) 2002-9 Bruce Allen <smartmontools-support@lists.sourceforge.net> + * Copyright (C) 2008-9 Christian Franke <smartmontools-support@lists.sourceforge.net> * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org> * * This program is free software; you can redistribute it and/or modify @@ -49,9 +50,8 @@ #include "atacmds.h" #include "dev_interface.h" -// Any local header files should be represented by a CVSIDX just below. -const char* utility_c_cvsid="$Id$" -CONFIG_H_CVSID INT64_H_CVSID UTILITY_H_CVSID; +const char * utility_cpp_cvsid = "$Id$" + UTILITY_H_CVSID INT64_H_CVSID; const char * packet_types[] = { "Direct-access (disk)", @@ -85,15 +85,39 @@ unsigned char debugmode = 0; #endif // Make version information string -const char *format_version_info(const char *progname) +std::string format_version_info(const char * prog_name, bool full /*= false*/) { - static char info[200]; - snprintf(info, sizeof(info), - "%s %s %s r%s [%s] %s\n" + std::string info = strprintf( + "%s "PACKAGE_VERSION" "SMARTMONTOOLS_SVN_DATE" r"SMARTMONTOOLS_SVN_REV + " [%s] "BUILD_INFO"\n" "Copyright (C) 2002-9 by Bruce Allen, http://smartmontools.sourceforge.net\n", - progname, PACKAGE_VERSION, SMARTMONTOOLS_SVN_DATE, SMARTMONTOOLS_SVN_REV, - smi()->get_os_version_str(), BUILD_INFO + prog_name, smi()->get_os_version_str() ); + if (!full) + return info; + + info += strprintf( + "\n" + "%s comes with ABSOLUTELY NO WARRANTY. This is free\n" + "software, and you are welcome to redistribute it under\n" + "the terms of the GNU General Public License Version 2.\n" + "See http://www.gnu.org for further details.\n" + "\n" + "smartmontools release "PACKAGE_VERSION + " dated "SMARTMONTOOLS_RELEASE_DATE" at "SMARTMONTOOLS_RELEASE_TIME"\n" + "smartmontools SVN rev "SMARTMONTOOLS_SVN_REV + " dated "SMARTMONTOOLS_SVN_DATE" at "SMARTMONTOOLS_SVN_TIME"\n" + "smartmontools build host: "SMARTMONTOOLS_BUILD_HOST"\n" + "smartmontools build configured: "SMARTMONTOOLS_CONFIGURE_DATE "\n" + "%s compile dated "__DATE__" at "__TIME__"\n", + prog_name, prog_name + ); + info += strprintf( + "smartmontools configure arguments: %s\n", + (sizeof(SMARTMONTOOLS_CONFIGURE_ARGS) > 1 ? + SMARTMONTOOLS_CONFIGURE_ARGS : "[no arguments given]") + ); + return info; } @@ -304,61 +328,6 @@ void dateandtimezone(char *buffer){ return; } -// These are two utility functions for printing CVS IDs. Massagecvs() -// returns distance that it has moved ahead in the input string -int massagecvs(char *out, const char *cvsid){ - char *copy,*filename,*date,*version; - int retVal=0; - const char delimiters[] = " ,$"; - - // make a copy on the heap, go to first token, - if (!(copy=strdup(cvsid))) - return 0; - - if (!(filename=strtok(copy, delimiters))) - goto endmassage; - - // move to first instance of "Id:" - while (strcmp(filename,"Id:")) - if (!(filename=strtok(NULL, delimiters))) - goto endmassage; - - // get filename, skip "v", get version and date - if (!( filename=strtok(NULL, delimiters) ) || - !( strtok(NULL, delimiters) ) || - !( version=strtok(NULL, delimiters) ) || - !( date=strtok(NULL, delimiters) ) ) - goto endmassage; - - sprintf(out,"%-16s revision: %-5s date: %-15s", filename, version, date); - retVal = (date-copy)+strlen(date); - - endmassage: - free(copy); - return retVal; -} - -// prints a single set of CVS ids -void printone(char *block, const char *cvsid){ - char strings[CVSMAXLEN]; - const char *here=cvsid; - int bi=0, len=strlen(cvsid)+1; - - // check that the size of the output block is sufficient - if (len>=CVSMAXLEN) { - pout("CVSMAXLEN=%d must be at least %d\n",CVSMAXLEN,len+1); - EXIT(1); - } - - // loop through the different strings - while (bi<CVSMAXLEN && (len=massagecvs(strings,here))){ - bi+=snprintf(block+bi,CVSMAXLEN-bi,"%s %s\n",(bi==0?"Module:":" uses:"),strings); - here+=len; - } - return; -} - - // A replacement for perror() that sends output to our choice of // printing. If errno not set then just print message. void syserror(const char *message){ diff --git a/smartmontools/utility.h b/smartmontools/utility.h index 892e42c82..215e9d2aa 100644 --- a/smartmontools/utility.h +++ b/smartmontools/utility.h @@ -3,7 +3,8 @@ * * Home page of code is: http://smartmontools.sourceforge.net * - * Copyright (C) 2002-8 Bruce Allen <smartmontools-support@lists.sourceforge.net> + * Copyright (C) 2002-9 Bruce Allen <smartmontools-support@lists.sourceforge.net> + * Copyright (C) 2008-9 Christian Franke <smartmontools-support@lists.sourceforge.net> * Copyright (C) 2000 Michael Cornwell <cornwell@acm.org> * * This program is free software; you can redistribute it and/or modify @@ -25,7 +26,7 @@ #ifndef UTILITY_H_ #define UTILITY_H_ -#define UTILITY_H_CVSID "$Id: utility.h,v 1.68 2009/07/07 19:28:29 chrfranke Exp $\n" +#define UTILITY_H_CVSID "$Id$" #include <time.h> #include <sys/types.h> // for regex.h (according to POSIX) @@ -40,7 +41,7 @@ #endif // Make version information string -const char *format_version_info(const char *prog_name); +std::string format_version_info(const char * prog_name, bool full = false); // return (v)sprintf() formated std::string std::string strprintf(const char * fmt, ...) @@ -69,10 +70,6 @@ void dateandtimezone(char *buffer); // Same, but for time defined by epoch tval void dateandtimezoneepoch(char *buffer, time_t tval); -// utility function for printing out CVS strings -#define CVSMAXLEN 1024 -void printone(char *block, const char *cvsid); - // like printf() except that we can control it better. Note -- // although the prototype is given here in utility.h, the function // itself is defined differently in smartctl and smartd. So the -- GitLab