Skip to content
Snippets Groups Projects
Commit ca8f08a0 authored by ballen4705's avatar ballen4705
Browse files

Simply exit after printing licence/version/copyright information. It's simpler this way.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@424 4ea69e1a-61f1-4043-bf83-b5c94c648137
parent d3846de5
Branches
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.35 2003/01/05 05:15:55 ballen4705 Exp $" const char* CVSid5="$Id: smartctl.c,v 1.36 2003/01/05 05:47:55 ballen4705 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
...@@ -88,7 +88,7 @@ void Usage (void){ ...@@ -88,7 +88,7 @@ void Usage (void){
-?\n\ -?\n\
Same as -h\n\ Same as -h\n\
-V, --version, --copyright, --license\n\ -V, --version, --copyright, --license\n\
Print license, copyright, and version information\n\ Print license, copyright, and version information and exit\n\
-i, --info (ATA/SCSI)\n\ -i, --info (ATA/SCSI)\n\
Show drive information\n\ Show drive information\n\
-a, --all (ATA/SCSI)\n\ -a, --all (ATA/SCSI)\n\
...@@ -253,7 +253,7 @@ void printbadargmessage(int opt, const char *optarg) { ...@@ -253,7 +253,7 @@ void printbadargmessage(int opt, const char *optarg) {
pout(" <======= \n\n"); pout(" <======= \n\n");
} }
unsigned char printcopyleft=0,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 */
void ParseOpts (int argc, char** argv){ void ParseOpts (int argc, char** argv){
...@@ -307,7 +307,8 @@ void ParseOpts (int argc, char** argv){ ...@@ -307,7 +307,8 @@ void ParseOpts (int argc, char** argv){
)){ )){
switch (optchar){ switch (optchar){
case 'V': case 'V':
printcopyleft=TRUE; printcopy();
exit(0);
break; break;
case 'q': case 'q':
if (!strcmp(optarg,"errorsonly")) { if (!strcmp(optarg,"errorsonly")) {
...@@ -483,6 +484,7 @@ void ParseOpts (int argc, char** argv){ ...@@ -483,6 +484,7 @@ void ParseOpts (int argc, char** argv){
// check to see if any of those options had unrecognized or // check to see if any of those options had unrecognized or
// incorrect arguments. // incorrect arguments.
if (badarg) { if (badarg) {
printslogan();
printbadargmessage(optchar, optarg); printbadargmessage(optchar, optarg);
pout("Use smartctl -h to get a usage summary\n\n"); pout("Use smartctl -h to get a usage summary\n\n");
exit(FAILCMD); exit(FAILCMD);
...@@ -497,8 +499,8 @@ void ParseOpts (int argc, char** argv){ ...@@ -497,8 +499,8 @@ void ParseOpts (int argc, char** argv){
con->smartshortcapselftest+con->smartextendcapselftest+con->smartselftestabort)){ con->smartshortcapselftest+con->smartextendcapselftest+con->smartselftestabort)){
con->veryquietmode=FALSE; con->veryquietmode=FALSE;
printslogan(); printslogan();
Usage(); pout("\nERROR: smartctl can only run a single test (or abort) at a time.\n");
printf("\nERROR: smartctl can only run a single test (or abort) at a time.\n\n"); pout("Use smartctl -h to get a usage summary\n\n");
exit(FAILCMD); exit(FAILCMD);
} }
...@@ -516,26 +518,19 @@ void ParseOpts (int argc, char** argv){ ...@@ -516,26 +518,19 @@ void ParseOpts (int argc, char** argv){
// From here on, normal operations... // From here on, normal operations...
printslogan(); printslogan();
// Print Copyright/License info if needed
if (printcopyleft){
printcopy();
if (argc==2)
exit(0);
}
// Warn if the user has provided no device name // Warn if the user has provided no device name
if (argc-optind<1){ if (argc-optind<1){
printf("ERROR: smartctl requires a device name as the final command-line argument.\n\n"); pout("\nERROR: smartctl requires a device name as the final command-line argument.\n\n");
exit(FAILCMD); exit(FAILCMD);
} }
// Warn if the user has provided more than one device name // Warn if the user has provided more than one device name
if (argc-optind>1){ if (argc-optind>1){
int i; int i;
printf("ERROR: smartctl takes ONE device name as the final command-line argument.\n"); pout("\nERROR: smartctl takes ONE device name as the final command-line argument.\n");
printf("You have provided %d device names:\n",argc-optind); pout("You have provided %d device names:\n",argc-optind);
for (i=0; i<argc-optind; i++) for (i=0; i<argc-optind; i++)
printf("%s\n",argv[optind+i]); pout("%s\n",argv[optind+i]);
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.35 2003/01/05 05:15:55 ballen4705 Exp $" const char* CVSid5="$Id: smartctl.cpp,v 1.36 2003/01/05 05:47:55 ballen4705 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
...@@ -88,7 +88,7 @@ void Usage (void){ ...@@ -88,7 +88,7 @@ void Usage (void){
-?\n\ -?\n\
Same as -h\n\ Same as -h\n\
-V, --version, --copyright, --license\n\ -V, --version, --copyright, --license\n\
Print license, copyright, and version information\n\ Print license, copyright, and version information and exit\n\
-i, --info (ATA/SCSI)\n\ -i, --info (ATA/SCSI)\n\
Show drive information\n\ Show drive information\n\
-a, --all (ATA/SCSI)\n\ -a, --all (ATA/SCSI)\n\
...@@ -253,7 +253,7 @@ void printbadargmessage(int opt, const char *optarg) { ...@@ -253,7 +253,7 @@ void printbadargmessage(int opt, const char *optarg) {
pout(" <======= \n\n"); pout(" <======= \n\n");
} }
unsigned char printcopyleft=0,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 */
void ParseOpts (int argc, char** argv){ void ParseOpts (int argc, char** argv){
...@@ -307,7 +307,8 @@ void ParseOpts (int argc, char** argv){ ...@@ -307,7 +307,8 @@ void ParseOpts (int argc, char** argv){
)){ )){
switch (optchar){ switch (optchar){
case 'V': case 'V':
printcopyleft=TRUE; printcopy();
exit(0);
break; break;
case 'q': case 'q':
if (!strcmp(optarg,"errorsonly")) { if (!strcmp(optarg,"errorsonly")) {
...@@ -483,6 +484,7 @@ void ParseOpts (int argc, char** argv){ ...@@ -483,6 +484,7 @@ void ParseOpts (int argc, char** argv){
// check to see if any of those options had unrecognized or // check to see if any of those options had unrecognized or
// incorrect arguments. // incorrect arguments.
if (badarg) { if (badarg) {
printslogan();
printbadargmessage(optchar, optarg); printbadargmessage(optchar, optarg);
pout("Use smartctl -h to get a usage summary\n\n"); pout("Use smartctl -h to get a usage summary\n\n");
exit(FAILCMD); exit(FAILCMD);
...@@ -497,8 +499,8 @@ void ParseOpts (int argc, char** argv){ ...@@ -497,8 +499,8 @@ void ParseOpts (int argc, char** argv){
con->smartshortcapselftest+con->smartextendcapselftest+con->smartselftestabort)){ con->smartshortcapselftest+con->smartextendcapselftest+con->smartselftestabort)){
con->veryquietmode=FALSE; con->veryquietmode=FALSE;
printslogan(); printslogan();
Usage(); pout("\nERROR: smartctl can only run a single test (or abort) at a time.\n");
printf("\nERROR: smartctl can only run a single test (or abort) at a time.\n\n"); pout("Use smartctl -h to get a usage summary\n\n");
exit(FAILCMD); exit(FAILCMD);
} }
...@@ -516,26 +518,19 @@ void ParseOpts (int argc, char** argv){ ...@@ -516,26 +518,19 @@ void ParseOpts (int argc, char** argv){
// From here on, normal operations... // From here on, normal operations...
printslogan(); printslogan();
// Print Copyright/License info if needed
if (printcopyleft){
printcopy();
if (argc==2)
exit(0);
}
// Warn if the user has provided no device name // Warn if the user has provided no device name
if (argc-optind<1){ if (argc-optind<1){
printf("ERROR: smartctl requires a device name as the final command-line argument.\n\n"); pout("\nERROR: smartctl requires a device name as the final command-line argument.\n\n");
exit(FAILCMD); exit(FAILCMD);
} }
// Warn if the user has provided more than one device name // Warn if the user has provided more than one device name
if (argc-optind>1){ if (argc-optind>1){
int i; int i;
printf("ERROR: smartctl takes ONE device name as the final command-line argument.\n"); pout("\nERROR: smartctl takes ONE device name as the final command-line argument.\n");
printf("You have provided %d device names:\n",argc-optind); pout("You have provided %d device names:\n",argc-optind);
for (i=0; i<argc-optind; i++) for (i=0; i<argc-optind; i++)
printf("%s\n",argv[optind+i]); pout("%s\n",argv[optind+i]);
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