0
|
1 /* rcvpack.c - a rcvmail program to keep a copy */
|
|
2 #ifndef lint
|
12
|
3 static char ident[] = "@(#)$Id: rcvpack.c,v 1.1.1.1 2005/04/18 14:46:07 kono Exp $";
|
0
|
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 /* */
|
|
16
|
|
17 static struct swit switches[] = {
|
|
18 #define HELPSW 0
|
|
19 "help", 4,
|
|
20
|
|
21 NULL, 0
|
|
22 };
|
|
23
|
|
24 /* */
|
|
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 #ifdef JAPAN
|
|
45 ml_init();
|
|
46 #endif /* JAPAN */
|
|
47 invo_name = r1bindex (argv[0], '/');
|
|
48 mts_init (invo_name);
|
|
49 if ((cp = m_find (invo_name)) != NULL) {
|
|
50 ap = brkstring (cp = getcpy (cp), " ", "\n");
|
|
51 ap = copyip (ap, arguments);
|
|
52 }
|
|
53 else
|
|
54 ap = arguments;
|
|
55 (void) copyip (argv + 1, ap);
|
|
56 argp = arguments;
|
|
57
|
|
58 /* */
|
|
59
|
|
60 while (cp = *argp++) {
|
|
61 if (*cp == '-')
|
|
62 switch (smatch (++cp, switches)) {
|
|
63 case AMBIGSW:
|
|
64 ambigsw (cp, switches);
|
|
65 done (1);
|
|
66 case UNKWNSW:
|
|
67 adios (NULLCP, "-%s unknown", cp);
|
|
68 case HELPSW:
|
|
69 (void) sprintf (buf, "%s [switches] file", invo_name);
|
|
70 help (buf, switches);
|
|
71 done (1);
|
|
72 }
|
|
73 if (file)
|
|
74 adios (NULLCP, "only one file at a time!");
|
|
75 else
|
|
76 file = cp;
|
|
77 }
|
|
78
|
|
79 /* */
|
|
80
|
|
81 if (!file)
|
|
82 adios (NULLCP, "%s [switches] file", invo_name);
|
|
83
|
|
84 (void) sprintf (ddate, "Delivery-Date: %s\n", dtimenow ());
|
|
85 rewind (stdin);
|
|
86 if ((md = mbx_open (file, getuid (), getgid (), m_gmprot ())) == NOTOK
|
|
87 || mbx_copy (file, md, fileno (stdin), 1, ddate, 0) == NOTOK
|
|
88 || mbx_close (file, md) == NOTOK) {
|
|
89 if (md != NOTOK)
|
|
90 (void) mbx_close (file, md);
|
|
91 done (RCV_MBX);
|
|
92 }
|
|
93
|
|
94 done (RCV_MOK);
|
|
95 }
|