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[] = {
25 main(int argc, char **argv)
28 char *cp, *file = NULL, buf[BUFSIZ];
29 char **argp, **arguments;
32 setlocale(LC_ALL, "");
34 invo_name = mhbasename(argv[0]);
36 /* read user profile/context */
40 arguments = getarguments(invo_name, argc, argv, 1);
44 while ((cp = *argp++)) {
46 switch (smatch(++cp, switches)) {
48 ambigsw(cp, switches);
51 adios(NULL, "-%s unknown", cp);
54 snprintf(buf, sizeof(buf),
57 print_help(buf, switches, 1);
60 print_version(invo_name);
65 adios(NULL, "only one file at a time!");
71 adios(NULL, "%s [switches] file", invo_name);
75 /* open and lock the file */
76 if ((md = mbx_open(file, getuid(), getgid(), m_gmprot()))
80 /* append the message */
81 if (mbx_copy(file, md, fileno(stdin), NULL, 0) == NOTOK) {
86 /* close and unlock the file */
87 if (mbx_close(file, md) == NOTOK)