Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / uip / RCS / post.c,v
1 head    2.26;
2 access;
3 symbols;
4 locks; strict;
5 comment @ * @;
6
7
8 2.26
9 date    96.02.10.00.22.14;      author jromine; state Exp;
10 branches;
11 next    2.25;
12
13 2.25
14 date    95.12.06.19.20.22;      author jromine; state Exp;
15 branches;
16 next    2.24;
17
18 2.24
19 date    94.04.21.19.23.38;      author jromine; state Exp;
20 branches;
21 next    2.23;
22
23 2.23
24 date    93.08.25.17.26.51;      author jromine; state Exp;
25 branches;
26 next    2.22;
27
28 2.22
29 date    93.08.20.15.53.20;      author jromine; state Exp;
30 branches;
31 next    2.21;
32
33 2.21
34 date    92.12.15.00.20.22;      author jromine; state Exp;
35 branches;
36 next    2.20;
37
38 2.20
39 date    92.11.24.19.02.24;      author jromine; state Exp;
40 branches;
41 next    2.19;
42
43 2.19
44 date    92.11.19.23.24.00;      author jromine; state Exp;
45 branches;
46 next    2.18;
47
48 2.18
49 date    92.11.04.02.58.40;      author jromine; state Exp;
50 branches;
51 next    2.17;
52
53 2.17
54 date    92.11.04.00.55.52;      author jromine; state Exp;
55 branches;
56 next    2.16;
57
58 2.16
59 date    92.10.16.23.55.56;      author jromine; state Exp;
60 branches;
61 next    2.15;
62
63 2.15
64 date    92.10.16.21.37.31;      author jromine; state Exp;
65 branches;
66 next    2.14;
67
68 2.14
69 date    92.03.02.17.06.14;      author jromine; state Exp;
70 branches;
71 next    2.13;
72
73 2.13
74 date    92.01.31.22.23.44;      author jromine; state Exp;
75 branches;
76 next    2.12;
77
78 2.12
79 date    92.01.31.16.34.06;      author jromine; state Exp;
80 branches;
81 next    2.11;
82
83 2.11
84 date    92.01.30.22.39.58;      author jromine; state Exp;
85 branches;
86 next    2.10;
87
88 2.10
89 date    92.01.29.23.54.10;      author jromine; state Exp;
90 branches;
91 next    2.9;
92
93 2.9
94 date    92.01.24.00.05.24;      author jromine; state Exp;
95 branches;
96 next    2.8;
97
98 2.8
99 date    90.04.05.15.35.20;      author sources; state Exp;
100 branches;
101 next    2.7;
102
103 2.7
104 date    90.04.05.14.55.10;      author sources; state Exp;
105 branches;
106 next    2.6;
107
108 2.6
109 date    90.03.20.16.21.26;      author sources; state Exp;
110 branches;
111 next    2.5;
112
113 2.5
114 date    90.03.12.13.58.09;      author sources; state Exp;
115 branches;
116 next    2.4;
117
118 2.4
119 date    90.02.23.14.18.43;      author sources; state Exp;
120 branches;
121 next    2.3;
122
123 2.3
124 date    90.02.06.13.27.11;      author sources; state Exp;
125 branches;
126 next    2.2;
127
128 2.2
129 date    90.02.05.15.40.11;      author sources; state Exp;
130 branches;
131 next    2.1;
132
133 2.1
134 date    90.02.05.14.25.54;      author sources; state Exp;
135 branches;
136 next    2.0;
137
138 2.0
139 date    89.11.17.15.58.07;      author sources; state Exp;
140 branches;
141 next    1.2;
142
143 1.2
144 date    89.05.03.16.25.05;      author sources; state Exp;
145 branches;
146 next    1.1;
147
148 1.1
149 date    89.05.03.16.07.15;      author sources; state Exp;
150 branches;
151 next    ;
152
153
154 desc
155 @@
156
157
158 2.26
159 log
160 @allow "whom -c" to work (default -c to -check)
161 @
162 text
163 @/* post.c - enter messages into the transport system */
164 #ifndef lint
165 static char ident[] = "@@(#)$Id: post.c,v 2.25 1995/12/06 19:20:22 jromine Exp jromine $";
166 #endif  /* lint */
167
168 #include "../h/mh.h"
169 #include "../h/addrsbr.h"
170 #include "../h/aliasbr.h"
171 #include "../h/dropsbr.h"
172 #include "../zotnet/tws.h"
173 #ifndef MMDFMTS
174 #include <ctype.h>
175 #include <errno.h>
176 #include <setjmp.h>
177 #include <stdio.h>
178 #include <sys/types.h>
179 #else   /* MMDFMTS */
180 #include "../mts/mmdf/util.h"
181 #include "../mts/mmdf/mmdf.h"
182 #endif  /* MMDFMTS */
183 #include "../zotnet/mts.h"
184 #ifdef  MHMTS
185 #ifndef V7
186 #include <sys/ioctl.h>
187 #endif  /* not V7 */
188 #include <sys/stat.h>
189 #endif  /* MHMTS */
190 #ifdef  SENDMTS
191 #include "../mts/sendmail/smail.h"
192 #undef  MF
193 #endif  /* SENDMTS */
194 #include <signal.h>
195 #ifdef  MIME
196 #include "../h/mhn.h"
197 #endif  /* MIME */
198 #ifdef LOCALE
199 #include <locale.h>
200 #endif
201
202
203 #ifndef MMDFMTS
204 #define uptolow(c)      ((isalpha(c) && isupper (c)) ? tolower (c) : (c))
205 #endif  /* not MMDFMTS */
206
207 #define FCCS            10      /* max number of fccs allowed */
208
209 /* \f */
210
211 #ifndef MIME
212 #define MIMEminc(a)     (a)
213 #else
214 #define MIMEminc(a)     0
215 #endif
216
217 #ifndef TMA
218 #define TMAminc(a)      (a)
219 #else   /* TMA */
220 #define TMAminc(a)      0
221 #endif  /* TMA */
222
223 static struct swit switches[] = {
224 #define ALIASW  0
225     "alias aliasfile", 0,
226
227 #define CHKSW   1
228     "check", -1,                /* interface from whom */
229 #define NCHKSW  2
230     "nocheck", -3,              /* interface from whom */
231
232 #define DEBUGSW 3
233     "debug", -5,
234
235 #define DISTSW  4
236     "dist", -4,                 /* interface from dist */
237
238 #define ENCRSW  5
239     "encrypt", TMAminc (-7),
240 #define NENCRSW 6
241     "noencrypt", TMAminc (-9),
242
243 #define FILTSW  7
244     "filter filterfile", 0,
245 #define NFILTSW 8
246     "nofilter", 0,
247
248 #define FRMTSW  9
249     "format", 0,
250 #define NFRMTSW 10
251     "noformat", 0,
252
253 #define LIBSW   11              /* interface from send, whom */
254     "library directory", -7,
255
256 #define MIMESW  12
257     "mime", MIMEminc(-4),
258 #define NMIMESW 13
259     "nomime", MIMEminc(-6),
260
261 #define MSGDSW  14
262     "msgid", 0,
263 #define NMSGDSW 15
264     "nomsgid", 0,
265
266 #define VERBSW  16
267     "verbose", 0,
268 #define NVERBSW 17
269     "noverbose", 0,
270
271 #define WATCSW  18
272     "watch", 0,
273 #define NWATCSW 19
274     "nowatch", 0,
275
276 #define WHOMSW  20      /* interface from whom */
277     "whom", -4,         
278
279 #define WIDTHSW 21
280     "width columns", 0,
281
282 #define HELPSW  22
283     "help", 4,
284
285 #define MAILSW  23
286     "mail", -4,
287 #define SAMLSW  24
288     "saml", -4,
289 #define SENDSW  25
290     "send", -4,
291 #define SOMLSW  26
292     "soml", -4,
293
294 #define ANNOSW  27              /* interface from send */
295     "idanno number", -6,
296
297 #define DLVRSW  28
298     "deliver address-list", -7,
299
300 #define CLIESW  29
301     "client host", -6,
302 #define SERVSW  30
303     "server host", -6,
304 #define SNOOPSW 31
305     "snoop", -5,
306
307 #define FILLSW  32
308     "fill-in file", -7,
309 #define FILLUSW 33
310     "fill-up", -7,
311 #define PARTSW  34
312     "partno", -6,
313
314 #define QUEUESW 35
315     "queued", -6,
316
317 #define RECORSW 36
318     "record program", -6,
319 #define NRECOSW 37
320     "norecord", -8,
321
322     NULL, 0
323 };
324
325 /* \f */
326
327 struct headers {
328     char   *value;
329
330     unsigned int    flags;
331 #define HNOP    0x0000          /* just used to keep .set around */
332 #define HBAD    0x0001          /* bad header - don't let it through */
333 #define HADR    0x0002          /* header has an address field */
334 #define HSUB    0x0004          /* Subject: header */
335 #define HTRY    0x0008          /* try to send to addrs on header */
336 #define HBCC    0x0010          /* don't output this header */
337 #define HMNG    0x0020          /* munge this header */
338 #define HNGR    0x0040          /* no groups allowed in this header */
339 #define HFCC    0x0080          /* FCC: type header */
340 #define HNIL    0x0100          /* okay for this header not to have addrs */
341 #define HIGN    0x0200          /* ignore this header */
342 #define HDCC    0x0400          /* another undocumented feature */
343
344     unsigned int    set;
345 #define MFRM    0x0001          /* we've seen a From: */
346 #define MDAT    0x0002          /* we've seen a Date: */
347 #define MRFM    0x0004          /* we've seen a Resent-From: */
348 #define MVIS    0x0008          /* we've seen sighted addrs */
349 #define MINV    0x0010          /* we've seen blind addrs */
350 #define MRPY    0x0020          /* we've seen a Reply-to: */
351 };
352
353 /* \f */
354
355 static struct headers  NHeaders[] = {
356     "Return-Path", HBAD, 0,
357     "Received", HBAD, 0,
358     "Reply-To", HADR | HNGR, MRPY,
359     "From", HADR | HNGR, MFRM,
360     "Sender", HADR | HBAD, 0,
361     "Date", HBAD, 0,
362     "Subject", HSUB, 0,
363     "To", HADR | HTRY, MVIS,
364     "cc", HADR | HTRY, MVIS,
365     "Bcc", HADR | HTRY | HBCC | HNIL, MINV,
366     "Dcc", HADR | HTRY | HDCC | HNIL, MVIS,     /* sorta cc & bcc combined */
367     "Message-ID", HBAD, 0,
368     "Fcc", HFCC, 0,
369
370     NULL
371 };
372
373 static struct headers  RHeaders[] = {
374     "Resent-Reply-To", HADR | HNGR, MRPY,
375     "Resent-From", HADR | HNGR, MRFM,
376     "Resent-Sender", HADR | HBAD, 0,
377     "Resent-Date", HBAD, 0,
378     "Resent-Subject", HSUB, 0,
379     "Resent-To", HADR | HTRY, MVIS,
380     "Resent-cc", HADR | HTRY, MVIS,
381     "Resent-Bcc", HADR | HTRY | HBCC, MINV,
382     "Resent-Message-ID", HBAD, 0,
383     "Resent-Fcc", HFCC, 0,
384     "Reply-To", HADR, MRPY,
385     "From", HADR | HNGR, MFRM,
386 #ifdef  MMDFI
387     "Sender", HADR | HMNG | HNGR, 0,
388 #else   /* not MMFDI */
389     "Sender", HADR | HNGR, 0,
390 #endif  /* not MMDFI */
391     "Date", HNOP, MDAT,
392     "To", HADR | HNIL, 0,
393     "cc", HADR | HNIL, 0,
394     "Bcc", HADR | HTRY | HBCC | HNIL, 0,
395     "Fcc", HIGN, 0,
396
397     NULL
398 };
399
400 /* \f */
401
402
403 static short    fccind = 0;     /* index into fccfold[] */
404 static short    outputlinelen = OUTPUTLINELEN;
405
406 static int  pfd = NOTOK;        /* fd to write annotation list to */
407 static int  myuid= -1;          /* my user id */
408 static int  mygid= -1;          /* my group id */
409 static int  recipients = 0;     /* how many people will get a copy */
410 static int  unkadr = 0;         /* how many of those were unknown */
411 static int  badadr = 0;         /* number of bad addrs */
412 static int  badmsg = 0;         /* message has bad semantics */
413 static int  verbose = 0;        /* spell it out */
414 static int  format = 1;         /* format addresses */
415 static int  mime = 0;           /* use MIME-style encapsulations */
416 static int  msgid = 0;          /* add msgid */
417 static int  debug = 0;          /* debugging post */
418 static int  watch = 0;          /* watch the delivery process */
419 static int  whomsw = 0;         /* we are whom not post */
420 static int  checksw = 0;        /* whom -check */
421 static int  linepos=0;          /* putadr()'s position on the line */
422 static int  nameoutput=0;       /* putadr() has output header name */
423
424 static unsigned msgflags = 0;   /* what we've seen */
425
426 #define NORMAL 0
427 #define RESENT 1
428 static int msgstate = NORMAL;
429
430 static long tclock = 0L;                /* the time we started (more or less) */
431
432 static TYPESIG  (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();
433
434 static char tmpfil[BUFSIZ];
435 static char bccfil[BUFSIZ];
436
437 static char from[BUFSIZ];       /* my network address */
438 static char signature[BUFSIZ];  /* my signature */
439 static char *filter = NULL;     /* the filter for BCC'ing */
440 static char *msgfrom = NULL;    /* the From: field for Bcc'ing */
441 static char *subject = NULL;    /* the subject field for BCC'ing */
442 static char *fccfold[FCCS];     /* foldernames for FCC'ing */
443
444 static struct headers  *hdrtab; /* table for the message we're doing */
445
446 static struct mailname localaddrs={NULL};       /* local addrs */
447 static struct mailname netaddrs={NULL};         /* network addrs */
448 static struct mailname uuaddrs={NULL};          /* uucp addrs */
449 static struct mailname tmpaddrs={NULL};         /* temporary queue */
450
451 /* \f */
452
453 #ifdef  MMDFMTS
454 static char *submitmode = "m";  /* deliver to mailbox only */
455 static char submitopts[6] = "vl";/* initial options for submit */
456 #endif  /* MMDFMTS */
457
458 #ifdef  MHMTS
459 static char *deliver = NULL;
460
461 extern char **environ;
462
463 TYPESIG sigser ();
464 #endif  /* MHMTS */
465
466 #ifdef  SENDMTS
467 static int smtpmode = S_MAIL;
468 static int snoop = 0;
469 static char *clientsw = NULL;
470 static char *serversw = NULL;
471
472 extern struct smtp  sm_reply;
473 #endif  /* SENDMTS */
474
475 #ifdef  TMA
476 #define post(a,b,c) \
477     if (encryptsw) postcipher ((a), (b), (c)); else postplain ((a), (b), (c))
478
479 #ifndef SENDMTS
480 #define tmasnoop        0
481 #else   /* SENDMTS */
482 #define tmasnoop        snoop
483 #endif  /* SENDMTS */
484 #endif  /* TMA */
485
486 static int  encryptsw = 0;      /* encrypt it */
487
488
489 #ifdef  BERK
490 #undef  WP
491 #endif
492
493 #ifdef MIME
494 static char     prefix[] = "----- =_aaaaaaaaaa";
495 static int      find_prefix();
496 #endif /* MIME */
497
498 static int      fill_up = 0;
499 static char    *fill_in = NULLCP;
500 static char    *partno = NULLCP;
501
502 static  int     queued = 0;
503
504 static  char   *record = NULLCP;
505
506 off_t   lseek ();
507 long    time ();
508
509 static  putfmt(), start_headers(), finish_headers(), putgrp(), pl();
510 static  anno(), make_bcc_file(), verify_all_addresses();
511 static  chkadr(), do_addresses(), do_text(), do_an_address(), sigon();
512 static  sigoff(), p_refile(), fcc(), die(), insert_fcc(), p_record ();
513 static int      get_header(), putadr(), insert(), annoaux();
514 #ifdef TMA
515 static  postplain();
516 #else
517 static  post();
518 #endif  /* !TMA */
519 /* \f   MAIN */
520
521 /* ARGSUSED */
522
523 main (argc, argv)
524 int     argc;
525 char   *argv[];
526 {
527     int     state,
528             compnum;
529     char   *cp,
530            *msg = NULL,
531           **argp = argv + 1,
532             buf[BUFSIZ],
533             name[NAMESZ];
534     FILE   *in,
535            *out;
536
537 #ifdef LOCALE
538         setlocale(LC_ALL, "");
539 #endif
540     invo_name = r1bindex (argv[0], '/');
541     m_foil (NULLCP);
542     mts_init (invo_name);
543 #ifdef  MMDFMTS
544 #ifdef  MMDFII
545     mmdf_init (invo_name);
546 #endif  /* MMDFII */
547 #endif  /* MMDFMTS */
548
549 /* \f */
550
551     while (cp = *argp++) {
552         if (*cp == '-')
553             switch (smatch (++cp, switches)) {
554                 case AMBIGSW: 
555                     ambigsw (cp, switches);
556                     done (1);
557                 case UNKWNSW: 
558                     adios (NULLCP, "-%s unknown", cp);
559                 case HELPSW: 
560                     (void) sprintf (buf, "%s [switches] file", invo_name);
561                     help (buf, switches);
562                     done (1);
563
564                 case LIBSW:
565                     if (!(cp = *argp++) || *cp == '-')
566                         adios (NULLCP, "missing argument to %s", argp[-2]);
567                     m_foil (cp);
568                     continue;
569
570                 case ALIASW: 
571                     if (!(cp = *argp++) || *cp == '-')
572                         adios (NULLCP, "missing argument to %s", argp[-2]);
573 #ifdef  MHMTS
574                     if (access (libpath (cp), 04) == NOTOK)
575                         adios (cp, "unable to read");
576 #endif  /* MHMTS */
577                     if ((state = alias (cp)) != AK_OK)
578                         adios (NULLCP, "aliasing error in %s - %s",
579                                 cp, akerror (state));
580                     continue;
581
582                 case CHKSW: 
583                     checksw++;
584                     continue;
585                 case NCHKSW: 
586                     checksw = 0;
587                     continue;
588
589                 case DEBUGSW: 
590                     debug++;
591                     continue;
592
593                 case DISTSW:
594                     msgstate = RESENT;
595                     continue;
596
597                 case FILTSW:
598                     if (!(filter = *argp++) || *filter == '-')
599                         adios (NULLCP, "missing argument to %s", argp[-2]);
600                     mime = 0;
601                     continue;
602                 case NFILTSW:
603                     filter = NULL;
604                     continue;
605                 
606                 case FRMTSW: 
607                     format++;
608                     continue;
609                 case NFRMTSW: 
610                     format = 0;
611                     continue;
612
613                 case MIMESW:
614 #ifdef  MIME
615                     mime++;
616                     filter = 0;
617 #endif
618                     continue;
619                 case NMIMESW: 
620                     mime = 0;
621                     continue;
622
623                 case MSGDSW: 
624                     msgid++;
625                     continue;
626                 case NMSGDSW: 
627                     msgid = 0;
628                     continue;
629
630                 case VERBSW: 
631                     verbose++;
632                     continue;
633                 case NVERBSW: 
634                     verbose = 0;
635                     continue;
636
637                 case WATCSW: 
638                     watch++;
639                     continue;
640                 case NWATCSW: 
641                     watch = 0;
642                     continue;
643
644                 case WHOMSW: 
645                     whomsw++;
646                     continue;
647
648                 case WIDTHSW: 
649                     if (!(cp = *argp++) || *cp == '-')
650                         adios (NULLCP, "missing argument to %s", argp[-2]);
651                     if ((outputlinelen = atoi (cp)) < 10)
652                         adios (NULLCP, "impossible width %d", outputlinelen);
653                     continue;
654
655                 case ENCRSW:
656                     encryptsw++;
657                     continue;
658                 case NENCRSW:
659                     encryptsw = 0;
660                     continue;
661
662                 case ANNOSW: 
663                     if (!(cp = *argp++) || *cp == '-')
664                         adios (NULLCP, "missing argument to %s", argp[-2]);
665                     if ((pfd = atoi (cp)) <= 2)
666                         adios (NULLCP, "bad argument %s %s", argp[-2], cp);
667                     continue;
668
669 #ifdef  MMDFMTS
670                 case MAILSW:
671                     submitmode = "m";
672                     continue;
673                 case SOMLSW:    /* for right now, sigh... */
674                 case SAMLSW:
675                     submitmode = "b";
676                     continue;
677                 case SENDSW:
678                     submitmode = "y";
679                     continue;
680 #endif  /* MMDFMTS */
681
682 #ifndef MHMTS
683                 case DLVRSW:
684                     if (!(cp = *argp++) || *cp == '-')
685                         adios (NULLCP, "missing argument to %s", argp[-2]);
686                     continue;
687 #else   /* MHMTS */
688                 case MAILSW:
689                 case SAMLSW:
690                 case SOMLSW:
691                 case SENDSW:
692                     continue;
693                 case DLVRSW: 
694                     if (!(deliver = *argp++) || *deliver == '-')
695                         adios (NULLCP, "missing argument to %s", argp[-2]);
696                     continue;
697 #endif  /* MHMTS */
698
699 #ifndef SENDMTS
700                 case CLIESW:
701                 case SERVSW:
702                     if (!(cp = *argp++) || *cp == '-')
703                         adios (NULLCP, "missing argument to %s", argp[-2]);
704                     continue;
705
706                 case SNOOPSW:
707                     continue;
708 #else   /* SENDMTS */
709                 case MAILSW:
710                     smtpmode = S_MAIL;
711                     continue;
712                 case SAMLSW:
713                     smtpmode = S_SAML;
714                     continue;
715                 case SOMLSW:
716                     smtpmode = S_SOML;
717                     continue;
718                 case SENDSW:
719                     smtpmode = S_SEND;
720                     continue;
721                 case CLIESW:
722                     if (!(clientsw = *argp++) || *clientsw == '-')
723                         adios (NULLCP, "missing argument to %s", argp[-2]);
724                     continue;
725                 case SERVSW:
726                     if (!(serversw = *argp++) || *serversw == '-')
727                         adios (NULLCP, "missing argument to %s", argp[-2]);
728                     continue;
729                 case SNOOPSW:
730                     snoop++;
731                     continue;
732 #endif  /* SENDMTS */
733
734                 case FILLSW:
735                     if (!(fill_in = *argp++) || *fill_in == '-')
736                         adios (NULLCP, "missing argument to %s", argp[-2]);
737                     continue;
738                 case FILLUSW:
739                     fill_up++;
740                     continue;
741                 case PARTSW:
742                     if (!(partno = *argp++) || *partno == '-')
743                         adios (NULLCP, "missing argument to %s", argp[-2]);
744                     continue;
745
746                 case QUEUESW:
747                     queued++;
748                     continue;
749
750                 case RECORSW:
751                     if (!(record = *argp++) || *record == '-')
752                         adios (NULLCP, "missing argument to %s", argp[-2]);
753                     continue;
754                 case NRECOSW:
755                     record = NULLCP;
756                     continue;
757             }
758         if (msg)
759             adios (NULLCP, "only one message at a time!");
760         else
761             msg = cp;
762     }
763
764     (void) alias (AliasFile);
765
766 /* \f */
767
768     if (!msg)
769         adios (NULLCP, "usage: %s [switches] file", invo_name);
770
771     if (outputlinelen < 10)
772         adios (NULLCP, "impossible width %d", outputlinelen);
773
774 #ifdef  MHMTS
775     if (access (msg, 04) == NOTOK)
776         adios (msg, "unable to read");
777 #endif  /* MHMTS */
778     if ((in = fopen (msg, "r")) == NULL)
779         adios (msg, "unable to open");
780
781     start_headers ();
782     if (debug) {
783         verbose++;
784         discard (out = stdout); /* XXX: reference discard() to help loader */
785 #ifdef  MHMTS
786         if (deliver) {
787             (void) strcpy (tmpfil, msg);
788             putfmt ("To", deliver, out);
789             goto daemon;
790         }
791 #endif  /* MHMTS */
792     }
793     else
794 #ifdef  MHMTS
795     if (deliver) {
796         if ((out = fopen ("/dev/null", "r")) == NULL)
797             adios ("/dev/null", "unable to write");
798         (void) strcpy (tmpfil, msg);
799         putfmt ("To", deliver, out);
800         goto daemon;
801     }
802     else
803 #endif  /* MHMTS */
804         if (whomsw) {
805             if ((out = fopen (fill_in ? fill_in : "/dev/null", "w")) == NULL)
806                 adios ("/dev/null", "unable to open");
807         }
808         else {
809             (void) strcpy (tmpfil, m_scratch ("", m_maildir (invo_name)));
810             if ((out = fopen (tmpfil, "w")) == NULL) {
811                 (void) strcpy (tmpfil, m_tmpfil (invo_name));
812                 if ((out = fopen (tmpfil, "w")) == NULL)
813                     adios (tmpfil, "unable to create");
814             }
815 #ifdef  MHMTS
816             (void) chown (tmpfil, myuid, mygid);
817 #endif  /* MHMTS */
818             (void) chmod (tmpfil, 0600);
819         }
820
821 /* \f */
822
823     hdrtab = msgstate == NORMAL ? NHeaders : RHeaders;
824
825     for (compnum = 1, state = FLD;;) {
826         switch (state = m_getfld (state, name, buf, sizeof buf, in)) {
827             case FLD: 
828             case FLDEOF: 
829             case FLDPLUS: 
830                 compnum++;
831                 cp = add (buf, NULLCP);
832                 while (state == FLDPLUS) {
833                     state = m_getfld (state, name, buf, sizeof buf, in);
834                     cp = add (buf, cp);
835                 }
836                 putfmt (name, cp, out);
837                 free (cp);
838                 if (state != FLDEOF)
839                     continue;
840                 finish_headers (out);
841                 break;
842
843             case BODY: 
844             case BODYEOF: 
845                 finish_headers (out);
846                 if (whomsw && !fill_in)
847                     break;
848                 fprintf (out, "\n%s", buf);
849                 while (state == BODY) {
850                     state = m_getfld (state, name, buf, sizeof buf, in);
851                     fputs (buf, out);
852                 }
853                 break;
854
855             case FILEEOF: 
856                 finish_headers (out);
857                 break;
858
859             case LENERR: 
860             case FMTERR: 
861                 adios (NULLCP, "message format error in component #%d",
862                         compnum);
863
864             default: 
865                 adios (NULLCP, "getfld() returned %d", state);
866         }
867         break;
868     }
869
870 /* \f */
871
872 #ifdef  MHMTS
873 daemon: ;
874 #endif  /* MHMTS */
875     if (pfd != NOTOK)
876         anno ();
877     (void) fclose (in);
878     if (debug) {
879         pl ();
880         done (0);
881     }
882     else
883         (void) fclose (out);
884
885 #ifdef  TMA
886     if (encryptsw)
887         tmastart (tmasnoop);
888 #endif  /* TMA */
889     if (whomsw) {
890         if (!fill_up)
891             verify_all_addresses (1);
892         done (0);
893     }
894
895 #ifdef  MMDFMTS
896     (void) strcat (submitopts, submitmode);
897     if (watch)
898         (void) strcat (submitopts, "nw");
899 #endif  /* MMDFMTS */
900 #ifdef  MHMTS
901     verify_all_addresses (0);
902 #endif  /* MHMTS */
903     if (encryptsw)
904         verify_all_addresses (verbose);
905     if (msgflags & MINV) {
906         make_bcc_file ();
907         if (msgflags & MVIS) {
908 #ifndef MHMTS
909             if (!encryptsw)
910                 verify_all_addresses (verbose);
911 #endif  /* not MHMTS */
912             post (tmpfil, 0, verbose);
913         }
914         post (bccfil, 1, verbose);
915         (void) unlink (bccfil);
916     }
917     else
918         post (tmpfil, 0, isatty (1));
919 #ifdef  TMA
920     if (encryptsw)
921         tmastop ();
922 #endif  /* TMA */
923
924     p_refile (tmpfil);
925
926     p_record ();
927
928 #ifdef  MHMTS
929     if (!deliver)
930 #endif  /* MHMTS */
931         (void) unlink (tmpfil);
932
933     if (verbose)
934         printf (partno ? "Partial Message #%s Processed\n" : "Message Processed\n",
935                 partno);
936
937     done (0);
938 }
939
940 /* \f   DRAFT GENERATION */
941
942 static putfmt (name, str, out)
943 register char   *name,
944                 *str;
945 register FILE *out;
946 {
947     int     count,
948             grp,
949             i,
950             keep;
951     register char  *cp,
952                    *pp,
953                    *qp;
954     char    namep[BUFSIZ];
955     register struct mailname   *mp,
956                                *np;
957     register struct headers *hdr;
958
959     while (*str == ' ' || *str == '\t')
960         str++;
961
962     if (msgstate == NORMAL && uprf (name, "resent")) {
963         advise (NULLCP, "illegal header line -- %s:", name);
964         badmsg++;
965         return;
966     }
967
968     if ((i = get_header (name, hdrtab)) == NOTOK) {
969         fprintf (out, "%s: %s", name, str);
970         return;
971     }
972
973     hdr = &hdrtab[i];
974     if (hdr -> flags & HIGN) {
975         if (fill_in)
976             fprintf (out, "%s: %s", name, str);
977         return;
978     }
979     if (hdr -> flags & HBAD) {
980         if (fill_in)
981             fprintf (out, "%s: %s", name, str);
982         else {
983             advise (NULLCP, "illegal header line -- %s:", name);
984             badmsg++;
985         }
986         return;
987     }
988     msgflags |= (hdr -> set & ~(MVIS | MINV));
989
990     if (hdr -> set & MFRM)
991         msgfrom = msgfrom ? add (str, add (",", msgfrom)) : getcpy (str);
992     if (hdr -> flags & HSUB)
993         subject = subject ? add (str, add ("\t", subject)) : getcpy (str);
994     if (hdr -> flags & HFCC) {
995         if (fill_in) {
996             fprintf (out, "%s: %s", name, str);
997             return;
998         }
999
1000         if (cp = rindex (str, '\n'))
1001             *cp = 0;
1002         for (cp = pp = str; cp = index (pp, ','); pp = cp) {
1003             *cp++ = 0;
1004             insert_fcc (hdr, pp);
1005         }
1006         insert_fcc (hdr, pp);
1007         return;
1008     }
1009
1010 /* \f */
1011
1012     if (!(hdr -> flags & HADR)) {
1013         fprintf (out, "%s: %s", name, str);
1014         return;
1015     }
1016
1017     tmpaddrs.m_next = NULL;
1018     for (count = 0; cp = getname (str); count++)
1019         if (mp = getm (cp, NULLCP, 0, AD_HOST, NULLCP)) {
1020             if (tmpaddrs.m_next)
1021                 np -> m_next = mp;
1022             else
1023                 tmpaddrs.m_next = mp;
1024             np = mp;
1025         }
1026         else
1027             if (hdr -> flags & HTRY)
1028                 badadr++;
1029             else
1030                 badmsg++;
1031
1032     if (count < 1) {
1033         if (hdr -> flags & HNIL) {
1034             if (!(hdr -> flags & HBCC))
1035                 fprintf (out, "%s: %s", name, str);
1036         }
1037         else {
1038 #ifdef  notdef
1039             advise (NULLCP, "%s: field requires at least one address", name);
1040             badmsg++;
1041 #endif  /* notdef */
1042         }
1043         return;
1044     }
1045
1046 /* \f */
1047
1048     nameoutput = linepos = 0;
1049     (void) sprintf (namep, "%s%s",
1050                     !fill_in && (hdr -> flags & HMNG) ? "Original-" : "",
1051                     name);
1052
1053     for (grp = 0, mp = tmpaddrs.m_next; mp; mp = np)
1054         if (mp -> m_nohost) {   /* also used to test (hdr -> flags & HTRY) */
1055             pp = akvalue (mp -> m_mbox);
1056             qp = akvisible () ? mp -> m_mbox : "";
1057             np = mp;
1058             if (np -> m_gname)
1059                 putgrp (namep, np -> m_gname, out, hdr -> flags);
1060             while (cp = getname (pp)) {
1061                 if (!(mp = getm (cp, NULLCP, 0, AD_HOST, NULLCP))) {
1062                     badadr++;
1063                     continue;
1064                 }
1065                 if (hdr -> flags & HBCC)
1066                     mp -> m_bcc++;
1067                 if (np -> m_ingrp)
1068                     mp -> m_ingrp = np -> m_ingrp;
1069                 else
1070                     if (mp -> m_gname)
1071                         putgrp (namep, mp -> m_gname, out, hdr -> flags);
1072                 if (mp -> m_ingrp)
1073                     grp++;
1074 #ifdef  MHMTS
1075                 mp -> m_aka = getcpy (np -> m_mbox);
1076 #endif  /* MHMTS */
1077                 if (putadr (namep, qp, mp, out, hdr -> flags))
1078                     msgflags |= (hdr -> set & (MVIS | MINV));
1079                 else
1080                     mnfree (mp);
1081             }
1082             mp = np;
1083             np = np -> m_next;
1084             mnfree (mp);
1085         }
1086         else {
1087             if (hdr -> flags & HBCC)
1088                 mp -> m_bcc++;
1089             if (mp -> m_gname)
1090                 putgrp (namep, mp -> m_gname, out, hdr -> flags);
1091             if (mp -> m_ingrp)
1092                 grp++;
1093             keep = putadr (namep, "", mp, out, hdr -> flags);
1094             np = mp -> m_next;
1095             if (keep) {
1096                 mp -> m_next = NULL;
1097                 msgflags |= (hdr -> set & (MVIS | MINV));
1098             }
1099             else
1100                 mnfree (mp);
1101         }
1102
1103     if (grp > 0 && (hdr -> flags & HNGR)) {
1104         advise (NULLCP, "%s: field does not allow groups", name);
1105         badmsg++;
1106     }
1107     if (linepos) {
1108         if (fill_in && grp > 0)
1109             (void) putc (';', out);
1110         (void) putc ('\n', out);
1111     }
1112 }
1113
1114 /* \f */
1115
1116 static  start_headers () {
1117     register char  *cp;
1118     char    myhost[BUFSIZ],
1119             sigbuf[BUFSIZ];
1120     register struct mailname   *mp;
1121
1122     myuid = getuid ();
1123     mygid = getgid ();
1124     (void) time (&tclock);
1125
1126     (void) strcpy (from, adrsprintf (NULLCP, NULLCP));
1127
1128     (void) strcpy (myhost, LocalName ());
1129     for (cp = myhost; *cp; cp++)
1130         *cp = uptolow (*cp);
1131
1132 #ifdef  MHMTS
1133     if (deliver) {
1134         if (geteuid () == 0 && myuid != 0 && myuid != 1 && mygid != 1)
1135             adios (NULLCP, "-deliver unknown");
1136         (void) strcpy (signature, from);
1137     }
1138 #endif  /* MHMTS */
1139
1140     if ((cp = getfullname ()) && *cp) {
1141         (void) strcpy (sigbuf, cp);
1142         (void) sprintf (signature, "%s <%s>", sigbuf, adrsprintf (NULLCP, NULLCP));
1143         if ((cp = getname (signature)) == NULL)
1144             adios (NULLCP, "getname () failed -- you lose extraordinarily big");
1145         if ((mp = getm (cp, NULLCP, 0, AD_HOST, NULLCP)) == NULL)
1146             adios (NULLCP, "bad signature '%s'", sigbuf);
1147         mnfree (mp);
1148         while (getname (""))
1149             continue;
1150     }
1151     else
1152         (void) strcpy (signature, adrsprintf (NULLCP, NULLCP));
1153 }
1154
1155 /* \f */
1156
1157 static finish_headers (out)
1158 register FILE *out;
1159 {
1160     switch (msgstate) {
1161         case NORMAL: 
1162             if (whomsw && !fill_up)
1163                 break;
1164
1165             fprintf (out, "Date: %s\n", dtime (&tclock));
1166             if (msgid)
1167                 fprintf (out, "Message-ID: <%d.%ld@@%s>\n",
1168                         getpid (), tclock, LocalName ());
1169             if (msgflags & MFRM)
1170                 fprintf (out, "Sender: %s\n", from);
1171             else
1172                 fprintf (out, "From: %s\n", signature);
1173             if (whomsw)
1174                 break;
1175
1176             if (!(msgflags & MVIS))
1177                 fprintf (out, "Bcc: Blind Distribution List: ;\n");
1178             break;
1179
1180         case RESENT: 
1181             if (!(msgflags & MDAT)) {
1182                 advise (NULLCP, "message has no Date: header");
1183                 badmsg++;
1184             }
1185             if (!(msgflags & MFRM)) {
1186                 advise (NULLCP, "message has no From: header");
1187                 badmsg++;
1188             }
1189             if (whomsw && !fill_up)
1190                 break;
1191
1192 #ifdef  MMDFI                   /* sigh */
1193             fprintf (out, "Sender: %s\n", from);
1194 #endif  /* MMDFI */
1195
1196             fprintf (out, "Resent-Date: %s\n", dtime (&tclock));
1197             if (msgid)
1198                 fprintf (out, "Resent-Message-ID: <%d.%ld@@%s>\n",
1199                         getpid (), tclock, LocalName ());
1200             if (msgflags & MRFM)
1201                 fprintf (out, "Resent-Sender: %s\n", from);
1202             else
1203                 fprintf (out, "Resent-From: %s\n", signature);
1204             if (whomsw)
1205                 break;
1206             if (!(msgflags & MVIS))
1207                 fprintf (out, "Resent-Bcc: Blind Re-Distribution List: ;\n");
1208             break;
1209     }
1210
1211     if (badmsg)
1212         adios (NULLCP, "re-format message and try again");
1213     if (!recipients)
1214         adios (NULLCP, "no addressees");
1215 }
1216
1217 /* \f */
1218
1219 static int     get_header (header, table)
1220 register char   *header;
1221 register struct headers *table;
1222 {
1223     register struct headers *h;
1224
1225     for (h = table; h -> value; h++)
1226         if (uleq (header, h -> value))
1227             return (h - table);
1228
1229     return NOTOK;
1230 }
1231
1232 /* \f */
1233
1234 static int     putadr (name, aka, mp, out, flags)
1235 register char   *name,
1236                 *aka;
1237 register struct mailname *mp;
1238 register FILE *out;
1239 unsigned int    flags;
1240 {
1241     int     len;
1242     register char   *cp;
1243     char    buffer[BUFSIZ];
1244
1245     if (mp -> m_mbox == NULL || ((flags & HTRY) && !insert (mp)))
1246         return 0;
1247     if (!fill_in && (flags & (HBCC | HDCC)) || mp -> m_ingrp)
1248         return 1;
1249
1250     if (!nameoutput) {
1251         fprintf (out, "%s: ", name);
1252         linepos += (nameoutput = strlen (name) + 2);
1253     }
1254
1255     if (*aka && mp -> m_type != UUCPHOST && !mp -> m_pers)
1256         mp -> m_pers = getcpy (aka);
1257     if (format) {
1258         if (mp -> m_gname && !fill_in)
1259             (void) sprintf (cp = buffer, "%s;", mp -> m_gname);
1260         else
1261             cp = adrformat (mp);
1262     }
1263     else
1264         cp = mp -> m_text;
1265     len = strlen (cp);
1266
1267     if (linepos != nameoutput)
1268         if (len + linepos + 2 > outputlinelen)
1269             fprintf (out, ",\n%*s", linepos = nameoutput, "");
1270         else {
1271             fputs (", ", out);
1272             linepos += 2;
1273         }
1274
1275     fputs (cp, out);
1276     linepos += len;
1277
1278     return (flags & HTRY);
1279 }
1280
1281 /* \f */
1282
1283 static putgrp (name, group, out, flags)
1284 register char   *name,
1285                 *group;
1286 register FILE *out;
1287 unsigned int    flags;
1288 {
1289     int     len;
1290     char   *cp;
1291
1292     if (!fill_in && (flags & HBCC))
1293         return;
1294
1295     if (!nameoutput) {
1296         fprintf (out, "%s: ", name);
1297         linepos += (nameoutput = strlen (name) + 2);
1298         if (fill_in)
1299             linepos -= strlen (group);
1300     }
1301
1302     cp = fill_in ? group : concat (group, ";", NULLCP);
1303     len = strlen (cp);
1304
1305     if (linepos > nameoutput)
1306         if (len + linepos + 2 > outputlinelen) {
1307             fprintf (out, ",\n%*s", nameoutput, "");
1308             linepos = nameoutput;
1309         }
1310         else {
1311             fputs (", ", out);
1312             linepos += 2;
1313         }
1314
1315     fputs (cp, out);
1316     linepos += len;
1317 }
1318
1319 /* \f */
1320
1321 static int     insert (np)
1322 register struct mailname   *np;
1323 {
1324     register struct mailname   *mp;
1325
1326     if (np -> m_mbox == NULL)
1327         return 0;
1328
1329     for (mp = np -> m_type == LOCALHOST ? &localaddrs
1330             : np -> m_type == UUCPHOST ? &uuaddrs
1331             : &netaddrs;
1332             mp -> m_next;
1333             mp = mp -> m_next)
1334         if (uleq (np -> m_host, mp -> m_next -> m_host)
1335                 && uleq (np -> m_mbox, mp -> m_next -> m_mbox)
1336                 && np -> m_bcc == mp -> m_next -> m_bcc)
1337             return 0;
1338
1339     mp -> m_next = np;
1340     recipients++;
1341     return 1;
1342 }
1343
1344
1345 static  pl () {
1346     register int     i;
1347     register struct mailname *mp;
1348
1349     printf ("-------\n\t-- Addresses --\nlocal:\t");
1350     for (mp = localaddrs.m_next; mp; mp = mp -> m_next)
1351         printf ("%s%s%s", mp -> m_mbox,
1352                 mp -> m_bcc ? "[BCC]" : "",
1353                 mp -> m_next ? ",\n\t" : "");
1354
1355     printf ("\nnet:\t");
1356     for (mp = netaddrs.m_next; mp; mp = mp -> m_next)
1357         printf ("%s%s@@%s%s%s", mp -> m_path ? mp -> m_path : "",
1358                 mp -> m_mbox, mp -> m_host,
1359                 mp -> m_bcc ? "[BCC]" : "",
1360                 mp -> m_next ? ",\n\t" : "");
1361
1362     printf ("\nuucp:\t");
1363     for (mp = uuaddrs.m_next; mp; mp = mp -> m_next)
1364         printf ("%s!%s%s", mp -> m_host, mp -> m_mbox,
1365                 mp -> m_bcc ? "[BCC]" : "",
1366                 mp -> m_next ? ",\n\t" : "");
1367
1368     printf ("\n\t-- Folder Copies --\nfcc:\t");
1369     for (i = 0; i < fccind; i++)
1370         printf ("%s%s", fccfold[i], i + 1 < fccind ? ",\n\t" : "");
1371     printf ("\n");
1372 }
1373
1374 /* \f */
1375
1376 static  anno () {
1377     register struct mailname *mp;
1378
1379     for (mp = localaddrs.m_next; mp; mp = mp -> m_next)
1380         if (annoaux (mp) == NOTOK)
1381             goto oops;
1382
1383     for (mp = netaddrs.m_next; mp; mp = mp -> m_next)
1384         if (annoaux (mp) == NOTOK)
1385             goto oops;
1386
1387     for (mp = uuaddrs.m_next; mp; mp = mp -> m_next)
1388         if (annoaux (mp) == NOTOK)
1389             break;
1390
1391 oops: ;
1392     (void) close (pfd);
1393     pfd = NOTOK;
1394 }
1395
1396
1397 static int  annoaux (mp)
1398 register struct mailname *mp;
1399 {
1400     int     i;
1401     char    buffer[BUFSIZ];
1402
1403     (void) sprintf (buffer, "%s\n", adrformat (mp));
1404     i = strlen (buffer);
1405
1406     return (write (pfd, buffer, i) == i ? OK : NOTOK);
1407 }
1408
1409 /* \f */
1410
1411 static  insert_fcc (hdr, pp)
1412 register struct headers *hdr;
1413 register char   *pp;
1414 {
1415     register char   *cp;
1416
1417     for (cp = pp; isspace (*cp); cp++)
1418         continue;
1419     for (pp += strlen (pp) - 1; pp > cp && isspace (*pp); pp--)
1420         continue;
1421     if (pp >= cp)
1422         *++pp = 0;
1423     if (*cp == 0)
1424         return;
1425
1426     if (fccind >= FCCS)
1427         adios (NULLCP, "too many %ss", hdr -> value);
1428     fccfold[fccind++] = getcpy (cp);
1429 }
1430
1431 /* \f   BCC GENERATION */
1432
1433 static  make_bcc_file () {
1434     int     fd,
1435             i,
1436             child_id;
1437     char   *vec[6];
1438     register FILE   *out;
1439
1440     (void) strcpy (bccfil, m_tmpfil ("bccs"));
1441     if ((out = fopen (bccfil, "w")) == NULL)
1442         adios (bccfil, "unable to create");
1443     (void) chmod (bccfil, 0600);
1444
1445     fprintf (out, "Date: %s\n", dtime (&tclock));
1446     if (msgid)
1447         fprintf (out, "Message-ID: <%d.%ld.1@@%s>\n",
1448                 getpid (), tclock, LocalName ());
1449     if (msgflags & MFRM) {
1450         fprintf (out, "From: %s", msgfrom);
1451         fprintf (out, "Sender: %s\n", from);
1452     }
1453     else
1454         fprintf (out, "From: %s\n", signature);
1455     if (subject)
1456         fprintf (out, "Subject: %s", subject);
1457     fprintf (out, "BCC:\n");
1458 #ifdef MIME
1459     if (mime) {
1460         char   *cp;
1461
1462         if ((cp = index (prefix, 'a')) == NULL)
1463             adios (NULLCP, "lost prefix start");
1464         while (find_prefix () == NOTOK)
1465             if (*cp < 'z')
1466                 (*cp)++;
1467             else
1468                 if (*++cp == 0)
1469                     adios (NULLCP,
1470                            "giving up trying to find a unique delimiter string");
1471                 else
1472                     (*cp)++;
1473
1474         fprintf (out, "%s: %s\n%s: multipart/digest; boundary=\"",
1475                  VRSN_FIELD, VRSN_VALUE, TYPE_FIELD);
1476         fprintf (out, "%s\"\n%s: %s\n\n--%s\n%s: %s\n%s: %s\n\n", prefix,
1477                  DESCR_FIELD, "Blind Carbon Copy", prefix,
1478                  TYPE_FIELD, "message/rfc822",
1479                  DESCR_FIELD, "Original Message");
1480     }
1481     else
1482 #endif /* MIME */
1483         fprintf (out, "\n------- Blind-Carbon-Copy\n\n");
1484     (void) fflush (out);
1485
1486     if (filter == NULL) {
1487         if ((fd = open (tmpfil, 0)) == NOTOK)
1488             adios (tmpfil, "unable to re-open");
1489 #ifdef MIME
1490         if (mime)
1491             cpydata (fd, fileno (out), tmpfil, bccfil);
1492         else
1493 #endif /* MIME */
1494             cpydgst (fd, fileno (out), tmpfil, bccfil);
1495         (void) close (fd);
1496     }
1497     else {
1498         vec[0] = r1bindex (mhlproc, '/');
1499
1500         for (i = 0; (child_id = fork ()) == NOTOK && i < 5; i++)
1501             sleep (5);
1502         switch (child_id) {
1503             case NOTOK: 
1504                 adios ("fork", "unable to");
1505
1506             case OK: 
1507                 (void) dup2 (fileno (out), 1);
1508
1509                 i = 1;
1510                 vec[i++] = "-forward";
1511                 vec[i++] = "-form";
1512                 vec[i++] = filter;
1513                 vec[i++] = tmpfil;
1514                 vec[i] = NULL;
1515
1516                 execvp (mhlproc, vec);
1517                 fprintf (stderr, "unable to exec ");
1518                 perror (mhlproc);
1519                 _exit (-1);
1520
1521             default: 
1522                 (void) pidXwait (child_id, mhlproc);
1523                 break;
1524         }
1525     }
1526
1527     (void) fseek (out, 0L, 2);
1528 #ifdef  MIME
1529     if (mime)
1530         fprintf (out, "\n--%s--\n", prefix);
1531     else
1532 #endif /* MIME */
1533         fprintf (out, "\n------- End of Blind-Carbon-Copy\n");
1534     (void) fclose (out);
1535 }
1536
1537 /* \f */
1538
1539 #ifdef MIME
1540 static int  find_prefix ()
1541 {
1542     int     len,
1543             result;
1544     char    buffer[BUFSIZ];
1545     FILE   *in;
1546
1547     if ((in = fopen (tmpfil, "r")) == NULL)
1548         adios (tmpfil, "unable to re-open");
1549
1550     len = strlen (prefix);
1551
1552     result = OK;
1553     while (fgets (buffer, sizeof buffer - 1, in))
1554         if (buffer[0] == '-' && buffer[1] == '-') {
1555             register char *cp;
1556
1557             for (cp = buffer + strlen (buffer) - 1; cp >= buffer; cp--)
1558                 if (!isspace (*cp))
1559                     break;
1560             *++cp = NULL;
1561             if (strcmp (buffer + 2, prefix) == 0) {
1562                 result = NOTOK;
1563                 break;
1564             }
1565         }
1566
1567     (void) fclose (in);
1568         
1569     return result;
1570 }
1571 #endif /* MIME */
1572
1573 /* \f   ADDRESS VERIFICATION */
1574
1575 static  verify_all_addresses (talk)
1576 int     talk;
1577 {
1578 #ifndef MHMTS
1579     int     retval;
1580 #endif  /* not MHMTS */
1581 #ifdef  MMDFMTS
1582 #ifdef  RP_NS
1583     int     len;
1584     struct rp_bufstruct reply;
1585 #endif  /* RP_NS */
1586 #endif  /* MMDFMTS */
1587     register struct mailname *lp;
1588
1589 #ifndef MHMTS
1590     sigon ();
1591 #endif  /* not MHMTS */
1592
1593 #ifdef  MMDFMTS
1594     if (!whomsw || checksw) {
1595         if (rp_isbad (retval = mm_init ())
1596                 || rp_isbad (retval = mm_sbinit ())
1597                 || rp_isbad (retval = mm_winit (NULLCP, submitopts, from)))
1598             die (NULLCP, "problem initializing MMDF system [%s]",
1599                     rp_valstr (retval));
1600 #ifdef  RP_NS
1601         if (rp_isbad (retval = mm_rrply (&reply, &len)))
1602             die (NULLCP, "problem with sender address [%s]",
1603                     rp_valstr (retval));
1604 #endif  /* RP_NS */
1605     }
1606 #endif  /* MMDFMTS */
1607 #ifdef  SENDMTS
1608     if (!whomsw || checksw)
1609         if (rp_isbad (retval = sm_init (clientsw, serversw, 0, 0, snoop, 0, 0))
1610                 || rp_isbad (retval = sm_winit (smtpmode, from)))
1611             die (NULLCP, "problem initializing server; %s",
1612                     rp_string (retval));
1613 #endif  /* SENDMTS */
1614
1615     if (talk && !whomsw)
1616         printf (" -- Address Verification --\n");
1617 #ifndef BERK
1618     if (talk && localaddrs.m_next)
1619         printf ("  -- Local Recipients --\n");
1620 #endif  /* BERK */
1621     for (lp = localaddrs.m_next; lp; lp = lp -> m_next)
1622         do_an_address (lp, talk, encryptsw);
1623
1624 #ifndef BERK
1625     if (talk && uuaddrs.m_next)
1626         printf ("  -- UUCP Recipients --\n");
1627 #endif  /* BERK */
1628     for (lp = uuaddrs.m_next; lp; lp = lp -> m_next)
1629         do_an_address (lp, talk, encryptsw);
1630
1631 #ifndef BERK
1632     if (talk && netaddrs.m_next)
1633         printf ("  -- Network Recipients --\n");
1634 #endif  /* BERK */
1635     for (lp = netaddrs.m_next; lp; lp = lp -> m_next)
1636         do_an_address (lp, talk, encryptsw);
1637
1638     chkadr ();
1639     if (talk && !whomsw)
1640         printf (" -- Address Verification Successful --\n");
1641
1642 #ifdef  MMDFMTS
1643     if (!whomsw || checksw)
1644         (void) mm_end (NOTOK);
1645 #endif  /* MMDFMTS */
1646 #ifdef  SENDMTS
1647     if (!whomsw || checksw)
1648         (void) sm_end (DONE);
1649 #endif  /* SENDMTS */
1650     (void) fflush (stdout);
1651
1652 #ifndef MHMTS
1653     sigoff ();
1654 #endif  /* not MHMTS */
1655 }
1656
1657 /* \f */
1658
1659 static  chkadr () {
1660 #define plural(x) (x == 1 ? "" : "s")
1661
1662     if (badadr && unkadr)
1663         die (NULLCP, "%d address%s unparsable, %d addressee%s undeliverable",
1664                 badadr, plural (badadr), unkadr, plural (badadr));
1665     if (badadr)
1666         die (NULLCP, "%d address%s unparsable", badadr, plural (badadr));
1667     if (unkadr)
1668         die (NULLCP, "%d addressee%s undeliverable", unkadr, plural (unkadr));
1669 }
1670
1671 /* \f   MTS INTERACTION */
1672
1673 #ifdef  TMA
1674 static postplain (file, bccque, talk)
1675 #else   /* TMA */
1676 static post (file, bccque, talk)
1677 #endif  /* TMA */
1678 register char   *file;
1679 int     bccque,
1680         talk;
1681 {
1682     int     fd,
1683             onex = !(msgflags & MINV) || bccque;
1684 #ifndef MHMTS
1685     int     retval;
1686 #ifdef  MMDFMTS
1687 #ifdef  RP_NS
1688     int     len;
1689     struct rp_bufstruct reply;
1690 #endif  /* RP_NS */
1691 #endif  /* MMDFMTS */
1692 #else   /* MHMTS */
1693     int     ud;
1694 #endif  /* MHMTS */
1695
1696     if (verbose)
1697         if (msgflags & MINV)
1698             printf (" -- Posting for %s Recipients --\n",
1699                     bccque ? "Blind" : "Sighted");
1700         else
1701             printf (" -- Posting for All Recipients --\n");
1702
1703     sigon ();
1704
1705 #ifdef  MMDFMTS
1706     if (rp_isbad (retval = mm_init ())
1707             || rp_isbad (retval = mm_sbinit ())
1708             || rp_isbad (retval = mm_winit (NULLCP, submitopts, from)))
1709         die (NULLCP, "problem initializing MMDF system [%s]",
1710                 rp_valstr (retval));
1711 #ifdef  RP_NS
1712         if (rp_isbad (retval = mm_rrply (&reply, &len)))
1713             die (NULLCP, "problem with sender address [%s]",
1714                     rp_valstr (retval));
1715 #endif  /* RP_NS */
1716 #endif  /* MMDFMTS */
1717 #ifdef  SENDMTS
1718     if (rp_isbad (retval = sm_init (clientsw, serversw, watch, verbose, snoop,
1719                                     onex, queued))
1720             || rp_isbad (retval = sm_winit (smtpmode, from)))
1721         die (NULLCP, "problem initializing server; %s", rp_string (retval));
1722 #endif  /* SENDMTS */
1723
1724 #ifndef MHMTS
1725     do_addresses (bccque, talk && verbose);
1726     if ((fd = open (file, 0)) == NOTOK)
1727         die (file, "unable to re-open");
1728     do_text (file, fd);
1729 #else   /* MHMTS */
1730     if ((fd = open (file, 0)) == NULL)
1731         adios (file, "unable to re-open");
1732 #ifdef  MF
1733     ud = UucpChan () && uuaddrs.m_next ? make_uucp_file (fd) : NOTOK;
1734 #else   /* not MF */
1735     ud = NOTOK;
1736 #endif  /* not MF */
1737     do_addresses (file, fd, ud, bccque, talk && verbose);
1738     if (ud != NOTOK)
1739         (void) close (ud);
1740 #endif  /* MHMTS */
1741     (void) close (fd);
1742     (void) fflush (stdout);
1743
1744 #ifdef  MMDFMTS
1745     (void) mm_sbend ();
1746     (void) mm_end (OK);
1747 #endif  /* MMDFMTS */
1748 #ifdef  SENDMTS
1749     (void) sm_end (onex ? OK : DONE);
1750 #endif  /* SENDMTS */
1751
1752     sigoff ();
1753
1754     if (verbose)
1755         if (msgflags & MINV)
1756             printf (" -- %s Recipient Copies Posted --\n",
1757                     bccque ? "Blind" : "Sighted");
1758         else
1759             printf (" -- Recipient Copies Posted --\n");
1760     (void) fflush (stdout);
1761 }
1762
1763 /* \f */
1764
1765 #ifdef  TMA
1766 static postcipher (file, bccque, talk)
1767 register char   *file;
1768 int     bccque,
1769         talk;
1770 {
1771     int     fdP,
1772             state;
1773     char    reason[BUFSIZ];
1774     struct mailname *lp;
1775
1776     if (verbose)
1777         if (msgflags & MINV)
1778             printf (" -- Posting for %s Recipients --\n",
1779                     bccque ? "Blind" : "Sighted");
1780         else
1781             printf (" -- Posting for All Recipients --\n");
1782
1783     if ((fdP = open (file, 0)) == NOTOK)
1784         adios (file, "unable to re-open");
1785     if (ciphinit (fdP, reason) == NOTOK)
1786         adios (NULLCP, "%s", reason);
1787     (void) close (fdP);
1788
1789     for (state = 0, lp = localaddrs.m_next; lp; lp = lp -> m_next)
1790         if (lp -> m_bcc ? bccque : !bccque) {
1791 #ifndef BERK
1792             if (talk && !state)
1793                 printf ("  -- Local Recipients --\n");
1794 #endif  /* BERK */
1795             do_a_cipher (lp, talk);
1796 #ifndef BERK
1797             state++;
1798 #endif  /* BERK */
1799         }
1800
1801     for (state = 0, lp = uuaddrs.m_next; lp; lp = lp -> m_next)
1802         if (lp -> m_bcc ? bccque : !bccque) {
1803 #ifndef BERK
1804             if (talk && !state)
1805                 printf ("  -- UUCP Recipients --\n");
1806 #endif  /* BERK */
1807             do_a_cipher (lp, talk);
1808 #ifndef BERK
1809             state++;
1810 #endif  /* BERK */
1811         }
1812
1813     for (state = 0, lp = netaddrs.m_next; lp; lp = lp -> m_next)
1814         if (lp -> m_bcc ? bccque : !bccque) {
1815 #ifndef BERK
1816             if (talk && !state)
1817                 printf ("  -- Network Recipients --\n");
1818 #endif  /* BERK */
1819             do_a_cipher (lp, talk);
1820 #ifndef BERK
1821             state++;
1822 #endif  /* BERK */
1823         }
1824
1825     if (ciphdone (reason) == NOTOK)
1826         admonish (NULLCP, "%s", reason);
1827 #ifdef  SENDMTS
1828     if (!(msgflags & MINV) || bccque)
1829         (void) sm_end (OK);
1830 #endif  /* SENDMTS */
1831
1832     if (verbose)
1833         if (msgflags & MINV)
1834             printf (" -- %s Recipient Copies Posted --\n",
1835                     bccque ? "Blind" : "Sighted");
1836         else
1837             printf (" -- Recipient Copies Posted --\n");
1838     (void) fflush (stdout);
1839 }
1840
1841 /* \f */
1842
1843 static do_a_cipher (lp, talk)
1844 register struct mailname *lp;
1845 int     talk;
1846 {
1847     int     fd,
1848             retval;
1849     register char  *mbox,
1850                    *host;
1851     char    addr[BUFSIZ],
1852             reason[BUFSIZ];
1853 #ifdef  MMDFMTS
1854 #ifdef  RP_NS
1855     int     len;
1856     struct rp_bufstruct reply;
1857 #endif  /* RP_NS */
1858 #endif  /* MMDFMTS */
1859
1860     sigon ();
1861
1862 #ifdef  MMDFMTS
1863     if (rp_isbad (retval = mm_init ())
1864             || rp_isbad (retval = mm_sbinit ())
1865             || rp_isbad (retval = mm_winit (NULL, submitopts, from)))
1866         die (NULLCP, "problem initializing MMDF system [%s]",
1867                 rp_valstr (retval));
1868 #ifdef  RP_NS
1869         if (rp_isbad (retval = mm_rrply (&reply, &len)))
1870             die (NULLCP, "problem with sender address [%s]",
1871                     rp_valstr (retval));
1872 #endif  /* RP_NS */
1873 #endif  /* MMDFMTS */
1874 #ifdef  SENDMTS
1875     if (rp_isbad (retval = sm_init (clientsw, serversw, watch, verbose, snoop,
1876                                     0, 0))
1877             || rp_isbad (retval = sm_winit (smtpmode, from)))
1878         die (NULLCP, "problem initializing server; %s", rp_string (retval));
1879 #endif  /* SENDMTS */
1880
1881     do_an_address (lp, talk, 0);
1882
1883     switch (lp -> m_type) {
1884         case LOCALHOST: 
1885             mbox = lp -> m_mbox;
1886             host = LocalName ();
1887             (void) strcpy (addr, mbox);
1888             break;
1889
1890         case UUCPHOST: 
1891 #ifdef  MMDFMTS
1892             mbox = concat (lp -> m_host, "!", lp -> m_mbox, NULLCP);
1893             host = UucpChan ();
1894 #endif  /* MMDFMTS */
1895 #ifdef  SENDMTS
1896             mbox = auxformat (lp, 0);
1897             host = NULL;
1898 #endif  /* SENDMTS */
1899             (void) sprintf (addr, "%s!%s", lp -> m_host, lp -> m_mbox);
1900             break;
1901
1902         default: 
1903             mbox = lp -> m_mbox;
1904             host = lp -> m_host;
1905             (void) sprintf (addr, "%s at %s", lp -> m_mbox, lp -> m_host);
1906             break;
1907     }
1908     chkadr ();                  /* XXX */
1909
1910 #ifdef  MMDFMTS
1911     if (rp_isbad (retval = mm_waend ()))
1912         die (NULLCP, "problem ending addresses [%s]\n",
1913                 rp_valstr (retval));
1914 #endif  /* MMDFMTS */
1915 #ifdef  SENDMTS
1916     if (rp_isbad (retval = sm_waend ()))
1917         die (NULLCP, "problem ending addresses; %s", rp_string (retval));
1918 #endif  /* SENDMTS */
1919
1920     if ((fd = encipher (mbox, host, reason)) == NOTOK)
1921         die (NULLCP, "%s: %s", addr, reason);
1922     do_text ("temporary file", fd);
1923     (void) close (fd);
1924     (void) fflush (stdout);
1925
1926 #ifdef  MMDFMTS
1927     (void) mm_sbend ();
1928     (void) mm_end (OK);
1929 #endif  /* MMDFMTS */
1930 #ifdef  SENDMTS
1931     (void) sm_end (DONE);
1932 #endif  /* SENDMTS */
1933
1934     sigoff ();
1935 }
1936 #endif  /* TMA */
1937
1938 /* \f */
1939
1940 #ifndef MHMTS
1941 static do_addresses (bccque, talk)
1942 #else   /* MHMTS */
1943 static do_addresses (file, fd, ud, bccque, talk)
1944 register char   *file;
1945 int     fd,
1946         ud;
1947 #endif  /* MHMTS */
1948 int     bccque,
1949         talk;
1950 {
1951     int     retval;
1952 #ifndef BERK
1953     int     state;
1954 #endif  /* not BERK */
1955     register struct mailname *lp;
1956
1957 #ifndef BERK
1958     state = 0;
1959 #endif  /* not BERK */
1960     for (lp = localaddrs.m_next; lp; lp = lp -> m_next)
1961         if (lp -> m_bcc ? bccque : !bccque) {
1962 #ifndef BERK
1963             if (talk && !state)
1964                 printf ("  -- Local Recipients --\n");
1965 #endif  /* not BERK */
1966 #ifndef MHMTS
1967             do_an_address (lp, talk, 0);
1968 #else   /* MHMTS */
1969             localmail (lp, talk, fd);
1970 #endif  /* MHMTS */
1971 #ifndef BERK
1972             state++;
1973 #endif  /* not BERK */
1974         }
1975
1976 #ifndef BERK
1977     state = 0;
1978 #endif  /* not BERK */
1979     for (lp = uuaddrs.m_next; lp; lp = lp -> m_next)
1980         if (lp -> m_bcc ? bccque : !bccque) {
1981 #ifndef BERK
1982             if (talk && !state)
1983                 printf ("  -- UUCP Recipients --\n");
1984 #endif  /* not BERK */
1985 #ifndef MHMTS
1986             do_an_address (lp, talk, 0);
1987 #else   /* MHMTS */
1988             uucpmail (lp, talk, ud != NOTOK ? ud : fd, ud == NOTOK);
1989 #endif  /* MHMTS */
1990 #ifndef BERK
1991             state++;
1992 #endif  /* not BERK */
1993         }
1994
1995 #ifndef BERK
1996     state = 0;
1997 #endif  /* not BERK */
1998     for (lp = netaddrs.m_next; lp; lp = lp -> m_next)
1999         if (lp -> m_bcc ? bccque : !bccque) {
2000 #ifndef BERK
2001             if (talk && !state)
2002                 printf ("  -- Network Recipients --\n");
2003 #endif  /* not BERK */
2004 #ifndef MHMTS
2005             do_an_address (lp, talk, 0);
2006 #else   /* MHMTS */
2007             netmail (talk, fd, bccque);
2008 #endif  /* MHMTS */
2009 #ifndef BERK
2010             state++;
2011 #endif  /* not BERK */
2012         }
2013
2014 /* \f */
2015
2016     chkadr ();
2017
2018 #ifdef  MMDFMTS
2019     if (rp_isbad (retval = mm_waend ()))
2020         die (NULLCP, "problem ending addresses [%s]\n",
2021                 rp_valstr (retval));
2022 #endif  /* MMDFMTS */
2023 #ifdef  SENDMTS
2024     if (rp_isbad (retval = sm_waend ()))
2025         die (NULLCP, "problem ending addresses; %s", rp_string (retval));
2026 #endif  /* SENDMTS */
2027 }
2028
2029 /* \f */
2030
2031 #ifndef MHMTS
2032 static  do_text (file, fd)
2033 register char   *file;
2034 int     fd;
2035 {
2036     int     retval,
2037             state;
2038     char    buf[BUFSIZ];
2039 #ifdef  MMDFMTS
2040     struct rp_bufstruct reply;
2041 #endif  /* MMDFMTS */
2042
2043     (void) lseek (fd, (off_t)0, 0);
2044     while ((state = read (fd, buf, sizeof buf)) > 0)
2045 #ifdef  MMDFMTS
2046         if (rp_isbad (mm_wtxt (buf, state)))
2047             die (NULLCP, "problem writing text [%s]\n", rp_valstr (retval));
2048 #endif  /* MMDFMTS */
2049 #ifdef  SENDMTS
2050         if (rp_isbad (retval = sm_wtxt (buf, state)))
2051             die (NULLCP, "problem writing text; %s\n", rp_string (retval));
2052 #endif  /* SENDMTS */
2053
2054     if (state == NOTOK)
2055         die (file, "problem reading from");
2056
2057 #ifdef  MMDFMTS
2058     if (rp_isbad (retval = mm_wtend ()))
2059         die (NULLCP, "problem ending text [%s]\n", rp_valstr (retval));
2060
2061     if (rp_isbad (retval = mm_rrply (&reply, &state)))
2062         die (NULLCP, "problem getting submission status [%s]\n",
2063                 rp_valstr (retval));
2064
2065     switch (rp_gval (reply.rp_val)) {
2066         case RP_OK: 
2067         case RP_MOK: 
2068             break;
2069
2070         case RP_NO: 
2071             die (NULLCP, "you lose; %s", reply.rp_line);
2072
2073         case RP_NDEL: 
2074             die (NULLCP, "no delivery occurred; %s", reply.rp_line);
2075
2076         case RP_AGN: 
2077             die (NULLCP, "try again later; %s", reply.rp_line);
2078
2079         case RP_NOOP: 
2080             die (NULLCP, "nothing done; %s", reply.rp_line);
2081
2082         default: 
2083             die (NULLCP, "unexpected response;\n\t[%s] -- %s",
2084                     rp_valstr (reply.rp_val), reply.rp_line);
2085     }
2086 #endif  /* MMDFMTS */
2087 #ifdef  SENDMTS
2088     switch (retval = sm_wtend ()) {
2089         case RP_OK: 
2090             break;
2091
2092         case RP_NO: 
2093         case RP_NDEL: 
2094             die (NULLCP, "posting failed; %s", rp_string (retval));
2095
2096         default: 
2097             die (NULLCP, "unexpected response; %s", rp_string (retval));
2098     }
2099 #endif  /* SENDMTS */
2100 }
2101 #endif  /* not MHMTS */
2102
2103 /* \f   MTS-SPECIFIC INTERACTION */
2104
2105 #ifdef  MMDFMTS
2106
2107 #ifndef TMA
2108 /* ARGSUSED */
2109 #endif  /* TMA */
2110
2111 static do_an_address (lp, talk, tma)
2112 register struct mailname *lp;
2113 int     talk,
2114         tma;
2115 {
2116     int     len,
2117             retval;
2118     register char  *mbox,
2119                    *host,
2120                    *text,
2121                    *path;
2122     char    addr[BUFSIZ];
2123 #ifdef  TMA
2124     char    reason[BUFSIZ];
2125 #endif  /* TMA */
2126     struct rp_bufstruct reply;
2127
2128     switch (lp -> m_type) {
2129         case LOCALHOST: 
2130             mbox = lp -> m_mbox;
2131             host = LocalName ();
2132             (void) strcpy (addr, mbox);
2133             break;
2134
2135         case UUCPHOST: 
2136 #ifdef  MF
2137             mbox = concat (lp -> m_host, "!", lp -> m_mbox, NULLCP);
2138             host = UucpChan ();
2139             (void) strcpy (addr, mbox);
2140             break;
2141 #else   /* MF */
2142             fprintf (talk ? stdout : stderr, "  %s!%s: %s\n",
2143                 lp -> m_host, lp -> m_mbox, "not supported; UUCP address");
2144             unkadr++;
2145             (void) fflush (stdout);
2146             return;
2147 #endif  /* MF */
2148
2149         default:                /* let MMDF decide if the host is bad */
2150             mbox = lp -> m_mbox;
2151             host = lp -> m_host;
2152             (void) sprintf (addr, "%s at %s", mbox, host);
2153             break;
2154     }
2155 #ifdef  TMA
2156     if ((!whomsw || checksw)
2157             && tma
2158             && seekaddr (mbox, host, reason) == NOTOK) {
2159         fprintf (talk ? stdout : stderr, "  %s%s: %s\n",
2160                 addr, "[TMA]", reason);
2161         unkadr++;
2162     }
2163 #endif  /* TMA */
2164
2165     if (talk)
2166         printf ("  %s%s", addr, whomsw && lp -> m_bcc ? "[BCC]" : "");
2167
2168     if (whomsw && !checksw) {
2169         (void) putchar ('\n');
2170         return;
2171     }
2172     if (talk)
2173         printf (": ");
2174     (void) fflush (stdout);
2175
2176 /* \f */
2177
2178 #ifdef  MMDFII
2179     if (lp -> m_path)
2180         path = concat (lp -> m_path, mbox, "@@", host, NULLCP);
2181     else
2182 #endif  /* MMDFII */
2183         path = NULLCP;
2184     if (rp_isbad (retval = mm_wadr (path ? NULLCP : host, path ? path : mbox))
2185             || rp_isbad (retval = mm_rrply (&reply, &len)))
2186         die (NULLCP, "problem submitting address [%s]", rp_valstr (retval));
2187
2188     switch (rp_gval (reply.rp_val)) {
2189         case RP_AOK: 
2190             if (talk)
2191                 printf ("address ok\n");
2192             (void) fflush (stdout);
2193             return;
2194
2195 #ifdef  RP_DOK
2196         case RP_DOK: 
2197             if (talk)
2198                 printf ("nameserver timeout - queued for checking\n");
2199             (void) fflush (stdout);
2200             return;
2201 #endif  /* RP_DOK */
2202
2203         case RP_NO: 
2204             text = "you lose";
2205             break;
2206
2207 #ifdef  RP_NS
2208         case RP_NS: 
2209             text = "temporary nameserver failure";
2210             break;
2211
2212 #endif  /* RP_NS */
2213
2214         case RP_USER: 
2215         case RP_NDEL: 
2216             text = "not deliverable";
2217             break;
2218
2219         case RP_AGN: 
2220             text = "try again later";
2221             break;
2222
2223         case RP_NOOP: 
2224             text = "nothing done";
2225             break;
2226
2227         default: 
2228             if (!talk)
2229                 fprintf (stderr, "  %s: ", addr);
2230             text = "unexpected response";
2231             die (NULLCP, "%s;\n    [%s] -- %s", text,
2232                     rp_valstr (reply.rp_val), reply.rp_line);
2233     }
2234
2235     if (!talk)
2236         fprintf (stderr, "  %s: ", addr);
2237     fprintf (talk ? stdout : stderr, "%s;\n    %s\n", text, reply.rp_line);
2238     unkadr++;
2239
2240     (void) fflush (stdout);
2241 }
2242 #endif  /* MMDFMTS */
2243
2244 /* \f */
2245
2246 #ifdef  MHMTS
2247 /* ARGSUSED */
2248
2249 static do_an_address (lp, talk, tma)
2250 register struct mailname *lp;
2251 int     talk,
2252         tma;
2253 {
2254     register char  *mbox;
2255     char    addr[BUFSIZ];
2256
2257     switch (lp -> m_type) {
2258         case LOCALHOST: 
2259             (void) strcpy (addr, lp -> m_mbox);
2260             break;
2261
2262         case UUCPHOST: 
2263             (void) sprintf (addr, "%s!%s", lp -> m_host, lp -> m_mbox);
2264             break;
2265
2266         default: 
2267             (void) sprintf (addr, "%s at %s", lp -> m_mbox, lp -> m_host);
2268             break;
2269     }
2270     if (talk)
2271         printf ("  %s%s", addr, whomsw && lp -> m_bcc ? "[BCC]" : "");
2272
2273     if (whomsw && !checksw) {
2274         (void) putchar ('\n');
2275         return;
2276     }
2277     if (talk)
2278         printf (": ");
2279     (void) fflush (stdout);
2280
2281 /* \f */
2282
2283     switch (lp -> m_type) {
2284         case LOCALHOST: 
2285             mbox = lp -> m_mbox;
2286             if (*mbox == '~')
2287                 mbox++;
2288             if (seek_home (mbox)) {
2289                 lp -> m_mbox = mbox;
2290                 if (talk)
2291                     printf ("address ok\n");
2292             }
2293             else {
2294                 if (!talk)
2295                     fprintf (stderr, "  %s: ", addr);
2296                 fprintf (talk ? stdout : stderr,
2297                         "not deliverable; unknown user\n");
2298                 unkadr++;
2299             }
2300             break;
2301
2302         case UUCPHOST: 
2303             if (uucpsite (lp -> m_host) == OK) {
2304                 if (talk)
2305                     printf ("address ok\n");
2306             }
2307             else {
2308                 if (!talk)
2309                     fprintf (stderr, "  %s: ", addr);
2310                 fprintf (talk ? stdout : stderr,
2311                         "not deliverable; unknown system\n");
2312                 unkadr++;
2313             }
2314             break;
2315
2316         case NETHOST: 
2317             if (talk)
2318                 printf ("address ok\n");
2319             break;
2320
2321         default: 
2322             if (!talk)
2323                 fprintf (stderr, "  %s: ", addr);
2324             fprintf (talk ? stdout : stderr,
2325                     "not deliverable; unknown host\n");
2326             unkadr++;
2327             break;
2328     }
2329
2330     (void) fflush (stdout);
2331 }
2332 #endif  /* MHMTS */
2333
2334 /* \f */
2335
2336 #ifdef  SENDMTS
2337
2338 #ifndef TMA
2339 /* ARGSUSED */
2340 #endif  /* TMA */
2341
2342 static do_an_address (lp, talk, tma)
2343 register struct mailname *lp;
2344 int     talk,
2345         tma;
2346 {
2347     int     retval;
2348     register char  *mbox,
2349                    *host;
2350     char    addr[BUFSIZ];
2351 #ifdef  TMA
2352     char    reason[BUFSIZ];
2353 #endif  /* TMA */
2354
2355     switch (lp -> m_type) {
2356         case LOCALHOST: 
2357             mbox = lp -> m_mbox;
2358             host = lp -> m_host;
2359             (void) strcpy (addr, mbox);
2360             break;
2361
2362         case UUCPHOST: 
2363             mbox = auxformat (lp, 0);
2364             host = NULL;
2365             (void) sprintf (addr, "%s!%s", lp -> m_host, lp -> m_mbox);
2366             break;
2367
2368         default:                /* let SendMail decide if the host is bad  */
2369             mbox = lp -> m_mbox;
2370             host = lp -> m_host;
2371             (void) sprintf (addr, "%s at %s", mbox, host);
2372             break;
2373     }
2374
2375 #ifdef  TMA
2376     if ((!whomsw || checksw)
2377             && tma
2378             && seekaddr (mbox, host, reason) == NOTOK) {
2379         fprintf (talk ? stdout : stderr, "  %s%s: %s\n",
2380                 addr, "[TMA]", reason);
2381         unkadr++;
2382     }
2383 #endif  /* TMA */
2384
2385     if (talk)
2386         printf ("  %s%s", addr, whomsw && lp -> m_bcc ? "[BCC]" : "");
2387
2388     if (whomsw && !checksw) {
2389         (void) putchar ('\n');
2390         return;
2391     }
2392     if (talk)
2393         printf (": ");
2394     (void) fflush (stdout);
2395
2396 /* \f */
2397
2398     switch (retval = sm_wadr (mbox, host,
2399                          lp -> m_type != UUCPHOST ? lp -> m_path : NULLCP)) {
2400         case RP_OK: 
2401             if (talk)
2402                 printf ("address ok\n");
2403             break;
2404
2405         case RP_NO: 
2406         case RP_USER: 
2407             if (!talk)
2408                 fprintf (stderr, "  %s: ", addr);
2409             fprintf (talk ? stdout : stderr, "loses; %s\n",
2410                         rp_string (retval));
2411             unkadr++;
2412             break;
2413
2414         default: 
2415             if (!talk)
2416                 fprintf (stderr, "  %s: ", addr);
2417             die (NULLCP, "unexpected response; %s", rp_string (retval));
2418     }
2419
2420     (void) fflush (stdout);
2421 }
2422 #endif  /* SENDMTS */
2423
2424 /* \f   SIGNAL HANDLING */
2425
2426 #ifndef MHMTS
2427
2428 /* ARGSUSED */
2429
2430 static  TYPESIG sigser (i)
2431 int     i;
2432 {
2433 #ifndef BSD42
2434     (void) signal (i, SIG_IGN);
2435 #endif  /* not BSD42 */
2436     (void) unlink (tmpfil);
2437     if (msgflags & MINV)
2438         (void) unlink (bccfil);
2439 #ifdef  MMDFMTS
2440     if (!whomsw || checksw)
2441         (void) mm_end (NOTOK);
2442 #endif  /* MMDFMTS */
2443 #ifdef  SENDMTS
2444     if (!whomsw || checksw)
2445         (void) sm_end (NOTOK);
2446 #endif  /* SENDMTS */
2447     done (1);
2448 }
2449 #endif  /* not MHMTS */
2450
2451
2452 static  sigon () {
2453     if (debug)
2454         return;
2455
2456 #ifndef MHMTS
2457     setsigx (hstat, SIGHUP, sigser);
2458     setsigx (istat, SIGINT, sigser);
2459     setsigx (qstat, SIGQUIT, sigser);
2460     setsigx (tstat, SIGTERM, sigser);
2461 #else   /* MHMTS */
2462     setsigx (hstat, SIGHUP, SIG_IGN);
2463     setsigx (istat, SIGINT, SIG_IGN);
2464     setsigx (qstat, SIGQUIT, SIG_IGN);
2465     setsigx (tstat, SIGTERM, SIG_IGN);
2466 #endif  /* MHMTS */
2467 }
2468
2469
2470 static sigoff () {
2471     if (debug)
2472         return;
2473
2474     (void) signal (SIGHUP, hstat);
2475     (void) signal (SIGINT, istat);
2476     (void) signal (SIGQUIT, qstat);
2477     (void) signal (SIGTERM, tstat);
2478 }
2479
2480 /* \f   FCC INTERACTION */
2481
2482 static  p_refile (file)
2483 register char   *file;
2484 {
2485     register int     i;
2486
2487     if (fccind == 0)
2488         return;
2489
2490 #ifdef  MHMTS
2491     (void) setuid (myuid);
2492 #endif  /* MHMTS */
2493     if (verbose)
2494         printf (" -- Filing Folder Copies --\n");
2495     for (i = 0; i < fccind; i++)
2496         fcc (file, fccfold[i]);
2497     if (verbose)
2498         printf (" -- Folder Copies Filed --\n");
2499 }
2500
2501
2502 static fcc (file, folder)
2503 register char   *file,
2504                 *folder;
2505 {
2506     int     i,
2507             child_id,
2508             status;
2509     char    fold[BUFSIZ];
2510
2511     if (verbose)
2512         printf ("  %sFcc %s: ", msgstate == RESENT ? "Resent-" : "", folder);
2513     (void) fflush (stdout);
2514
2515     for (i = 0; (child_id = fork ()) == NOTOK && i < 5; i++)
2516         sleep (5);
2517     switch (child_id) {
2518         case NOTOK: 
2519             if (!verbose)
2520                 fprintf (stderr, "  %sFcc %s: ",
2521                         msgstate == RESENT ? "Resent-" : "", folder);
2522             fprintf (verbose ? stdout : stderr, "no forks, so not ok\n");
2523             break;
2524
2525         case OK: 
2526             (void) sprintf (fold, "%s%s",
2527                     *folder == '+' || *folder == '@@' ? "" : "+", folder);
2528             execlp (fileproc, r1bindex (fileproc, '/'),
2529                     "-link", "-file", file, fold, NULLCP);
2530             _exit (-1);
2531
2532         default: 
2533             if (status = pidwait (child_id, OK)) {
2534                 if (!verbose)
2535                     fprintf (stderr, "  %sFcc %s: ",
2536                             msgstate == RESENT ? "Resent-" : "", folder);
2537                 (void) pidstatus (status, verbose ? stdout : stderr, NULLCP);
2538             }
2539             else
2540                 if (verbose)
2541                     printf ("folder ok\n");
2542     }
2543
2544     (void) fflush (stdout);
2545 }
2546
2547 /* \f   RECORD RECIPIENTS */
2548
2549 static  p_record ()
2550 {
2551     int     i,
2552             child_id,
2553             status;
2554     char    recfile[BUFSIZ];
2555     register struct mailname  *ap,
2556                              **app;
2557     struct mailname *addrs[3];
2558     register FILE   *out;
2559
2560     if (!record || (msgflags & (MFRM | MRFM | MRPY)))
2561         return;
2562
2563     addrs[0] = &localaddrs;
2564     addrs[1] = &netaddrs;
2565     addrs[2] = NULL;
2566     if (verbose) {
2567         printf ("recording recipients... ");
2568         fflush (stdout);
2569     }
2570
2571     (void) strcpy (recfile, m_tmpfil ("record"));
2572     if ((out = fopen (recfile, "w")) == NULL) {
2573         fprintf (verbose ? stdout : stderr, "unable to create temporary file");
2574         if (!verbose)
2575             fprintf (stderr, ", so can't record recipients");
2576         fprintf (verbose ? stdout : stderr, "\n");
2577         return;
2578     }
2579     (void) chmod (recfile, 0600);
2580
2581     for (app = addrs; ap = *app; app++) {
2582         register struct mailname *mp;
2583
2584         for (mp = ap -> m_next; mp; mp = mp -> m_next)
2585             fprintf (out, "%s\n", adrformat (mp));
2586     }
2587
2588     (void) fclose (out);
2589
2590     for (i = 0; (child_id = fork ()) == NOTOK && i < 5; i++)
2591         sleep (5);
2592     switch (child_id) {
2593         case NOTOK:
2594             fprintf (verbose ? stdout : stderr, "unable to fork");
2595             if (!verbose)
2596                 fprintf (stderr, ", so can't record recipients");
2597             fprintf (verbose ? stdout : stderr, "\n");
2598             break;
2599
2600         case OK:
2601             execlp (record, r1bindex (record, '/'), recfile, NULLCP);
2602             _exit (-1);
2603
2604         default:
2605             if (status = pidwait (child_id, OK)) {
2606                 if (!verbose)
2607                     fprintf (stderr, "problem with %s: ", recfile);
2608                 (void) pidstatus (status, verbose ? stdout : stderr, NULLCP);
2609             }
2610             else
2611                 if (verbose)
2612                     printf ("done\n");
2613     }
2614
2615     (void) unlink (recfile);
2616 }
2617
2618 /* \f   TERMINATION */
2619
2620 /* VARARGS2 */
2621
2622 static die (what, fmt, a, b, c, d)
2623 char   *what,
2624        *fmt,
2625        *a,
2626        *b,
2627        *c,
2628        *d;
2629 {
2630 #ifndef MHMTS
2631     (void) unlink (tmpfil);
2632     if (msgflags & MINV)
2633         (void) unlink (bccfil);
2634 #endif  /* MHMTS */
2635 #ifdef  MMDFMTS
2636     if (!whomsw || checksw)
2637         (void) mm_end (NOTOK);
2638 #endif  /* MMDFMTS */
2639 #ifdef  SENDMTS
2640     if (!whomsw || checksw)
2641         (void) sm_end (NOTOK);
2642 #endif  /* SENDMTS */
2643
2644     adios (what, fmt, a, b, c, d);
2645 }
2646
2647
2648 #ifdef  MMDFMTS
2649 /* 
2650  *    err_abrt() is used by the mm_ routines
2651  *               do not, under *ANY* circumstances, remove it from post,
2652  *               or you will lose *BIG*
2653  */
2654
2655 err_abrt (code, fmt, a, b, c)
2656 int     code;
2657 char   *fmt,
2658        *a,
2659        *b,
2660        *c;
2661 {
2662     char    buffer[BUFSIZ];
2663
2664     (void) sprintf (buffer, "[%s]", rp_valstr (code));
2665
2666     adios (buffer, fmt, a, b, c);
2667 }
2668 #endif  /* MMDFMTS */
2669
2670 /* \f   STAND-ALONE DELIVERY */
2671
2672 #ifdef  MHMTS
2673
2674 /* BUG: MHMTS ignores 822-style route addresses... */
2675
2676 static  localmail (lp, talk, fd)
2677 register struct mailname *lp;
2678 int     talk,
2679         fd;
2680 {
2681     int     md;
2682     char    mailbox[BUFSIZ],
2683             ddate[BUFSIZ];
2684     register struct home *hp;
2685
2686     if (talk)
2687         printf ("  %s: ", lp -> m_mbox);
2688     (void) fflush (stdout);
2689
2690     if ((hp = seek_home (lp -> m_mbox)) == NULL) {
2691         if (!talk)
2692             fprintf (stderr, "  %s: ", lp -> m_mbox);
2693         fprintf (talk ? stdout : stderr,
2694                 "not deliverable; unknown address\n");
2695         unkadr++;
2696         return;
2697     }
2698
2699     (void) sprintf (mailbox, "%s/%s",
2700             mmdfldir[0] ? mmdfldir : hp -> h_home,
2701             mmdflfil[0] ? mmdflfil : hp -> h_name);
2702
2703 /* \f */
2704
2705     switch (access (slocalproc, 01)) {
2706         default: 
2707             if (talk)
2708                 printf ("(invoking hook)\n\t");
2709             (void) fflush (stdout);
2710
2711             if (usr_hook (lp, talk, fd, hp, mailbox) != NOTOK)
2712                 return;
2713             if (talk)
2714                 printf ("  %s: ", lp -> m_mbox);
2715             (void) fflush (stdout);
2716
2717         case NOTOK: 
2718             (void) lseek (fd, (off_t)0, 0);
2719             if ((md = mbx_open (mailbox, hp -> h_uid, hp -> h_gid, m_gmprot ()))
2720                     == NOTOK) {
2721                 if (!talk)
2722                     fprintf (stderr, "  %s: ", lp -> m_mbox);
2723                 fprintf (talk ? stdout : stderr,
2724                         "error in transmission; unable to open maildrop\n");
2725                 unkadr++;
2726                 return;
2727             }
2728             (void) sprintf (ddate, "Delivery-Date: %s\n", dtimenow ());
2729             if (mbx_copy (mailbox, md, fd, 0, ddate, 0) == NOTOK) {
2730                 if (!talk)
2731                     fprintf (stderr, "  %s: ", lp -> m_mbox);
2732                 fprintf (talk ? stdout : stderr,
2733                         "error in transmission; write to maildrop failed\n");
2734                 unkadr++;
2735                 (void) close (md);
2736                 return;
2737             }
2738             mbx_close (mailbox, md);
2739
2740             if (talk)
2741                 printf ("sent\n");
2742             break;
2743     }
2744
2745     (void) fflush (stdout);
2746 }
2747
2748 /* \f */
2749
2750 static int  usr_hook (lp, talk, fd, hp, mailbox)
2751 register struct mailname *lp;
2752 int     talk,
2753         fd;
2754 register struct home *hp;
2755 register char   *mailbox;
2756 {
2757     int     i,
2758             child_id,
2759             status;
2760     char    tmpfil[BUFSIZ];
2761
2762     if ((fd = copyfile (fd, tmpfil)) == NOTOK) {
2763         if (!talk)
2764             fprintf (stderr, "  %s: ", lp -> m_mbox);
2765         fprintf (talk ? stdout : stderr,
2766                 "unable to copy message; skipping hook\n");
2767         return NOTOK;
2768     }
2769     (void) chown (tmpfil, hp -> h_uid, hp -> h_gid);
2770
2771     (void) fflush (stdout);
2772
2773     for (i = 0; (child_id = fork ()) == NOTOK && i < 5; i++)
2774         sleep (5);
2775     switch (child_id) {
2776         case NOTOK: 
2777             if (!talk)
2778                 fprintf (stderr, "  %s: ", lp -> m_mbox);
2779             fprintf (talk ? stdout : stderr,
2780                     "unable to invoke hook; fork() failed\n");
2781             return NOTOK;
2782
2783         case OK: 
2784             if (fd != 0)
2785                 (void) dup2 (fd, 0);
2786             (void) freopen ("/dev/null", "w", stdout);
2787             (void) freopen ("/dev/null", "w", stderr);
2788             if (fd != 3)        /* backwards compatible... */
2789                 (void) dup2 (fd, 3);
2790             closefds (4);
2791 #ifdef  TIOCNOTTY
2792             if ((fd = open ("/dev/tty", 2)) != NOTOK) {
2793                 (void) ioctl (fd, TIOCNOTTY, NULLCP);
2794                 (void) close (fd);
2795             }
2796 #endif  /* TIOCNOTTY */
2797 #ifdef  BSD42
2798             (void) setpgrp (0, getpid ());
2799 #endif  /* BSD42 */
2800
2801             *environ = NULL;
2802             (void) m_putenv ("USER", hp -> h_name);
2803             (void) m_putenv ("HOME", hp -> h_home);
2804             (void) m_putenv ("SHELL", hp -> h_shell);
2805             if (chdir (hp -> h_home) == NOTOK)
2806                 (void) chdir ("/");
2807             (void) umask (0077);
2808 #ifdef  BSD41A
2809             (void) inigrp (hp -> h_name, hp -> h_gid);
2810 #endif  /* BSD41A */
2811             (void) setgid (hp -> h_gid);
2812 #ifdef  BSD42
2813             (void) initgroups (hp -> h_name, hp -> h_gid);
2814 #endif  /* BSD42 */
2815             (void) setuid (hp -> h_uid);
2816
2817             execlp (slocalproc, r1bindex (slocalproc, '/'),
2818                     "-file", tmpfil, "-mailbox", mailbox,
2819                     "-home", hp -> h_home, "-addr", lp -> m_aka,
2820                     "-user", hp -> h_name, "-sender", from,
2821                     talk ? "-verbose" : NULLCP, NULLCP);
2822             _exit (-1);
2823
2824 /* \f */
2825
2826         default: 
2827             (void) close (fd);
2828
2829             status = pidwait (child_id, OK);
2830
2831             (void) unlink (tmpfil);
2832             if (status == 0) {
2833                 if (talk)
2834                     printf ("accepted\n");
2835                 return OK;
2836             }
2837             if (!talk)
2838                 fprintf (stderr, "  %s: ", lp -> m_mbox);
2839             fprintf (talk ? stdout : stderr,
2840                     "%s error on hook; status=0%o\n",
2841                     status & 0x00ff ? "system" : "user",
2842                     status & 0x00ff ? status & 0xff
2843                     : (status & 0xff00) >> 8);
2844             return NOTOK;
2845     }
2846 }
2847
2848 /* \f */
2849
2850 static int  copyfile (qd, tmpfil)
2851 int     qd;
2852 register char   *tmpfil;
2853 {
2854     int     i,
2855             fd;
2856     char    buffer[BUFSIZ];
2857
2858     (void) strcpy (tmpfil, m_tmpfil ("hook"));
2859     if ((fd = creat (tmpfil, 0600)) == NOTOK)
2860         return NOTOK;
2861     (void) close (fd);
2862     if ((fd = open (tmpfil, 2)) == NOTOK)
2863         return NOTOK;
2864
2865     (void) lseek (qd, (off_t)0, 0);
2866     while ((i = read (qd, buffer, sizeof buffer)) > 0)
2867         if (write (fd, buffer, i) != i) {
2868             (void) close (fd);
2869             return NOTOK;
2870         }
2871     if (i == NOTOK) {
2872         (void) close (fd);
2873         return NOTOK;
2874     }
2875
2876     (void) lseek (fd, (off_t)0, 0);
2877
2878     return fd;
2879 }
2880
2881 /* \f */
2882
2883 static  uucpmail (lp, talk, fd, from)
2884 register struct mailname *lp;
2885 int     talk,
2886         fd,
2887         from;
2888 {
2889     int     i;
2890     TYPESIG     (*pstat) ();
2891     char    addr[BUFSIZ],
2892             buffer[BUFSIZ];
2893     register FILE *fp;
2894
2895     (void) sprintf (addr, "%s!%s", lp -> m_host, lp -> m_mbox);
2896     if (talk)
2897         printf ("  %s: ", addr);
2898     (void) fflush (stdout);
2899
2900 #ifndef UCI
2901     (void) sprintf (buffer, "uux -r -p %s!rmail \\(%s\\)",
2902                 lp -> m_host, lp -> m_mbox);
2903 #else   /* UCI */
2904     (void) sprintf (buffer, "uux -p %s!rmail \\(%s\\)", lp -> m_host,
2905             lp -> m_mbox);
2906 #endif  /* UCI */
2907     if ((fp = popen (buffer, "w")) == NULL) {
2908         if (!talk)
2909             fprintf (stderr, "  %s: ", addr);
2910         fprintf (talk ? stdout : stderr,
2911                 "unable to start uux; popen() failed\n");
2912         unkadr++;
2913         return;
2914     }
2915
2916     pstat = signal (SIGPIPE, SIG_IGN);
2917     if (from) {                 /* no mail filtering, so... */
2918         (void) sprintf (buffer, "From %s %.24s remote from %s\n",
2919                 getusr (), ctime (&tclock), SystemName ());
2920         i = strlen (buffer);
2921         if (fwrite (buffer, sizeof *buffer, i, fp) != i)
2922             goto oops;
2923     }
2924
2925     (void) lseek (fd, (off_t)0, 0);
2926     while ((i = read (fd, buffer, sizeof buffer)) > 0)
2927         if (fwrite (buffer, sizeof *buffer, i, fp) != i) {
2928     oops:   ;
2929             if (!talk)
2930                 fprintf (stderr, "  %s: ", addr);
2931             fprintf (talk ? stdout : stderr,
2932                     "error in transmission; write to uux failed\n");
2933             unkadr++;
2934             (void) pclose (fp);
2935             return;
2936         }
2937     if (pclose (fp))
2938         goto oops;
2939     (void) signal (SIGPIPE, pstat);
2940
2941     if (i < 0) {
2942         if (!talk)
2943             fprintf (stderr, "  %s: ", addr);
2944         fprintf (talk ? stdout : stderr,
2945                 "error in transmission; read failed\n");
2946         unkadr++;
2947         return;
2948     }
2949
2950     if (talk)
2951         printf ("queued (via uux)\n");
2952     (void) fflush (stdout);
2953 }
2954
2955 /* \f */
2956
2957 #ifdef  MF
2958 static int  make_uucp_file (td)
2959 int     td;
2960 {
2961     int     i,
2962             qd,
2963             fd;
2964     char    tmpfil[BUFSIZ];
2965
2966     (void) lseek (td, (off_t)0, 0);
2967     if ((qd = dup (td)) == NOTOK)
2968         adios ("fd", "unable to dup");
2969
2970     (void) strcpy (tmpfil, m_tmpfil ("uumf"));
2971     if ((fd = creat (tmpfil, 0600)) == NOTOK)
2972         adios (tmpfil, "unable to create");
2973     (void) close (fd);
2974     if ((fd = open (tmpfil, 2)) == NOTOK)
2975         adios (tmpfil, "unable to re-open");
2976
2977     switch (i = mmdf2uucp (qd, fd, 1)) {
2978         case OK: 
2979             if (!debug)
2980                 (void) unlink (tmpfil);
2981             break;
2982
2983         default: 
2984             adios (NULLCP, "unable to filter mail(%d), examine %s", i, tmpfil);
2985     }
2986     (void) close (qd);
2987
2988     return fd;
2989 }
2990 #endif  /* MF */
2991
2992 /* \f */
2993
2994 static  netmail (talk, fd, bccque)
2995 int     talk,
2996         fd,
2997         bccque;
2998 {
2999     int     i,
3000             naddrs;
3001     char    buffer[BUFSIZ];
3002     register struct mailname *lp;
3003
3004     naddrs = 0;
3005     if (nm_init (getusr (), &tclock) == NOTOK) {
3006         for (lp = netaddrs.m_next; lp; lp = lp -> m_next)
3007             if (lp -> m_bcc ? bccque : !bccque)
3008                 fprintf (stderr, "  %s at %s: unable to get queue file\n",
3009                         lp -> m_mbox, lp -> m_host);
3010         return;
3011     }
3012
3013     for (lp = netaddrs.m_next; lp; lp = lp -> m_next)
3014         if (lp -> m_bcc ? bccque : !bccque) {
3015             (void) nm_wadr (lp -> m_mbox, lp -> m_host);
3016             naddrs++;
3017             if (talk)
3018                 printf ("  %s at %s: queued\n", lp -> m_mbox, lp -> m_host);
3019             (void) fflush (stdout);
3020         }
3021     nm_waend ();
3022
3023     (void) lseek (fd, (off_t)0, 0);
3024     while ((i = read (fd, buffer, sizeof buffer)) > 0)
3025         if (nm_wtxt (buffer, i) == NOTOK) {
3026             fprintf (stderr,
3027                     "error in transmission; write to temporary failed");
3028             unkadr += naddrs;
3029             return;
3030         }
3031
3032     if (i < 0) {
3033         fprintf (stderr, "error in transmission; read failed\n");
3034         unkadr += naddrs;
3035         return;
3036     }
3037
3038     if (nm_wtend () == NOTOK) {
3039         fprintf (stderr, "error in transmission; unable to queue message\n");
3040         unkadr += naddrs;
3041         return;
3042     }
3043 }
3044 #endif  /* MHMTS */
3045 @
3046
3047
3048 2.25
3049 log
3050 @fixes from mtr
3051 @
3052 text
3053 @d3 1
3054 a3 1
3055 static char ident[] = "@@(#)$Id: post.c,v 2.24 1994/04/21 19:23:38 jromine Exp jromine $";
3056 d66 1
3057 a66 1
3058     "check", -5,                /* interface from whom */
3059 d68 1
3060 a68 1
3061     "nocheck", -7,              /* interface from whom */
3062 @
3063
3064
3065 2.24
3066 log
3067 @mhn fixes from MTR
3068 @
3069 text
3070 @d3 1
3071 a3 1
3072 static char ident[] = "@@(#)$Id: post.c,v 2.23 1993/08/25 17:26:51 jromine Exp jromine $";
3073 d155 5
3074 d188 1
3075 d196 1
3076 a196 1
3077     "Reply-To", HADR | HNGR, 0,
3078 d212 1
3079 a212 1
3080     "Resent-Reply-To", HADR | HNGR, 0,
3081 d222 1
3082 a222 1
3083     "Reply-To", HADR, 0,
3084 d278 1
3085 d342 2
3086 d350 1
3087 a350 1
3088 static  sigoff(), p_refile(), fcc(), die(), insert_fcc();
3089 d587 8
3090 d764 2
3091 d828 2
3092 d871 4
3093 a874 2
3094         if (hdr -> flags & HNIL)
3095             fprintf (out, "%s: %s", name, str);
3096 d1287 6
3097 a1292 1
3098     fprintf (out, "From: %s\n", signature);
3099 d1314 4
3100 a1317 2
3101         fprintf (out, "%s\"\n%s: %s\n\n--%s\n%s: %s\n\n", prefix, DESCR_FIELD,
3102                  "Blind Carbon Copy", prefix, DESCR_FIELD, "Original Message");
3103 d2383 71
3104 @
3105
3106
3107 2.23
3108 log
3109 @off_t fixes for BSD44
3110 @
3111 text
3112 @d3 1
3113 a3 1
3114 static char ident[] = "@@(#)$Id: post.c,v 2.22 1993/08/20 15:53:20 jromine Exp jromine $";
3115 d1262 1
3116 a1262 1
3117         fprintf (out, "Message-ID: <%d.%ld@@%s>\n",
3118 d1286 2
3119 a1287 1
3120         fprintf (out, "%s\"\n\n--%s\n\n", prefix, prefix);
3121 @
3122
3123
3124 2.22
3125 log
3126 @add -queued switch
3127 make use of ONEX SMTP command
3128 @
3129 text
3130 @d3 1
3131 a3 1
3132 static char ident[] = "@@(#)$Id: post.c,v 2.21 1992/12/15 00:20:22 jromine Exp jromine $";
3133 d335 2
3134 a336 1
3135 long    lseek (), time ();
3136 d1850 1
3137 a1850 1
3138     (void) lseek (fd, 0L, 0);
3139 d2454 1
3140 a2454 1
3141             (void) lseek (fd, 0L, 0);
3142 d2601 1
3143 a2601 1
3144     (void) lseek (qd, 0L, 0);
3145 d2612 1
3146 a2612 1
3147     (void) lseek (fd, 0L, 0);
3148 d2661 1
3149 a2661 1
3150     (void) lseek (fd, 0L, 0);
3151 d2702 1
3152 a2702 1
3153     (void) lseek (td, 0L, 0);
3154 d2759 1
3155 a2759 1
3156     (void) lseek (fd, 0L, 0);
3157 @
3158
3159
3160 2.21
3161 log
3162 @endif sugar
3163 @
3164 text
3165 @d3 1
3166 a3 1
3167 static char ident[] = "@@(#)$Id: post.c,v 2.20 1992/11/24 19:02:24 jromine Exp jromine $";
3168 d152 3
3169 d333 2
3170 d573 4
3171 d1415 1
3172 a1415 1
3173         if (rp_isbad (retval = sm_init (clientsw, serversw, 0, 0, snoop))
3174 d1488 2
3175 a1489 1
3176     int     fd;
3177 d1524 2
3178 a1525 1
3179     if (rp_isbad (retval = sm_init (clientsw, serversw, watch, verbose, snoop))
3180 d1555 1
3181 a1555 1
3182     (void) sm_end (!(msgflags & MINV) || bccque ? OK : DONE);
3183 d1681 2
3184 a1682 1
3185     if (rp_isbad (retval = sm_init (clientsw, serversw, watch, verbose, snoop))
3186 @
3187
3188
3189 2.20
3190 log
3191 @add decl
3192 @
3193 text
3194 @d3 2
3195 a4 2
3196 static char ident[] = "@@(#)$Id: post.c,v 2.19 1992/11/19 23:24:00 jromine Exp jromine $";
3197 #endif  lint
3198 d17 1
3199 a17 1
3200 #else   MMDFMTS
3201 d20 1
3202 a20 1
3203 #endif  MMDFMTS
3204 d25 1
3205 a25 1
3206 #endif  not V7
3207 d27 1
3208 a27 1
3209 #endif  MHMTS
3210 d31 1
3211 a31 1
3212 #endif  SENDMTS
3213 d43 1
3214 a43 1
3215 #endif  not MMDFMTS
3216 d57 1
3217 a57 1
3218 #else   TMA
3219 d59 1
3220 a59 1
3221 #endif  TMA
3222 d217 1
3223 a217 1
3224 #else   not MMFDI
3225 d219 1
3226 a219 1
3227 #endif  not MMDFI
3228 d284 1
3229 a284 1
3230 #endif  MMDFMTS
3231 d292 1
3232 a292 1
3233 #endif  MHMTS
3234 d301 1
3235 a301 1
3236 #endif  SENDMTS
3237 d309 1
3238 a309 1
3239 #else   SENDMTS
3240 d311 2
3241 a312 2
3242 #endif  SENDMTS
3243 #endif  TMA
3244 d341 1
3245 a341 1
3246 #endif !TMA
3247 d369 2
3248 a370 2
3249 #endif  MMDFII
3250 #endif  MMDFMTS
3251 d399 1
3252 a399 1
3253 #endif  MHMTS
3254 d503 1
3255 a503 1
3256 #endif  MMDFMTS
3257 d510 1
3258 a510 1
3259 #else   MHMTS
3260 d520 1
3261 a520 1
3262 #endif  MHMTS
3263 d531 1
3264 a531 1
3265 #else   SENDMTS
3266 d555 1
3267 a555 1
3268 #endif  SENDMTS
3269 d588 1
3270 a588 1
3271 #endif  MHMTS
3272 d602 1
3273 a602 1
3274 #endif  MHMTS
3275 d614 1
3276 a614 1
3277 #endif  MHMTS
3278 d628 1
3279 a628 1
3280 #endif  MHMTS
3281 d685 1
3282 a685 1
3283 #endif  MHMTS
3284 d699 1
3285 a699 1
3286 #endif  TMA
3287 d710 1
3288 a710 1
3289 #endif  MMDFMTS
3290 d713 1
3291 a713 1
3292 #endif  MHMTS
3293 d722 1
3294 a722 1
3295 #endif  not MHMTS
3296 d733 1
3297 a733 1
3298 #endif  TMA
3299 d739 1
3300 a739 1
3301 #endif  MHMTS
3302 d846 1
3303 a846 1
3304 #endif  notdef
3305 d881 1
3306 a881 1
3307 #endif  MHMTS
3308 d943 1
3309 a943 1
3310 #endif  MHMTS
3311 d999 1
3312 a999 1
3313 #endif  MMDFI
3314 d1377 1
3315 a1377 1
3316 #endif  not MHMTS
3317 d1382 2
3318 a1383 2
3319 #endif  RP_NS
3320 #endif  MMDFMTS
3321 d1388 1
3322 a1388 1
3323 #endif  not MHMTS
3324 d1401 1
3325 a1401 1
3326 #endif  RP_NS
3327 d1403 1
3328 a1403 1
3329 #endif  MMDFMTS
3330 d1410 1
3331 a1410 1
3332 #endif  SENDMTS
3333 d1417 1
3334 a1417 1
3335 #endif  BERK
3336 d1424 1
3337 a1424 1
3338 #endif  BERK
3339 d1431 1
3340 a1431 1
3341 #endif  BERK
3342 d1442 1
3343 a1442 1
3344 #endif  MMDFMTS
3345 d1446 1
3346 a1446 1
3347 #endif  SENDMTS
3348 d1451 1
3349 a1451 1
3350 #endif  not MHMTS
3351 d1472 1
3352 a1472 1
3353 #else   TMA
3354 d1474 1
3355 a1474 1
3356 #endif  TMA
3357 d1486 3
3358 a1488 3
3359 #endif  RP_NS
3360 #endif  MMDFMTS
3361 #else   MHMTS
3362 d1490 1
3363 a1490 1
3364 #endif  MHMTS
3365 d1511 2
3366 a1512 2
3367 #endif  RP_NS
3368 #endif  MMDFMTS
3369 d1517 1
3370 a1517 1
3371 #endif  SENDMTS
3372 d1524 1
3373 a1524 1
3374 #else   MHMTS
3375 d1529 1
3376 a1529 1
3377 #else   not MF
3378 d1531 1
3379 a1531 1
3380 #endif  not MF
3381 d1535 1
3382 a1535 1
3383 #endif  MHMTS
3384 d1542 1
3385 a1542 1
3386 #endif  MMDFMTS
3387 d1545 1
3388 a1545 1
3389 #endif  SENDMTS
3390 d1589 1
3391 a1589 1
3392 #endif  BERK
3393 d1593 1
3394 a1593 1
3395 #endif  BERK
3396 d1601 1
3397 a1601 1
3398 #endif  BERK
3399 d1605 1
3400 a1605 1
3401 #endif  BERK
3402 d1613 1
3403 a1613 1
3404 #endif  BERK
3405 d1617 1
3406 a1617 1
3407 #endif  BERK
3408 d1625 1
3409 a1625 1
3410 #endif  SENDMTS
3411 d1652 2
3412 a1653 2
3413 #endif  RP_NS
3414 #endif  MMDFMTS
3415 d1667 2
3416 a1668 2
3417 #endif  RP_NS
3418 #endif  MMDFMTS
3419 d1673 1
3420 a1673 1
3421 #endif  SENDMTS
3422 d1688 1
3423 a1688 1
3424 #endif  MMDFMTS
3425 d1692 1
3426 a1692 1
3427 #endif  SENDMTS
3428 d1708 1
3429 a1708 1
3430 #endif  MMDFMTS
3431 d1712 1
3432 a1712 1
3433 #endif  SENDMTS
3434 d1723 1
3435 a1723 1
3436 #endif  MMDFMTS
3437 d1726 1
3438 a1726 1
3439 #endif  SENDMTS
3440 d1730 1
3441 a1730 1
3442 #endif  TMA
3443 d1736 1
3444 a1736 1
3445 #else   MHMTS
3446 d1741 1
3447 a1741 1
3448 #endif  MHMTS
3449 d1748 1
3450 a1748 1
3451 #endif  not BERK
3452 d1753 1
3453 a1753 1
3454 #endif  not BERK
3455 d1759 1
3456 a1759 1
3457 #endif  not BERK
3458 d1762 1
3459 a1762 1
3460 #else   MHMTS
3461 d1764 1
3462 a1764 1
3463 #endif  MHMTS
3464 d1767 1
3465 a1767 1
3466 #endif  not BERK
3467 d1772 1
3468 a1772 1
3469 #endif  not BERK
3470 d1778 1
3471 a1778 1
3472 #endif  not BERK
3473 d1781 1
3474 a1781 1
3475 #else   MHMTS
3476 d1783 1
3477 a1783 1
3478 #endif  MHMTS
3479 d1786 1
3480 a1786 1
3481 #endif  not BERK
3482 d1791 1
3483 a1791 1
3484 #endif  not BERK
3485 d1797 1
3486 a1797 1
3487 #endif  not BERK
3488 d1800 1
3489 a1800 1
3490 #else   MHMTS
3491 d1802 1
3492 a1802 1
3493 #endif  MHMTS
3494 d1805 1
3495 a1805 1
3496 #endif  not BERK
3497 d1816 1
3498 a1816 1
3499 #endif  MMDFMTS
3500 d1820 1
3501 a1820 1
3502 #endif  SENDMTS
3503 d1835 1
3504 a1835 1
3505 #endif  MMDFMTS
3506 d1842 1
3507 a1842 1
3508 #endif  MMDFMTS
3509 d1846 1
3510 a1846 1
3511 #endif  SENDMTS
3512 d1880 1
3513 a1880 1
3514 #endif  MMDFMTS
3515 d1893 1
3516 a1893 1
3517 #endif  SENDMTS
3518 d1895 1
3519 a1895 1
3520 #endif  not MHMTS
3521 d1903 1
3522 a1903 1
3523 #endif  TMA
3524 d1919 1
3525 a1919 1
3526 #endif  TMA
3527 d1935 1
3528 a1935 1
3529 #else   MF
3530 d1941 1
3531 a1941 1
3532 #endif  MF
3533 d1957 1
3534 a1957 1
3535 #endif  TMA
3536 d1976 1
3537 a1976 1
3538 #endif  MMDFII
3539 d1995 1
3540 a1995 1
3541 #endif  RP_DOK
3542 d2006 1
3543 a2006 1
3544 #endif  RP_NS
3545 d2036 1
3546 a2036 1
3547 #endif  MMDFMTS
3548 d2126 1
3549 a2126 1
3550 #endif  MHMTS
3551 d2134 1
3552 a2134 1
3553 #endif  TMA
3554 d2147 1
3555 a2147 1
3556 #endif  TMA
3557 d2177 1
3558 a2177 1
3559 #endif  TMA
3560 d2216 1
3561 a2216 1
3562 #endif  SENDMTS
3563 d2229 1
3564 a2229 1
3565 #endif  not BSD42
3566 d2236 1
3567 a2236 1
3568 #endif  MMDFMTS
3569 d2240 1
3570 a2240 1
3571 #endif  SENDMTS
3572 d2243 1
3573 a2243 1
3574 #endif  not MHMTS
3575 d2255 1
3576 a2255 1
3577 #else   MHMTS
3578 d2260 1
3579 a2260 1
3580 #endif  MHMTS
3581 d2286 1
3582 a2286 1
3583 #endif  MHMTS
3584 d2357 1
3585 a2357 1
3586 #endif  MHMTS
3587 d2361 1
3588 a2361 1
3589 #endif  MMDFMTS
3590 d2365 1
3591 a2365 1
3592 #endif  SENDMTS
3593 d2391 1
3594 a2391 1
3595 #endif  MMDFMTS
3596 d2519 1
3597 a2519 1
3598 #endif  TIOCNOTTY
3599 d2522 1
3600 a2522 1
3601 #endif  BSD42
3602 d2533 1
3603 a2533 1
3604 #endif  BSD41A
3605 d2537 1
3606 a2537 1
3607 #endif  BSD42
3608 d2626 1
3609 a2626 1
3610 #else   UCI
3611 d2629 1
3612 a2629 1
3613 #endif  UCI
3614 d2713 1
3615 a2713 1
3616 #endif  MF
3617 d2767 1
3618 a2767 1
3619 #endif  MHMTS
3620 @
3621
3622
3623 2.19
3624 log
3625 @fix bug in blind list handling
3626 @
3627 text
3628 @d3 1
3629 a3 1
3630 static char ident[] = "@@(#)$Id: post.c,v 2.18 1992/11/04 02:58:40 jromine Exp $";
3631 d323 1
3632 @
3633
3634
3635 2.18
3636 log
3637 @m_putenv
3638 @
3639 text
3640 @d3 1
3641 a3 1
3642 static char ident[] = "@@(#)$Id: post.c,v 2.17 1992/11/04 00:55:52 jromine Exp jromine $";
3643 d871 5
3644 a875 3
3645 #ifndef afix
3646                 if (mp -> m_ingrp = np -> m_ingrp)
3647 #else afix
3648 a876 1
3649 #endif afix
3650 a880 4
3651 #ifdef afix
3652                 if (mp -> m_gname)
3653                     putgrp (namep, mp -> m_gname, out, hdr -> flags);
3654 #endif afix
3655 @
3656
3657
3658 2.17
3659 log
3660 @LOCALE
3661 TYPESIG
3662 @
3663 text
3664 @d3 1
3665 a3 1
3666 static char ident[] = "@@(#)$Id: post.c,v 2.16 1992/10/16 23:55:56 jromine Exp jromine $";
3667 d2527 3
3668 a2529 3
3669             (void) putenv ("USER", hp -> h_name);
3670             (void) putenv ("HOME", hp -> h_home);
3671             (void) putenv ("SHELL", hp -> h_shell);
3672 @
3673
3674
3675 2.16
3676 log
3677 @typo
3678 @
3679 text
3680 @d3 1
3681 a3 1
3682 static char ident[] = "@@(#)$Id: post.c,v 2.15 1992/10/16 21:37:31 jromine Exp jromine $";
3683 d36 3
3684 d42 1
3685 a42 1
3686 #define uptolow(c)      (isupper (c) ? tolower (c) : (c))
3687 d291 1
3688 a291 1
3689 int     sigser ();
3690 d359 3
3691 d2226 1
3692 a2226 1
3693 static  int sigser (i)
3694 @
3695
3696
3697 2.15
3698 log
3699 @MIME changes
3700 @
3701 text
3702 @d3 1
3703 a3 1
3704 static char ident[] = "@@(#)$Id: post.c,v 2.14 1992/03/02 17:06:14 jromine Exp jromine $";
3705 d35 1
3706 a35 1
3707 #endidf /* MIME */
3708 @
3709
3710
3711 2.14
3712 log
3713 @back off alias fix
3714 @
3715 text
3716 @d3 1
3717 a3 1
3718 static char ident[] = "@@(#)$Id: post.c,v 2.13 1992/01/31 22:23:44 jromine Exp jromine $";
3719 d33 3
3720 d46 6
3721 d91 6
3722 a96 1
3723 #define MSGDSW  12
3724 d98 1
3725 a98 1
3726 #define NMSGDSW 13
3727 d101 1
3728 a101 1
3729 #define VERBSW  14
3730 d103 1
3731 a103 1
3732 #define NVERBSW 15
3733 d106 1
3734 a106 1
3735 #define WATCSW  16
3736 d108 1
3737 a108 1
3738 #define NWATCSW 17
3739 d111 1
3740 a111 1
3741 #define WHOMSW  18      /* interface from whom */
3742 d114 1
3743 a114 1
3744 #define WIDTHSW 19
3745 d117 1
3746 a117 1
3747 #define HELPSW  20
3748 d120 1
3749 a120 1
3750 #define MAILSW  21
3751 d122 1
3752 a122 1
3753 #define SAMLSW  22
3754 d124 1
3755 a124 1
3756 #define SENDSW  23
3757 d126 1
3758 a126 1
3759 #define SOMLSW  24
3760 d129 1
3761 a129 1
3762 #define ANNOSW  25              /* interface from send */
3763 d132 1
3764 a132 1
3765 #define DLVRSW  26
3766 d135 1
3767 a135 1
3768 #define CLIESW  27
3769 d137 1
3770 a137 1
3771 #define SERVSW  28
3772 d139 1
3773 a139 1
3774 #define SNOOPSW 29
3775 d142 1
3776 a142 1
3777 #define FILLSW  30
3778 d144 1
3779 a144 1
3780 #define FILLUSW 31
3781 d146 1
3782 a146 1
3783 #define PARTSW  32
3784 d241 1
3785 d318 4
3786 d416 1
3787 d429 10
3788 d1253 24
3789 a1276 1
3790     fprintf (out, "BCC:\n\n------- Blind-Carbon-Copy\n\n");
3791 d1281 7
3792 a1287 2
3793             adios (NULLCP, "unable to re-open");
3794         cpydgst (fd, fileno (out), tmpfil, bccfil);
3795 d1321 6
3796 a1326 1
3797     fprintf (out, "\n------- End of Blind-Carbon-Copy\n");
3798 d1329 36
3799 @
3800
3801
3802 2.13
3803 log
3804 @kerberos
3805 @
3806 text
3807 @d3 1
3808 a3 1
3809 static char ident[] = "@@(#)$Id: post.c,v 2.12 1992/01/31 16:34:06 jromine Exp jromine $";
3810 d835 3
3811 d839 1
3812 d844 1
3813 d847 1
3814 @
3815
3816
3817 2.12
3818 log
3819 @Multimedia MH
3820 @
3821 text
3822 @d3 1
3823 a3 1
3824 static char ident[] = "@@(#)$Id: post.c,v 2.11 1992/01/30 22:39:58 jromine Exp $";
3825 d135 1
3826 a135 1
3827     NULL, NULL
3828 d168 3
3829 a170 3
3830     "Return-Path", HBAD, NULL,
3831     "Received", HBAD, NULL,
3832     "Reply-To", HADR | HNGR, NULL,
3833 d172 3
3834 a174 3
3835     "Sender", HADR | HBAD, NULL,
3836     "Date", HBAD, NULL,
3837     "Subject", HSUB, NULL,
3838 d179 2
3839 a180 2
3840     "Message-ID", HBAD, NULL,
3841     "Fcc", HFCC, NULL,
3842 d186 1
3843 a186 1
3844     "Resent-Reply-To", HADR | HNGR, NULL,
3845 d188 3
3846 a190 3
3847     "Resent-Sender", HADR | HBAD, NULL,
3848     "Resent-Date", HBAD, NULL,
3849     "Resent-Subject", HSUB, NULL,
3850 d194 3
3851 a196 3
3852     "Resent-Message-ID", HBAD, NULL,
3853     "Resent-Fcc", HFCC, NULL,
3854     "Reply-To", HADR, NULL,
3855 d199 1
3856 a199 1
3857     "Sender", HADR | HMNG | HNGR, NULL,
3858 d201 1
3859 a201 1
3860     "Sender", HADR | HNGR, NULL,
3861 d204 4
3862 a207 4
3863     "To", HADR | HNIL, NULL,
3864     "cc", HADR | HNIL, NULL,
3865     "Bcc", HADR | HTRY | HBCC | HNIL, NULL,
3866     "Fcc", HIGN, NULL,
3867 d310 1
3868 a310 1
3869 static  anno(), insert_foc(), make_bcc_file(), verify_all_addresses();
3870 d771 1
3871 a771 1
3872             *cp = NULL;
3873 d773 1
3874 a773 1
3875             *cp++ = NULL;
3876 d1187 2
3877 a1188 2
3878         *++pp = NULL;
3879     if (*cp == NULL)
3880 @
3881
3882
3883 2.11
3884 log
3885 @remove WP
3886 @
3887 text
3888 @d3 1
3889 a3 1
3890 static char ident[] = "@@(#)$Id: post.c,v 2.10 1992/01/29 23:54:10 jromine Exp jromine $";
3891 d128 7
3892 d299 8
3893 d519 12
3894 d579 1
3895 a579 1
3896             if ((out = fopen ("/dev/null", "w")) == NULL)
3897 d620 1
3898 a620 1
3899                 if (whomsw)
3900 d664 2
3901 a665 1
3902         verify_all_addresses (1);
3903 d706 2
3904 a707 1
3905         printf ("Message Processed\n");
3906 d746 3
3907 a748 1
3908     if (hdr -> flags & HIGN)
3909 d750 1
3910 d752 6
3911 a757 2
3912         advise (NULLCP, "illegal header line -- %s:", name);
3913         badmsg++;
3914 d765 5
3915 d818 2
3916 a819 1
3917                     (hdr -> flags & HMNG) ? "Original-" : "", name);
3918 d872 3
3919 a874 1
3920     if (linepos)
3921 d876 1
3922 d927 1
3923 a927 1
3924             if (whomsw)
3925 d938 3
3926 d954 1
3927 a954 1
3928             if (whomsw)
3929 d969 2
3930 d1012 1
3931 a1012 1
3932     if ((flags & (HBCC|HDCC)) || mp -> m_ingrp)
3933 d1023 1
3934 a1023 1
3935         if (mp -> m_gname)
3936 d1057 1
3937 a1057 1
3938     if (flags & HBCC)
3939 d1063 2
3940 d1067 1
3941 a1067 1
3942     cp = concat (group, ";", NULLCP);
3943 @
3944
3945
3946 2.10
3947 log
3948 @bug fix for groups in alias files (yea!)
3949 @
3950 text
3951 @d3 1
3952 a3 1
3953 static char ident[] = "@@(#)$Id: post.c,v 2.9 1992/01/24 00:05:24 jromine Exp jromine $";
3954 a127 3
3955 #define FILLSW  30
3956     "fill-in file", -7,
3957
3958 a291 6
3959 #ifdef  WP
3960 extern int      do_wp;          /* fill-in white pages queries */
3961 #endif
3962 static char    *fill_in = NULLCP;
3963
3964
3965 a503 7
3966
3967                 case FILLSW:
3968 #ifdef  WP
3969                     if (!(fill_in = *argp++) || *fill_in == '-')
3970                         adios (NULLCP, "missing argument to %s", argp[-2]);
3971 #endif
3972                     continue;
3973 a511 3
3974 #ifdef  WP
3975     do_wp++;
3976 #endif
3977 d552 1
3978 a552 1
3979             if ((out = fopen (fill_in ? fill_in : "/dev/null", "w")) == NULL)
3980 d593 1
3981 a593 1
3982                 if (whomsw && !fill_in)
3983 d717 1
3984 a717 3
3985     if (hdr -> flags & HIGN) {
3986         if (fill_in)
3987             fprintf (out, "%s: %s", name, str);
3988 a718 1
3989     }
3990 d720 2
3991 a721 6
3992         if (fill_in)
3993             fprintf (out, "%s: %s", name, str);
3994         else {
3995             advise (NULLCP, "illegal header line -- %s:", name);
3996             badmsg++;
3997         }
3998 a728 5
3999         if (fill_in) {
4000             fprintf (out, "%s: %s", name, str);
4001             return;
4002         }
4003
4004 d777 1
4005 a777 2
4006                     !fill_in && (hdr -> flags & HMNG) ? "Original-" : "",
4007                     name);
4008 d830 1
4009 a830 3
4010     if (linepos) {
4011         if (fill_in && grp > 0)
4012             (void) putc (';', out);
4013 a831 1
4014     }
4015 d962 1
4016 a962 1
4017     if (!fill_in && ((flags & (HBCC|HDCC)) || mp -> m_ingrp))
4018 d973 1
4019 a973 1
4020         if (mp -> m_gname && !fill_in)
4021 d1007 1
4022 a1007 1
4023     if (!fill_in && (flags & HBCC))
4024 a1012 2
4025         if (fill_in)
4026             linepos -= strlen (group);
4027 d1015 1
4028 a1015 1
4029     cp = fill_in ? group : concat (group, ";", NULLCP);
4030 @
4031
4032
4033 2.9
4034 log
4035 @"clock" -> "tclock" (reserved word on ncr)
4036 @
4037 text
4038 @d3 1
4039 a3 1
4040 static char ident[] = "@@(#)$Id: post.c,v 2.8 1990/04/05 15:35:20 sources Exp jromine $";
4041 d825 1
4042 a825 1
4043                 if (mp -> m_ingrp = np -> m_ingrp)
4044 d830 2
4045 @
4046
4047
4048 2.8
4049 log
4050 @add ID
4051 @
4052 text
4053 @d3 1
4054 a3 1
4055 static char ident[] = "@@(#)$Id:$";
4056 d237 1
4057 a237 1
4058 static long clock = 0L;         /* the time we started (more or less) */
4059 d877 1
4060 a877 1
4061     (void) time (&clock);
4062 d918 1
4063 a918 1
4064             fprintf (out, "Date: %s\n", dtime (&clock));
4065 d921 1
4066 a921 1
4067                         getpid (), clock, LocalName ());
4068 d946 1
4069 a946 1
4070             fprintf (out, "Resent-Date: %s\n", dtime (&clock));
4071 d949 1
4072 a949 1
4073                         getpid (), clock, LocalName ());
4074 d1193 1
4075 a1193 1
4076     fprintf (out, "Date: %s\n", dtime (&clock));
4077 d1196 1
4078 a1196 1
4079                 getpid (), clock, LocalName ());
4080 d2516 1
4081 a2516 1
4082                 getusr (), ctime (&clock), SystemName ());
4083 d2602 1
4084 a2602 1
4085     if (nm_init (getusr (), &clock) == NOTOK) {
4086 @
4087
4088
4089 2.7
4090 log
4091 @add ID
4092 @
4093 text
4094 @d3 1
4095 a3 1
4096 static char ident[] = "@@(#)$Id:";
4097 @
4098
4099
4100 2.6
4101 log
4102 @ansi fixup
4103 @
4104 text
4105 @d2 3
4106 @
4107
4108
4109 2.5
4110 log
4111 @TYPESIG fix
4112 @
4113 text
4114 @d303 1
4115 a303 1
4116 static  sigoff(), p_refile(), fcc(), die();
4117 @
4118
4119
4120 2.4
4121 log
4122 @"refile" -> "p_refile()"
4123 @
4124 text
4125 @d2484 1
4126 a2484 1
4127     int     (*pstat) ();
4128 @
4129
4130
4131 2.3
4132 log
4133 @ANSI Compilance
4134 @
4135 text
4136 @d303 1
4137 a303 1
4138 static  sigoff(), refile(), fcc(), die();
4139 d686 1
4140 a686 1
4141     refile (tmpfil);
4142 d2147 1
4143 a2147 1
4144 static  refile (file)
4145 @
4146
4147
4148 2.2
4149 log
4150 @WP Changes
4151 @
4152 text
4153 @d300 10
4154 @
4155
4156
4157 2.1
4158 log
4159 @TYPESIG
4160 @
4161 text
4162 @d125 3
4163 d292 6
4164 d500 7
4165 d515 3
4166 d558 1
4167 a558 1
4168             if ((out = fopen ("/dev/null", "w")) == NULL)
4169 d599 1
4170 a599 1
4171                 if (whomsw)
4172 d723 3
4173 a725 1
4174     if (hdr -> flags & HIGN)
4175 d727 1
4176 d729 6
4177 a734 2
4178         advise (NULLCP, "illegal header line -- %s:", name);
4179         badmsg++;
4180 d742 5
4181 d795 2
4182 a796 1
4183             (hdr -> flags & HMNG) ? "Original-" : "", name);
4184 d847 3
4185 a849 1
4186     if (linepos)
4187 d851 1
4188 d982 1
4189 a982 1
4190     if ((flags & (HBCC|HDCC)) || mp -> m_ingrp)
4191 d993 1
4192 a993 1
4193         if (mp -> m_gname)
4194 d1027 1
4195 a1027 1
4196     if (flags & (HBCC|HDCC))
4197 d1033 2
4198 d1037 1
4199 a1037 1
4200     cp = concat (group, ";", NULLCP);
4201 d1040 1
4202 a1040 1
4203     if (linepos != nameoutput)
4204 @
4205
4206
4207 2.0
4208 log
4209 @changes for SUN40 shared libraries and NNTP under bbc
4210 @
4211 text
4212 @d233 1
4213 a233 1
4214 static int  (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();
4215 @
4216
4217
4218 1.2
4219 log
4220 @add "Dcc:" header line.  This is basically a blind distribution copy.
4221 addresses listed on Dcc: lines are put in the envelope only!
4222 I don't intend to document this since Bcc: is the socially appropriate
4223 header to use for such copies.
4224 /JLR
4225 @
4226 text
4227 @d145 1
4228 a145 1
4229 #define HDCC    0x0400          /* oh joy, another undocumented feature */
4230 @
4231
4232
4233 1.1
4234 log
4235 @Initial revision
4236 @
4237 text
4238 @d145 1
4239 d168 1
4240 d947 1
4241 a947 1
4242     if ((flags & HBCC) || mp -> m_ingrp)
4243 d992 1
4244 a992 1
4245     if (flags & HBCC)
4246 @