]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Include long-options.h.
authorJim Meyering <jim@meyering.net>
Sat, 6 Mar 1999 15:28:54 +0000 (15:28 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 6 Mar 1999 15:28:54 +0000 (15:28 +0000)
[long_options]: Remove the "help" and "version" entries.
Remove declarations of show_help and show_version.
(main): Use parse_long_options, including author name(s).
Remove the show_version and show_help blocks.

17 files changed:
src/date.c
src/env.c
src/id.c
src/logname.c
src/pathchk.c
src/pinky.c
src/printenv.c
src/seq.c
src/sleep.c
src/su.c
src/tee.c
src/tty.c
src/uname.c
src/uptime.c
src/users.c
src/who.c
src/whoami.c

index e6429fa46eff79b15b66d91be0f8d62d9c1df772..b38c5f036558e3c2bdcb14648c6617fac7065e06 100644 (file)
 
 #include "system.h"
 #include "closeout.h"
-#include "getline.h"
 #include "error.h"
 #include "getdate.h"
+#include "getline.h"
+#include "long-options.h"
 #include "posixtm.h"
 
 #ifndef STDC_HEADERS
@@ -44,12 +45,6 @@ static void show_date PARAMS ((const char *format, time_t when));
 /* The name this program was run with, for error messages. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 /* If non-zero, display time in RFC-822 format for mail or news. */
 static int rfc_format = 0;
 
@@ -60,14 +55,12 @@ static struct option const long_options[] =
 {
   {"date", required_argument, NULL, 'd'},
   {"file", required_argument, NULL, 'f'},
-  {"help", no_argument, &show_help, 1},
   {"reference", required_argument, NULL, 'r'},
   {"rfc-822", no_argument, NULL, 'R'},
   {"set", required_argument, NULL, 's'},
   {"uct", no_argument, NULL, 'u'},
   {"utc", no_argument, NULL, 'u'},
   {"universal", no_argument, NULL, 'u'},
-  {"version", no_argument, &show_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -287,6 +280,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "date", GNU_PACKAGE, VERSION,
+                     "David MacKenzie", usage);
+
   while ((optc = getopt_long (argc, argv, "d:f:r:Rs:u", long_options, NULL))
         != -1)
     switch (optc)
@@ -316,15 +312,6 @@ main (int argc, char **argv)
        usage (1);
       }
 
-  if (show_version)
-    {
-      printf ("date (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   n_args = argc - optind;
 
   option_specified_date = ((datestr ? 1 : 0)
index 8f677359c6c5fd39c636c3b1f4ac957e5545b0e6..a0d81191d656e2af91b30cc562a38c327c09dff7 100644 (file)
--- a/src/env.c
+++ b/src/env.c
@@ -85,6 +85,7 @@
 
 #include "system.h"
 #include "error.h"
+#include "long-options.h"
 
 int putenv ();
 
@@ -93,18 +94,10 @@ extern char **environ;
 /* The name by which this program was run. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const longopts[] =
 {
-  {"help", no_argument, &show_help, 1},
   {"ignore-environment", no_argument, NULL, 'i'},
   {"unset", required_argument, NULL, 'u'},
-  {"version", no_argument, &show_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -146,6 +139,9 @@ main (register int argc, register char **argv, char **envp)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "env", GNU_PACKAGE, VERSION,
+                     "Richard Mlynarik and David MacKenzie", usage);
+
   while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1)
     {
       switch (optc)
@@ -162,15 +158,6 @@ main (register int argc, register char **argv, char **envp)
        }
     }
 
-  if (show_version)
-    {
-      printf ("env (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (optind != argc && !strcmp (argv[optind], "-"))
     ignore_environment = 1;
 
index b9a404cd3d0ee6e06e874019c8e2090cac30f66c..24c72497cb8652e41a9123aab10b5abf42410b32 100644 (file)
--- a/src/id.c
+++ b/src/id.c
@@ -28,6 +28,7 @@
 
 #include "system.h"
 #include "error.h"
+#include "long-options.h"
 
 #ifndef _POSIX_VERSION
 struct passwd *getpwuid ();
@@ -70,21 +71,13 @@ static gid_t rgid, egid;
 /* The number of errors encountered so far. */
 static int problems = 0;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const longopts[] =
 {
   {"group", no_argument, NULL, 'g'},
   {"groups", no_argument, NULL, 'G'},
-  {"help", no_argument, &show_help, 1},
   {"name", no_argument, NULL, 'n'},
   {"real", no_argument, NULL, 'r'},
   {"user", no_argument, NULL, 'u'},
-  {"version", no_argument, &show_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -126,6 +119,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "id", GNU_PACKAGE, VERSION,
+                     "Arnold Robbins and David MacKenzie", usage);
+
   while ((optc = getopt_long (argc, argv, "agnruG", longopts, NULL)) != -1)
     {
       switch (optc)
@@ -155,15 +151,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("id (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (just_user + just_group + just_group_list > 1)
     error (1, 0, _("cannot print only user and only group"));
 
index b9b3f60fa368b5c8e7a827f1f0c12ea930e2fa38..913cf53d28d7a7fcbff6d4e17a5dca870d201417 100644 (file)
 #include <getopt.h>
 
 #include "system.h"
+#include "long-options.h"
 
 /* The name this program was run with. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const long_options[] =
 {
-  {"help", no_argument, &show_help, 1},
-  {"version", no_argument, &show_version, 1},
   {0, 0, 0, 0}
 };
 
@@ -69,6 +62,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "logname", GNU_PACKAGE, VERSION,
+                     "FIXME: unknown", usage);
+
   while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
     {
       switch (c)
@@ -81,15 +77,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("logname (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (argc - optind != 0)
     usage (1);
 
index 2fc24dd699f2287b6fc17b59abcb07c5d169eeab..ad285706a5a46fa40b3ade8879f377732cb29f74 100644 (file)
@@ -45,6 +45,7 @@
 
 #include "system.h"
 #include "error.h"
+#include "long-options.h"
 
 #ifdef _POSIX_VERSION
 # ifndef PATH_MAX
@@ -96,17 +97,8 @@ static int validate_path PARAMS ((char *path, int portability));
 /* The name this program was run with. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const longopts[] =
 {
-  {"help", no_argument, &show_help, 1},
-  {"portability", no_argument, NULL, 'p'},
-  {"version", no_argument, &show_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -143,6 +135,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "pathchk", GNU_PACKAGE, VERSION,
+                     "David MacKenzie and Jim Meyering", usage);
+
   while ((optc = getopt_long (argc, argv, "p", longopts, NULL)) != -1)
     {
       switch (optc)
@@ -159,15 +154,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("pathchk (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (optind == argc)
     {
       error (0, 0, _("too few arguments"));
index 0f0327ea5d417a1c4074a24e2284e6bb95012efe..31c75ea7b60eed7c6a2e2c4718e09d048a4f85a3 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "system.h"
 #include "error.h"
+#include "long-options.h"
 #include "readutmp.h"
 
 #ifndef MAXHOSTNAMELEN
@@ -40,12 +41,6 @@ char *ttyname ();
 /* The name this program was run with. */
 const char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 /* If nonzero, display the hours:minutes since each user has touched
    the keyboard, or blank if within the last minute, or days followed
    by a 'd' if not within the last day. */
@@ -77,8 +72,6 @@ static int include_where = 1;
 
 static struct option const longopts[] =
 {
-  {"help", no_argument, &show_help, 1},
-  {"version", no_argument, &show_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -433,7 +426,7 @@ The utmp file will be %s.\n\
 }
 
 int
-main (int argc, char *const argv[])
+main (int argc, char **argv)
 {
   int optc, longind;
 
@@ -442,6 +435,10 @@ main (int argc, char *const argv[])
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "pinky", GNU_PACKAGE, VERSION,
+                     "Joseph Arceneaux, David MacKenzie, and Kaveh Ghazi",
+                     usage);
+
   while ((optc = getopt_long (argc, argv, "sfwiqbhlp", longopts, &longind))
         != -1)
     {
@@ -498,15 +495,6 @@ main (int argc, char *const argv[])
        }
     }
 
-  if (show_version)
-    {
-      printf ("pinky (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (do_short_format)
     short_pinky (UTMP_FILE, argc - optind, argv + optind);
   else
index 3ac1f25ad252a6d72fad4be2a2cb71bffaf62ecc..6496392eebec60ebbba5b39515b618047c1001bf 100644 (file)
 #include "system.h"
 #include "closeout.h"
 #include "error.h"
+#include "long-options.h"
 
 /* The name this program was run with. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const long_options[] =
 {
-  {"help", no_argument, &show_help, 1},
-  {"version", no_argument, &show_version, 1},
   {0, 0, 0, 0}
 };
 
@@ -88,6 +81,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "printenv", GNU_PACKAGE, VERSION,
+                     "David MacKenzie and Richard Mlynarik", usage);
+
   while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
     {
       switch (c)
@@ -100,15 +96,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("printenv (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (optind == argc)
     {
       for (env = environ; *env != NULL; ++env)
index b1c10f4ee2d104dfe27dac7e3309b5995dd56ca2..5dd9a3b26b52cb070a974b6b82a99f05ae0ac95e 100644 (file)
--- a/src/seq.c
+++ b/src/seq.c
@@ -25,6 +25,7 @@
 
 #include "system.h"
 #include "error.h"
+#include "long-options.h"
 #include "xstrtod.h"
 
 static double scan_double_arg PARAMS ((const char *arg));
@@ -52,12 +53,6 @@ static char *separator;
 /* FIXME: make this an option.  */
 static char *terminator = "\n";
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 /* The increment.  */
 static double step;
 
@@ -68,9 +63,7 @@ static struct option const long_options[] =
 {
   { "equal-width", no_argument, NULL, 'w'},
   { "format", required_argument, NULL, 'f'},
-  { "help", no_argument, &show_help, 1},
   { "separator", required_argument, NULL, 's'},
-  { "version", no_argument, &show_version, 1},
   { NULL, 0, NULL, 0}
 };
 
@@ -119,6 +112,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "seq", GNU_PACKAGE, VERSION,
+                     "Ulrich Drepper", usage);
+
   equal_width = 0;
   format_str = NULL;
   separator = "\n";
@@ -162,18 +158,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("seq (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    {
-      usage (0);
-      /* NOTREACHED */
-    }
-
   if (optind >= argc)
     {
       error (0, 0, _("too few arguments"));
index 74c14263254ac323156c9bf847ae02285edff9f1..3f1ca5f74d85d249d5c4100c47f3c0121f80698b 100644 (file)
 
 #include "system.h"
 #include "error.h"
+#include "long-options.h"
 
 static long argdecode PARAMS ((const char *s));
 
 /* The name by which this program was run. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const long_options[] =
 {
-  {"help", no_argument, &show_help, 1},
-  {"version", no_argument, &show_version, 1},
   {0, 0, 0, 0}
 };
 
@@ -73,6 +66,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "sleep", GNU_PACKAGE, VERSION,
+                     "FIXME: unknown", usage);
+
   while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
     {
       switch (c)
@@ -85,15 +81,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("sleep (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (argc == 1)
     {
       error (0, 0, _("too few arguments"));
index f1a8bb92def4a5157e1c3b6a5ad2d3bdb3774277..3d32a57b7b3cac55744dceded16f89a4e0b1da3a 100644 (file)
--- a/src/su.c
+++ b/src/su.c
@@ -82,6 +82,7 @@
 #define getusershell _getusershell_sys_proto_
 
 #include "system.h"
+#include "long-options.h"
 
 #undef getusershell
 
@@ -152,12 +153,6 @@ extern char **environ;
 /* The name this program was run with.  */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 /* If nonzero, pass the `-f' option to the subshell.  */
 static int fast_startup;
 
@@ -171,11 +166,9 @@ static struct option const longopts[] =
 {
   {"command", required_argument, 0, 'c'},
   {"fast", no_argument, NULL, 'f'},
-  {"help", no_argument, &show_help, 1},
   {"login", no_argument, NULL, 'l'},
   {"preserve-environment", no_argument, &change_environment, 0},
   {"shell", required_argument, 0, 's'},
-  {"version", no_argument, &show_version, 1},
   {0, 0, 0, 0}
 };
 
@@ -467,6 +460,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "su", GNU_PACKAGE, VERSION,
+                     "David MacKenzie", usage);
+
   fast_startup = 0;
   simulate_login = 0;
   change_environment = 1;
@@ -504,15 +500,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("su (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (optind < argc && !strcmp (argv[optind], "-"))
     {
       simulate_login = 1;
index b4b3553685eb39fdecf939a4e1f4026a642c4d8c..f0d3aad0e5217fd8dd869dc750f8e2ceaa5f3c0a 100644 (file)
--- a/src/tee.c
+++ b/src/tee.c
@@ -26,6 +26,7 @@
 #include "system.h"
 #include "closeout.h"
 #include "error.h"
+#include "long-options.h"
 
 int full_write ();
 
@@ -40,18 +41,10 @@ static int ignore_interrupts;
 /* The name that this program was run with. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const long_options[] =
 {
   {"append", no_argument, NULL, 'a'},
-  {"help", no_argument, &show_help, 1},
   {"ignore-interrupts", no_argument, NULL, 'i'},
-  {"version", no_argument, &show_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -88,6 +81,10 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "tee", GNU_PACKAGE, VERSION,
+                     "Mike Parker, Richard M. Stallman, and David MacKenzie",
+                     usage);
+
   append = 0;
   ignore_interrupts = 0;
 
@@ -111,15 +108,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("tee (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (ignore_interrupts)
     {
 #ifdef _POSIX_SOURCE
index 056cb935d990ea315ed5c2fda4b0cb7041b271eb..088a22565e7ac97d0477555bcda1ac246e13b32a 100644 (file)
--- a/src/tty.c
+++ b/src/tty.c
@@ -30,6 +30,7 @@
 #include "system.h"
 #include "closeout.h"
 #include "error.h"
+#include "long-options.h"
 
 /* The name under which this program was run. */
 char *program_name;
@@ -37,18 +38,10 @@ char *program_name;
 /* If nonzero, return an exit status but produce no output. */
 static int silent;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const longopts[] =
 {
-  {"help", no_argument, &show_help, 1},
   {"silent", no_argument, NULL, 's'},
   {"quiet", no_argument, NULL, 's'},
-  {"version", no_argument, &show_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -84,6 +77,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "tty", GNU_PACKAGE, VERSION,
+                     "David MacKenzie", usage);
+
   silent = 0;
 
   while ((optc = getopt_long (argc, argv, "s", longopts, NULL)) != -1)
@@ -102,15 +98,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("tty (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (optind != argc)
     usage (2);
 
index 62b9e5f27d1a63e38e5f1e63a217fb8b47412400..f2499b8e2064fd2e77521af4bc643a839816393e 100644 (file)
@@ -40,6 +40,7 @@
 
 #include "system.h"
 #include "error.h"
+#include "long-options.h"
 
 static void print_element PARAMS ((unsigned int mask, char *element));
 
@@ -68,21 +69,13 @@ static unsigned char toprint;
 /* The name this program was run with, for error messages. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const long_options[] =
 {
-  {"help", no_argument, &show_help, 1},
   {"machine", no_argument, NULL, 'm'},
   {"nodename", no_argument, NULL, 'n'},
   {"release", no_argument, NULL, 'r'},
   {"sysname", no_argument, NULL, 's'},
   {"processor", no_argument, NULL, 'p'},
-  {"version", no_argument, &show_version, 1},
   {"all", no_argument, NULL, 'a'},
   {NULL, 0, NULL, 0}
 };
@@ -125,6 +118,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "uname", GNU_PACKAGE, VERSION,
+                     "David MacKenzie", usage);
+
   toprint = 0;
 
   while ((c = getopt_long (argc, argv, "snrvpma", long_options, NULL)) != -1)
@@ -168,15 +164,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("uname (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (optind != argc)
     usage (1);
 
index 993f3fbfdffd7dc636339e48e2898b9a0833e6d8..e7e7cb5ab0e0f460541c8897d7f60c3c74cd20fe 100644 (file)
 #include <stdio.h>
 
 #include "error.h"
+#include "long-options.h"
 #include "readutmp.h"
 #include "system.h"
 
 /* The name this program was run with. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const longopts[] =
 {
-  {"help", no_argument, &show_help, 1},
-  {"version", no_argument, &show_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -190,6 +183,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "uptime", GNU_PACKAGE, VERSION,
+                     "Joseph Arceneaux and David MacKenzie", usage);
+
   while ((optc = getopt_long (argc, argv, "", longopts, &longind)) != -1)
     {
       switch (optc)
@@ -202,15 +198,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("uptime (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   switch (argc - optind)
     {
     case 0:                    /* uptime */
index e580583d4d26a003fcbb38317289bc90dde5c410..09fff715ca8972a60e69e70b1ecc338c28779485 100644 (file)
 #include <stdio.h>
 
 #include "error.h"
+#include "long-options.h"
 #include "readutmp.h"
 #include "system.h"
 
 /* The name this program was run with. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const longopts[] =
 {
-  {"help", no_argument, &show_help, 1},
-  {"version", no_argument, &show_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -136,6 +129,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "users", GNU_PACKAGE, VERSION,
+                     "Joseph Arceneaux and David MacKenzie", usage);
+
   while ((optc = getopt_long (argc, argv, "", longopts, &longind)) != -1)
     {
       switch (optc)
@@ -148,15 +144,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("users (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   switch (argc - optind)
     {
     case 0:                    /* users */
index e939435043c96f2948a08a9832338b0f588b5346..557fe21f9dd13494b81f2c287d8a13f66974e6c0 100644 (file)
--- a/src/who.c
+++ b/src/who.c
@@ -29,6 +29,7 @@
 #include <stdio.h>
 
 #include "error.h"
+#include "long-options.h"
 #include "readutmp.h"
 #include "system.h"
 
@@ -46,12 +47,6 @@ char *ttyname ();
 /* The name this program was run with. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 /* If nonzero, attempt to canonicalize hostnames via a DNS lookup. */
 static int do_lookup;
 
@@ -81,8 +76,6 @@ static struct option const longopts[] =
   {"message", no_argument, NULL, 'T'},
   {"mesg", no_argument, NULL, 'T'},
   {"writable", no_argument, NULL, 'T'},
-  {"help", no_argument, &show_help, 1},
-  {"version", no_argument, &show_version, 1},
   {NULL, 0, NULL, 0}
 };
 
@@ -390,7 +383,11 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
-  while ((optc = getopt_long (argc, argv, "ilmqsuwHT", longopts, &longind)) != -1)
+  parse_long_options (argc, argv, "who", GNU_PACKAGE, VERSION,
+                     "Joseph Arceneaux and David MacKenzie", usage);
+
+  while ((optc = getopt_long (argc, argv, "ilmqsuwHT", longopts, &longind))
+        != -1)
     {
       switch (optc)
        {
@@ -431,15 +428,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("who (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   switch (argc - optind)
     {
     case 0:                    /* who */
index 2ecf9d8c746a9f92cc1c4fa8e2a1096709a22f1b..3c021ab199cce846768253daff0512ac0bcd24af 100644 (file)
 #include <getopt.h>
 
 #include "system.h"
+#include "long-options.h"
 
 /* The name this program was run with. */
 char *program_name;
 
-/* If nonzero, display usage information and exit.  */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit.  */
-static int show_version;
-
 static struct option const long_options[] =
 {
-  {"help", no_argument, &show_help, 1},
-  {"version", no_argument, &show_version, 1},
   {0, 0, 0, 0}
 };
 
@@ -74,6 +67,9 @@ main (int argc, char **argv)
   bindtextdomain (PACKAGE, LOCALEDIR);
   textdomain (PACKAGE);
 
+  parse_long_options (argc, argv, "whoami", GNU_PACKAGE, VERSION,
+                     "Richard Mlynarik", usage);
+
   while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
     {
       switch (c)
@@ -86,15 +82,6 @@ main (int argc, char **argv)
        }
     }
 
-  if (show_version)
-    {
-      printf ("whoami (%s) %s\n", GNU_PACKAGE, VERSION);
-      exit (0);
-    }
-
-  if (show_help)
-    usage (0);
-
   if (optind != argc)
     usage (1);