Remove RCS keywords, since they no longer work after git migration.
[mmh] / uip / rcvpack.c
1
2 /*
3  * rcvpack.c -- append message to a file
4  *
5  * This code is Copyright (c) 2002, by the authors of nmh.  See the
6  * COPYRIGHT file in the root directory of the nmh distribution for
7  * complete copyright information.
8  */
9
10 #include <h/mh.h>
11 #include <h/dropsbr.h>
12 #include <h/rcvmail.h>
13 #include <h/tws.h>
14 #include <h/mts.h>
15
16 static struct swit switches[] = {
17 #define MBOXSW       0
18     { "mbox", 0 },
19 #define MMDFSW       1
20     { "mmdf", 0 },
21 #define VERSIONSW    2
22     { "version", 0 },
23 #define HELPSW       3
24     { "help", 0 },
25     { NULL, 0 }
26 };
27
28 /*
29  * default format in which to save messages
30  */
31 static int mbx_style = MBOX_FORMAT;
32
33
34 int
35 main (int argc, char **argv)
36 {
37     int md;
38     char *cp, *file = NULL, buf[BUFSIZ];
39     char **argp, **arguments;
40
41 #ifdef LOCALE
42     setlocale(LC_ALL, "");
43 #endif
44     invo_name = r1bindex (argv[0], '/');
45
46     /* read user profile/context */
47     context_read();
48
49     mts_init (invo_name);
50     arguments = getarguments (invo_name, argc, argv, 1);
51     argp = arguments;
52
53     /* parse arguments */
54     while ((cp = *argp++)) {
55         if (*cp == '-') {
56             switch (smatch (++cp, switches)) {
57                 case AMBIGSW: 
58                     ambigsw (cp, switches);
59                     done (1);
60                 case UNKWNSW: 
61                     adios (NULL, "-%s unknown", cp);
62
63                 case HELPSW: 
64                     snprintf (buf, sizeof(buf), "%s [switches] file", invo_name);
65                     print_help (buf, switches, 1);
66                     done (1);
67                 case VERSIONSW:
68                     print_version(invo_name);
69                     done (1);
70
71                 case MBOXSW:
72                     mbx_style = MBOX_FORMAT;
73                     continue;
74                 case MMDFSW:
75                     mbx_style = MMDF_FORMAT;
76                     continue;
77             }
78         }
79         if (file)
80             adios (NULL, "only one file at a time!");
81         else
82             file = cp;
83     }
84
85     if (!file)
86         adios (NULL, "%s [switches] file", invo_name);
87
88     rewind (stdin);
89
90     /* open and lock the file */
91     if ((md = mbx_open (file, mbx_style, getuid(), getgid(), m_gmprot())) == NOTOK)
92         done (RCV_MBX);
93
94     /* append the message */
95     if (mbx_copy (file, mbx_style, md, fileno(stdin), 1, NULL, 0) == NOTOK) {
96         mbx_close (file, md);
97         done (RCV_MBX);
98     }
99
100     /* close and unlock the file */
101     if (mbx_close (file, md) == NOTOK)
102         done (RCV_MBX);
103
104     done (RCV_MOK);
105     return 1;
106 }