annotate uip/rcvpack.c @ 17:76d91e545ea8 default tip

addrsbr and dtimep fix
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 24 Nov 2014 14:49:25 +0900
parents 441a2190cfae
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bce86c4163a3 Initial revision
kono
parents:
diff changeset
1 /* rcvpack.c - a rcvmail program to keep a copy */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
2 #ifndef lint
12
441a2190cfae Lion fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
3 static char ident[] = "@(#)$Id: rcvpack.c,v 1.1.1.1 2005/04/18 14:46:07 kono Exp $";
0
bce86c4163a3 Initial revision
kono
parents:
diff changeset
4 #endif /* lint */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
5
bce86c4163a3 Initial revision
kono
parents:
diff changeset
6 #include "../h/mh.h"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
7 #include "../h/dropsbr.h"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
8 #include "../h/rcvmail.h"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
9 #include "../zotnet/tws.h"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
10 #include "../zotnet/mts.h"
bce86c4163a3 Initial revision
kono
parents:
diff changeset
11 #ifdef LOCALE
bce86c4163a3 Initial revision
kono
parents:
diff changeset
12 #include <locale.h>
bce86c4163a3 Initial revision
kono
parents:
diff changeset
13 #endif
bce86c4163a3 Initial revision
kono
parents:
diff changeset
14
bce86c4163a3 Initial revision
kono
parents:
diff changeset
15 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
16
bce86c4163a3 Initial revision
kono
parents:
diff changeset
17 static struct swit switches[] = {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
18 #define HELPSW 0
bce86c4163a3 Initial revision
kono
parents:
diff changeset
19 "help", 4,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
20
bce86c4163a3 Initial revision
kono
parents:
diff changeset
21 NULL, 0
bce86c4163a3 Initial revision
kono
parents:
diff changeset
22 };
bce86c4163a3 Initial revision
kono
parents:
diff changeset
23
bce86c4163a3 Initial revision
kono
parents:
diff changeset
24 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
25
bce86c4163a3 Initial revision
kono
parents:
diff changeset
26 /* ARGSUSED */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
27
bce86c4163a3 Initial revision
kono
parents:
diff changeset
28 main (argc, argv)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
29 int argc;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
30 char **argv;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
31 {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
32 int md;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
33 char *cp,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
34 *file = NULL,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
35 buf[100],
bce86c4163a3 Initial revision
kono
parents:
diff changeset
36 ddate[BUFSIZ],
bce86c4163a3 Initial revision
kono
parents:
diff changeset
37 **ap,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
38 **argp,
bce86c4163a3 Initial revision
kono
parents:
diff changeset
39 *arguments[MAXARGS];
bce86c4163a3 Initial revision
kono
parents:
diff changeset
40
bce86c4163a3 Initial revision
kono
parents:
diff changeset
41 #ifdef LOCALE
bce86c4163a3 Initial revision
kono
parents:
diff changeset
42 setlocale(LC_ALL, "");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
43 #endif
bce86c4163a3 Initial revision
kono
parents:
diff changeset
44 #ifdef JAPAN
bce86c4163a3 Initial revision
kono
parents:
diff changeset
45 ml_init();
bce86c4163a3 Initial revision
kono
parents:
diff changeset
46 #endif /* JAPAN */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
47 invo_name = r1bindex (argv[0], '/');
bce86c4163a3 Initial revision
kono
parents:
diff changeset
48 mts_init (invo_name);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
49 if ((cp = m_find (invo_name)) != NULL) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
50 ap = brkstring (cp = getcpy (cp), " ", "\n");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
51 ap = copyip (ap, arguments);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
52 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
53 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
54 ap = arguments;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
55 (void) copyip (argv + 1, ap);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
56 argp = arguments;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
57
bce86c4163a3 Initial revision
kono
parents:
diff changeset
58 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
59
bce86c4163a3 Initial revision
kono
parents:
diff changeset
60 while (cp = *argp++) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
61 if (*cp == '-')
bce86c4163a3 Initial revision
kono
parents:
diff changeset
62 switch (smatch (++cp, switches)) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
63 case AMBIGSW:
bce86c4163a3 Initial revision
kono
parents:
diff changeset
64 ambigsw (cp, switches);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
65 done (1);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
66 case UNKWNSW:
bce86c4163a3 Initial revision
kono
parents:
diff changeset
67 adios (NULLCP, "-%s unknown", cp);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
68 case HELPSW:
bce86c4163a3 Initial revision
kono
parents:
diff changeset
69 (void) sprintf (buf, "%s [switches] file", invo_name);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
70 help (buf, switches);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
71 done (1);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
72 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
73 if (file)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
74 adios (NULLCP, "only one file at a time!");
bce86c4163a3 Initial revision
kono
parents:
diff changeset
75 else
bce86c4163a3 Initial revision
kono
parents:
diff changeset
76 file = cp;
bce86c4163a3 Initial revision
kono
parents:
diff changeset
77 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
78
bce86c4163a3 Initial revision
kono
parents:
diff changeset
79 /* */
bce86c4163a3 Initial revision
kono
parents:
diff changeset
80
bce86c4163a3 Initial revision
kono
parents:
diff changeset
81 if (!file)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
82 adios (NULLCP, "%s [switches] file", invo_name);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
83
bce86c4163a3 Initial revision
kono
parents:
diff changeset
84 (void) sprintf (ddate, "Delivery-Date: %s\n", dtimenow ());
bce86c4163a3 Initial revision
kono
parents:
diff changeset
85 rewind (stdin);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
86 if ((md = mbx_open (file, getuid (), getgid (), m_gmprot ())) == NOTOK
bce86c4163a3 Initial revision
kono
parents:
diff changeset
87 || mbx_copy (file, md, fileno (stdin), 1, ddate, 0) == NOTOK
bce86c4163a3 Initial revision
kono
parents:
diff changeset
88 || mbx_close (file, md) == NOTOK) {
bce86c4163a3 Initial revision
kono
parents:
diff changeset
89 if (md != NOTOK)
bce86c4163a3 Initial revision
kono
parents:
diff changeset
90 (void) mbx_close (file, md);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
91 done (RCV_MBX);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
92 }
bce86c4163a3 Initial revision
kono
parents:
diff changeset
93
bce86c4163a3 Initial revision
kono
parents:
diff changeset
94 done (RCV_MOK);
bce86c4163a3 Initial revision
kono
parents:
diff changeset
95 }