1 /* anno.c - annotate messages */
3 static char ident[] = "@(#)$Id: anno.c,v 2.6 1992/12/15 00:20:22 jromine Exp $";
16 static struct swit switches[] = {
64 setlocale(LC_ALL, "");
66 invo_name = r1bindex (argv[0], '/');
67 if ((cp = m_find (invo_name)) != NULL) {
68 ap = brkstring (cp = getcpy (cp), " ", "\n");
69 ap = copyip (ap, arguments);
73 (void) copyip (argv + 1, ap);
78 while (cp = *argp++) {
80 switch (smatch (++cp, switches)) {
82 ambigsw (cp, switches);
85 adios (NULLCP, "-%s unknown", cp);
87 (void) sprintf (buf, "%s [+folder] [msgs] [switches]",
94 adios (NULLCP, "only one component at a time!");
95 if (!(comp = *argp++) || *comp == '-')
96 adios (NULLCP, "missing argument to %s", argp[-2]);
115 adios (NULLCP, "only one body at a time!");
116 if (!(text = *argp++) || *text == '-')
117 adios (NULLCP, "missing argument to %s", argp[-2]);
120 if (*cp == '+' || *cp == '@') {
122 adios (NULLCP, "only one folder at a time!");
124 folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
130 if (strcmp(invo_name, "fanno") == 0) /* ugh! */
136 if (!m_find ("path"))
137 free (path ("./", TFOLDER));
139 msgs[msgp++] = "cur";
141 folder = m_getfolder ();
142 maildir = m_maildir (folder);
144 if (chdir (maildir) == NOTOK)
145 adios (maildir, "unable to change directory to");
146 if (!(mp = m_gmsg (folder)))
147 adios (NULLCP, "unable to read folder %s", folder);
148 if (mp -> hghmsg == 0)
149 adios (NULLCP, "no messages in %s", folder);
151 for (msgnum = 0; msgnum < msgp; msgnum++)
152 if (!m_convert (mp, msgs[msgnum]))
157 for (msgnum = mp -> lowsel; msgnum <= mp -> hghsel; msgnum++)
158 if (mp -> msgstats[msgnum] & SELECTED)
159 (void) annotate (m_name (msgnum), comp, text, inplace, datesw);
161 m_replace (pfolder, folder);
162 if (mp -> lowsel != mp -> curmsg)
163 m_setcur (mp, mp -> lowsel);
172 static make_comp (ap)
179 printf ("Enter component name: ");
180 (void) fflush (stdout);
182 if (fgets (buffer, sizeof buffer, stdin) == NULL)
184 *ap = trimcpy (buffer);
187 if ((cp = *ap + strlen (*ap) - 1) > *ap && *cp == ':')
189 if (strlen (*ap) == 0)
190 adios (NULLCP, "null component name");
192 adios (NULLCP, "invalid component name %s", *ap);
193 if (strlen (*ap) >= NAMESZ)
194 adios (NULLCP, "too large component name %s", *ap);
196 for (cp = *ap; *cp; cp++)
197 if (!isalnum (*cp) && *cp != '-')
198 adios (NULLCP, "invalid component name %s", *ap);