Mercurial > emacs
changeset 20328:000f4d300712
Include getopt.h.
(main): Use getopt_long to handle --version and --help.
author | Karl Heuer <kwzh@gnu.org> |
---|---|
date | Sun, 23 Nov 1997 02:17:36 +0000 |
parents | 5f8d36dfb126 |
children | 0302b5c33acf |
files | lib-src/b2m.c |
diffstat | 1 files changed, 31 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/lib-src/b2m.c Sun Nov 23 02:16:13 1997 +0000 +++ b/lib-src/b2m.c Sun Nov 23 02:17:36 1997 +0000 @@ -21,6 +21,7 @@ #include <stdio.h> #include <time.h> #include <sys/types.h> +#include <getopt.h> #ifdef MSDOS #include <fcntl.h> #endif @@ -78,6 +79,15 @@ char *progname; +struct option longopts[] = +{ + { "help", no_argument, NULL, 'h' }, + { "version", no_argument, NULL, 'V' }, + { 0 } +}; + +extern int optind; + main (argc, argv) int argc; char **argv; @@ -101,11 +111,31 @@ #endif progname = argv[0]; - if (argc != 1) + while (1) + { + int opt = getopt_long (argc, argv, "hV", longopts, 0); + if (opt == EOF) + break; + + switch (opt) + { + case 'V': + printf ("%s (GNU Emacs %s)\n", "b2m", VERSION); + puts ("b2m is in the public domain."); + exit (GOOD); + + case 'h': + fprintf (stderr, "Usage: %s <babylmailbox >unixmailbox\n", progname); + exit (GOOD); + } + } + + if (optind != argc) { fprintf (stderr, "Usage: %s <babylmailbox >unixmailbox\n", progname); exit (GOOD); } + labels_saved = printing = header = FALSE; ltoday = time (0); today = ctime (<oday);