Commit e4b34a85 authored by Karl Heuer's avatar Karl Heuer
Browse files

Include getopt.h.

(main): Use getopt_long to handle --version and --help.
parent 7e7dab81
......@@ -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 @@ void fatal ();
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 @@ main (argc, argv)
#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 (&ltoday);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment