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;
30 setlocale(LC_ALL, "");
31 invo_name = mhbasename(argv[0]);
33 /* read user profile/context */
36 arguments = getarguments(invo_name, argc, argv, 1);
40 while ((cp = *argp++)) {
42 switch (smatch(++cp, switches)) {
44 ambigsw(cp, switches);
47 adios(NULL, "-%s unknown", cp);
50 snprintf(buf, sizeof(buf),
53 print_help(buf, switches, 1);
56 print_version(invo_name);
61 adios(NULL, "only one file at a time!");
66 /* copy stdin to stdout, converting rfc822 message to mbox */
68 if (mbox_copy(fileno(stdout), fileno(stdin)) == NOTOK) {
75 /* open and lock the file */
76 if ((md = mbox_open(file, getuid(), getgid(), m_gmprot()))
80 /* append the message */
81 if (mbox_copy(md, fileno(stdin)) == NOTOK) {
86 /* close and unlock the file */
87 if (mbox_close(file, md) == NOTOK)