Commit 7d210b49 7d210b4993b69d06e42e555dafd13090a994909a by Jeff Bailey

Support --mail and --version in mail

1 parent dddb3013
1 1999-10-03 Jeff Bailey <jbailey@cr499794-a.crdva1.bc.wave.home.com> 1 1999-10-03 Jeff Bailey <jbailey@cr499794-a.crdva1.bc.wave.home.com>
2 2
3 * mail/mail.c: Support --help, --version.
4
3 * mail/Makefile.am: Add -Wall to compile line. 5 * mail/Makefile.am: Add -Wall to compile line.
4 6
5 * libmailbox/Makefile.am: Add -Wall to compile line. 7 * libmailbox/Makefile.am: Add -Wall to compile line.
......
1 CPPFLAGS = -I$(top_srcdir)/libmailbox -Wall 1 CPPFLAGS = -I$(top_srcdir)/libmailbox -Wall -pedantic
2 2
3 bin_PROGRAMS = mail 3 bin_PROGRAMS = mail
4 4
......
...@@ -22,6 +22,9 @@ ...@@ -22,6 +22,9 @@
22 #include <mailbox.h> 22 #include <mailbox.h>
23 #include <stdio.h> 23 #include <stdio.h>
24 #include <stdlib.h> 24 #include <stdlib.h>
25 #include <unistd.h>
26 #include <string.h>
27 #include <getopt.h>
25 28
26 #ifdef HAVE_PATHS_H 29 #ifdef HAVE_PATHS_H
27 #include <paths.h> 30 #include <paths.h>
...@@ -31,21 +34,47 @@ ...@@ -31,21 +34,47 @@
31 #define _PATH_MAILDIR "/var/spool/mail" 34 #define _PATH_MAILDIR "/var/spool/mail"
32 #endif 35 #endif
33 36
37 static struct option long_options[] =
38 {
39 {"help", 0, NULL, 'h'},
40 {"version", 0, NULL, 'v'},
41 {NULL, 0, NULL, 0}
42 };
43
34 int 44 int
35 main (int argc, char **argv) 45 main (int argc, char **argv)
36 { 46 {
37 char *foo, bar[80]; 47 char *foo, bar[80];
38 int i = 0; 48 int i = 0;
39 char c = 0; 49 char c = 0;
40 char *mboxname; 50 char *mboxname = 0;
41 mailbox *mbox; 51 mailbox *mbox = 0;
52
53 i = getopt_long (argc, argv, "hv", long_options, (int *)0);
42 54
43 if (argc != 1) 55 switch (i)
44 { 56 {
45 fprintf (stderr, "Usage: %s\n", argv[0]); 57 case 'v':
46 return 1; 58 printf("mail (GNU mailutils) %s\n", VERSION);
59 exit (0);
60 break;
61 case 'h':
62 printf("\
63 Usage: mail [OPTION]...\n\
64 Access the current users mailbox through a simple text mode interface\n\
65 \n\
66 --version Show version information\n\
67 --help Show this message\n\
68 \n\
69 Report bugs to <bug-mailutils@gnu.org>.\n");
70 exit (0);
71 break;
72 default:
73 break;
47 } 74 }
48 75
76
77
49 mboxname = getenv ("MAIL"); 78 mboxname = getenv ("MAIL");
50 if (mboxname == NULL) 79 if (mboxname == NULL)
51 { 80 {
......