9 date 92.12.15.00.20.22; author jromine; state Exp;
14 date 92.11.04.00.41.21; author jromine; state Exp;
19 date 92.02.04.17.46.56; author jromine; state Exp;
24 date 92.01.31.22.09.12; author jromine; state Exp;
29 date 92.01.31.22.08.51; author jromine; state Exp;
43 @/* dist.c - re-distribute a message */
45 static char ident[] = "@@(#)$Id: dist.c,v 1.4 1992/11/04 00:41:21 jromine Exp jromine $";
50 #include <sys/types.h>
58 static struct swit switches[] = {
65 "draftfolder +folder", 0,
67 "draftmessage msg", 0,
85 "whatnowproc program", 0,
93 "file file", -4, /* interface from msh */
100 static struct swit aqrnl[] = {
116 static struct swit aqrl[] = {
157 struct msgs *mp = NULL;
161 setlocale(LC_ALL, "");
163 invo_name = r1bindex (argv[0], '/');
164 if ((cp = m_find (invo_name)) != NULL) {
165 ap = brkstring (cp = getcpy (cp), " ", "\n");
166 ap = copyip (ap, arguments);
170 (void) copyip (argv + 1, ap);
175 while (cp = *argp++) {
177 switch (smatch (++cp, switches)) {
179 ambigsw (cp, switches);
182 adios (NULLCP, "-%s unknown", cp);
184 (void) sprintf (buf, "%s [+folder] [msg] [switches]",
186 help (buf, switches);
197 if (!(ed = *argp++) || *ed == '-')
198 adios (NULLCP, "missing argument to %s", argp[-2]);
206 if (!(whatnowproc = *argp++) || *whatnowproc == '-')
207 adios (NULLCP, "missing argument to %s", argp[-2]);
216 adios (NULLCP, "only one file at a time!");
217 if (!(cp = *argp++) || *cp == '-')
218 adios (NULLCP, "missing argument to %s", argp[-2]);
219 file = path (cp, TFILE);
222 if (!(form = *argp++) || *form == '-')
223 adios (NULLCP, "missing argument to %s", argp[-2]);
235 adios (NULLCP, "only one draft folder at a time!");
236 if (!(cp = *argp++) || *cp == '-')
237 adios (NULLCP, "missing argument to %s", argp[-2]);
238 dfolder = path (*cp == '+' || *cp == '@@' ? cp + 1 : cp,
239 *cp != '@@' ? TFOLDER : TSUBCWF);
243 adios (NULLCP, "only one draft message at a time!");
244 if (!(dmsg = *argp++) || *dmsg == '-')
245 adios (NULLCP, "missing argument to %s", argp[-2]);
252 if (*cp == '+' || *cp == '@@') {
254 adios (NULLCP, "only one folder at a time!");
256 folder = path (cp + 1, *cp == '+' ? TFOLDER : TSUBCWF);
260 adios (NULLCP, "only one message at a time!");
267 cwd = getcpy (pwd ());
269 if (!m_find ("path"))
270 free (path ("./", TFOLDER));
271 if (file && (msg || folder))
272 adios (NULLCP, "can't mix files and folders/msgs");
275 if ((in = open (libpath (form), 0)) == NOTOK)
276 adios (form, "unable to open form file");
279 if ((in = open (libpath (distcomps), 0)) == NOTOK)
280 adios (distcomps, "unable to open default components file");
285 (void) strcpy (drft, m_draft (dfolder, dmsg, NOUSE, &isdf));
286 if (stat (drft, &st) != NOTOK) {
287 printf ("Draft \"%s\" exists (%ld bytes).", drft, st.st_size);
288 for (i = LISTDSW; i != YESW;) {
289 if (!(argp = getans ("\nDisposition? ", isdf ? aqrnl : aqrl)))
291 switch (i = smatch (*argp, isdf ? aqrnl : aqrl)) {
300 (void) showfile (++argp, drft);
303 if (refile (++argp, drft) == 0)
307 advise (NULLCP, "say what?");
312 if ((out = creat (drft, m_gmprot ())) == NOTOK)
313 adios (drft, "unable to create");
315 cpydata (in, out, form, drft);
329 folder = m_getfolder ();
330 maildir = m_maildir (folder);
332 if (chdir (maildir) == NOTOK)
333 adios (maildir, "unable to change directory to");
334 if (!(mp = m_gmsg (folder)))
335 adios (NULLCP, "unable to read folder %s", folder);
336 if (mp -> hghmsg == 0)
337 adios (NULLCP, "no messages in %s", folder);
339 if (!m_convert (mp, msg))
343 if (mp -> numsel > 1)
344 adios (NULLCP, "only one message at a time!");
347 if ((in = open (msgnam = file ? file : getcpy (m_name (mp -> lowsel)), 0))
349 adios (msgnam, "unable to open message");
352 m_replace (pfolder, folder);
353 if (mp -> lowsel != mp -> curmsg)
354 m_setcur (mp, mp -> lowsel);
361 (void) what_now (ed, nedit, NOUSE, drft, msgnam, 1, mp,
362 anot ? "Resent" : NULLCP, inplace, cwd);
375 static char ident[] = "@@(#)$Id: dist.c,v 1.3 1992/02/04 17:46:56 jromine Exp jromine $";
382 @rename m_whatnow() to what_now() since it's not a m_ routine
387 static char ident[] = "@@(#)$Id: dist.c,v 1.2 1992/01/31 22:09:12 jromine Exp jromine $";
400 static char ident[] = "@@(#)$Id: scan.c,v 1.9 1992/01/23 23:06:45 jromine Exp $";
403 (void) m_whatnow (ed, nedit, NOUSE, drft, msgnam, 1, mp,