3 * rcvpack.c -- append message to a file
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.
11 #include <h/dropsbr.h>
12 #include <h/rcvmail.h>
16 static struct swit switches[] = {
29 * default format in which to save messages
31 static int mbx_style = MBOX_FORMAT;
35 main (int argc, char **argv)
38 char *cp, *file = NULL, buf[BUFSIZ];
39 char **argp, **arguments;
42 setlocale(LC_ALL, "");
44 invo_name = r1bindex (argv[0], '/');
46 /* read user profile/context */
50 arguments = getarguments (invo_name, argc, argv, 1);
54 while ((cp = *argp++)) {
56 switch (smatch (++cp, switches)) {
58 ambigsw (cp, switches);
61 adios (NULL, "-%s unknown", cp);
64 snprintf (buf, sizeof(buf), "%s [switches] file", invo_name);
65 print_help (buf, switches, 1);
68 print_version(invo_name);
72 mbx_style = MBOX_FORMAT;
75 mbx_style = MMDF_FORMAT;
80 adios (NULL, "only one file at a time!");
86 adios (NULL, "%s [switches] file", invo_name);
90 /* open and lock the file */
91 if ((md = mbx_open (file, mbx_style, getuid(), getgid(), m_gmprot())) == NOTOK)
94 /* append the message */
95 if (mbx_copy (file, mbx_style, md, fileno(stdin), 1, NULL, 0) == NOTOK) {
100 /* close and unlock the file */
101 if (mbx_close (file, md) == NOTOK)