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>
14 static struct swit switches[] = {
24 main(int argc, char **argv)
27 char *cp, *file = NULL, buf[BUFSIZ];
28 char **argp, **arguments;
31 setlocale(LC_ALL, "");
33 invo_name = mhbasename(argv[0]);
35 /* read user profile/context */
38 arguments = getarguments(invo_name, argc, argv, 1);
42 while ((cp = *argp++)) {
44 switch (smatch(++cp, switches)) {
46 ambigsw(cp, switches);
49 adios(NULL, "-%s unknown", cp);
52 snprintf(buf, sizeof(buf),
55 print_help(buf, switches, 1);
58 print_version(invo_name);
63 adios(NULL, "only one file at a time!");
69 adios(NULL, "%s [switches] file", invo_name);
73 /* open and lock the file */
74 if ((md = mbx_open(file, getuid(), getgid(), m_gmprot()))
78 /* append the message */
79 if (mbx_copy(file, md, fileno(stdin), 0) == NOTOK) {
84 /* close and unlock the file */
85 if (mbx_close(file, md) == NOTOK)