2 Proprietary Rand Corporation
, 1981.
3 Further distribution of
this software
4 subject to the terms of the Rand
16 /* The minimum match numbers below are all at least 2 as
17 /* a kludge to avoid conflict between switches intended for
18 /* "show" and those that it passes on to pr, mhl, c, ...
20 struct swit switches
[] = {
24 "noheader", 3, /* 3 */
26 "noformat", 3, /* 5 */
33 extern char _sobuf
[]; /* MLW standard out buffer */
39 char *folder
, *maildir
, *msgs
[100];
41 register char *cp
, **ap
;
42 int msgp
, drft
, pr
, format
;
43 char *arguments
[50], **argp
;
46 setbuf(stdout
, _sobuf
);
54 cp
= r1bindex(argv
[0], '/');
55 if((cp
= m_find(cp
)) != NULL
) {
56 ap
= brkstring(cp
= getcpy(cp
), " ", "\n");
57 ap
= copyip(ap
, arguments
);
60 VOID
copyip(argv
+1, ap
);
64 switch(smatch(++cp
, switches
)) {
65 case -2:ambigsw(cp
, switches
); /* ambiguous */
68 case -1:vec
[vecp
++] = --cp
; continue;
70 case 0: fprintf(stderr
, "\"-all\" changed to \"all\"\n");
72 case 1: drft
= 1; continue; /* -draft */
73 case 2: header
= 1; continue; /* -header */
74 case 3: header
= 0; continue; /* -noheader */
75 case 4: format
= 1; continue; /* -format */
76 case 5: format
= 0; continue; /* -noformat */
77 case 6: pr
= 1; continue; /* -pr */
78 case 7: pr
= 0; vecp
= 1; continue;/* -nopr */
80 help("show [+folder] [msgs] [switches] [switches for \"type\" or \"pr\" ]",
86 fprintf(stderr
, "Only one folder at a time.\n");
89 folder
= path(cp
+1, TFOLDER
);
93 if(!m_find("path")) free(path("./", TFOLDER
));
95 maildir
= m_maildir("");
100 folder
= m_getfolder();
101 maildir
= m_maildir(folder
);
103 if(chdir(maildir
) < 0) {
104 fprintf(stderr
, "Can't chdir to: ");
112 if(!(mp
= m_gmsg(folder
))) {
113 fprintf(stderr
, "Can't read folder!?\n");
116 if(mp
->hghmsg
== 0) {
117 fprintf(stderr
, "No messages in \"%s\".\n", folder
);
121 for(msgnum
= 0; msgnum
< msgp
; msgnum
++)
122 if(!m_convert(msgs
[msgnum
]))
124 if(mp
->numsel
== 0) {
125 fprintf(stderr
, "show: potato pancakes.\n"); /* never get here */
128 if(mp
->numsel
> MAXARGS
-2) {
129 fprintf(stderr
, "show: more than %d messages for show-exec\n", MAXARGS
-2);
132 for(msgnum
= mp
->lowsel
; msgnum
<= mp
->hghsel
; msgnum
++)
133 if(mp
->msgstats
[msgnum
]&SELECTED
)
134 vec
[vecp
++] = getcpy(m_name(msgnum
));
135 m_replace(pfolder
, folder
);
136 if(mp
->hghsel
!= mp
->curmsg
)
137 m_setcur(mp
->hghsel
);
138 if(vecp
== 2 && header
) {
139 printf("(Message %s:%s)\n", folder
, vec
[1]);
149 putenv("mhfolder", folder
);
158 /* THIS IS INEFFICIENT */
159 /* what we really should do in this case is
160 /* copy it out ourself to save the extra exec */
163 vec
[0] = r1bindex(proc
, '/');
173 #define switches mhlswitches
174 #define INCLUDED_BY_SHOW
175 #define main(a,b) mhl(a,b)