diff --git a/sm5/Makefile b/sm5/Makefile index 6fe07357c3f02005ebbd074c2b2302cc8d1aca83..f71753df732b6f6fa643fc071a5d5e3f88069224 100644 --- a/sm5/Makefile +++ b/sm5/Makefile @@ -2,7 +2,7 @@ # # Home page: http://smartmontools.sourceforge.net # -# $Id: Makefile,v 1.47 2003/01/16 15:51:09 ballen4705 Exp $ +# $Id: Makefile,v 1.48 2003/01/17 12:20:24 ballen4705 Exp $ # # Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> # @@ -62,7 +62,7 @@ smartd: smartd.c atacmds.o ataprint.o scsicmds.o utility.o\ $(CC) -DSMARTMONTOOLS_VERSION=$(counter) -o smartd $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) smartd.c \ atacmds.o ataprint.o scsicmds.o utility.o -atacmds.o: atacmds.h atacmds.c Makefile +atacmds.o: atacmds.c atacmds.h utility.h Makefile $(CC) $(CFLAGS) $(CPPFLAGS) -c atacmds.c ataprint.o: ataprint.c atacmds.h ataprint.h smartctl.h extern.h utility.h Makefile diff --git a/sm5/atacmds.c b/sm5/atacmds.c index b16e49dc6580fbc970d4ed8b33db85319bc6c277..d98b86ebd20de465911bd0b82d22a980a5230dde 100644 --- a/sm5/atacmds.c +++ b/sm5/atacmds.c @@ -28,8 +28,9 @@ #include <errno.h> #include <stdlib.h> #include "atacmds.h" +#include "utility.h" -const char *atacmds_c_cvsid="$Id: atacmds.c,v 1.52 2003/01/16 15:51:09 ballen4705 Exp $" ATACMDS_H_CVSID; +const char *atacmds_c_cvsid="$Id: atacmds.c,v 1.53 2003/01/17 12:20:24 ballen4705 Exp $" ATACMDS_H_CVSID UTILITY_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 @@ -194,23 +195,6 @@ char *create_vendor_attribute_arg_list(void){ return s; } -// A replacement for perror() that sends output to our choice of -// printing. -void syserror(const char *message){ - const char *errormessage; - - // Get the correct system error message: - errormessage=strerror(errno); - - // Check that caller has handed a sensible string, and provide - // appropriate output. See perrror(3) man page to understand better. - if (message && *message) - pout("%s: %s\n",message, errormessage); - else - pout("%s\n",errormessage); - - return; -} // We no longer use this function, because the IOCTL appears to return // only the drive identity at the time that the system was booted diff --git a/sm5/atacmds.cpp b/sm5/atacmds.cpp index 282dff7d8046bb677568823fa508add4c3e2f6f6..10a4e0b4282788264ecb2a03c206e3e31cd3d244 100644 --- a/sm5/atacmds.cpp +++ b/sm5/atacmds.cpp @@ -28,8 +28,9 @@ #include <errno.h> #include <stdlib.h> #include "atacmds.h" +#include "utility.h" -const char *atacmds_c_cvsid="$Id: atacmds.cpp,v 1.52 2003/01/16 15:51:09 ballen4705 Exp $" ATACMDS_H_CVSID; +const char *atacmds_c_cvsid="$Id: atacmds.cpp,v 1.53 2003/01/17 12:20:24 ballen4705 Exp $" ATACMDS_H_CVSID UTILITY_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 @@ -194,23 +195,6 @@ char *create_vendor_attribute_arg_list(void){ return s; } -// A replacement for perror() that sends output to our choice of -// printing. -void syserror(const char *message){ - const char *errormessage; - - // Get the correct system error message: - errormessage=strerror(errno); - - // Check that caller has handed a sensible string, and provide - // appropriate output. See perrror(3) man page to understand better. - if (message && *message) - pout("%s: %s\n",message, errormessage); - else - pout("%s\n",errormessage); - - return; -} // We no longer use this function, because the IOCTL appears to return // only the drive identity at the time that the system was booted diff --git a/sm5/atacmds.h b/sm5/atacmds.h index 541279547540947cf28797dafbb89f7d29655563..1e4e8eed4d1fc3982e0c052c42e4abe3cc040606 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.32 2003/01/16 15:51:09 ballen4705 Exp $\n" +#define ATACMDS_H_CVSID "$Id: atacmds.h,v 1.33 2003/01/17 12:20:24 ballen4705 Exp $\n" #endif // These are the major and minor versions for smartd and smartctl @@ -345,14 +345,6 @@ int TestTime(struct ata_smart_values *data,int testtype); // 30 byte string with attribute name into output void ataPrintSmartAttribName(char *output, unsigned char id, unsigned char *defs); -// like printf() except that we can control it better.... -void pout(char *fmt, ...) - __attribute__ ((format (printf, 1, 2))); - -// replacement for perror() with redirected output. -void syserror(const char *message); - - // This checks the n'th attribute in the attribute list, NOT the // attribute with id==n. If the attribute does not exist, or the // attribute is > threshold, then returns zero. If the attribute is @@ -363,7 +355,6 @@ int ataCheckAttribute(struct ata_smart_values *data, struct ata_smart_thresholds *thresholds, int n); - // External handler function, for when a checksum is not correct. Can // simply return if no action is desired, or can print error messages // as needed, or exit. Is passed a string with the name of the Data diff --git a/sm5/utility.c b/sm5/utility.c index 22016c1017a20c3580910285aba97a0b97881c08..75158b0849277d59a5a4c188948476b271ecb4d7 100644 --- a/sm5/utility.c +++ b/sm5/utility.c @@ -30,11 +30,12 @@ #include <unistd.h> #include <string.h> #include <time.h> +#include <errno.h> +#include <stdlib.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.2 2003/01/16 15:51:10 ballen4705 Exp $" UTILITY_H_CVSID; +const char* utility_c_cvsid="$Id: utility.c,v 1.3 2003/01/17 12:20:24 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 @@ -130,3 +131,21 @@ void printone(char *block, const char *cvsid){ return; } + +// A replacement for perror() that sends output to our choice of +// printing. +void syserror(const char *message){ + const char *errormessage; + + // Get the correct system error message: + errormessage=strerror(errno); + + // Check that caller has handed a sensible string, and provide + // appropriate output. See perrror(3) man page to understand better. + if (message && *message) + pout("%s: %s\n",message, errormessage); + else + pout("%s\n",errormessage); + + return; +} diff --git a/sm5/utility.cpp b/sm5/utility.cpp index 0bab4162201056cf711ebcd86627ec72171cb78a..edcc2811bdbb8566fbff0d6f86eb0b1f418080f4 100644 --- a/sm5/utility.cpp +++ b/sm5/utility.cpp @@ -30,11 +30,12 @@ #include <unistd.h> #include <string.h> #include <time.h> +#include <errno.h> +#include <stdlib.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.2 2003/01/16 15:51:10 ballen4705 Exp $" UTILITY_H_CVSID; +const char* utility_c_cvsid="$Id: utility.cpp,v 1.3 2003/01/17 12:20:24 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 @@ -130,3 +131,21 @@ void printone(char *block, const char *cvsid){ return; } + +// A replacement for perror() that sends output to our choice of +// printing. +void syserror(const char *message){ + const char *errormessage; + + // Get the correct system error message: + errormessage=strerror(errno); + + // Check that caller has handed a sensible string, and provide + // appropriate output. See perrror(3) man page to understand better. + if (message && *message) + pout("%s: %s\n",message, errormessage); + else + pout("%s\n",errormessage); + + return; +} diff --git a/sm5/utility.h b/sm5/utility.h index da875041c9d7dedf436d04306d4a80b98e811eab..7f8e2cbecf645b19d96a6278443f497d79859e0c 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.2 2003/01/16 15:51:10 ballen4705 Exp $\n" +#define UTILITY_H_CVSID "$Id: utility.h,v 1.3 2003/01/17 12:20:24 ballen4705 Exp $\n" #endif // Utility function prints date and time and timezone into a character @@ -38,4 +38,16 @@ void dateandtimezone(char *buffer); #define CVSMAXLEN 512 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 +// function definition is in smartd.c and in smartctl.c. +void pout(char *fmt, ...) + __attribute__ ((format (printf, 1, 2))); + +// replacement for perror() with redirected output. +void syserror(const char *message); + + + #endif