2 ** rcvpack.c -- append message to a file
4 ** This code is Copyright (c) 2002, by the authors of nmh. See the
5 ** COPYRIGHT file in the root directory of the nmh distribution for
6 ** complete copyright information.
10 #include <h/dropsbr.h>
11 #include <h/rcvmail.h>
15 static struct swit switches[] = {
28 ** default format in which to save messages
30 static int mbx_style = MBOX_FORMAT;
34 main (int argc, char **argv)
37 char *cp, *file = NULL, buf[BUFSIZ];
38 char **argp, **arguments;
41 setlocale(LC_ALL, "");
43 invo_name = r1bindex (argv[0], '/');
45 /* read user profile/context */
49 arguments = getarguments (invo_name, argc, argv, 1);
53 while ((cp = *argp++)) {
55 switch (smatch (++cp, switches)) {
57 ambigsw (cp, switches);
60 adios (NULL, "-%s unknown", cp);
63 snprintf (buf, sizeof(buf),
66 print_help (buf, switches, 1);
69 print_version(invo_name);
73 mbx_style = MBOX_FORMAT;
76 mbx_style = MMDF_FORMAT;
81 adios (NULL, "only one file at a time!");
87 adios (NULL, "%s [switches] file", invo_name);
91 /* open and lock the file */
92 if ((md = mbx_open (file, mbx_style, getuid(), getgid(), m_gmprot()))
96 /* append the message */
97 if (mbx_copy (file, mbx_style, md, fileno(stdin), 1, NULL, 0)
103 /* close and unlock the file */
104 if (mbx_close (file, md) == NOTOK)