Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / uip / RCS / anno.c,v
1 head    2.6;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 2.6
9 date    92.12.15.00.20.22;      author jromine; state Exp;
10 branches;
11 next    2.5;
12
13 2.5
14 date    92.11.04.00.38.29;      author jromine; state Exp;
15 branches;
16 next    2.4;
17
18 2.4
19 date    92.01.31.22.07.02;      author jromine; state Exp;
20 branches;
21 next    2.3;
22
23 2.3
24 date    90.04.05.15.35.14;      author sources; state Exp;
25 branches;
26 next    2.2;
27
28 2.2
29 date    90.04.05.14.54.59;      author sources; state Exp;
30 branches;
31 next    2.1;
32
33 2.1
34 date    90.02.06.13.15.50;      author sources; state Exp;
35 branches;
36 next    2.0;
37
38 2.0
39 date    89.11.17.15.57.49;      author sources; state Exp;
40 branches;
41 next    1.2;
42
43 1.2
44 date    88.06.30.08.28.24;      author sources; state Exp;
45 branches;
46 next    1.1;
47
48 1.1
49 date    88.06.30.08.27.05;      author sources; state Exp;
50 branches;
51 next    ;
52
53
54 desc
55 @Original with no mods.
56 @
57
58
59 2.6
60 log
61 @endif sugar
62 @
63 text
64 @/* anno.c - annotate messages */
65 #ifndef lint
66 static char ident[] = "@@(#)$Id: anno.c,v 2.5 1992/11/04 00:38:29 jromine Exp jromine $";
67 #endif  /* lint */
68
69 #include "../h/mh.h"
70 #include <ctype.h>
71 #include <stdio.h>
72 #ifdef LOCALE
73 #include        <locale.h>
74 #endif
75
76 static make_comp();
77 /* \f */
78
79 static struct swit switches[] = {
80 #define COMPSW  0
81     "component field", 0,
82
83 #define INPLSW  1
84     "inplace", 0,
85 #define NINPLSW 2
86     "noinplace", 0,
87
88 #define DATESW  3
89     "date", 0,
90 #define NDATESW 4
91     "nodate", 0,
92
93 #define TEXTSW  5
94     "text body", 0,
95
96 #define HELPSW  6
97     "help", 4,
98
99     NULL, 0
100 };
101
102 /* \f */
103
104 /* ARGSUSED */
105
106 main (argc, argv)
107 int     argc;
108 char  **argv;
109 {
110     int     inplace = 0,
111             datesw = 1,
112             msgp = 0,
113             msgnum;
114     char   *cp,
115            *maildir,
116            *comp = NULL,
117            *text = NULL,
118            *folder = NULL,
119             buf[100],
120           **ap,
121           **argp,
122            *arguments[MAXARGS],
123            *msgs[MAXARGS];
124     struct msgs *mp;
125
126 #ifdef LOCALE
127         setlocale(LC_ALL, "");
128 #endif
129     invo_name = r1bindex (argv[0], '/');
130     if ((cp = m_find (invo_name)) != NULL) {
131         ap = brkstring (cp = getcpy (cp), " ", "\n");
132         ap = copyip (ap, arguments);
133     }
134     else
135         ap = arguments;
136     (void) copyip (argv + 1, ap);
137     argp = arguments;
138
139 /* \f */
140
141     while (cp = *argp++) {
142         if (*cp == '-')
143             switch (smatch (++cp, switches)) {
144                 case AMBIGSW: 
145                     ambigsw (cp, switches);
146                     done (1);
147                 case UNKWNSW: 
148                     adios (NULLCP, "-%s unknown", cp);
149                 case HELPSW: 
150                     (void) sprintf (buf, "%s [+folder] [msgs] [switches]",
151                             invo_name);
152                     help (buf, switches);
153                     done (1);
154
155                 case COMPSW: 
156                     if (comp)
157                         adios (NULLCP, "only one component at a time!");
158                     if (!(comp = *argp++) || *comp == '-')
159                         adios (NULLCP, "missing argument to %s", argp[-2]);
160                     continue;
161
162                 case DATESW: 
163                     datesw++;
164                     continue;
165                 case NDATESW: 
166                     datesw = 0;
167                     continue;
168
169                 case INPLSW: 
170                     inplace++;
171                     continue;
172                 case NINPLSW: 
173                     inplace = 0;
174                     continue;
175
176                 case TEXTSW: 
177                     if (text)
178                         adios (NULLCP, "only one body at a time!");
179                     if (!(text = *argp++) || *text == '-')
180                         adios (NULLCP, "missing argument to %s", argp[-2]);
181                     continue;
182             }
183         if (*cp == '+' || *cp == '@@') {
184             if (folder)
185                 adios (NULLCP, "only one folder at a time!");
186             else
187                 folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
188         }
189         else
190             msgs[msgp++] = cp;
191     }
192 #ifdef UCI
193     if (strcmp(invo_name, "fanno") == 0)        /* ugh! */
194         datesw = 0;
195 #endif  /* UCI */
196
197 /* \f */
198
199     if (!m_find ("path"))
200         free (path ("./", TFOLDER));
201     if (!msgp)
202         msgs[msgp++] = "cur";
203     if (!folder)
204         folder = m_getfolder ();
205     maildir = m_maildir (folder);
206
207     if (chdir (maildir) == NOTOK)
208         adios (maildir, "unable to change directory to");
209     if (!(mp = m_gmsg (folder)))
210         adios (NULLCP, "unable to read folder %s", folder);
211     if (mp -> hghmsg == 0)
212         adios (NULLCP, "no messages in %s", folder);
213
214     for (msgnum = 0; msgnum < msgp; msgnum++)
215         if (!m_convert (mp, msgs[msgnum]))
216             done (1);
217
218     make_comp (&comp);
219
220     for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
221         if (mp -> msgstats[msgnum] & SELECTED)
222             (void) annotate (m_name (msgnum), comp, text, inplace, datesw);
223
224     m_replace (pfolder, folder);
225     if (mp -> lowsel != mp -> curmsg)
226         m_setcur (mp, mp -> lowsel);
227     m_sync (mp);
228     m_update ();
229
230     done (0);
231 }
232
233 /* \f */
234
235 static make_comp (ap)
236 register char **ap;
237 {
238     register char  *cp;
239     char    buffer[BUFSIZ];
240
241     if (*ap == NULL) {
242         printf ("Enter component name: ");
243         (void) fflush (stdout);
244
245         if (fgets (buffer, sizeof buffer, stdin) == NULL)
246             done (1);
247         *ap = trimcpy (buffer);
248     }
249
250     if ((cp = *ap + strlen (*ap) - 1) > *ap && *cp == ':')
251         *cp = 0;
252     if (strlen (*ap) == 0)
253         adios (NULLCP, "null component name");
254     if (**ap == '-')
255         adios (NULLCP, "invalid component name %s", *ap);
256     if (strlen (*ap) >= NAMESZ)
257         adios (NULLCP, "too large component name %s", *ap);
258
259     for (cp = *ap; *cp; cp++)
260         if (!isalnum (*cp) && *cp != '-')
261             adios (NULLCP, "invalid component name %s", *ap);
262 }
263 @
264
265
266 2.5
267 log
268 @putenv -> m_putenv
269 @
270 text
271 @d3 2
272 a4 2
273 static char ident[] = "@@(#)$Id: anno.c,v 2.4 1992/01/31 22:07:02 jromine Exp jromine $";
274 #endif  lint
275 d132 1
276 a132 1
277 #endif UCI
278 @
279
280
281 2.4
282 log
283 @kerberos
284 @
285 text
286 @d3 1
287 a3 1
288 static char ident[] = "@@(#)$Id: anno.c,v 2.3 1990/04/05 15:35:14 sources Exp jromine $";
289 d9 3
290 d63 3
291 @
292
293
294 2.3
295 log
296 @add ID
297 @
298 text
299 @d3 1
300 a3 1
301 static char ident[] = "@@(#)$Id:$";
302 d33 1
303 a33 1
304     NULL, NULL
305 d182 1
306 a182 1
307         *cp = NULL;
308 @
309
310
311 2.2
312 log
313 @add ID
314 @
315 text
316 @d3 1
317 a3 1
318 static char ident[] = "@@(#)$Id:";
319 @
320
321
322 2.1
323 log
324 @ANSI Compilance
325 @
326 text
327 @d2 3
328 @
329
330
331 2.0
332 log
333 @changes for SUN40 shared libraries and NNTP under bbc
334 @
335 text
336 @d7 1
337 @
338
339
340 1.2
341 log
342 @Added the code for fanno.
343 Gary <erickson>
344 @
345 text
346 @d18 6
347 a23 1
348 #define TEXTSW  3
349 d26 1
350 a26 1
351 #define HELPSW  4
352 a31 4
353 #ifdef UCI
354 extern int fanno;
355 #endif UCI
356
357 d41 1
358 d89 7
359 d120 2
360 a121 1
361     if (strcmp(invo_name,"fanno") == 0) fanno = 1;
362 d149 1
363 a149 1
364             (void) annotate (m_name (msgnum), comp, text, inplace);
365 @
366
367
368 1.1
369 log
370 @Initial revision
371 @
372 text
373 @d27 4
374 d110 3
375 @