]>
diplodocus.org Git - nmh/blob - uip/rcvpack.c
3 * rcvpack.c -- append message to a file
10 #include <h/rcvmail.h>
11 #include <zotnet/tws/tws.h>
12 #include <zotnet/mts/mts.h>
14 static struct swit switches
[] = {
27 * default format in which to save messages
29 static int mbx_style
= MBOX_FORMAT
;
33 main (int argc
, char **argv
)
36 char *cp
, *file
= NULL
, buf
[BUFSIZ
];
37 char **argp
, **arguments
;
40 setlocale(LC_ALL
, "");
42 invo_name
= r1bindex (argv
[0], '/');
44 /* read user profile/context */
48 arguments
= getarguments (invo_name
, argc
, argv
, 1);
52 while ((cp
= *argp
++)) {
54 switch (smatch (++cp
, switches
)) {
56 ambigsw (cp
, switches
);
59 adios (NULL
, "-%s unknown", cp
);
62 snprintf (buf
, sizeof(buf
), "%s [switches] file", invo_name
);
63 print_help (buf
, switches
, 1);
66 print_version(invo_name
);
70 mbx_style
= MBOX_FORMAT
;
73 mbx_style
= MMDF_FORMAT
;
78 adios (NULL
, "only one file at a time!");
84 adios (NULL
, "%s [switches] file", invo_name
);
88 /* open and lock the file */
89 if ((md
= mbx_open (file
, mbx_style
, getuid(), getgid(), m_gmprot())) == NOTOK
)
92 /* append the message */
93 if (mbx_copy (file
, mbx_style
, md
, fileno(stdin
), 1, NULL
, 0) == NOTOK
) {
98 /* close and unlock the file */
99 if (mbx_close (file
, md
) == NOTOK
)
102 return done (RCV_MOK
);