about summary refs log tree commit diff
path: root/lib/util/shhopt.h
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2012-11-18 00:56:58 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2012-11-18 00:56:58 +0000
commiteb5a0b4e1b3698be49ef8e570532ca19c23a9a63 (patch)
tree4cba264999b9c67d17a52322f1fd2ae45f912f82 /lib/util/shhopt.h
parent7cedf303a515993e87302f8c042cb139586b890f (diff)
downloadnetpbm-mirror-eb5a0b4e1b3698be49ef8e570532ca19c23a9a63.tar.gz
netpbm-mirror-eb5a0b4e1b3698be49ef8e570532ca19c23a9a63.tar.xz
netpbm-mirror-eb5a0b4e1b3698be49ef8e570532ca19c23a9a63.zip
Improve comments
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1764 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/util/shhopt.h')
-rw-r--r--lib/util/shhopt.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/util/shhopt.h b/lib/util/shhopt.h
index 6be7f411..9a446290 100644
--- a/lib/util/shhopt.h
+++ b/lib/util/shhopt.h
@@ -22,7 +22,8 @@ main ( int argc, char **argv ) {
     
     optStruct3 opt;
     unsigned int option_def_index = 0;
-    optEntry *option_def = malloc(100*sizeof(option_def[0]));
+    optEntry * option_def;
+    MALLOCARRAY(option_def, 100);
 
     OPTENT3(0,   "help",     OPT_FLAG,     &help_flag,    &help_spec,   0);
     OPTENT3(0,   "height",   OPT_INT,      &height,       &height_spec, 0);
@@ -69,6 +70,13 @@ Now run this program with something like
   myprog -v /etc/passwd -name=Bryan --hei=4
 
 
+  If your program takes no options (so you have no OPTENT3 macro invocations),
+  you need an OPTENTINIT call to establish the empty option table:
+
+    optEntry * option_def;
+    MALLOCARRAY(option_def, 1);
+    OPTENTINIT;
+
 ========================================================================
 #endif /* 0 */
 
@@ -190,9 +198,10 @@ typedef struct {
     }
 
 /* OPTENT3 is the same as OPTENTRY except that it also sets the "specified"
-   element of the table entry (so it assumes OPTION_DEF is a table of
-   optEntry instead of optStruct).  It sets it to the number of times that
-   the option appears in the command line.
+   element of the table entry (so it assumes OPTION_DEF is a table of optEntry
+   instead of optStruct).  This is a pointer to a variable that the parser
+   will set to the number of times that the option appears in the command
+   line.
 
    Here is an example: