1: /* mhpath.c - print full pathnames */
2:
3: #include "../h/mh.h"
4: #include <stdio.h>
5:
6: /* */
7:
8: static struct swit switches[] = {
9: #define HELPSW 0
10: "help", 4,
11:
12: NULL, NULL
13: };
14:
15: /* */
16:
17: /* ARGSUSED */
18:
19: main(argc, argv)
20: int argc;
21: char *argv[];
22: {
23: int msgp = 0,
24: msgnum;
25: char *cp,
26: *maildir,
27: *folder = NULL,
28: buf[100],
29: **ap,
30: **argp,
31: *arguments[MAXARGS],
32: *msgs[MAXARGS];
33: struct msgs *mp;
34:
35: invo_name = r1bindex (argv[0], '/');
36: if ((cp = m_find (invo_name)) != NULL) {
37: ap = brkstring (cp = getcpy (cp), " ", "\n");
38: ap = copyip (ap, arguments);
39: }
40: else
41: ap = arguments;
42: (void) copyip (argv + 1, ap);
43: argp = arguments;
44:
45: /* */
46:
47: while (cp = *argp++) {
48: if (*cp == '-')
49: switch (smatch (++cp, switches)) {
50: case AMBIGSW:
51: ambigsw (cp, switches);
52: done (1);
53: case UNKWNSW:
54: adios (NULLCP, "-%s unknown", cp);
55: case HELPSW:
56: (void) sprintf (buf, "%s [+folder] [msgs] [switches]",
57: invo_name);
58: help (buf, switches);
59: done (1);
60: }
61: if (*cp == '+' || *cp == '@') {
62: if (folder)
63: adios (NULLCP, "only one folder at a time!");
64: else
65: folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
66: }
67: else
68: msgs[msgp++] = cp;
69: }
70:
71: /* */
72:
73: if (!m_find ("path"))
74: free (path ("./", TFOLDER));
75:
76: if (!folder)
77: folder = m_getfolder ();
78: maildir = m_maildir (folder);
79: if (!msgp) {
80: printf ("%s\n", maildir);
81: done (0);
82: }
83:
84: if (chdir (maildir) == NOTOK)
85: adios (maildir, "unable to change directory to");
86: if (!(mp = m_gmsg (folder)))
87: adios (NULLCP, "unable to read folder %s", folder);
88:
89: if ((mp = m_remsg (mp, 0, MAXFOLDER)) == NULL)
90: adios (NULLCP, "unable to allocate folder storage");
91: mp -> msgflags |= MHPATH;
92:
93: for (msgnum = 0; msgnum < msgp; msgnum++)
94: if (!m_convert (mp, msgs[msgnum]))
95: done (1);
96: m_setseq (mp);
97:
98: /* */
99:
100: if (mp -> numsel > MAXARGS - 2)
101: adios (NULLCP, "more than %d messages", MAXARGS - 2);
102:
103: for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
104: if (mp -> msgstats[msgnum] & SELECTED)
105: printf ("%s/%s\n", mp -> foldpath, m_name (msgnum));
106:
107: m_sync (mp);
108: m_update ();
109:
110: done (0);
111: }
Defined functions
main
defined in line
19;
never used
Defined variables
Defined macros
HELPSW
defined in line
9;
never used