]> diplodocus.org Git - nmh/blob - docs/historical/mh-6.8.5/uip/RCS/mark.c,v
sbr/mts.c: Delete mmdlm2; use same-valued mmdlm1 instead.
[nmh] / docs / historical / mh-6.8.5 / uip / RCS / mark.c,v
1 head 1.5;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 1.5
9 date 95.12.06.23.44.31; author jromine; state Exp;
10 branches;
11 next 1.4;
12
13 1.4
14 date 92.12.15.00.20.22; author jromine; state Exp;
15 branches;
16 next 1.3;
17
18 1.3
19 date 92.11.04.00.44.21; author jromine; state Exp;
20 branches;
21 next 1.2;
22
23 1.2
24 date 92.01.31.22.12.18; author jromine; state Exp;
25 branches;
26 next 1.1;
27
28 1.1
29 date 92.01.31.22.11.55; author jromine; state Exp;
30 branches;
31 next ;
32
33
34 desc
35 @@
36
37
38 1.5
39 log
40 @null ptr fix
41 @
42 text
43 @/* mark.c - mark messages */
44 #ifndef lint
45 static char ident[] = "@@(#)$Id: mark.c,v 1.4 1992/12/15 00:20:22 jromine Exp jromine $";
46 #endif /* lint */
47
48 #include "../h/mh.h"
49 #include <stdio.h>
50 #ifdef LOCALE
51 #include <locale.h>
52 #endif
53
54 /* \f */
55
56 static struct swit switches[] = {
57 #define ADDSW 0
58 "add", 0,
59 #define DELSW 1
60 "delete", 0,
61 #define LSTSW 2
62 "list", 0,
63
64 #define SEQSW 3
65 "sequence name", 0,
66
67 #define PUBLSW 4
68 "public", 0,
69 #define NPUBLSW 5
70 "nopublic", 0,
71
72 #define ZEROSW 6
73 "zero", 0,
74 #define NZEROSW 7
75 "nozero", 0,
76
77 #define HELPSW 8
78 "help", 4,
79
80 #define DEBUGSW 9
81 "debug", -5,
82
83 NULL, 0
84 };
85
86 /* \f */
87
88 /* ARGSUSED */
89
90 main (argc, argv)
91 int argc;
92 char **argv;
93 {
94 int addsw = 0,
95 deletesw = 0,
96 debugsw = 0,
97 listsw = 0,
98 publicsw = -1,
99 zerosw = 0,
100 seqp = 0,
101 msgp = 0,
102 i,
103 msgnum;
104 char *cp,
105 *maildir,
106 *folder = NULL,
107 buf[100],
108 **ap,
109 **argp,
110 *arguments[MAXARGS],
111 *seqs[NATTRS + 1],
112 *msgs[MAXARGS];
113 struct msgs *mp;
114
115 #ifdef LOCALE
116 setlocale(LC_ALL, "");
117 #endif
118 invo_name = r1bindex (argv[0], '/');
119 if ((cp = m_find (invo_name)) != NULL) {
120 ap = brkstring (cp = getcpy (cp), " ", "\n");
121 ap = copyip (ap, arguments);
122 }
123 else
124 ap = arguments;
125 (void) copyip (argv + 1, ap);
126 argp = arguments;
127
128 /* \f */
129
130 while (cp = *argp++) {
131 if (*cp == '-')
132 switch (smatch (++cp, switches)) {
133 case AMBIGSW:
134 ambigsw (cp, switches);
135 done (1);
136 case UNKWNSW:
137 adios (NULLCP, "-%s unknown\n", cp);
138 case HELPSW:
139 (void) sprintf (buf, "%s [+folder] [msgs] [switches]",
140 invo_name);
141 help (buf, switches);
142 done (1);
143
144 case ADDSW:
145 addsw++;
146 deletesw = listsw = 0;
147 continue;
148 case DELSW:
149 deletesw++;
150 addsw = listsw = 0;
151 continue;
152 case LSTSW:
153 listsw++;
154 addsw = deletesw = 0;
155 continue;
156
157 case SEQSW:
158 if (!(cp = *argp++) || *cp == '-')
159 adios (NULLCP, "missing argument to %s", argp[-2]);
160 if (seqp < NATTRS)
161 seqs[seqp++] = cp;
162 else
163 adios (NULLCP, "only %d sequences allowed!", NATTRS);
164 continue;
165
166 case PUBLSW:
167 publicsw = 1;
168 continue;
169 case NPUBLSW:
170 publicsw = 0;
171 continue;
172
173 case DEBUGSW:
174 debugsw++;
175 continue;
176
177 case ZEROSW:
178 zerosw++;
179 continue;
180 case NZEROSW:
181 zerosw = 0;
182 continue;
183 }
184 if (*cp == '+' || *cp == '@@') {
185 if (folder)
186 adios (NULLCP, "only one folder at a time!");
187 else
188 folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
189 }
190 else
191 msgs[msgp++] = cp;
192 }
193
194 /* \f */
195
196 if (!addsw && !deletesw && !listsw)
197 if (seqp)
198 addsw++;
199 else
200 listsw++;
201
202 if (!m_find ("path"))
203 free (path ("./", TFOLDER));
204 if (!msgp)
205 msgs[msgp++] = listsw ? "all" :"cur";
206 if (!folder)
207 folder = m_getfolder ();
208 maildir = m_maildir (folder);
209
210 if (chdir (maildir) == NOTOK)
211 adios (maildir, "unable to change directory to");
212 if (!(mp = m_gmsg (folder)))
213 adios (NULLCP, "unable to read folder %s", folder);
214 if (mp -> hghmsg == 0)
215 adios (NULLCP, "no messages in %s", folder);
216
217 for (msgnum = 0; msgnum < msgp; msgnum++)
218 if (!m_convert (mp, msgs[msgnum]))
219 done (1);
220
221 if (publicsw == -1)
222 publicsw = mp -> msgflags & READONLY ? 0 : 1;
223 if (publicsw && (mp -> msgflags & READONLY))
224 adios (NULLCP, "folder %s is read-only, so -public not allowed",
225 folder);
226
227 /* \f */
228
229 if (debugsw) {
230 printf ("invo_name=%s mypath=%s defpath=%s\n",
231 invo_name, mypath, defpath);
232 printf ("ctxpath=%s context flags=%s\n",
233 ctxpath, sprintb (buf, (unsigned) ctxflags, DBITS));
234 printf ("foldpath=%s flags=%s\n",
235 mp -> foldpath,
236 sprintb (buf, (unsigned) mp -> msgflags, FBITS));
237 printf ("lowmsg=%d hghmsg=%d nummsg=%d curmsg=%d\n",
238 mp -> lowmsg, mp -> hghmsg, mp -> nummsg, mp -> curmsg);
239 printf ("lowsel=%d hghsel=%d numsel=%d\n",
240 mp -> lowsel, mp -> hghsel, mp -> numsel);
241 #ifndef MTR
242 printf ("lowoff=%d hghoff=%d\n",
243 mp -> lowoff, mp -> hghoff);
244 #else /* MTR */
245 printf ("lowoff=%d hghoff=%d msgbase=0x%x msgstats=0x%x\n",
246 mp -> lowoff, mp -> hghoff, mp -> msgbase, mp -> msgstats);
247 #endif /* MTR */
248 }
249
250 if (seqp == 0 && (addsw || deletesw))
251 adios (NULLCP, "-%s requires at least one -sequence argument",
252 addsw ? "add" : "delete");
253 seqs[seqp] = NULL;
254
255 if (addsw)
256 for (seqp = 0; seqs[seqp]; seqp++) {
257 if (zerosw && !m_seqnew (mp, seqs[seqp], publicsw))
258 done (1);
259 for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
260 if (mp -> msgstats[msgnum] & SELECTED)
261 if (!m_seqadd (mp, seqs[seqp], msgnum, publicsw))
262 done (1);
263 }
264
265 if (deletesw)
266 for (seqp = 0; seqs[seqp]; seqp++) {
267 if (zerosw)
268 for (msgnum = mp -> lowmsg; msgnum <= mp -> hghmsg; msgnum++)
269 if (mp -> msgstats[msgnum] & EXISTS)
270 if (!m_seqadd (mp, seqs[seqp], msgnum, publicsw))
271 done (1);
272 for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
273 if (mp -> msgstats[msgnum] & SELECTED)
274 if (!m_seqdel (mp, seqs[seqp], msgnum))
275 done (1);
276 }
277
278 if (listsw) {
279 int bits = FFATTRSLOT;
280
281 #define empty(s) ((s) ? (s) : "")
282 if (seqp == 0)
283 for (i = 0; mp -> msgattrs[i]; i++)
284 printf ("%s%s: %s\n", mp -> msgattrs[i],
285 mp -> attrstats & (1 << (bits + i))
286 ? " (private)" : "",
287 empty(m_seq (mp, mp -> msgattrs[i])));
288 else
289 for (seqp = 0; seqs[seqp]; seqp++)
290 printf ("%s: %s\n", seqs[seqp], empty(m_seq (mp, seqs[seqp])));
291 #undef empty
292
293 if (debugsw)
294 for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
295 if (mp -> msgstats[msgnum] & SELECTED)
296 printf ("%*d: %s\n", DMAXFOLDER, msgnum,
297 sprintb (buf, (unsigned) mp -> msgstats[msgnum],
298 m_seqbits (mp)));
299 }
300
301 m_replace (pfolder, folder);
302 m_sync (mp);
303 m_update ();
304
305 done (0);
306 }
307 @
308
309
310 1.4
311 log
312 @endif sugar
313 @
314 text
315 @d3 1
316 a3 1
317 static char ident[] = "@@(#)$Id: mark.c,v 1.3 1992/11/04 00:44:21 jromine Exp jromine $";
318 d239 1
319 d245 1
320 a245 1
321 m_seq (mp, mp -> msgattrs[i]));
322 d248 2
323 a249 1
324 printf ("%s: %s\n", seqs[seqp], m_seq (mp, seqs[seqp]));
325 @
326
327
328 1.3
329 log
330 @LOCALE
331 @
332 text
333 @d3 2
334 a4 2
335 static char ident[] = "@@(#)$Id: mark.c,v 1.2 1992/01/31 22:12:18 jromine Exp jromine $";
336 #endif lint
337 d202 1
338 a202 1
339 #else MTR
340 d205 1
341 a205 1
342 #endif MTR
343 @
344
345
346 1.2
347 log
348 @kerberos
349 @
350 text
351 @d3 1
352 a3 1
353 static char ident[] = "@@(#)$Id: scan.c,v 1.9 1992/01/23 23:06:45 jromine Exp $";
354 d8 3
355 d73 3
356 @
357
358
359 1.1
360 log
361 @Initial revision
362 @
363 text
364 @d2 3
365 d38 1
366 a38 1
367 NULL, NULL
368 @