diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG index fca1a008e16956362e7fdf7ee944f8c0ebb974f7..433210909af46f0e3d9aea112a93baf981af849f 100644 --- a/sm5/CHANGELOG +++ b/sm5/CHANGELOG @@ -1,6 +1,6 @@ CHANGELOG for smartmontools -$Id: CHANGELOG,v 1.71 2002/12/28 16:16:52 pjwilliams Exp $ +$Id: CHANGELOG,v 1.72 2002/12/29 01:10:41 pjwilliams Exp $ Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> @@ -32,6 +32,8 @@ NOTES FOR FUTURE RELEASES: see TODO file. CURRENT RELEASE (see VERSION file in this directory): + [PW] Replaced smartd.conf directive -C with smartd option -i + [PW] Changed options for smartctl -- see man page. [BA] Use strerror() to generate system call error messages. diff --git a/sm5/README b/sm5/README index 435c2169d4b264b0f3717446d2a29fa6bc0b5e77..c791f793d7409f536066e4ebdcd4ce1d28b1567a 100644 --- a/sm5/README +++ b/sm5/README @@ -218,7 +218,7 @@ old to new smartd.conf directives: -A -X --abort - SHOULD BECOME A COMMAND-LINE ARGUMENT (-i N, --interval N) =======> -C N Set checktime NOW CMD LINE: -i N + NOW A COMMAND-LINE OPTION (-i N, --interval N) =======> -C N Set checktime CMD LINE: -i N -f usage attributes -f -M ADD Email addresses -m ADD -m -3 Email mode -M diminishing,test @@ -234,7 +234,7 @@ old to new smartd.conf directives: \ Line continuation \ ------------------------------------------------------------------------------------------------------------------- -Changes to smartd options (not yet implemented): +Changes to smartd options (in progress): ---------------------------------------------------------------------------------------------------------- 5.0 short 5.0 long 5.1 short 5.1 long diff --git a/sm5/smartd.8 b/sm5/smartd.8 index fdbb71efa5415b6b16feb3e12007b34bac0617ac..5f92c1d1aa9ecffdd860e88d100beb856f23e89d 100644 --- a/sm5/smartd.8 +++ b/sm5/smartd.8 @@ -1,6 +1,6 @@ \# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> \# -\# $Id: smartd.8,v 1.41 2002/12/08 12:56:52 pjwilliams Exp $ +\# $Id: smartd.8,v 1.42 2002/12/29 01:10:42 pjwilliams Exp $ \# \# 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 @@ -16,11 +16,11 @@ \# Research Center), Jack Baskin School of Engineering, University of \# California, Santa Cruz. http://ssrc.soe.ucsc.edu/ \# -.TH SMARTD 8 "$Date: 2002/12/08 12:56:52 $" "smartmontools-5.0" +.TH SMARTD 8 "$Date: 2002/12/29 01:10:42 $" "smartmontools-5.0" .SH NAME smartd \- S.M.A.R.T. Daemon .SH SYNOPSIS -.B smartd [-XVh] [--debug] [--version] [--help] +.B smartd [options] .SH DESCRIPTION .B smartd @@ -65,8 +65,8 @@ signal to .B smartd it will immediately check the status of the disks, and then return to polling the disks every 30 minutes. See the -.B '\-C' -Directive below for additional details. +.B '\-i' +option below for additional details. On startup, in the absence of the configuration file .B /etc/smartd.conf, @@ -104,6 +104,34 @@ in "debug" mode. In this mode, it does not .B fork (2) and displays status information to STDOUT. It also prints more verbose information about what it is doing. +.TP +.B \-i N, \-\-interval=N +Sets the interval between disk checks to +.I N +seconds, where +.I N +is a decimal integer. The minimum allowed value is ten and the maximum is the +largest positive integer that can be represented on your system (often 2^31-1). +The default is 1800 seconds. + +Note that the superuser can make +.B smartd +check the status of the disks at any time by sending it the +.B SIGHUP +signal, for example with the command: +.nf +.B kill -SIGUSR1 <pid> +.fi +where +.B <pid> +is the process id number of +.B smartd. +One may also use: +.nf +.B killall -USR1 smartd +.fi +for the same purpose. + .TP .B \-V, \-\-version, \-\-license, \-\-copyright Prints license, copyright, and CVS version information onto @@ -276,7 +304,7 @@ possible. .B If a SCSI disk is listed, it will be monitored at the only implemented level: roughly equivalent -to using the '\-c' option for an ATA disk. So with the exception of '\-S', '\-C', '\-M', and '\-m', +to using the '\-c' option for an ATA disk. So with the exception of '\-S', '\-M', and '\-m', the Directives below are ignored for SCSI disks. For SCSI disks, the '\-M' Directive sends a warning email if the SMART status indicates a disk failure or problem. @@ -298,33 +326,6 @@ device names like /dev/hda or /dev/sdb. If can't guess from this sixth character, then it will simply try to access the device using first ATA and then SCSI ioctl()s. .TP -.B \-C <N> -This sets the time in between disk checks to be -.B <N> -seconds apart, where N is a decimal integer. Note that although you can give this Directive -multiple times on different lines of the configuration file, only the -final value that is given is used. That final value applies to all the disks. -The default value of -.B <N> -is 1800 sec, and the minimum allowed value is -ten seconds. The maximum value is 2^31-1 seconds. - -Note that the superuser can make -.B smartd -check the status of the disks at any time by sending it the -.B SIGHUP -signal, for example with the command: -.nf -.B kill -SIGUSR1 <pid> -.fi -where -.B <pid> -is the process id number of smartd. One may also use: -.nf -.B killall -USR1 smartd -.fi -for the same purpose. -.TP .B \-P Permissive: Even if the disk appears to lack SMART capabilities, try to monitor it anyway. This may be required for some old disks (prior @@ -656,4 +657,4 @@ Please let us know if there is an on\-line source for this document. .SH CVS ID OF THIS PAGE: -$Id: smartd.8,v 1.41 2002/12/08 12:56:52 pjwilliams Exp $ +$Id: smartd.8,v 1.42 2002/12/29 01:10:42 pjwilliams Exp $ diff --git a/sm5/smartd.c b/sm5/smartd.c index eb66adf5d9e6e1d576d646d0ae8d8a9e961f04bf..5c49c733edfc84a59d77a229c275ebe068dd870c 100644 --- a/sm5/smartd.c +++ b/sm5/smartd.c @@ -50,7 +50,7 @@ // CVS ID strings extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.c,v 1.88 2002/12/16 12:27:00 ballen4705 Exp $" +const char *CVSid6="$Id: smartd.c,v 1.89 2002/12/29 01:10:42 pjwilliams Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; // global variable used for control of printing, passing arguments, etc. @@ -318,7 +318,6 @@ void Directives() { printout(LOG_INFO,"Configuration file Directives (following device name):\n"); printout(LOG_INFO," -A Device is an ATA device\n"); printout(LOG_INFO," -S Device is a SCSI device\n"); - printout(LOG_INFO," -C N Check disks once every N seconds, where N>=10.\n"); printout(LOG_INFO," -P Permissive, ignore apparent lack of SMART.\n"); printout(LOG_INFO," -T N Automatic offline tests. N=0: Disable, 1: Enable.\n"); printout(LOG_INFO," -s N Attribute Autosave. N=0: Disable, 1: Enable.\n"); @@ -337,24 +336,26 @@ void Directives() { printout(LOG_INFO," # Comment: text after a hash sign is ignored\n"); printout(LOG_INFO," \\ Line continuation character\n"); printout(LOG_INFO,"Attribute ID is a decimal integer 1 <= ID <= 255\n"); - printout(LOG_INFO,"SCSI devices: only -S, -C, -M, and -m Directives allowed.\n"); + printout(LOG_INFO,"SCSI devices: only -S, -M, and -m Directives allowed.\n"); printout(LOG_INFO,"Example: /dev/hda -a\n"); return; } /* prints help information for command syntax */ void Usage (void){ + printout(LOG_INFO,"Usage: smartd [options]\n\n"); #ifdef HAVE_GETOPT_LONG - printout(LOG_INFO,"Usage: smartd [-XVh] [--debug] [--version] [--help]\n\n"); printout(LOG_INFO,"Command Line Options:\n"); printout(LOG_INFO," -X, --debug\n Start smartd in debug mode\n\n"); + printout(LOG_INFO," -i N, --interval=N\n"); + printout(LOG_INFO," Set interval between disk checks to N seconds, where N >= 10\n\n"); printout(LOG_INFO," -V, --version, --license, --copyright\n"); printout(LOG_INFO," Print License, Copyright, and version information\n\n"); printout(LOG_INFO," -h, -?, --help, --usage\n Display this help and exit\n\n"); #else - printout(LOG_INFO,"Usage: smartd [-XVh]\n\n"); printout(LOG_INFO,"Command Line Options:\n"); printout(LOG_INFO," -X Start smartd in debug mode\n"); + printout(LOG_INFO," -i N Set interval between disk checks to N seconds, where N >= 10\n"); printout(LOG_INFO," -V Print License, Copyright, and version information\n"); printout(LOG_INFO," -h Display this help and exit\n"); printout(LOG_INFO," -? Same as -h\n"); @@ -1067,10 +1068,6 @@ int parsetoken(char *token,cfgfile *cfg){ val=inttoken(arg=strtok(NULL,delim), name, token, lineno, CONFIGFILE, 1, 255); isattoff(val,cfg->trackatt,1); break; - case 'C': - // period (time interval) for checking - checktime=inttoken(arg=strtok(NULL,delim), name, token, lineno, CONFIGFILE, 10, INT_MAX); - break; case 'M': // send email to address that follows arg=strtok(NULL,delim); @@ -1325,15 +1322,20 @@ void ParseOpts(int argc, char **argv){ extern char *optarg; extern int optopt, optind, opterr; int optchar; + char *tailptr; + long lchecktime; + const char *shortopts = "Xi:Vh?"; #ifdef HAVE_GETOPT_LONG - struct option long_options[] = { - { "debug", no_argument, 0, 'X'}, - { "version", no_argument, 0, 'V'}, - { "license", no_argument, 0, 'V'}, - { "copyright", no_argument, 0, 'V'}, - { "help", no_argument, 0, 'h'}, - { "usage", no_argument, 0, 'h'}, - { 0, 0, 0, 0 } + char *arg; + struct option longopts[] = { + { "debug", no_argument, 0, 'X' }, + { "interval", required_argument, 0, 'i' }, + { "version", no_argument, 0, 'V' }, + { "license", no_argument, 0, 'V' }, + { "copyright", no_argument, 0, 'V' }, + { "help", no_argument, 0, 'h' }, + { "usage", no_argument, 0, 'h' }, + { 0, 0, 0, 0 } }; #endif @@ -1341,14 +1343,29 @@ void ParseOpts(int argc, char **argv){ // Parse input options: #ifdef HAVE_GETOPT_LONG - while (-1 != (optchar = getopt_long(argc, argv, "XVh?", long_options, NULL))){ + while (-1 != (optchar = getopt_long(argc, argv, shortopts, longopts, NULL))){ #else - while (-1 != (optchar = getopt(argc, argv, "XVh?"))){ + while (-1 != (optchar = getopt(argc, argv, shortopts))){ #endif switch(optchar) { case 'X': debugmode = TRUE; break; + case 'i': + // Period (time interval) for checking + // strtol will set errno in the event of overflow, so we'll check it. + errno = 0; + lchecktime = strtol(optarg, &tailptr, 10); + if (*tailptr != '\0' || lchecktime < 10 || lchecktime > INT_MAX || errno) { + debugmode=1; + printhead(); + printout(LOG_CRIT, "======> INVALID INTERVAL: %s <=======\n", optarg); + printout(LOG_CRIT, "======> INTERVAL MUST BE INTEGER BETWEEN %d AND %d <=======\n", 10, INT_MAX); + Usage(); + exit(-1); + } + checktime = (int)lchecktime; + break; case 'V': PrintCopyleft(); exit(0); @@ -1357,25 +1374,36 @@ void ParseOpts(int argc, char **argv){ case 'h': default: debugmode=1; - if (optopt) { - printhead(); - printout(LOG_CRIT,"=======> UNRECOGNIZED OPTION: %c <======= \n\n",optopt); - Usage(); - exit(-1); + printhead(); #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); + // Point arg to the argument in which this option was found. + arg = argv[optind-1]; + // Check whether the option is a long option that doesn't map to -h. + if (arg[1] == '-' && optchar != 'h') { + // Iff optopt holds a valid option then argument must be missing. + if (optopt && (strchr(shortopts, optopt) != NULL)) { + printout(LOG_CRIT, "=======> ARGUMENT REQUIRED FOR OPTION: %s <=======\n\n",arg+2); + } else { + printout(LOG_CRIT, "=======> UNRECOGNIZED OPTION: %s <=======\n\n",arg+2); + } + Usage(); + exit(-1); + } #endif + if (optopt) { + // Iff optopt holds a valid option then argument must be missing. + if (strchr(shortopts, optopt) != NULL){ + printout(LOG_CRIT, "=======> ARGUMENT REQUIRED FOR OPTION: %c <=======\n\n",optopt); + } else { + printout(LOG_CRIT, "=======> UNRECOGNIZED OPTION: %c <=======\n\n",optopt); + } + Usage(); + exit(-1); } - printhead(); Usage(); exit(0); } } - // print header printhead(); return; diff --git a/sm5/smartd.conf b/sm5/smartd.conf index 10bfe8df039a18753abe3f46e300a799b6dada71..66ce40d9e7e1f52f446e0b282bc15332c93c0e9e 100644 --- a/sm5/smartd.conf +++ b/sm5/smartd.conf @@ -34,7 +34,6 @@ monitor. # HERE IS A LIST OF DIRECTIVES FOR THIS CONFIGURATION FILE # -A Device is an ATA device # -S Device is a SCSI device -# -C N Check disks every N seconds. N must be 10 or greater # -P Ignore lack of SMART (for disks before ATA-3 Rev 4) # -T N Automatic Offline Testing. N=1: enable, N=0: disable # -s N Attribute Autosave. N=1: enable, N=0: disable diff --git a/sm5/smartd.conf.5 b/sm5/smartd.conf.5 index 4a353363fbb9d276479cd83392fef98ae7cf0285..9ae2d02a691dbc8518698739fd4940ba9bdcf1d4 100644 --- a/sm5/smartd.conf.5 +++ b/sm5/smartd.conf.5 @@ -1,6 +1,6 @@ \# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net> \# -\# $Id: smartd.conf.5,v 1.14 2002/12/03 23:29:21 pjwilliams Exp $ +\# $Id: smartd.conf.5,v 1.15 2002/12/29 01:10:42 pjwilliams Exp $ \# \# 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 @@ -16,7 +16,7 @@ \# Research Center), Jack Baskin School of Engineering, University of \# California, Santa Cruz. http://ssrc.soe.ucsc.edu/ \# -.TH SMARTD.CONF 5 "$Date: 2002/12/03 23:29:21 $" "smartmontools-5.0" +.TH SMARTD.CONF 5 "$Date: 2002/12/29 01:10:42 $" "smartmontools-5.0" .SH NAME smartd.conf \- S.M.A.R.T. Monitoring Daemon Configuration File @@ -160,7 +160,7 @@ possible. .B If a SCSI disk is listed, it will be monitored at the only implemented level: roughly equivalent -to using the '\-c' option for an ATA disk. So with the exception of '\-S', '\-C', '\-M', and '\-m', +to using the '\-c' option for an ATA disk. So with the exception of '\-S', '\-M', and '\-m', the Directives below are ignored for SCSI disks. For SCSI disks, the '\-M' Directive sends a warning email if the SMART status indicates a disk failure or problem. @@ -182,33 +182,6 @@ device names like /dev/hda or /dev/sdb. If can't guess from this sixth character, then it will simply try to access the device using first ATA and then SCSI ioctl()s. .TP -.B \-C <N> -This sets the time in between disk checks to be -.B <N> -seconds apart, where N is a decimal integer. Note that although you can give this Directive -multiple times on different lines of the configuration file, only the -final value that is given is used. That final value applies to all the disks. -The default value of -.B <N> -is 1800 sec, and the minimum allowed value is -ten seconds. The maximum value is 2^31-1 seconds. - -Note that the superuser can make -.B smartd -check the status of the disks at any time by sending it the -.B SIGHUP -signal, for example with the command: -.nf -.B kill -SIGUSR1 <pid> -.fi -where -.B <pid> -is the process id number of smartd. One may also use: -.nf -.B killall -USR1 smartd -.fi -for the same purpose. -.TP .B \-P Permissive: Even if the disk appears to lack SMART capabilities, try to monitor it anyway. This may be required for some old disks (prior @@ -470,4 +443,4 @@ SEE ALSO: .SH CVS ID OF THIS PAGE: -$Id: smartd.conf.5,v 1.14 2002/12/03 23:29:21 pjwilliams Exp $ +$Id: smartd.conf.5,v 1.15 2002/12/29 01:10:42 pjwilliams Exp $ diff --git a/sm5/smartd.cpp b/sm5/smartd.cpp index 72dafec7c273d2bf4cde9c42cab7de102ff1e3aa..e81d6a4f588c71578ef990b5b66554af97dd5efe 100644 --- a/sm5/smartd.cpp +++ b/sm5/smartd.cpp @@ -50,7 +50,7 @@ // CVS ID strings extern const char *CVSid1, *CVSid2; -const char *CVSid6="$Id: smartd.cpp,v 1.88 2002/12/16 12:27:00 ballen4705 Exp $" +const char *CVSid6="$Id: smartd.cpp,v 1.89 2002/12/29 01:10:42 pjwilliams Exp $" CVSID1 CVSID2 CVSID3 CVSID4 CVSID7; // global variable used for control of printing, passing arguments, etc. @@ -318,7 +318,6 @@ void Directives() { printout(LOG_INFO,"Configuration file Directives (following device name):\n"); printout(LOG_INFO," -A Device is an ATA device\n"); printout(LOG_INFO," -S Device is a SCSI device\n"); - printout(LOG_INFO," -C N Check disks once every N seconds, where N>=10.\n"); printout(LOG_INFO," -P Permissive, ignore apparent lack of SMART.\n"); printout(LOG_INFO," -T N Automatic offline tests. N=0: Disable, 1: Enable.\n"); printout(LOG_INFO," -s N Attribute Autosave. N=0: Disable, 1: Enable.\n"); @@ -337,24 +336,26 @@ void Directives() { printout(LOG_INFO," # Comment: text after a hash sign is ignored\n"); printout(LOG_INFO," \\ Line continuation character\n"); printout(LOG_INFO,"Attribute ID is a decimal integer 1 <= ID <= 255\n"); - printout(LOG_INFO,"SCSI devices: only -S, -C, -M, and -m Directives allowed.\n"); + printout(LOG_INFO,"SCSI devices: only -S, -M, and -m Directives allowed.\n"); printout(LOG_INFO,"Example: /dev/hda -a\n"); return; } /* prints help information for command syntax */ void Usage (void){ + printout(LOG_INFO,"Usage: smartd [options]\n\n"); #ifdef HAVE_GETOPT_LONG - printout(LOG_INFO,"Usage: smartd [-XVh] [--debug] [--version] [--help]\n\n"); printout(LOG_INFO,"Command Line Options:\n"); printout(LOG_INFO," -X, --debug\n Start smartd in debug mode\n\n"); + printout(LOG_INFO," -i N, --interval=N\n"); + printout(LOG_INFO," Set interval between disk checks to N seconds, where N >= 10\n\n"); printout(LOG_INFO," -V, --version, --license, --copyright\n"); printout(LOG_INFO," Print License, Copyright, and version information\n\n"); printout(LOG_INFO," -h, -?, --help, --usage\n Display this help and exit\n\n"); #else - printout(LOG_INFO,"Usage: smartd [-XVh]\n\n"); printout(LOG_INFO,"Command Line Options:\n"); printout(LOG_INFO," -X Start smartd in debug mode\n"); + printout(LOG_INFO," -i N Set interval between disk checks to N seconds, where N >= 10\n"); printout(LOG_INFO," -V Print License, Copyright, and version information\n"); printout(LOG_INFO," -h Display this help and exit\n"); printout(LOG_INFO," -? Same as -h\n"); @@ -1067,10 +1068,6 @@ int parsetoken(char *token,cfgfile *cfg){ val=inttoken(arg=strtok(NULL,delim), name, token, lineno, CONFIGFILE, 1, 255); isattoff(val,cfg->trackatt,1); break; - case 'C': - // period (time interval) for checking - checktime=inttoken(arg=strtok(NULL,delim), name, token, lineno, CONFIGFILE, 10, INT_MAX); - break; case 'M': // send email to address that follows arg=strtok(NULL,delim); @@ -1325,15 +1322,20 @@ void ParseOpts(int argc, char **argv){ extern char *optarg; extern int optopt, optind, opterr; int optchar; + char *tailptr; + long lchecktime; + const char *shortopts = "Xi:Vh?"; #ifdef HAVE_GETOPT_LONG - struct option long_options[] = { - { "debug", no_argument, 0, 'X'}, - { "version", no_argument, 0, 'V'}, - { "license", no_argument, 0, 'V'}, - { "copyright", no_argument, 0, 'V'}, - { "help", no_argument, 0, 'h'}, - { "usage", no_argument, 0, 'h'}, - { 0, 0, 0, 0 } + char *arg; + struct option longopts[] = { + { "debug", no_argument, 0, 'X' }, + { "interval", required_argument, 0, 'i' }, + { "version", no_argument, 0, 'V' }, + { "license", no_argument, 0, 'V' }, + { "copyright", no_argument, 0, 'V' }, + { "help", no_argument, 0, 'h' }, + { "usage", no_argument, 0, 'h' }, + { 0, 0, 0, 0 } }; #endif @@ -1341,14 +1343,29 @@ void ParseOpts(int argc, char **argv){ // Parse input options: #ifdef HAVE_GETOPT_LONG - while (-1 != (optchar = getopt_long(argc, argv, "XVh?", long_options, NULL))){ + while (-1 != (optchar = getopt_long(argc, argv, shortopts, longopts, NULL))){ #else - while (-1 != (optchar = getopt(argc, argv, "XVh?"))){ + while (-1 != (optchar = getopt(argc, argv, shortopts))){ #endif switch(optchar) { case 'X': debugmode = TRUE; break; + case 'i': + // Period (time interval) for checking + // strtol will set errno in the event of overflow, so we'll check it. + errno = 0; + lchecktime = strtol(optarg, &tailptr, 10); + if (*tailptr != '\0' || lchecktime < 10 || lchecktime > INT_MAX || errno) { + debugmode=1; + printhead(); + printout(LOG_CRIT, "======> INVALID INTERVAL: %s <=======\n", optarg); + printout(LOG_CRIT, "======> INTERVAL MUST BE INTEGER BETWEEN %d AND %d <=======\n", 10, INT_MAX); + Usage(); + exit(-1); + } + checktime = (int)lchecktime; + break; case 'V': PrintCopyleft(); exit(0); @@ -1357,25 +1374,36 @@ void ParseOpts(int argc, char **argv){ case 'h': default: debugmode=1; - if (optopt) { - printhead(); - printout(LOG_CRIT,"=======> UNRECOGNIZED OPTION: %c <======= \n\n",optopt); - Usage(); - exit(-1); + printhead(); #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); + // Point arg to the argument in which this option was found. + arg = argv[optind-1]; + // Check whether the option is a long option that doesn't map to -h. + if (arg[1] == '-' && optchar != 'h') { + // Iff optopt holds a valid option then argument must be missing. + if (optopt && (strchr(shortopts, optopt) != NULL)) { + printout(LOG_CRIT, "=======> ARGUMENT REQUIRED FOR OPTION: %s <=======\n\n",arg+2); + } else { + printout(LOG_CRIT, "=======> UNRECOGNIZED OPTION: %s <=======\n\n",arg+2); + } + Usage(); + exit(-1); + } #endif + if (optopt) { + // Iff optopt holds a valid option then argument must be missing. + if (strchr(shortopts, optopt) != NULL){ + printout(LOG_CRIT, "=======> ARGUMENT REQUIRED FOR OPTION: %c <=======\n\n",optopt); + } else { + printout(LOG_CRIT, "=======> UNRECOGNIZED OPTION: %c <=======\n\n",optopt); + } + Usage(); + exit(-1); } - printhead(); Usage(); exit(0); } } - // print header printhead(); return;