diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG index 840e7cb6050389b66f42d1cb8292739c1184aac2..0f5bb88467587a7d044ade77769a74ada33898b8 100644 --- a/sm5/CHANGELOG +++ b/sm5/CHANGELOG @@ -1,6 +1,6 @@ CHANGELOG for smartmontools -$Id: CHANGELOG,v 1.63 2002/12/01 07:07:46 ballen4705 Exp $ +$Id: CHANGELOG,v 1.64 2002/12/01 12:14:15 pjwilliams Exp $ Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> @@ -32,6 +32,10 @@ NOTES FOR FUTURE RELEASES: see TODO file. CURRENT RELEASE (see VERSION file in this directory): + [PW] smartd: ParseOpts() now uses getopt_long() if HAVE_GETOPT_LONG is + defined and uses getopt() otherwise. This is controlled by CPPFLAGS in + the Makefile. + [BA] smartd: Fixed a couple of error messages done with perror() to redirect them as needed. diff --git a/sm5/Makefile b/sm5/Makefile index f6697f46ef56a84471a05eae56f9daaa7ffba739..68c936fe88f3e2cf51b97aa4ef41344abcecee89 100644 --- a/sm5/Makefile +++ b/sm5/Makefile @@ -2,7 +2,7 @@ # # Home page: http://smartmontools.sourceforge.net # -# $Id: Makefile,v 1.38 2002/11/15 14:51:31 ballen4705 Exp $ +# $Id: Makefile,v 1.39 2002/12/01 12:14:15 pjwilliams Exp $ # # Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> # @@ -34,8 +34,9 @@ CC = gcc # #8404. If you are getting strange output from gcc 3.2 try # uncommenting LDFLAGS -s below. Stripping the symbols seems to fix # the problem. -CFLAGS = -fsigned-char -Wall -O2 -LDFLAGS = # -s +CFLAGS = -fsigned-char -Wall -O2 +CPPFLAGS = -DHAVE_GETOPT_H -DHAVE_GETOPT_LONG +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\ @@ -52,25 +53,25 @@ all: smartd smartctl smartctl: smartctl.c atacmds.o ataprint.o scsicmds.o scsiprint.o \ smartctl.h atacmds.h ataprint.h scsicmds.h scsiprint.h extern.h VERSION Makefile - $(CC) -DSMARTMONTOOLS_VERSION=$(counter) -o smartctl $(CFLAGS) $(LDFLAGS) smartctl.c \ + $(CC) -DSMARTMONTOOLS_VERSION=$(counter) -o smartctl $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) smartctl.c \ atacmds.o scsicmds.o ataprint.o scsiprint.o smartd: smartd.c atacmds.o ataprint.o scsicmds.o \ smartd.h atacmds.h ataprint.h scsicmds.h extern.h VERSION Makefile - $(CC) -DSMARTMONTOOLS_VERSION=$(counter) -o smartd $(CFLAGS) $(LDFLAGS) smartd.c \ + $(CC) -DSMARTMONTOOLS_VERSION=$(counter) -o smartd $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) smartd.c \ scsicmds.o atacmds.o ataprint.o atacmds.o: atacmds.h atacmds.c Makefile - $(CC) $(CFLAGS) -c atacmds.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c atacmds.c ataprint.o: ataprint.c atacmds.h ataprint.h smartctl.h extern.h Makefile - $(CC) $(CFLAGS) -c ataprint.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c ataprint.c scsicmds.o: scsicmds.c scsicmds.h Makefile - $(CC) $(CFLAGS) -c scsicmds.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c scsicmds.c scsiprint.o: scsiprint.c extern.h scsicmds.h scsiprint.h smartctl.h Makefile - $(CC) $(CFLAGS) -c scsiprint.c + $(CC) $(CFLAGS) $(CPPFLAGS) -c scsiprint.c # This extracts the configuration file directives from smartd.8 and # inserts them into smartd.conf.5 diff --git a/sm5/smartd.c b/sm5/smartd.c index eb825522853c0a1cda50f113198cf7c30180ccde..946a73915b4359499d99bd6e93e80102a3539872 100644 --- a/sm5/smartd.c +++ b/sm5/smartd.c @@ -37,7 +37,9 @@ #include <string.h> #include <time.h> #include <limits.h> +#ifdef HAVE_GETOPT_H #include <getopt.h> +#endif #include "atacmds.h" #include "scsicmds.h" #include "smartd.h" @@ -47,7 +49,7 @@ // CVS ID strings extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.c,v 1.80 2002/12/01 07:16:16 ballen4705 Exp $" +const char *CVSid6="$Id: smartd.c,v 1.81 2002/12/01 12:14:16 pjwilliams Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; // global variable used for control of printing, passing arguments, etc. @@ -1316,6 +1318,7 @@ void ParseOpts(int argc, char **argv){ extern char *optarg; extern int optopt, optind, opterr; int optchar; +#ifdef HAVE_GETOPT_LONG struct option long_options[] = { { "debugmode", no_argument, 0, 'X'}, { "version", no_argument, 0, 'V'}, @@ -1325,11 +1328,16 @@ void ParseOpts(int argc, char **argv){ { "usage", no_argument, 0, 'h'}, { 0, 0, 0, 0 } }; +#endif opterr=optopt=0; // Parse input options: +#ifdef HAVE_GETOPT_LONG while (-1 != (optchar = getopt_long(argc, argv, "XVh?", long_options, NULL))){ +#else + while (-1 != (optchar = getopt(argc, argv, "XVh?"))){ +#endif switch(optchar) { case 'X': debugmode = TRUE; @@ -1347,11 +1355,13 @@ void ParseOpts(int argc, char **argv){ printout(LOG_CRIT,"=======> UNRECOGNIZED OPTION: %c <======= \n\n",optopt); Usage(); exit(-1); +#ifdef HAVE_GETOPT_LONG } else if (optchar == '?' && argv[optind-1][1] == '-') { printhead(); printout(LOG_CRIT,"=======> UNRECOGNIZED OPTION: %s <======= \n\n",argv[optind-1]+2); Usage(); exit(-1); +#endif } printhead(); Usage(); diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp index cf2b855dc45cf964ecd3413fcbb089b8d0a9e2a7..69478a7c478982cec5938a60d1c1c7838722ebf9 100644 --- a/sm5/smartd.cpp +++ b/sm5/smartd.cpp @@ -37,7 +37,9 @@ #include <string.h> #include <time.h> #include <limits.h> +#ifdef HAVE_GETOPT_H #include <getopt.h> +#endif #include "atacmds.h" #include "scsicmds.h" #include "smartd.h" @@ -47,7 +49,7 @@ // CVS ID strings extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.cpp,v 1.80 2002/12/01 07:16:16 ballen4705 Exp $" +const char *CVSid6="$Id: smartd.cpp,v 1.81 2002/12/01 12:14:16 pjwilliams Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; // global variable used for control of printing, passing arguments, etc. @@ -1316,6 +1318,7 @@ void ParseOpts(int argc, char **argv){ extern char *optarg; extern int optopt, optind, opterr; int optchar; +#ifdef HAVE_GETOPT_LONG struct option long_options[] = { { "debugmode", no_argument, 0, 'X'}, { "version", no_argument, 0, 'V'}, @@ -1325,11 +1328,16 @@ void ParseOpts(int argc, char **argv){ { "usage", no_argument, 0, 'h'}, { 0, 0, 0, 0 } }; +#endif opterr=optopt=0; // Parse input options: +#ifdef HAVE_GETOPT_LONG while (-1 != (optchar = getopt_long(argc, argv, "XVh?", long_options, NULL))){ +#else + while (-1 != (optchar = getopt(argc, argv, "XVh?"))){ +#endif switch(optchar) { case 'X': debugmode = TRUE; @@ -1347,11 +1355,13 @@ void ParseOpts(int argc, char **argv){ printout(LOG_CRIT,"=======> UNRECOGNIZED OPTION: %c <======= \n\n",optopt); Usage(); exit(-1); +#ifdef HAVE_GETOPT_LONG } else if (optchar == '?' && argv[optind-1][1] == '-') { printhead(); printout(LOG_CRIT,"=======> UNRECOGNIZED OPTION: %s <======= \n\n",argv[optind-1]+2); Usage(); exit(-1); +#endif } printhead(); Usage();