]> diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/uip/rcvpack.c
sbr/mts.c: Delete mmdlm2; use same-valued mmdlm1 instead.
[nmh] / docs / historical / mh-6.8.5 / uip / rcvpack.c
1 /* rcvpack.c - a rcvmail program to keep a copy */
2 #ifndef lint
3 static char ident[] = "@(#)$Id: rcvpack.c,v 1.5 1993/08/25 17:27:19 jromine Exp $";
4 #endif /* lint */
5
6 #include "../h/mh.h"
7 #include "../h/dropsbr.h"
8 #include "../h/rcvmail.h"
9 #include "../zotnet/tws.h"
10 #include "../zotnet/mts.h"
11 #ifdef LOCALE
12 #include <locale.h>
13 #endif
14
15 /* \f */
16
17 static struct swit switches[] = {
18 #define HELPSW 0
19 "help", 4,
20
21 NULL, 0
22 };
23
24 /* \f */
25
26 /* ARGSUSED */
27
28 main (argc, argv)
29 int argc;
30 char **argv;
31 {
32 int md;
33 char *cp,
34 *file = NULL,
35 buf[100],
36 ddate[BUFSIZ],
37 **ap,
38 **argp,
39 *arguments[MAXARGS];
40
41 #ifdef LOCALE
42 setlocale(LC_ALL, "");
43 #endif
44 invo_name = r1bindex (argv[0], '/');
45 mts_init (invo_name);
46 if ((cp = m_find (invo_name)) != NULL) {
47 ap = brkstring (cp = getcpy (cp), " ", "\n");
48 ap = copyip (ap, arguments);
49 }
50 else
51 ap = arguments;
52 (void) copyip (argv + 1, ap);
53 argp = arguments;
54
55 /* \f */
56
57 while (cp = *argp++) {
58 if (*cp == '-')
59 switch (smatch (++cp, switches)) {
60 case AMBIGSW:
61 ambigsw (cp, switches);
62 done (1);
63 case UNKWNSW:
64 adios (NULLCP, "-%s unknown", cp);
65 case HELPSW:
66 (void) sprintf (buf, "%s [switches] file", invo_name);
67 help (buf, switches);
68 done (1);
69 }
70 if (file)
71 adios (NULLCP, "only one file at a time!");
72 else
73 file = cp;
74 }
75
76 /* \f */
77
78 if (!file)
79 adios (NULLCP, "%s [switches] file", invo_name);
80
81 (void) sprintf (ddate, "Delivery-Date: %s\n", dtimenow ());
82 rewind (stdin);
83 if ((md = mbx_open (file, getuid (), getgid (), m_gmprot ())) == NOTOK
84 || mbx_copy (file, md, fileno (stdin), 1, ddate, 0) == NOTOK
85 || mbx_close (file, md) == NOTOK) {
86 if (md != NOTOK)
87 (void) mbx_close (file, md);
88 done (RCV_MBX);
89 }
90
91 done (RCV_MOK);
92 }