diff --git a/sm5/Makefile b/sm5/Makefile index 9322316a8c41dd7ed1cb5f28a79233fa7c6bae39..6fe07357c3f02005ebbd074c2b2302cc8d1aca83 100644 --- a/sm5/Makefile +++ b/sm5/Makefile @@ -2,7 +2,7 @@ # # Home page: http://smartmontools.sourceforge.net # -# $Id: Makefile,v 1.46 2003/01/16 15:30:33 ballen4705 Exp $ +# $Id: Makefile,v 1.47 2003/01/16 15:51:09 ballen4705 Exp $ # # Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> # @@ -53,12 +53,12 @@ all: smartd smartctl @echo -e "to read the manual pages now. Unless you do a \"make install\" the manual pages won't be installed.\n" smartctl: smartctl.c atacmds.o ataprint.o scsicmds.o scsiprint.o utility.o\ - smartctl.h atacmds.h ataprint.h scsicmds.h scsiprint.h extern.h VERSION Makefile + smartctl.h atacmds.h ataprint.h scsicmds.h scsiprint.h utility.h extern.h VERSION Makefile $(CC) -DSMARTMONTOOLS_VERSION=$(counter) -o smartctl $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) smartctl.c \ atacmds.o ataprint.o scsicmds.o scsiprint.o utility.o smartd: smartd.c atacmds.o ataprint.o scsicmds.o utility.o\ - smartd.h atacmds.h ataprint.h scsicmds.h extern.h VERSION Makefile + smartd.h atacmds.h ataprint.h scsicmds.h utility.h extern.h VERSION Makefile $(CC) -DSMARTMONTOOLS_VERSION=$(counter) -o smartd $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) smartd.c \ atacmds.o ataprint.o scsicmds.o utility.o diff --git a/sm5/VERSION b/sm5/VERSION index 0cfbf08886fca9a91cb753ec8734c84fcbe52c9f..00750edc07d6415dcc07ae0351e9397b0222b7ba 100644 --- a/sm5/VERSION +++ b/sm5/VERSION @@ -1 +1 @@ -2 +3 diff --git a/sm5/atacmds.c b/sm5/atacmds.c index c18b0ffce97033b0b0ac522150ed6ad5b7012d9e..b16e49dc6580fbc970d4ed8b33db85319bc6c277 100644 --- a/sm5/atacmds.c +++ b/sm5/atacmds.c @@ -29,7 +29,7 @@ #include <stdlib.h> #include "atacmds.h" -const char *atacmds_c_cvsid="$Id: atacmds.c,v 1.51 2003/01/16 15:28:57 ballen4705 Exp $" ATACMDS_H_CVSID; +const char *atacmds_c_cvsid="$Id: atacmds.c,v 1.52 2003/01/16 15:51:09 ballen4705 Exp $" ATACMDS_H_CVSID; // These Drive Identity tables are taken from hdparm 5.2, and are also // given in the ATA/ATAPI specs for the IDENTIFY DEVICE command. Note @@ -932,60 +932,3 @@ void ataPrintSmartAttribName(char *out, unsigned char id, unsigned char *defs){ sprintf(out,"%3hhu %s",id,name); return; } - - -// These are two utility functions for printing CVS IDs. They don't -// really belong here. But it's the only common source file included -// in both smartd and smartctl. returns distance that it has moved -// ahead in the input string -int massagecvs(char *out, const char *cvsid){ - char *copy,*filename,*date,*version; - const char delimiters[] = " ,$"; - - // make a copy on stack, go to first token, - if (!(copy=strdup(cvsid)) || !(filename=strtok(copy, delimiters))) - return 0; - - // move to first instance of "Id:" - while (strcmp(filename,"Id:")) - if (!(filename=strtok(NULL, delimiters))) - return 0; - - // get filename, skip "v", get version and date - if (!( filename=strtok(NULL, delimiters) ) || - !( strtok(NULL, delimiters) ) || - !( version=strtok(NULL, delimiters) ) || - !( date=strtok(NULL, delimiters) ) ) - return 0; - - sprintf(out,"%-13s revision: %-6s date: %-15s", filename, version, date); - free(copy); - return (date-copy)+strlen(date); -} - -// prints a single set of CVS ids -void printone(char *block, const char *cvsid){ - char strings[CVSMAXLEN]; - const char *here=cvsid; - int line=1,len=strlen(cvsid)+1; - - // check that the size of the output block is sufficient - if (len>=CVSMAXLEN) { - fprintf(stderr,"CVSMAXLEN=%d must be at least %d\n",CVSMAXLEN,len+1); - exit(1); - } - - // loop through the different strings - while ((len=massagecvs(strings,here))){ - switch (line++){ - case 1: - block+=snprintf(block,CVSMAXLEN,"Module:"); - break; - default: - block+=snprintf(block,CVSMAXLEN," uses:"); - } - block+=snprintf(block,CVSMAXLEN," %s\n",strings); - here+=len; - } - return; -} diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp index b4e763ab062a044844f7cf9cbaca1a0ccbffb510..282dff7d8046bb677568823fa508add4c3e2f6f6 100644 --- a/sm5/atacmds.cpp +++ b/sm5/atacmds.cpp @@ -29,7 +29,7 @@ #include <stdlib.h> #include "atacmds.h" -const char *atacmds_c_cvsid="$Id: atacmds.cpp,v 1.51 2003/01/16 15:28:57 ballen4705 Exp $" ATACMDS_H_CVSID; +const char *atacmds_c_cvsid="$Id: atacmds.cpp,v 1.52 2003/01/16 15:51:09 ballen4705 Exp $" ATACMDS_H_CVSID; // These Drive Identity tables are taken from hdparm 5.2, and are also // given in the ATA/ATAPI specs for the IDENTIFY DEVICE command. Note @@ -932,60 +932,3 @@ void ataPrintSmartAttribName(char *out, unsigned char id, unsigned char *defs){ sprintf(out,"%3hhu %s",id,name); return; } - - -// These are two utility functions for printing CVS IDs. They don't -// really belong here. But it's the only common source file included -// in both smartd and smartctl. returns distance that it has moved -// ahead in the input string -int massagecvs(char *out, const char *cvsid){ - char *copy,*filename,*date,*version; - const char delimiters[] = " ,$"; - - // make a copy on stack, go to first token, - if (!(copy=strdup(cvsid)) || !(filename=strtok(copy, delimiters))) - return 0; - - // move to first instance of "Id:" - while (strcmp(filename,"Id:")) - if (!(filename=strtok(NULL, delimiters))) - return 0; - - // get filename, skip "v", get version and date - if (!( filename=strtok(NULL, delimiters) ) || - !( strtok(NULL, delimiters) ) || - !( version=strtok(NULL, delimiters) ) || - !( date=strtok(NULL, delimiters) ) ) - return 0; - - sprintf(out,"%-13s revision: %-6s date: %-15s", filename, version, date); - free(copy); - return (date-copy)+strlen(date); -} - -// prints a single set of CVS ids -void printone(char *block, const char *cvsid){ - char strings[CVSMAXLEN]; - const char *here=cvsid; - int line=1,len=strlen(cvsid)+1; - - // check that the size of the output block is sufficient - if (len>=CVSMAXLEN) { - fprintf(stderr,"CVSMAXLEN=%d must be at least %d\n",CVSMAXLEN,len+1); - exit(1); - } - - // loop through the different strings - while ((len=massagecvs(strings,here))){ - switch (line++){ - case 1: - block+=snprintf(block,CVSMAXLEN,"Module:"); - break; - default: - block+=snprintf(block,CVSMAXLEN," uses:"); - } - block+=snprintf(block,CVSMAXLEN," %s\n",strings); - here+=len; - } - return; -} diff --git a/sm5/atacmds.h b/sm5/atacmds.h index 5f277887b72135f0a71ccddd4c97f54c87ceb3c7..541279547540947cf28797dafbb89f7d29655563 100644 --- a/sm5/atacmds.h +++ b/sm5/atacmds.h @@ -26,7 +26,7 @@ #define _ATACMDS_H_ #ifndef ATACMDS_H_CVSID -#define ATACMDS_H_CVSID "$Id: atacmds.h,v 1.31 2003/01/16 15:28:57 ballen4705 Exp $\n" +#define ATACMDS_H_CVSID "$Id: atacmds.h,v 1.32 2003/01/16 15:51:09 ballen4705 Exp $\n" #endif // These are the major and minor versions for smartd and smartctl @@ -349,12 +349,6 @@ void ataPrintSmartAttribName(char *output, unsigned char id, unsigned char *defs void pout(char *fmt, ...) __attribute__ ((format (printf, 1, 2))); - - -// utility function for printing out CVS strings -#define CVSMAXLEN 512 -void printone(char *block, const char *cvsid); - // replacement for perror() with redirected output. void syserror(const char *message); diff --git a/sm5/smartctl.c b/sm5/smartctl.c index a5e45d0c99108e68e46680c0d304c18dc4d0f26d..9ebd83d366e44faf28502d06173eb3971c1c4688 100644 --- a/sm5/smartctl.c +++ b/sm5/smartctl.c @@ -40,10 +40,11 @@ #include "scsicmds.h" #include "scsiprint.h" #include "smartctl.h" +#include "utility.h" extern const char *atacmds_c_cvsid, *ataprint_c_cvsid, *scsicmds_c_cvsid, *scsiprint_c_cvsid, *utility_c_cvsid; -const char* smartctl_c_cvsid="$Id: smartctl.c,v 1.48 2003/01/16 15:28:57 ballen4705 Exp $" -ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID; +const char* smartctl_c_cvsid="$Id: smartctl.c,v 1.49 2003/01/16 15:51:09 ballen4705 Exp $" +ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; // This is a block containing all the "control variables". We declare // this globally in this file, and externally in other files. diff --git a/sm5/smartctl.cpp b/sm5/smartctl.cpp index 6a821acfa8ccd587ed6796d277dea98fc6477155..833fcc915a995df496766f3d91738716e3638f75 100644 --- a/sm5/smartctl.cpp +++ b/sm5/smartctl.cpp @@ -40,10 +40,11 @@ #include "scsicmds.h" #include "scsiprint.h" #include "smartctl.h" +#include "utility.h" extern const char *atacmds_c_cvsid, *ataprint_c_cvsid, *scsicmds_c_cvsid, *scsiprint_c_cvsid, *utility_c_cvsid; -const char* smartctl_c_cvsid="$Id: smartctl.cpp,v 1.48 2003/01/16 15:28:57 ballen4705 Exp $" -ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID; +const char* smartctl_c_cvsid="$Id: smartctl.cpp,v 1.49 2003/01/16 15:51:09 ballen4705 Exp $" +ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; // This is a block containing all the "control variables". We declare // this globally in this file, and externally in other files. diff --git a/sm5/smartd.c b/sm5/smartd.c index e05e2e73de71ca6ec7a16768f22acc3feed7b6f3..eeb44afbead6c50c5030c4c6c27d3aa83724084a 100644 --- a/sm5/smartd.c +++ b/sm5/smartd.c @@ -46,11 +46,12 @@ #include "extern.h" #include "scsicmds.h" #include "smartd.h" +#include "utility.h" // CVS ID strings extern const char *atacmds_c_cvsid, *ataprint_c_cvsid, *scsicmds_c_cvsid, *utility_c_cvsid; -const char *smartd_c_cvsid="$Id: smartd.c,v 1.97 2003/01/16 15:28:57 ballen4705 Exp $" -ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SCSICMDS_H_CVSID SMARTD_H_CVSID; +const char *smartd_c_cvsid="$Id: smartd.c,v 1.98 2003/01/16 15:51:09 ballen4705 Exp $" +ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SCSICMDS_H_CVSID SMARTD_H_CVSID UTILITY_H_CVSID; // global variable used for control of printing, passing arguments, etc. atamainctrl *con=NULL; diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp index 4e5cdde3aae74408fb1bd1d440158e0ea2ae7bf4..0fa3b6b81e258702250c571ee1676882e5e0fa04 100644 --- a/sm5/smartd.cpp +++ b/sm5/smartd.cpp @@ -46,11 +46,12 @@ #include "extern.h" #include "scsicmds.h" #include "smartd.h" +#include "utility.h" // CVS ID strings extern const char *atacmds_c_cvsid, *ataprint_c_cvsid, *scsicmds_c_cvsid, *utility_c_cvsid; -const char *smartd_c_cvsid="$Id: smartd.cpp,v 1.97 2003/01/16 15:28:57 ballen4705 Exp $" -ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SCSICMDS_H_CVSID SMARTD_H_CVSID; +const char *smartd_c_cvsid="$Id: smartd.cpp,v 1.98 2003/01/16 15:51:09 ballen4705 Exp $" +ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SCSICMDS_H_CVSID SMARTD_H_CVSID UTILITY_H_CVSID; // global variable used for control of printing, passing arguments, etc. atamainctrl *con=NULL; diff --git a/sm5/utility.c b/sm5/utility.c index bc70d48194226f6465472bfd53efc9b2b3f7719f..22016c1017a20c3580910285aba97a0b97881c08 100644 --- a/sm5/utility.c +++ b/sm5/utility.c @@ -31,9 +31,10 @@ #include <string.h> #include <time.h> #include "utility.h" +#include "stdlib.h" // Any local header files should be represented by a CVSIDX just below. -const char* utility_c_cvsid="$Id: utility.c,v 1.1 2003/01/16 15:28:58 ballen4705 Exp $" UTILITY_H_CVSID; +const char* utility_c_cvsid="$Id: utility.c,v 1.2 2003/01/16 15:51:10 ballen4705 Exp $" UTILITY_H_CVSID; // Utility function prints date and time and timezone into a character // buffer of length>=64. All the fuss is needed to get the right @@ -73,3 +74,59 @@ 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; + const char delimiters[] = " ,$"; + + // make a copy on stack, go to first token, + if (!(copy=strdup(cvsid)) || !(filename=strtok(copy, delimiters))) + return 0; + + // move to first instance of "Id:" + while (strcmp(filename,"Id:")) + if (!(filename=strtok(NULL, delimiters))) + return 0; + + // get filename, skip "v", get version and date + if (!( filename=strtok(NULL, delimiters) ) || + !( strtok(NULL, delimiters) ) || + !( version=strtok(NULL, delimiters) ) || + !( date=strtok(NULL, delimiters) ) ) + return 0; + + sprintf(out,"%-13s revision: %-6s date: %-15s", filename, version, date); + free(copy); + return (date-copy)+strlen(date); +} + +// prints a single set of CVS ids +void printone(char *block, const char *cvsid){ + char strings[CVSMAXLEN]; + const char *here=cvsid; + int line=1,len=strlen(cvsid)+1; + + // check that the size of the output block is sufficient + if (len>=CVSMAXLEN) { + fprintf(stderr,"CVSMAXLEN=%d must be at least %d\n",CVSMAXLEN,len+1); + exit(1); + } + + // loop through the different strings + while ((len=massagecvs(strings,here))){ + switch (line++){ + case 1: + block+=snprintf(block,CVSMAXLEN,"Module:"); + break; + default: + block+=snprintf(block,CVSMAXLEN," uses:"); + } + block+=snprintf(block,CVSMAXLEN," %s\n",strings); + here+=len; + } + return; +} + diff --git a/sm5/utility.cpp b/sm5/utility.cpp index 97ba0350f667869a9bea3545fac7f9cebd5883c3..0bab4162201056cf711ebcd86627ec72171cb78a 100644 --- a/sm5/utility.cpp +++ b/sm5/utility.cpp @@ -31,9 +31,10 @@ #include <string.h> #include <time.h> #include "utility.h" +#include "stdlib.h" // Any local header files should be represented by a CVSIDX just below. -const char* utility_c_cvsid="$Id: utility.cpp,v 1.1 2003/01/16 15:28:58 ballen4705 Exp $" UTILITY_H_CVSID; +const char* utility_c_cvsid="$Id: utility.cpp,v 1.2 2003/01/16 15:51:10 ballen4705 Exp $" UTILITY_H_CVSID; // Utility function prints date and time and timezone into a character // buffer of length>=64. All the fuss is needed to get the right @@ -73,3 +74,59 @@ 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; + const char delimiters[] = " ,$"; + + // make a copy on stack, go to first token, + if (!(copy=strdup(cvsid)) || !(filename=strtok(copy, delimiters))) + return 0; + + // move to first instance of "Id:" + while (strcmp(filename,"Id:")) + if (!(filename=strtok(NULL, delimiters))) + return 0; + + // get filename, skip "v", get version and date + if (!( filename=strtok(NULL, delimiters) ) || + !( strtok(NULL, delimiters) ) || + !( version=strtok(NULL, delimiters) ) || + !( date=strtok(NULL, delimiters) ) ) + return 0; + + sprintf(out,"%-13s revision: %-6s date: %-15s", filename, version, date); + free(copy); + return (date-copy)+strlen(date); +} + +// prints a single set of CVS ids +void printone(char *block, const char *cvsid){ + char strings[CVSMAXLEN]; + const char *here=cvsid; + int line=1,len=strlen(cvsid)+1; + + // check that the size of the output block is sufficient + if (len>=CVSMAXLEN) { + fprintf(stderr,"CVSMAXLEN=%d must be at least %d\n",CVSMAXLEN,len+1); + exit(1); + } + + // loop through the different strings + while ((len=massagecvs(strings,here))){ + switch (line++){ + case 1: + block+=snprintf(block,CVSMAXLEN,"Module:"); + break; + default: + block+=snprintf(block,CVSMAXLEN," uses:"); + } + block+=snprintf(block,CVSMAXLEN," %s\n",strings); + here+=len; + } + return; +} + diff --git a/sm5/utility.h b/sm5/utility.h index 1d1d216a67d62c6ef4d86f18f960924aac687e77..da875041c9d7dedf436d04306d4a80b98e811eab 100644 --- a/sm5/utility.h +++ b/sm5/utility.h @@ -26,7 +26,7 @@ #define __UTILITY_H_ #ifndef UTILITY_H_CVSID -#define UTILITY_H_CVSID "$Id: utility.h,v 1.1 2003/01/16 15:28:58 ballen4705 Exp $\n" +#define UTILITY_H_CVSID "$Id: utility.h,v 1.2 2003/01/16 15:51:10 ballen4705 Exp $\n" #endif // Utility function prints date and time and timezone into a character @@ -34,4 +34,8 @@ // timezone info (sigh). void dateandtimezone(char *buffer); +// utility function for printing out CVS strings +#define CVSMAXLEN 512 +void printone(char *block, const char *cvsid); + #endif