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>
17 static struct swit switches[] = {
27 main(int argc, char **argv)
30 char *cp, *file = NULL, buf[BUFSIZ];
31 char **argp, **arguments;
33 setlocale(LC_ALL, "");
34 invo_name = mhbasename(argv[0]);
36 /* read user profile/context */
39 arguments = getarguments(invo_name, argc, argv, 1);
43 while ((cp = *argp++)) {
45 switch (smatch(++cp, switches)) {
47 ambigsw(cp, switches);
50 adios(EX_USAGE, NULL, "-%s unknown", cp);
53 snprintf(buf, sizeof(buf),
56 print_help(buf, switches, 1);
57 exit(argc == 2 ? EX_OK : EX_USAGE);
59 print_version(invo_name);
60 exit(argc == 2 ? EX_OK : EX_USAGE);
64 adios(EX_USAGE, NULL, "only one file at a time!");
69 /* copy stdin to stdout, converting rfc822 message to mbox */
71 if (mbox_copy(fileno(stdout), fileno(stdin)) == NOTOK) {
78 /* open and lock the file */
79 if ((md = mbox_open(file, getuid(), getgid(), m_gmprot()))
83 /* append the message */
84 if (mbox_copy(md, fileno(stdin)) == NOTOK) {
89 /* close and unlock the file */
90 if (mbox_close(file, md) == NOTOK)