Eliminated compilation warnings.
[mmh] / uip / spost.c
1
2 /*
3  * spost.c -- feed messages to sendmail
4  *
5  * This is a simpler, faster, replacement for "post" for use
6  * when "sendmail" is the transport system.
7  *
8  * $Id$
9  */
10
11 #include <h/mh.h>
12 #include <signal.h>
13 #include <h/addrsbr.h>
14 #include <h/aliasbr.h>
15 #include <h/dropsbr.h>
16 #include <zotnet/tws/tws.h>
17
18 #define uptolow(c)      ((isalpha(c) && isupper (c)) ? tolower (c) : c)
19
20 #define MAX_SM_FIELD    1476    /* < largest hdr field sendmail will accept */
21 #define FCCS            10      /* max number of fccs allowed */
22
23 struct swit switches[] = {
24 #define FILTSW               0
25     { "filter filterfile", 0 },
26 #define NFILTSW              1
27     { "nofilter", 0 },
28 #define FRMTSW               2
29     { "format", 0 },
30 #define NFRMTSW              3
31     { "noformat", 0 },
32 #define REMVSW               4
33     { "remove", 0 },
34 #define NREMVSW              5
35     { "noremove", 0 },
36 #define VERBSW               6
37     { "verbose", 0 },
38 #define NVERBSW              7
39     { "noverbose", 0 },
40 #define WATCSW               8
41     { "watch", 0 },
42 #define NWATCSW              9
43     { "nowatch", 0 },
44 #define BACKSW              10
45     { "backup", 0 },
46 #define NBACKSW             11
47     { "nobackup", 0 },
48 #define ALIASW              12
49     { "alias aliasfile", 0 },
50 #define NALIASW             13
51     { "noalias", 0 },
52 #define WIDTHSW             14
53     { "width columns", 0 },
54 #define VERSIONSW           15
55     { "version", 0 },
56 #define HELPSW              16
57     { "help", 4 },
58 #define DEBUGSW             17
59     { "debug", -5 },
60 #define DISTSW              18
61     { "dist", -4 },             /* interface from dist */
62 #define CHKSW               19
63     { "check", -5 },            /* interface from whom */
64 #define NCHKSW              20
65     { "nocheck", -7 },          /* interface from whom */
66 #define WHOMSW              21
67     { "whom", -4 },             /* interface from whom */
68 #define PUSHSW              22  /* fork to sendmail then exit */
69     { "push", -4 },
70 #define NPUSHSW             23  /* exec sendmail */
71     { "nopush", -6 },
72 #define LIBSW               24
73     { "library directory", -7 },
74 #define ANNOSW              25
75     { "idanno number", -6 },
76     { NULL, 0 }
77 };
78
79
80 /* flags for headers->flags */
81 #define HNOP    0x0000          /* just used to keep .set around */
82 #define HBAD    0x0001          /* bad header - don't let it through */
83 #define HADR    0x0002          /* header has an address field */
84 #define HSUB    0x0004          /* Subject: header */
85 #define HTRY    0x0008          /* try to send to addrs on header */
86 #define HBCC    0x0010          /* don't output this header */
87 #define HMNG    0x0020          /* mung this header */
88 #define HNGR    0x0040          /* no groups allowed in this header */
89 #define HFCC    0x0080          /* FCC: type header */
90 #define HNIL    0x0100          /* okay for this header not to have addrs */
91 #define HIGN    0x0200          /* ignore this header */
92
93 /* flags for headers->set */
94 #define MFRM    0x0001          /* we've seen a From: */
95 #define MDAT    0x0002          /* we've seen a Date: */
96 #define MRFM    0x0004          /* we've seen a Resent-From: */
97 #define MVIS    0x0008          /* we've seen sighted addrs */
98 #define MINV    0x0010          /* we've seen blind addrs */
99 #define MRDT    0x0020          /* we've seen a Resent-Date: */
100
101 struct headers {
102     char *value;
103     unsigned int flags;
104     unsigned int set;
105 };
106
107
108 static struct headers NHeaders[] = {
109     { "Return-Path", HBAD,                0 },
110     { "Received",    HBAD,                0 },
111     { "Reply-To",    HADR|HNGR,           0 },
112     { "From",        HADR|HNGR,           MFRM },
113     { "Sender",      HADR|HBAD,           0 },
114     { "Date",        HNOP,                MDAT },
115     { "Subject",     HSUB,                0 },
116     { "To",          HADR|HTRY,           MVIS },
117     { "cc",          HADR|HTRY,           MVIS },
118     { "Bcc",         HADR|HTRY|HBCC|HNIL, MINV },
119     { "Message-Id",  HBAD,                0 },
120     { "Fcc",         HFCC,                0 },
121     { NULL,          0,                   0 }
122 };
123
124 static struct headers RHeaders[] = {
125     { "Resent-Reply-To",   HADR|HNGR,      0 },
126     { "Resent-From",       HADR|HNGR,      MRFM },
127     { "Resent-Sender",     HADR|HBAD,      0 },
128     { "Resent-Date",       HNOP,           MRDT },
129     { "Resent-Subject",    HSUB,           0 },
130     { "Resent-To",         HADR|HTRY,      MVIS },
131     { "Resent-cc",         HADR|HTRY,      MVIS },
132     { "Resent-Bcc",        HADR|HTRY|HBCC, MINV },
133     { "Resent-Message-Id", HBAD,           0 },
134     { "Resent-Fcc",        HFCC,           0 },
135     { "Reply-To",          HADR,           0 },
136     { "Fcc",               HIGN,           0 },
137     { NULL,                0,              0 }
138 };
139
140
141 static short fccind = 0;        /* index into fccfold[] */
142
143 static int badmsg = 0;          /* message has bad semantics            */
144 static int verbose = 0;         /* spell it out                         */
145 static int debug = 0;           /* debugging post                       */
146 static int rmflg = 1;           /* remove temporary file when done      */
147 static int watch = 0;           /* watch the delivery process           */
148 static int backflg = 0;         /* rename input file as *.bak when done */
149 static int whomflg = 0;         /* if just checking addresses           */
150 static int pushflg = 0;         /* if going to fork to sendmail         */
151 static int aliasflg = -1;       /* if going to process aliases          */
152 static int outputlinelen=72;
153
154 static unsigned msgflags = 0;   /* what we've seen */
155
156 static enum {
157     normal, resent
158 } msgstate = normal;
159
160 static char tmpfil[] = "/tmp/pstXXXXXX";
161
162 static char from[BUFSIZ];       /* my network address */
163 static char signature[BUFSIZ];  /* my signature */
164 static char *filter = NULL;     /* the filter for BCC'ing */
165 static char *subject = NULL;    /* the subject field for BCC'ing */
166 static char *fccfold[FCCS];     /* foldernames for FCC'ing */
167
168 static struct headers *hdrtab;  /* table for the message we're doing */
169 static FILE *out;               /* output (temp) file */
170
171 extern char *sendmail;
172
173 /*
174  * external prototypes
175  */
176 extern char *getfullname (void);
177 extern char *getusername (void);
178
179 /*
180  * static prototypes
181  */
182 static void putfmt (char *, char *, FILE *);
183 static void start_headers (void);
184 static void finish_headers (FILE *);
185 static int get_header (char *, struct headers *);
186 static void putadr (char *, struct mailname *);
187 static int putone (char *, int, int);
188 static void insert_fcc (struct headers *, char *);
189 static void file (char *);
190 static void fcc (char *, char *);
191
192 #if 0
193 static void die (char *, char *, ...);
194 static void make_bcc_file (void);
195 #endif
196
197
198 int
199 main (int argc, char **argv)
200 {
201     int state, i, pid, compnum;
202     char *cp, *msg = NULL, **argp, **arguments;
203     char *sargv[16], buf[BUFSIZ], name[NAMESZ];
204     FILE *in;
205
206 #ifdef LOCALE
207     setlocale(LC_ALL, "");
208 #endif
209     invo_name = r1bindex (argv[0], '/');
210
211     /* foil search of user profile/context */
212     if (context_foil (NULL) == -1)
213         done (1);
214
215     mts_init (invo_name);
216     arguments = getarguments (invo_name, argc, argv, 0);
217     argp = arguments;
218
219     while ((cp = *argp++)) {
220         if (*cp == '-') {
221             switch (smatch (++cp, switches)) {
222                 case AMBIGSW: 
223                     ambigsw (cp, switches);
224                     done (1);
225                 case UNKWNSW: 
226                     adios (NULL, "-%s unknown", cp);
227
228                 case HELPSW: 
229                     snprintf (buf, sizeof(buf), "%s [switches] file", invo_name);
230                     print_help (buf, switches, 1);
231                     done (1);
232                 case VERSIONSW:
233                     print_version(invo_name);
234                     done (1);
235
236                 case DEBUGSW: 
237                     debug++;
238                     continue;
239
240                 case DISTSW:
241                     msgstate = resent;
242                     continue;
243
244                 case WHOMSW:
245                     whomflg++;
246                     continue;
247
248                 case FILTSW:
249                     if (!(filter = *argp++) || *filter == '-')
250                         adios (NULL, "missing argument to %s", argp[-2]);
251                     continue;
252                 case NFILTSW:
253                     filter = NULL;
254                     continue;
255                 
256                 case REMVSW: 
257                     rmflg++;
258                     continue;
259                 case NREMVSW: 
260                     rmflg = 0;
261                     continue;
262
263                 case BACKSW: 
264                     backflg++;
265                     continue;
266                 case NBACKSW: 
267                     backflg = 0;
268                     continue;
269
270                 case VERBSW: 
271                     verbose++;
272                     continue;
273                 case NVERBSW: 
274                     verbose = 0;
275                     continue;
276
277                 case WATCSW: 
278                     watch++;
279                     continue;
280                 case NWATCSW: 
281                     watch = 0;
282                     continue;
283                 
284                 case PUSHSW:
285                     pushflg++;
286                     continue;
287                 case NPUSHSW:
288                     pushflg = 0;
289                     continue;
290
291                 case ALIASW:
292                     if (!(cp = *argp++) || *cp == '-')
293                         adios (NULL, "missing argument to %s", argp[-2]);
294                     if (aliasflg < 0)
295                         alias (AliasFile);/* load default aka's */
296                     aliasflg = 1;
297                     if ((state = alias(cp)) != AK_OK)
298                         adios (NULL, "aliasing error in file %s - %s",
299                                cp, akerror(state) );
300                     continue;
301                 case NALIASW:
302                     aliasflg = 0;
303                     continue;
304
305                 case WIDTHSW:
306                     if (!(cp = *argp++) || *cp == '-')
307                         adios (NULL, "missing argument to %s", argp[-2]);
308                     outputlinelen = atoi (cp);
309                     if (outputlinelen <= 10)
310                         outputlinelen = 72;
311                     continue;
312
313                 case LIBSW:
314                     if (!(cp = *argp++) || *cp == '-')
315                         adios (NULL, "missing argument to %s", argp[-2]);
316                     /* create a minimal context */
317                     if (context_foil (cp) == -1)
318                         done(1);
319                     continue;
320
321                 case ANNOSW:
322                     /* -idanno switch ignored */
323                     if (!(cp = *argp++) || *cp == '-')
324                         adios (NULL, "missing argument to %s", argp[-2]);
325                     continue;
326             }
327         }
328         if (msg)
329             adios (NULL, "only one message at a time!");
330         else
331             msg = cp;
332     }
333
334     if (aliasflg < 0)
335         alias (AliasFile);      /* load default aka's */
336
337     if (!msg)
338         adios (NULL, "usage: %s [switches] file", invo_name);
339
340     if ((in = fopen (msg, "r")) == NULL)
341         adios (msg, "unable to open");
342
343     start_headers ();
344     if (debug) {
345         verbose++;
346         out = stdout;
347     }
348     else {
349 #ifdef HAVE_MKSTEMP
350             mkstemp (tmpfil);
351 #else
352             mktemp (tmpfil);
353 #endif
354             if ((out = fopen (tmpfil, "w")) == NULL)
355                 adios (tmpfil, "unable to create");
356             chmod (tmpfil, 0600);
357         }
358
359     hdrtab = (msgstate == normal) ? NHeaders : RHeaders;
360
361     for (compnum = 1, state = FLD;;) {
362         switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
363             case FLD: 
364                 compnum++;
365                 putfmt (name, buf, out);
366                 continue;
367
368             case FLDPLUS: 
369                 compnum++;
370                 cp = add (buf, cp);
371                 while (state == FLDPLUS) {
372                     state = m_getfld (state, name, buf, sizeof(buf), in);
373                     cp = add (buf, cp);
374                 }
375                 putfmt (name, cp, out);
376                 free (cp);
377                 continue;
378
379             case BODY: 
380                 finish_headers (out);
381                 fprintf (out, "\n%s", buf);
382                 if(whomflg == 0)
383                     while (state == BODY) {
384                         state = m_getfld (state, name, buf, sizeof(buf), in);
385                         fputs (buf, out);
386                     }
387                 break;
388
389             case FILEEOF: 
390                 finish_headers (out);
391                 break;
392
393             case LENERR: 
394             case FMTERR: 
395                 adios (NULL, "message format error in component #%d",
396                         compnum);
397
398             default: 
399                 adios (NULL, "getfld() returned %d", state);
400         }
401         break;
402     }
403
404     fclose (in);
405     if (backflg && !whomflg) {
406         strncpy (buf, m_backup (msg), sizeof(buf));
407         if (rename (msg, buf) == NOTOK)
408             advise (buf, "unable to rename %s to", msg);
409     }
410
411     if (debug) {
412         done (0);
413     }
414     else
415         fclose (out);
416
417     file (tmpfil);
418
419     /*
420      * re-open the temp file, unlink it and exec sendmail, giving it
421      * the msg temp file as std in.
422      */
423     if ( freopen( tmpfil, "r", stdin) == NULL)
424         adios (tmpfil, "can't reopen for sendmail");
425     if (rmflg)
426         unlink (tmpfil);
427
428     argp = sargv;
429     *argp++ = "send-mail";
430     *argp++ = "-m";     /* send to me too */
431     *argp++ = "-t";     /* read msg for recipients */
432     *argp++ = "-i";     /* don't stop on "." */
433     if (whomflg)
434         *argp++ = "-bv";
435     if (watch || verbose)
436         *argp++ = "-v";
437     *argp = NULL;
438
439     if (pushflg && !(watch || verbose)) {
440         /* fork to a child to run sendmail */
441         for (i=0; (pid = vfork()) == NOTOK && i < 5; i++)
442             sleep(5);
443         switch (pid) {
444             case NOTOK:
445                 fprintf (verbose ? stdout : stderr, "%s: can't fork to %s\n",
446                          invo_name, sendmail);
447                 exit(-1);
448             case OK:
449                 /* we're the child .. */
450                 break;
451             default:
452                 exit(0);
453         }
454     }
455     execv ( sendmail, sargv);
456     adios ( sendmail, "can't exec");
457     return 0;  /* dead code to satisfy the compiler */
458 }
459
460 /* DRAFT GENERATION */
461
462 static void
463 putfmt (char *name, char *str, FILE *out)
464 {
465     int i;
466     char *cp, *pp;
467     struct headers *hdr;
468
469     while (*str == ' ' || *str == '\t')
470         str++;
471
472     if ((i = get_header (name, hdrtab)) == NOTOK) {
473         fprintf (out, "%s: %s", name, str);
474         return;
475     }
476
477     hdr = &hdrtab[i];
478     if (hdr->flags & HIGN)
479         return;
480     if (hdr->flags & HBAD) {
481         advise (NULL, "illegal header line -- %s:", name);
482         badmsg++;
483         return;
484     }
485     msgflags |= hdr->set;
486
487     if (hdr->flags & HSUB)
488         subject = subject ? add (str, add ("\t", subject)) : getcpy (str);
489
490     if (hdr->flags & HFCC) {
491         if ((cp = strrchr(str, '\n')))
492             *cp = 0;
493         for (cp = pp = str; (cp = strchr(pp, ',')); pp = cp) {
494             *cp++ = 0;
495             insert_fcc (hdr, pp);
496         }
497         insert_fcc (hdr, pp);
498         return;
499     }
500
501 #ifdef notdef
502     if (hdr->flags & HBCC) {
503         insert_bcc(str);
504         return;
505     }
506 #endif  /* notdef */
507
508     if (*str != '\n' && *str != '\0') {
509         if (aliasflg && hdr->flags & HTRY) {
510             /* this header contains address(es) that we have to do
511              * alias expansion on.  Because of the saved state in
512              * getname we have to put all the addresses into a list.
513              * We then let putadr munch on that list, possibly
514              * expanding aliases.
515              */
516             register struct mailname *f = 0;
517             register struct mailname *mp = 0;
518
519             while ((cp = getname(str))) {
520                 mp = getm( cp, NULL, 0, AD_HOST, NULL);
521                 if (f == 0) {
522                     f = mp;
523                     mp->m_next = mp;
524                 } else {
525                     mp->m_next = f->m_next;
526                     f->m_next = mp;
527                     f = mp;
528                 }
529             }
530             f = mp->m_next; mp->m_next = 0;
531             putadr( name, f );
532         } else {
533             fprintf (out, "%s: %s", name, str );
534         }
535     }
536 }
537
538
539 static void
540 start_headers (void)
541 {
542     char *cp;
543     char sigbuf[BUFSIZ];
544
545     strncpy(from, getusername(), sizeof(from));
546
547     if ((cp = getfullname ()) && *cp) {
548         strncpy (sigbuf, cp, sizeof(sigbuf));
549         snprintf (signature, sizeof(signature), "%s <%s>", sigbuf,  from);
550     }
551     else
552         snprintf (signature, sizeof(signature), "%s",  from);
553 }
554
555
556 static void
557 finish_headers (FILE *out)
558 {
559     switch (msgstate) {
560         case normal: 
561             if (!(msgflags & MDAT))
562                 fprintf (out, "Date: %s\n", dtimenow (0));
563             if (msgflags & MFRM)
564                 fprintf (out, "Sender: %s\n", from);
565             else
566                 fprintf (out, "From: %s\n", signature);
567 #ifdef notdef
568             if (!(msgflags & MVIS))
569                 fprintf (out, "Bcc: Blind Distribution List: ;\n");
570 #endif  /* notdef */
571             break;
572
573         case resent: 
574             if (!(msgflags & MRDT))
575                 fprintf (out, "Resent-Date: %s\n", dtimenow(0));
576             if (msgflags & MRFM)
577                 fprintf (out, "Resent-Sender: %s\n", from);
578             else
579                 fprintf (out, "Resent-From: %s\n", signature);
580 #ifdef notdef
581             if (!(msgflags & MVIS))
582                 fprintf (out, "Resent-Bcc: Blind Re-Distribution List: ;\n");
583 #endif  /* notdef */
584             break;
585     }
586
587     if (badmsg)
588         adios (NULL, "re-format message and try again");
589 }
590
591
592 static int
593 get_header (char *header, struct headers *table)
594 {
595     struct headers *h;
596
597     for (h = table; h->value; h++)
598         if (!strcasecmp (header, h->value))
599             return (h - table);
600
601     return NOTOK;
602 }
603
604
605 /*
606  * output the address list for header "name".  The address list
607  * is a linked list of mailname structs.  "nl" points to the head
608  * of the list.  Alias substitution should be done on nl.
609  */
610 static void
611 putadr (char *name, struct mailname *nl)
612 {
613     register struct mailname *mp, *mp2;
614     register int linepos;
615     register char *cp;
616     int namelen;
617
618     fprintf (out, "%s: ", name);
619     namelen = strlen(name) + 2;
620     linepos = namelen;
621
622     for (mp = nl; mp; ) {
623         if (linepos > MAX_SM_FIELD) {
624                 fprintf (out, "\n%s: ", name);
625                 linepos = namelen;
626         }
627         if (mp->m_nohost) {
628             /* a local name - see if it's an alias */
629             cp = akvalue(mp->m_mbox);
630             if (cp == mp->m_mbox)
631                 /* wasn't an alias - use what the user typed */
632                 linepos = putone( mp->m_text, linepos, namelen );
633             else
634                 /* an alias - expand it */
635                 while ((cp = getname(cp))) {
636                     if (linepos > MAX_SM_FIELD) {
637                             fprintf (out, "\n%s: ", name);
638                             linepos = namelen;
639                     }
640                     mp2 = getm( cp, NULL, 0, AD_HOST, NULL);
641                     if (akvisible()) {
642                         mp2->m_pers = getcpy(mp->m_mbox);
643                         linepos = putone( adrformat(mp2), linepos, namelen );
644                     } else {
645                         linepos = putone( mp2->m_text, linepos, namelen );
646                     }
647                     mnfree( mp2 );
648                 }
649         } else {
650             /* not a local name - use what the user typed */
651             linepos = putone( mp->m_text, linepos, namelen );
652         }
653         mp2 = mp;
654         mp = mp->m_next;
655         mnfree( mp2 );
656     }
657     putc( '\n', out );
658 }
659
660 static int
661 putone (char *adr, int pos, int indent)
662 {
663     register int len;
664     static int linepos;
665
666     len = strlen( adr );
667     if (pos == indent)
668         linepos = pos;
669     else if ( linepos+len > outputlinelen ) {
670         fprintf ( out, ",\n%*s", indent, "");
671         linepos = indent;
672         pos += indent + 2;
673     }
674     else {
675         fputs( ", ", out );
676         linepos += 2;
677         pos += 2;
678     }
679     fputs( adr, out );
680
681     linepos += len;
682     return (pos+len);
683 }
684
685
686 static void
687 insert_fcc (struct headers *hdr, char *pp)
688 {
689     char   *cp;
690
691     for (cp = pp; isspace (*cp); cp++)
692         continue;
693     for (pp += strlen (pp) - 1; pp > cp && isspace (*pp); pp--)
694         continue;
695     if (pp >= cp)
696         *++pp = 0;
697     if (*cp == 0)
698         return;
699
700     if (fccind >= FCCS)
701         adios (NULL, "too many %ss", hdr->value);
702     fccfold[fccind++] = getcpy (cp);
703 }
704
705 #if 0
706 /* BCC GENERATION */
707
708 static void
709 make_bcc_file (void)
710 {
711     pid_t child_id;
712     int fd, i, status;
713     char *vec[6];
714     FILE * in, *out;
715
716     mktemp (bccfil);
717     if ((out = fopen (bccfil, "w")) == NULL)
718         adios (bccfil, "unable to create");
719     chmod (bccfil, 0600);
720
721     fprintf (out, "Date: %s\n", dtimenow (0));
722     fprintf (out, "From: %s\n", signature);
723     if (subject)
724         fprintf (out, "Subject: %s", subject);
725     fprintf (out, "BCC:\n\n------- Blind-Carbon-Copy\n\n");
726     fflush (out);
727
728     if (filter == NULL) {
729         if ((fd = open (tmpfil, O_RDONLY)) == NOTOK)
730             adios (NULL, "unable to re-open");
731         cpydgst (fd, fileno (out), tmpfil, bccfil);
732         close (fd);
733     }
734     else {
735         vec[0] = r1bindex (mhlproc, '/');
736
737         for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
738             sleep (5);
739         switch (child_id) {
740             case NOTOK: 
741                 adios ("vfork", "unable to");
742
743             case OK: 
744                 dup2 (fileno (out), 1);
745
746                 i = 1;
747                 vec[i++] = "-forward";
748                 vec[i++] = "-form";
749                 vec[i++] = filter;
750                 vec[i++] = tmpfil;
751                 vec[i] = NULL;
752
753                 execvp (mhlproc, vec);
754                 adios (mhlproc, "unable to exec");
755
756             default: 
757                 if (status = pidwait(child_id, OK))
758                     admonish (NULL, "%s lost (status=0%o)", vec[0], status);
759                 break;
760         }
761     }
762
763     fseek (out, 0L, SEEK_END);
764     fprintf (out, "\n------- End of Blind-Carbon-Copy\n");
765     fclose (out);
766 }
767 #endif  /* if 0 */
768
769 /* FCC INTERACTION */
770
771 static void
772 file (char *path)
773 {
774     int i;
775
776     if (fccind == 0)
777         return;
778
779     for (i = 0; i < fccind; i++)
780         if (whomflg)
781             printf ("Fcc: %s\n", fccfold[i]);
782         else
783             fcc (path, fccfold[i]);
784 }
785
786
787 static void
788 fcc (char *file, char *folder)
789 {
790     pid_t child_id;
791     int i, status;
792     char fold[BUFSIZ];
793
794     if (verbose)
795         printf ("%sFcc: %s\n", msgstate == resent ? "Resent-" : "", folder);
796     fflush (stdout);
797
798     for (i = 0; (child_id = vfork()) == NOTOK && i < 5; i++)
799         sleep (5);
800     switch (child_id) {
801         case NOTOK: 
802             if (!verbose)
803                 fprintf (stderr, "  %sFcc %s: ",
804                         msgstate == resent ? "Resent-" : "", folder);
805             fprintf (verbose ? stdout : stderr, "no forks, so not ok\n");
806             break;
807
808         case OK: 
809             snprintf (fold, sizeof(fold), "%s%s",
810                     *folder == '+' || *folder == '@' ? "" : "+", folder);
811             execlp (fileproc, r1bindex (fileproc, '/'),
812                     "-link", "-file", file, fold, NULL);
813             _exit (-1);
814
815         default: 
816             if ((status = pidwait(child_id, OK))) {
817                 if (!verbose)
818                     fprintf (stderr, "  %sFcc %s: ",
819                             msgstate == resent ? "Resent-" : "", folder);
820                 fprintf (verbose ? stdout : stderr,
821                         " errored (0%o)\n", status);
822             }
823     }
824
825     fflush (stdout);
826 }
827
828
829 #if 0
830
831 /*
832  * TERMINATION
833  */
834
835 static void
836 die (char *what, char *fmt, ...)
837 {
838     va_list ap;
839
840     va_start(ap, fmt);
841     advertise (what, NULL, fmt, ap);
842     va_end(ap);
843
844     done (1);
845 }
846 #endif