From 496c3c91c584a77043b99feced886d2639e9dd0c Mon Sep 17 00:00:00 2001
From: pjwilliams <pjwilliams@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Sun, 5 Jan 2003 20:05:32 +0000
Subject: [PATCH] Added "help" argument to -v for smartctl

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@432 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/CHANGELOG    |  4 +++-
 sm5/smartctl.8   |  9 ++++++---
 sm5/smartctl.c   | 16 ++++++++++++++--
 sm5/smartctl.cpp | 16 ++++++++++++++--
 4 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index a04676d03..b94008951 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 CHANGELOG for smartmontools
 
-$Id: CHANGELOG,v 1.82 2003/01/04 19:34:29 pjwilliams Exp $
+$Id: CHANGELOG,v 1.83 2003/01/05 20:05:31 pjwilliams Exp $
 
 Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 
@@ -36,6 +36,8 @@ CURRENT RELEASE (see VERSION file in this directory):
 
 smartmontools-5.1.1
 
+  [PW] Added "help" argument to -v for smartctl
+
   [PW] Added -D, --showdirectives option to smartd
 
   [DG] add '-l selftest' capability for SCSI devices (update smartctl.8)
diff --git a/sm5/smartctl.8 b/sm5/smartctl.8
index 0c57280af..92bf7e6d6 100644
--- a/sm5/smartctl.8
+++ b/sm5/smartctl.8
@@ -1,6 +1,6 @@
 \# Copyright (C) 2002 Bruce Allen <smartmontools-support@lists.sourceforge.net>
 \#
-\# $Id: smartctl.8,v 1.41 2003/01/05 06:02:36 ballen4705 Exp $
+\# $Id: smartctl.8,v 1.42 2003/01/05 20:05:32 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 SMARTCTL 8  "$Date: 2003/01/05 06:02:36 $" "smartmontools-5.1"
+.TH SMARTCTL 8  "$Date: 2003/01/05 20:05:32 $" "smartmontools-5.1"
 .SH NAME
 smartctl \- S.M.A.R.T. control and monitor utility 
 .SH SYNOPSIS
@@ -407,6 +407,9 @@ run using the '\-t' option described below (use ATA's test terminology).
 Sets a vendor-specific display OPTION for Attribute N.  Valid
 arguments to this option are:
 
+.I help
+\- Prints (to STDOUT) a list of all valid arguments to this option.
+
 .I 9,minutes
 \- Raw Attribute number 9 is power-on time in minutes.  It will be
 displayed in the form 'X h + Y m', where X is hours and Y is minutes.
@@ -665,4 +668,4 @@ Please let us know if there is an on\-line source for this document.
 
 .SH
 CVS ID OF THIS PAGE:
-$Id: smartctl.8,v 1.41 2003/01/05 06:02:36 ballen4705 Exp $
+$Id: smartctl.8,v 1.42 2003/01/05 20:05:32 pjwilliams Exp $
diff --git a/sm5/smartctl.c b/sm5/smartctl.c
index f70dd2433..66bdb47b5 100644
--- a/sm5/smartctl.c
+++ b/sm5/smartctl.c
@@ -42,7 +42,7 @@
 #include "extern.h"
 
 extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4; 
-const char* CVSid5="$Id: smartctl.c,v 1.42 2003/01/05 09:00:40 ballen4705 Exp $"
+const char* CVSid5="$Id: smartctl.c,v 1.43 2003/01/05 20:05:32 pjwilliams Exp $"
 CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6;
 
 // This is a block containing all the "control variables".  We declare
@@ -230,7 +230,7 @@ void printbadargmessage(int opt, const char *optarg) {
        pout("\nInsufficient memory to construct argument list\n");
        break;
      }
-     pout("%s", s);
+     pout("\"help\", %s", s);
      free(s);
      break;
   case 't':
@@ -413,6 +413,18 @@ void ParseOpts (int argc, char** argv){
       break;
     case 'v':
       // parse vendor-specific definitions of attributes
+      if (!strcmp(optarg,"help")) {
+        char *s;
+        con->veryquietmode=FALSE;
+        printslogan();
+        if (!(s = create_vendor_attribute_arg_list())) {
+          pout("Insufficient memory to construct argument list\n");
+          exit(FAILCMD);
+        }
+        pout("The valid arguments to -v are: \"help\", %s\n", s);
+        free(s);
+        exit(0);
+      }
       if (parse_attribute_def(optarg, con->attributedefs))
 	badarg = TRUE;
       break;    
diff --git a/sm5/smartctl.cpp b/sm5/smartctl.cpp
index 9d1f58c0a..c38e5a4f0 100644
--- a/sm5/smartctl.cpp
+++ b/sm5/smartctl.cpp
@@ -42,7 +42,7 @@
 #include "extern.h"
 
 extern const char *CVSid1, *CVSid2, *CVSid3, *CVSid4; 
-const char* CVSid5="$Id: smartctl.cpp,v 1.42 2003/01/05 09:00:40 ballen4705 Exp $"
+const char* CVSid5="$Id: smartctl.cpp,v 1.43 2003/01/05 20:05:32 pjwilliams Exp $"
 CVSID1 CVSID2 CVSID3 CVSID4 CVSID5 CVSID6;
 
 // This is a block containing all the "control variables".  We declare
@@ -230,7 +230,7 @@ void printbadargmessage(int opt, const char *optarg) {
        pout("\nInsufficient memory to construct argument list\n");
        break;
      }
-     pout("%s", s);
+     pout("\"help\", %s", s);
      free(s);
      break;
   case 't':
@@ -413,6 +413,18 @@ void ParseOpts (int argc, char** argv){
       break;
     case 'v':
       // parse vendor-specific definitions of attributes
+      if (!strcmp(optarg,"help")) {
+        char *s;
+        con->veryquietmode=FALSE;
+        printslogan();
+        if (!(s = create_vendor_attribute_arg_list())) {
+          pout("Insufficient memory to construct argument list\n");
+          exit(FAILCMD);
+        }
+        pout("The valid arguments to -v are: \"help\", %s\n", s);
+        free(s);
+        exit(0);
+      }
       if (parse_attribute_def(optarg, con->attributedefs))
 	badarg = TRUE;
       break;    
-- 
GitLab