Skip to content
Snippets Groups Projects
Commit 5e38d6be authored by pjwilliams's avatar pjwilliams
Browse files

Added printvalidarglistmessage()

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@440 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent 8caf6f8a
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include "extern.h" #include "extern.h"
extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4; extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4;
const char* CVSid5="$Id: smartctl.c,v 1.46 2003/01/07 19:29:26 pjwilliams Exp $" const char* CVSid5="$Id: smartctl.c,v 1.47 2003/01/07 19:47:24 pjwilliams Exp $"
CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6; CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6;
// This is a block containing all the "control variables". We declare // This is a block containing all the "control variables". We declare
...@@ -236,6 +236,19 @@ const char *getvalidarglist(char opt) { ...@@ -236,6 +236,19 @@ const char *getvalidarglist(char opt) {
} }
} }
/* Prints the message "=======> VALID ARGUMENTS ARE: <LIST> <=======\n", where
<LIST> is the list of valid arguments for option opt. */
void printvalidarglistmessage(char opt) {
const char *s;
pout("=======> VALID ARGUMENTS ARE: ");
if (!(s = getvalidarglist(opt)))
pout("Error whilst constructing argument list for option %c", opt);
else
pout((char *)s);
pout(" <=======\n");
}
unsigned char tryata=0,tryscsi=0; unsigned char tryata=0,tryscsi=0;
/* Takes command options and sets features to be run */ /* Takes command options and sets features to be run */
...@@ -460,7 +473,7 @@ void ParseOpts (int argc, char** argv){ ...@@ -460,7 +473,7 @@ void ParseOpts (int argc, char** argv){
// Iff optopt holds a valid option then argument must be missing. // Iff optopt holds a valid option then argument must be missing.
if (optopt && (strchr(shortopts, optopt) != NULL)) { if (optopt && (strchr(shortopts, optopt) != NULL)) {
pout("=======> ARGUMENT REQUIRED FOR OPTION: %s <=======\n", arg+2); pout("=======> ARGUMENT REQUIRED FOR OPTION: %s <=======\n", arg+2);
pout("=======> VALID ARGUMENTS ARE: %s <=======\n", getvalidarglist(optopt)); printvalidarglistmessage(optopt);
} else } else
pout("=======> UNRECOGNIZED OPTION: %s <=======\n",arg+2); pout("=======> UNRECOGNIZED OPTION: %s <=======\n",arg+2);
pout("\nUse smartctl --help to get a usage summary\n\n"); pout("\nUse smartctl --help to get a usage summary\n\n");
...@@ -471,7 +484,7 @@ void ParseOpts (int argc, char** argv){ ...@@ -471,7 +484,7 @@ void ParseOpts (int argc, char** argv){
// Iff optopt holds a valid option then argument must be missing. // Iff optopt holds a valid option then argument must be missing.
if (strchr(shortopts, optopt) != NULL) { if (strchr(shortopts, optopt) != NULL) {
pout("=======> ARGUMENT REQUIRED FOR OPTION: %c <=======\n", optopt); pout("=======> ARGUMENT REQUIRED FOR OPTION: %c <=======\n", optopt);
pout("=======> VALID ARGUMENTS ARE: %s <=======\n", getvalidarglist(optopt)); printvalidarglistmessage(optopt);
} else } else
pout("=======> UNRECOGNIZED OPTION: %c <=======\n",optopt); pout("=======> UNRECOGNIZED OPTION: %c <=======\n",optopt);
pout("\nUse smartctl -h to get a usage summary\n\n"); pout("\nUse smartctl -h to get a usage summary\n\n");
...@@ -488,7 +501,7 @@ void ParseOpts (int argc, char** argv){ ...@@ -488,7 +501,7 @@ void ParseOpts (int argc, char** argv){
// here, but we just print the short form. Please fix this if you know // here, but we just print the short form. Please fix this if you know
// a clean way to do it. // a clean way to do it.
pout("=======> INVALID ARGUMENT TO -%c: %s <======= \n", optchar, optarg); pout("=======> INVALID ARGUMENT TO -%c: %s <======= \n", optchar, optarg);
pout("=======> VALID ARGUMENTS ARE: %s <=======\n", getvalidarglist(optchar)); printvalidarglistmessage(optchar);
pout("\nUse smartctl -h to get a usage summary\n\n"); pout("\nUse smartctl -h to get a usage summary\n\n");
exit(FAILCMD); exit(FAILCMD);
} }
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include "extern.h" #include "extern.h"
extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4; extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4;
const char* CVSid5="$Id: smartctl.cpp,v 1.46 2003/01/07 19:29:26 pjwilliams Exp $" const char* CVSid5="$Id: smartctl.cpp,v 1.47 2003/01/07 19:47:24 pjwilliams Exp $"
CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6; CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6;
// This is a block containing all the "control variables". We declare // This is a block containing all the "control variables". We declare
...@@ -236,6 +236,19 @@ const char *getvalidarglist(char opt) { ...@@ -236,6 +236,19 @@ const char *getvalidarglist(char opt) {
} }
} }
/* Prints the message "=======> VALID ARGUMENTS ARE: <LIST> <=======\n", where
<LIST> is the list of valid arguments for option opt. */
void printvalidarglistmessage(char opt) {
const char *s;
pout("=======> VALID ARGUMENTS ARE: ");
if (!(s = getvalidarglist(opt)))
pout("Error whilst constructing argument list for option %c", opt);
else
pout((char *)s);
pout(" <=======\n");
}
unsigned char tryata=0,tryscsi=0; unsigned char tryata=0,tryscsi=0;
/* Takes command options and sets features to be run */ /* Takes command options and sets features to be run */
...@@ -460,7 +473,7 @@ void ParseOpts (int argc, char** argv){ ...@@ -460,7 +473,7 @@ void ParseOpts (int argc, char** argv){
// Iff optopt holds a valid option then argument must be missing. // Iff optopt holds a valid option then argument must be missing.
if (optopt && (strchr(shortopts, optopt) != NULL)) { if (optopt && (strchr(shortopts, optopt) != NULL)) {
pout("=======> ARGUMENT REQUIRED FOR OPTION: %s <=======\n", arg+2); pout("=======> ARGUMENT REQUIRED FOR OPTION: %s <=======\n", arg+2);
pout("=======> VALID ARGUMENTS ARE: %s <=======\n", getvalidarglist(optopt)); printvalidarglistmessage(optopt);
} else } else
pout("=======> UNRECOGNIZED OPTION: %s <=======\n",arg+2); pout("=======> UNRECOGNIZED OPTION: %s <=======\n",arg+2);
pout("\nUse smartctl --help to get a usage summary\n\n"); pout("\nUse smartctl --help to get a usage summary\n\n");
...@@ -471,7 +484,7 @@ void ParseOpts (int argc, char** argv){ ...@@ -471,7 +484,7 @@ void ParseOpts (int argc, char** argv){
// Iff optopt holds a valid option then argument must be missing. // Iff optopt holds a valid option then argument must be missing.
if (strchr(shortopts, optopt) != NULL) { if (strchr(shortopts, optopt) != NULL) {
pout("=======> ARGUMENT REQUIRED FOR OPTION: %c <=======\n", optopt); pout("=======> ARGUMENT REQUIRED FOR OPTION: %c <=======\n", optopt);
pout("=======> VALID ARGUMENTS ARE: %s <=======\n", getvalidarglist(optopt)); printvalidarglistmessage(optopt);
} else } else
pout("=======> UNRECOGNIZED OPTION: %c <=======\n",optopt); pout("=======> UNRECOGNIZED OPTION: %c <=======\n",optopt);
pout("\nUse smartctl -h to get a usage summary\n\n"); pout("\nUse smartctl -h to get a usage summary\n\n");
...@@ -488,7 +501,7 @@ void ParseOpts (int argc, char** argv){ ...@@ -488,7 +501,7 @@ void ParseOpts (int argc, char** argv){
// here, but we just print the short form. Please fix this if you know // here, but we just print the short form. Please fix this if you know
// a clean way to do it. // a clean way to do it.
pout("=======> INVALID ARGUMENT TO -%c: %s <======= \n", optchar, optarg); pout("=======> INVALID ARGUMENT TO -%c: %s <======= \n", optchar, optarg);
pout("=======> VALID ARGUMENTS ARE: %s <=======\n", getvalidarglist(optchar)); printvalidarglistmessage(optchar);
pout("\nUse smartctl -h to get a usage summary\n\n"); pout("\nUse smartctl -h to get a usage summary\n\n");
exit(FAILCMD); exit(FAILCMD);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment