diff --git a/sm5/Makefile b/sm5/Makefile index 0570bd9a8d99841ccf5055113218637870d5120d..68a193079e2ce8b56ccf4852cd4db7681e8f494a 100644 --- a/sm5/Makefile +++ b/sm5/Makefile @@ -2,7 +2,7 @@ # # Home page: http://smartmontools.sourceforge.net # -# $Id: Makefile,v 1.44 2003/01/14 13:07:40 ballen4705 Exp $ +# $Id: Makefile,v 1.45 2003/01/16 15:28:57 ballen4705 Exp $ # # Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> # @@ -40,7 +40,8 @@ LDFLAGS = # -s releasefiles=atacmds.c atacmds.h ataprint.c ataprint.h CHANGELOG COPYING extern.h Makefile\ README scsicmds.c scsicmds.h scsiprint.c scsiprint.h smartctl.8 smartctl.c smartctl.h\ - smartd.8 smartd.c smartd.h smartd.initd TODO WARNINGS VERSION smartd.conf smartd.conf.5 + smartd.8 smartd.c smartd.h smartd.initd TODO WARNINGS VERSION smartd.conf smartd.conf.5\ + utility.c utility.h counter=$(shell cat VERSION) newcounter=$(shell ./add ) @@ -51,27 +52,31 @@ all: smartd smartctl @echo -e "\n\nSmartd can now use a configuration file /etc/smartd.conf. Do:\n\n\tman ./smartctl.8\n\tman ./smartd.8\n\tman ./smartd.conf.5\n" @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 \ +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 $(CC) -DSMARTMONTOOLS_VERSION=$(counter) -o smartctl $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) smartctl.c \ - atacmds.o scsicmds.o ataprint.o scsiprint.o + atacmds.o ataprint.o scsicmds.o scsiprint.o utility.o -smartd: smartd.c atacmds.o ataprint.o scsicmds.o \ +smartd: smartd.c atacmds.o ataprint.o scsicmds.o utility.o\ smartd.h atacmds.h ataprint.h scsicmds.h extern.h VERSION Makefile $(CC) -DSMARTMONTOOLS_VERSION=$(counter) -o smartd $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) smartd.c \ - scsicmds.o atacmds.o ataprint.o + atacmds.o ataprint.o scsicmds.o utility.o atacmds.o: atacmds.h atacmds.c Makefile $(CC) $(CFLAGS) $(CPPFLAGS) -c atacmds.c -ataprint.o: ataprint.c atacmds.h ataprint.h smartctl.h extern.h Makefile +ataprint.o: ataprint.c atacmds.h ataprint.h smartctl.h extern.h utility.h Makefile $(CC) $(CFLAGS) $(CPPFLAGS) -c ataprint.c scsicmds.o: scsicmds.c scsicmds.h Makefile $(CC) $(CFLAGS) $(CPPFLAGS) -c scsicmds.c -scsiprint.o: scsiprint.c extern.h scsicmds.h scsiprint.h smartctl.h Makefile - $(CC) $(CFLAGS) $(CPPFLAGS) -c scsiprint.c +scsiprint.o: scsiprint.c extern.h scsicmds.h scsiprint.h smartctl.h utility.h Makefile + $(CC) $(CFLAGS) $(CPPFLAGS) -c scsiprint.c + +utility.o: utility.c utility.h Makefile + $(CC) $(CFLAGS) $(CPPFLAGS) -c utility.c + # This extracts the configuration file directives from smartd.8 and # inserts them into smartd.conf.5 diff --git a/sm5/atacmds.c b/sm5/atacmds.c index f77683c6d05d95b92de1b88a2a3346edec51445b..c18b0ffce97033b0b0ac522150ed6ad5b7012d9e 100644 --- a/sm5/atacmds.c +++ b/sm5/atacmds.c @@ -29,7 +29,7 @@ #include <stdlib.h> #include "atacmds.h" -const char *CVSid1="$Id: atacmds.c,v 1.50 2003/01/13 12:49:06 ballen4705 Exp $" CVSID1; +const char *atacmds_c_cvsid="$Id: atacmds.c,v 1.51 2003/01/16 15:28:57 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 diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp index 543377bb7e188f3a5534815472b5c2f16c51a3f5..b4e763ab062a044844f7cf9cbaca1a0ccbffb510 100644 --- a/sm5/atacmds.cpp +++ b/sm5/atacmds.cpp @@ -29,7 +29,7 @@ #include <stdlib.h> #include "atacmds.h" -const char *CVSid1="$Id: atacmds.cpp,v 1.50 2003/01/13 12:49:06 ballen4705 Exp $" CVSID1; +const char *atacmds_c_cvsid="$Id: atacmds.cpp,v 1.51 2003/01/16 15:28:57 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 diff --git a/sm5/atacmds.h b/sm5/atacmds.h index c8d717b99aadecc61f8d203ce628834a86c64c5d..5f277887b72135f0a71ccddd4c97f54c87ceb3c7 100644 --- a/sm5/atacmds.h +++ b/sm5/atacmds.h @@ -25,8 +25,8 @@ #ifndef _ATACMDS_H_ #define _ATACMDS_H_ -#ifndef CVSID1 -#define CVSID1 "$Id: atacmds.h,v 1.30 2003/01/04 17:34:16 pjwilliams Exp $\n" +#ifndef ATACMDS_H_CVSID +#define ATACMDS_H_CVSID "$Id: atacmds.h,v 1.31 2003/01/16 15:28:57 ballen4705 Exp $\n" #endif // These are the major and minor versions for smartd and smartctl diff --git a/sm5/ataprint.c b/sm5/ataprint.c index ee82f5525a86cf3d001ef774911c6725d8630950..2a520d57716da0591ea4a6a5c32601979cacfa63 100644 --- a/sm5/ataprint.c +++ b/sm5/ataprint.c @@ -25,14 +25,14 @@ #include <ctype.h> #include <stdio.h> #include <syslog.h> -#include <time.h> #include "atacmds.h" #include "ataprint.h" #include "smartctl.h" #include "extern.h" +#include "utility.h" -const char *CVSid2="$Id: ataprint.c,v 1.54 2003/01/14 20:04:07 ballen4705 Exp $" -CVSID1 CVSID2 CVSID3 CVSID6; +const char *ataprint_c_cvsid="$Id: ataprint.c,v 1.55 2003/01/16 15:28:57 ballen4705 Exp $" +ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; // for passing global control variables extern atamainctrl *con; @@ -64,13 +64,11 @@ void printswap(char *in, unsigned int n){ return; } - void ataPrintDriveInfo (struct hd_driveid *drive){ int version; const char *description; - char unknown[64]; + char unknown[64], timedatetz[64]; unsigned short minorrev; - time_t tval; // print out model, serial # and firmware versions (byte-swap ASCI strings) pout("Device Model: "); @@ -101,10 +99,10 @@ void ataPrintDriveInfo (struct hd_driveid *drive){ pout("ATA Version is: %d\n",(int)abs(version)); pout("ATA Standard is: %s\n",description); - // print current time and date - tval=time(NULL); - pout("Local Time is: %s", ctime(&tval)); - + // print current time and date and timezone + dateandtimezone(timedatetz); + pout("Local Time is: %s\n", timedatetz); + if (version>=3) return; diff --git a/sm5/ataprint.cpp b/sm5/ataprint.cpp index 2f86df9967ad6df5f9f2715ca87d62a4dbaea8b4..34f3f13d7e87fa3fdd1c44e7bb436ee6b0bf3123 100644 --- a/sm5/ataprint.cpp +++ b/sm5/ataprint.cpp @@ -25,14 +25,14 @@ #include <ctype.h> #include <stdio.h> #include <syslog.h> -#include <time.h> #include "atacmds.h" #include "ataprint.h" #include "smartctl.h" #include "extern.h" +#include "utility.h" -const char *CVSid2="$Id: ataprint.cpp,v 1.54 2003/01/14 20:04:07 ballen4705 Exp $" -CVSID1 CVSID2 CVSID3 CVSID6; +const char *ataprint_c_cvsid="$Id: ataprint.cpp,v 1.55 2003/01/16 15:28:57 ballen4705 Exp $" +ATACMDS_H_CVSID ATAPRINT_H_CVSID EXTERN_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; // for passing global control variables extern atamainctrl *con; @@ -64,13 +64,11 @@ void printswap(char *in, unsigned int n){ return; } - void ataPrintDriveInfo (struct hd_driveid *drive){ int version; const char *description; - char unknown[64]; + char unknown[64], timedatetz[64]; unsigned short minorrev; - time_t tval; // print out model, serial # and firmware versions (byte-swap ASCI strings) pout("Device Model: "); @@ -101,10 +99,10 @@ void ataPrintDriveInfo (struct hd_driveid *drive){ pout("ATA Version is: %d\n",(int)abs(version)); pout("ATA Standard is: %s\n",description); - // print current time and date - tval=time(NULL); - pout("Local Time is: %s", ctime(&tval)); - + // print current time and date and timezone + dateandtimezone(timedatetz); + pout("Local Time is: %s\n", timedatetz); + if (version>=3) return; diff --git a/sm5/ataprint.h b/sm5/ataprint.h index 993537101a617c3a344abacc1c3ce4cba878e229..309b2db6a2c5445ff61cf03830ddf24c82cd6089 100644 --- a/sm5/ataprint.h +++ b/sm5/ataprint.h @@ -25,8 +25,8 @@ #ifndef _SMART_PRINT_H_ #define _SMART_PRINT_H_ -#ifndef CVSID2 -#define CVSID2 "$Id: ataprint.h,v 1.14 2002/10/30 10:18:37 ballen4705 Exp $\n" +#ifndef ATAPRINT_H_CVSID +#define ATAPRINT_H_CVSID "$Id: ataprint.h,v 1.15 2003/01/16 15:28:57 ballen4705 Exp $\n" #endif #include <stdio.h> diff --git a/sm5/extern.h b/sm5/extern.h index d8a934c19f6878a71586856df47189eefbe35380..e009bfeaeddb01b02502186c5502eaac13451d0d 100644 --- a/sm5/extern.h +++ b/sm5/extern.h @@ -26,8 +26,8 @@ #define _EXTERN_H_ -#ifndef CVSID3 -#define CVSID3 "$Id: extern.h,v 1.12 2003/01/03 17:25:12 ballen4705 Exp $\n" +#ifndef EXTERN_H_CVSID +#define EXTERN_H_CVSID "$Id: extern.h,v 1.13 2003/01/16 15:28:57 ballen4705 Exp $\n" #endif // Block used for global control/communications. If you need more diff --git a/sm5/scsicmds.c b/sm5/scsicmds.c index 114aea7147753d640460453dfb62d02cfcd7e896..8c392fe09f9fd40f85a7f3db4d07ae9b0ce9f182 100644 --- a/sm5/scsicmds.c +++ b/sm5/scsicmds.c @@ -32,7 +32,7 @@ /* #include <scsi/scsi_ioctl.h> bypass for now */ #include "scsicmds.h" -const char *CVSid3="$Id: scsicmds.c,v 1.17 2003/01/04 01:37:48 dpgilbert Exp $" CVSID4; +const char *scsicmds_c_cvsid="$Id: scsicmds.c,v 1.18 2003/01/16 15:28:57 ballen4705 Exp $" SCSICMDS_H_CVSID; static int send_scsi_cmd(int device, int cmnd_len, void * io_hdr) { diff --git a/sm5/scsicmds.cpp b/sm5/scsicmds.cpp index b719fcb6251f6d3fc92b14a5ae6727329bbf8dcb..bdd389f7936c6ddbf18b691d0b9e97295485a9eb 100644 --- a/sm5/scsicmds.cpp +++ b/sm5/scsicmds.cpp @@ -32,7 +32,7 @@ /* #include <scsi/scsi_ioctl.h> bypass for now */ #include "scsicmds.h" -const char *CVSid3="$Id: scsicmds.cpp,v 1.17 2003/01/04 01:37:48 dpgilbert Exp $" CVSID4; +const char *scsicmds_c_cvsid="$Id: scsicmds.cpp,v 1.18 2003/01/16 15:28:57 ballen4705 Exp $" SCSICMDS_H_CVSID; static int send_scsi_cmd(int device, int cmnd_len, void * io_hdr) { diff --git a/sm5/scsicmds.h b/sm5/scsicmds.h index ec6ff9cff89ecb5fa2e008df29016d86fc41326f..9643aeeac84b3af01d260469617cb2b43a9ae94a 100644 --- a/sm5/scsicmds.h +++ b/sm5/scsicmds.h @@ -26,8 +26,8 @@ #ifndef SCSICMDS_H_ #define SCSICMDS_H_ -#ifndef CVSID4 -#define CVSID4 "$Id: scsicmds.h,v 1.9 2003/01/04 01:37:48 dpgilbert Exp $\n" +#ifndef SCSICMDS_H_CVSID +#define SCSICMDS_H_CVSID "$Id: scsicmds.h,v 1.10 2003/01/16 15:28:57 ballen4705 Exp $\n" #endif /* #define SCSI_DEBUG 1 */ /* Comment out to disable command debugging */ diff --git a/sm5/scsiprint.c b/sm5/scsiprint.c index 6f1c92326098790720b827cb2853c329d84e3ab9..677adc33a4dd0da7d18b9ec72103519d34e9587d 100644 --- a/sm5/scsiprint.c +++ b/sm5/scsiprint.c @@ -28,17 +28,17 @@ #include <string.h> #include <fcntl.h> #include <errno.h> -#include <time.h> -#include "smartctl.h" +#include "extern.h" #include "scsicmds.h" #include "scsiprint.h" -#include "extern.h" +#include "smartctl.h" +#include "utility.h" #define GBUF_SIZE 65535 -const char* CVSid4="$Id: scsiprint.c,v 1.18 2003/01/12 10:30:53 ballen4705 Exp $" -CVSID3 CVSID4 CVSID5 CVSID6; +const char* scsiprint_c_cvsid="$Id: scsiprint.c,v 1.19 2003/01/16 15:28:57 ballen4705 Exp $" +EXTERN_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; // control block which points to external global control variables extern atamainctrl *con; @@ -325,7 +325,7 @@ void scsiGetDriveInfo ( int device) char manufacturer[9]; char product[17]; char revision[5]; - time_t tval; + char timedatetz[64]; UINT8 smartsupport; @@ -347,9 +347,9 @@ void scsiGetDriveInfo ( int device) revision[4] = '\0'; printf("Device: %s %s Version: %s\n", manufacturer, product, revision); - // print current time and date - tval=time(NULL); - printf("Local Time is: %s", ctime(&tval)); + // print current time and date and timezone + dateandtimezone(timedatetz); + printf("Local Time is: %s\n", timedatetz); if ( scsiSmartSupport( device, (UINT8 *) &smartsupport) != 0) { diff --git a/sm5/scsiprint.cpp b/sm5/scsiprint.cpp index f2f0e6bd92aaf380a104bac239bb45766aefd839..a3e7441a5bea850e4208391ec728a8ecdc0f6b21 100644 --- a/sm5/scsiprint.cpp +++ b/sm5/scsiprint.cpp @@ -28,17 +28,17 @@ #include <string.h> #include <fcntl.h> #include <errno.h> -#include <time.h> -#include "smartctl.h" +#include "extern.h" #include "scsicmds.h" #include "scsiprint.h" -#include "extern.h" +#include "smartctl.h" +#include "utility.h" #define GBUF_SIZE 65535 -const char* CVSid4="$Id: scsiprint.cpp,v 1.18 2003/01/12 10:30:53 ballen4705 Exp $" -CVSID3 CVSID4 CVSID5 CVSID6; +const char* scsiprint_c_cvsid="$Id: scsiprint.cpp,v 1.19 2003/01/16 15:28:57 ballen4705 Exp $" +EXTERN_H_CVSID SCSICMDS_H_CVSID SCSIPRINT_H_CVSID SMARTCTL_H_CVSID UTILITY_H_CVSID; // control block which points to external global control variables extern atamainctrl *con; @@ -325,7 +325,7 @@ void scsiGetDriveInfo ( int device) char manufacturer[9]; char product[17]; char revision[5]; - time_t tval; + char timedatetz[64]; UINT8 smartsupport; @@ -347,9 +347,9 @@ void scsiGetDriveInfo ( int device) revision[4] = '\0'; printf("Device: %s %s Version: %s\n", manufacturer, product, revision); - // print current time and date - tval=time(NULL); - printf("Local Time is: %s", ctime(&tval)); + // print current time and date and timezone + dateandtimezone(timedatetz); + printf("Local Time is: %s\n", timedatetz); if ( scsiSmartSupport( device, (UINT8 *) &smartsupport) != 0) { diff --git a/sm5/scsiprint.h b/sm5/scsiprint.h index 2429e26878aa56a100bc5ef5f5a3d323e591cbd1..5e93c525d6a8fab6c6511f2af6deb2a22616804c 100644 --- a/sm5/scsiprint.h +++ b/sm5/scsiprint.h @@ -27,8 +27,8 @@ #ifndef SCSI_PRINT_H_ #define SCSI_PRINT_H_ -#ifndef CVSID5 -#define CVSID5 "$Id: scsiprint.h,v 1.8 2002/11/17 05:57:32 ballen4705 Exp $\n" +#ifndef SCSIPRINT_H_CVSID +#define SCSIPRINT_H_CVSID "$Id: scsiprint.h,v 1.9 2003/01/16 15:28:57 ballen4705 Exp $\n" #endif void scsiPrintMain(char *device, int fd); diff --git a/sm5/smartctl.c b/sm5/smartctl.c index a13d54ac1716f6904519f822e8f0569b4d72f7b6..a5e45d0c99108e68e46680c0d304c18dc4d0f26d 100644 --- a/sm5/smartctl.c +++ b/sm5/smartctl.c @@ -34,21 +34,22 @@ #ifdef HAVE_GETOPT_H #include <getopt.h> #endif -#include "smartctl.h" #include "atacmds.h" #include "ataprint.h" +#include "extern.h" #include "scsicmds.h" #include "scsiprint.h" -#include "extern.h" +#include "smartctl.h" -extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4; -const char* CVSid5="$Id: smartctl.c,v 1.47 2003/01/07 19:47:24 pjwilliams Exp $" -CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6; +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; // This is a block containing all the "control variables". We declare // this globally in this file, and externally in other files. atamainctrl *con=NULL; + void printslogan(){ pout("smartctl version %d.%d-%d Copyright (C) 2002 Bruce Allen\n", (int)RELEASE_MAJOR, (int)RELEASE_MINOR, (int)SMARTMONTOOLS_VERSION); @@ -64,15 +65,17 @@ void printcopy(){ 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"); - printone(out,CVSid1); + printone(out,atacmds_c_cvsid); + pout("%s",out); + printone(out,ataprint_c_cvsid); pout("%s",out); - printone(out,CVSid2); + printone(out,scsicmds_c_cvsid); pout("%s",out); - printone(out,CVSid3); + printone(out,scsiprint_c_cvsid); pout("%s",out); - printone(out,CVSid4); + printone(out,smartctl_c_cvsid); pout("%s",out); - printone(out,CVSid5); + printone(out,utility_c_cvsid); pout("%s",out); return; } diff --git a/sm5/smartctl.cpp b/sm5/smartctl.cpp index 1c244f095f2388f686a1227516402a574aa2023d..6a821acfa8ccd587ed6796d277dea98fc6477155 100644 --- a/sm5/smartctl.cpp +++ b/sm5/smartctl.cpp @@ -34,21 +34,22 @@ #ifdef HAVE_GETOPT_H #include <getopt.h> #endif -#include "smartctl.h" #include "atacmds.h" #include "ataprint.h" +#include "extern.h" #include "scsicmds.h" #include "scsiprint.h" -#include "extern.h" +#include "smartctl.h" -extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4; -const char* CVSid5="$Id: smartctl.cpp,v 1.47 2003/01/07 19:47:24 pjwilliams Exp $" -CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6; +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; // This is a block containing all the "control variables". We declare // this globally in this file, and externally in other files. atamainctrl *con=NULL; + void printslogan(){ pout("smartctl version %d.%d-%d Copyright (C) 2002 Bruce Allen\n", (int)RELEASE_MAJOR, (int)RELEASE_MINOR, (int)SMARTMONTOOLS_VERSION); @@ -64,15 +65,17 @@ void printcopy(){ 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"); - printone(out,CVSid1); + printone(out,atacmds_c_cvsid); + pout("%s",out); + printone(out,ataprint_c_cvsid); pout("%s",out); - printone(out,CVSid2); + printone(out,scsicmds_c_cvsid); pout("%s",out); - printone(out,CVSid3); + printone(out,scsiprint_c_cvsid); pout("%s",out); - printone(out,CVSid4); + printone(out,smartctl_c_cvsid); pout("%s",out); - printone(out,CVSid5); + printone(out,utility_c_cvsid); pout("%s",out); return; } diff --git a/sm5/smartctl.h b/sm5/smartctl.h index 7305c91032a5938d7723ff776def623e4f6cd73c..7036e8e7b95090fe20e62d389462077a362aabe0 100644 --- a/sm5/smartctl.h +++ b/sm5/smartctl.h @@ -25,8 +25,8 @@ #ifndef __SMARTCTL_H_ #define __SMARTCTL_H_ -#ifndef CVSID6 -#define CVSID6 "$Id: smartctl.h,v 1.15 2002/12/19 00:05:19 pjwilliams Exp $\n" +#ifndef SMARTCTL_H_CVSID +#define SMARTCTL_H_CVSID "$Id: smartctl.h,v 1.16 2003/01/16 15:28:57 ballen4705 Exp $\n" #endif /* Boolean Values */ diff --git a/sm5/smartd.c b/sm5/smartd.c index 7260278ae1e2ccd38a8d06f6ca4b5c76d25198dc..e05e2e73de71ca6ec7a16768f22acc3feed7b6f3 100644 --- a/sm5/smartd.c +++ b/sm5/smartd.c @@ -42,16 +42,15 @@ #include <getopt.h> #endif #include "atacmds.h" -#include "scsicmds.h" -#include "smartd.h" #include "ataprint.h" #include "extern.h" - +#include "scsicmds.h" +#include "smartd.h" // CVS ID strings -extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.c,v 1.96 2003/01/12 10:23:29 ballen4705 Exp $" -CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; +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; // global variable used for control of printing, passing arguments, etc. atamainctrl *con=NULL; @@ -1413,12 +1412,17 @@ void PrintCopyleft(void){ printhead(); printout(LOG_INFO,copyleftstring); printout(LOG_INFO,"CVS version IDs of files used to build this code are:\n"); - printone(out,CVSid1); + printone(out,atacmds_c_cvsid); + printout(LOG_INFO,"%s",out); + printone(out,ataprint_c_cvsid); printout(LOG_INFO,"%s",out); - printone(out,CVSid2); + printone(out,scsicmds_c_cvsid); printout(LOG_INFO,"%s",out); - printone(out,CVSid6); + printone(out,smartd_c_cvsid); printout(LOG_INFO,"%s",out); + printone(out,utility_c_cvsid); + printout(LOG_INFO,"%s",out); + } // Parses input line, prints usage message and diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp index 159cda0d0145dec5a4ff5e011cbe343e202fd16f..4e5cdde3aae74408fb1bd1d440158e0ea2ae7bf4 100644 --- a/sm5/smartd.cpp +++ b/sm5/smartd.cpp @@ -42,16 +42,15 @@ #include <getopt.h> #endif #include "atacmds.h" -#include "scsicmds.h" -#include "smartd.h" #include "ataprint.h" #include "extern.h" - +#include "scsicmds.h" +#include "smartd.h" // CVS ID strings -extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.cpp,v 1.96 2003/01/12 10:23:29 ballen4705 Exp $" -CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; +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; // global variable used for control of printing, passing arguments, etc. atamainctrl *con=NULL; @@ -1413,12 +1412,17 @@ void PrintCopyleft(void){ printhead(); printout(LOG_INFO,copyleftstring); printout(LOG_INFO,"CVS version IDs of files used to build this code are:\n"); - printone(out,CVSid1); + printone(out,atacmds_c_cvsid); + printout(LOG_INFO,"%s",out); + printone(out,ataprint_c_cvsid); printout(LOG_INFO,"%s",out); - printone(out,CVSid2); + printone(out,scsicmds_c_cvsid); printout(LOG_INFO,"%s",out); - printone(out,CVSid6); + printone(out,smartd_c_cvsid); printout(LOG_INFO,"%s",out); + printone(out,utility_c_cvsid); + printout(LOG_INFO,"%s",out); + } // Parses input line, prints usage message and diff --git a/sm5/smartd.h b/sm5/smartd.h index bbb4c1c48655e83026bdb052d4018eb4aeb5318d..71154d6690d50ed47a93128d5a19f285bb21e336 100644 --- a/sm5/smartd.h +++ b/sm5/smartd.h @@ -22,8 +22,8 @@ * */ -#ifndef CVSID7 -#define CVSID7 "$Id: smartd.h,v 1.25 2003/01/03 17:25:13 ballen4705 Exp $\n" +#ifndef SMARTD_H_CVSID +#define SMARTD_H_CVSID "$Id: smartd.h,v 1.26 2003/01/16 15:28:58 ballen4705 Exp $\n" #endif // Configuration file diff --git a/sm5/utility.c b/sm5/utility.c new file mode 100644 index 0000000000000000000000000000000000000000..bc70d48194226f6465472bfd53efc9b2b3f7719f --- /dev/null +++ b/sm5/utility.c @@ -0,0 +1,75 @@ +/* + * utility.c + * + * Home page of code is: http://smartmontools.sourceforge.net + * + * Copyright (C) 2002 Bruce Allen <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 + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * You should have received a copy of the GNU General Public License + * (for example COPYING); if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * This code was originally developed as a Senior Thesis by Michael Cornwell + * at the Concurrent Systems Laboratory (now part of the Storage Systems + * Research Center), Jack Baskin School of Engineering, University of + * California, Santa Cruz. http://ssrc.soe.ucsc.edu/ + * + */ + +// THIS FILE IS INTENDED FOR UTILITY ROUTINES THAT ARE APPLICABLE TO +// BOTH SCSI AND ATA DEVICES, AND THAT MAY BE USED IN SMARTD, +// SMARTCTL, OR BOTH. + +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <time.h> +#include "utility.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; + +// Utility function prints date and time and timezone into a character +// buffer of length>=64. All the fuss is needed to get the right +// timezone info (sigh). +void dateandtimezone(char *buffer){ + time_t tval; + struct tm *tmval; + char *timezonename; + char datebuffer[64]; + + // First get the time in seconds since Jan 1 1970 + tval=time(NULL); + + // Now get the time structure. We need this to determine if we + // are in daylight savings time or not. + tmval=localtime(&tval); + + // Convert to an ASCII string, put in datebuffer + asctime_r(tmval, datebuffer); + + // Remove newline + datebuffer[strlen(datebuffer)-1]='\0'; + + // correct timezone name + if (tmval->tm_isdst==0) + // standard time zone + timezonename=tzname[0]; + else if (tmval->tm_isdst>0) + // daylight savings in effect + timezonename=tzname[1]; + else + // unable to determine if daylight savings in effect + timezonename=""; + + // Finally put the information into the buffer as needed. + snprintf(buffer, 64, "%s %s", datebuffer, timezonename); + + return; +} diff --git a/sm5/utility.cpp b/sm5/utility.cpp new file mode 100644 index 0000000000000000000000000000000000000000..97ba0350f667869a9bea3545fac7f9cebd5883c3 --- /dev/null +++ b/sm5/utility.cpp @@ -0,0 +1,75 @@ +/* + * utility.c + * + * Home page of code is: http://smartmontools.sourceforge.net + * + * Copyright (C) 2002 Bruce Allen <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 + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * You should have received a copy of the GNU General Public License + * (for example COPYING); if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * This code was originally developed as a Senior Thesis by Michael Cornwell + * at the Concurrent Systems Laboratory (now part of the Storage Systems + * Research Center), Jack Baskin School of Engineering, University of + * California, Santa Cruz. http://ssrc.soe.ucsc.edu/ + * + */ + +// THIS FILE IS INTENDED FOR UTILITY ROUTINES THAT ARE APPLICABLE TO +// BOTH SCSI AND ATA DEVICES, AND THAT MAY BE USED IN SMARTD, +// SMARTCTL, OR BOTH. + +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <time.h> +#include "utility.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; + +// Utility function prints date and time and timezone into a character +// buffer of length>=64. All the fuss is needed to get the right +// timezone info (sigh). +void dateandtimezone(char *buffer){ + time_t tval; + struct tm *tmval; + char *timezonename; + char datebuffer[64]; + + // First get the time in seconds since Jan 1 1970 + tval=time(NULL); + + // Now get the time structure. We need this to determine if we + // are in daylight savings time or not. + tmval=localtime(&tval); + + // Convert to an ASCII string, put in datebuffer + asctime_r(tmval, datebuffer); + + // Remove newline + datebuffer[strlen(datebuffer)-1]='\0'; + + // correct timezone name + if (tmval->tm_isdst==0) + // standard time zone + timezonename=tzname[0]; + else if (tmval->tm_isdst>0) + // daylight savings in effect + timezonename=tzname[1]; + else + // unable to determine if daylight savings in effect + timezonename=""; + + // Finally put the information into the buffer as needed. + snprintf(buffer, 64, "%s %s", datebuffer, timezonename); + + return; +} diff --git a/sm5/utility.h b/sm5/utility.h new file mode 100644 index 0000000000000000000000000000000000000000..1d1d216a67d62c6ef4d86f18f960924aac687e77 --- /dev/null +++ b/sm5/utility.h @@ -0,0 +1,37 @@ +/* + * utility.h + * + * Home page of code is: http://smartmontools.sourceforge.net + * + * Copyright (C) 2002 Bruce Allen <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 + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * You should have received a copy of the GNU General Public License + * (for example COPYING); if not, write to the Free + * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * This code was originally developed as a Senior Thesis by Michael Cornwell + * at the Concurrent Systems Laboratory (now part of the Storage Systems + * Research Center), Jack Baskin School of Engineering, University of + * California, Santa Cruz. http://ssrc.soe.ucsc.edu/ + * + */ + +#ifndef __UTILITY_H_ +#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" +#endif + +// Utility function prints date and time and timezone into a character +// buffer of length>=64. All the fuss is needed to get the right +// timezone info (sigh). +void dateandtimezone(char *buffer); + +#endif