]>
diplodocus.org Git - nmh/blob - uip/rcvpack.c
3 * rcvpack.c -- append message to a file
7 * This code is Copyright (c) 2002, by the authors of nmh. See the
8 * COPYRIGHT file in the root directory of the nmh distribution for
9 * complete copyright information.
13 #include <h/dropsbr.h>
14 #include <h/rcvmail.h>
18 static struct swit switches
[] = {
31 * default format in which to save messages
33 static int mbx_style
= MBOX_FORMAT
;
37 main (int argc
, char **argv
)
40 char *cp
, *file
= NULL
, buf
[BUFSIZ
];
41 char **argp
, **arguments
;
44 setlocale(LC_ALL
, "");
46 invo_name
= r1bindex (argv
[0], '/');
48 /* read user profile/context */
52 arguments
= getarguments (invo_name
, argc
, argv
, 1);
56 while ((cp
= *argp
++)) {
58 switch (smatch (++cp
, switches
)) {
60 ambigsw (cp
, switches
);
63 adios (NULL
, "-%s unknown", cp
);
66 snprintf (buf
, sizeof(buf
), "%s [switches] file", invo_name
);
67 print_help (buf
, switches
, 1);
70 print_version(invo_name
);
74 mbx_style
= MBOX_FORMAT
;
77 mbx_style
= MMDF_FORMAT
;
82 adios (NULL
, "only one file at a time!");
88 adios (NULL
, "%s [switches] file", invo_name
);
92 /* open and lock the file */
93 if ((md
= mbx_open (file
, mbx_style
, getuid(), getgid(), m_gmprot())) == NOTOK
)
96 /* append the message */
97 if (mbx_copy (file
, mbx_style
, md
, fileno(stdin
), 1, NULL
, 0) == NOTOK
) {
102 /* close and unlock the file */
103 if (mbx_close (file
, md
) == NOTOK
)