aboutsummaryrefslogtreecommitdiffstats
path: root/lib-src
diff options
context:
space:
mode:
authorKarl Heuer1997-11-23 02:17:36 +0000
committerKarl Heuer1997-11-23 02:17:36 +0000
commite4b34a85e5fbafc7f8ca2b6adb9158af95457ee1 (patch)
tree99ccc7d64136e4c870e2829a3f69418ee070af73 /lib-src
parent7e7dab81236eb810834191298fdc68585c192ec1 (diff)
downloademacs-e4b34a85e5fbafc7f8ca2b6adb9158af95457ee1.tar.gz
emacs-e4b34a85e5fbafc7f8ca2b6adb9158af95457ee1.zip
Include getopt.h.
(main): Use getopt_long to handle --version and --help.
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/b2m.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/lib-src/b2m.c b/lib-src/b2m.c
index 2eb6a0354b8..6aea2270a51 100644
--- a/lib-src/b2m.c
+++ b/lib-src/b2m.c
@@ -21,6 +21,7 @@
21#include <stdio.h> 21#include <stdio.h>
22#include <time.h> 22#include <time.h>
23#include <sys/types.h> 23#include <sys/types.h>
24#include <getopt.h>
24#ifdef MSDOS 25#ifdef MSDOS
25#include <fcntl.h> 26#include <fcntl.h>
26#endif 27#endif
@@ -78,6 +79,15 @@ void fatal ();
78 79
79char *progname; 80char *progname;
80 81
82struct option longopts[] =
83{
84 { "help", no_argument, NULL, 'h' },
85 { "version", no_argument, NULL, 'V' },
86 { 0 }
87};
88
89extern int optind;
90
81main (argc, argv) 91main (argc, argv)
82 int argc; 92 int argc;
83 char **argv; 93 char **argv;
@@ -101,11 +111,31 @@ main (argc, argv)
101#endif 111#endif
102 progname = argv[0]; 112 progname = argv[0];
103 113
104 if (argc != 1) 114 while (1)
115 {
116 int opt = getopt_long (argc, argv, "hV", longopts, 0);
117 if (opt == EOF)
118 break;
119
120 switch (opt)
121 {
122 case 'V':
123 printf ("%s (GNU Emacs %s)\n", "b2m", VERSION);
124 puts ("b2m is in the public domain.");
125 exit (GOOD);
126
127 case 'h':
128 fprintf (stderr, "Usage: %s <babylmailbox >unixmailbox\n", progname);
129 exit (GOOD);
130 }
131 }
132
133 if (optind != argc)
105 { 134 {
106 fprintf (stderr, "Usage: %s <babylmailbox >unixmailbox\n", progname); 135 fprintf (stderr, "Usage: %s <babylmailbox >unixmailbox\n", progname);
107 exit (GOOD); 136 exit (GOOD);
108 } 137 }
138
109 labels_saved = printing = header = FALSE; 139 labels_saved = printing = header = FALSE;
110 ltoday = time (0); 140 ltoday = time (0);
111 today = ctime (&ltoday); 141 today = ctime (&ltoday);