⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 post.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 5 页
字号:
/* post.c - enter messages into the transport system */#ifndef	lintstatic char ident[] = "@(#)$Id: post.c,v 1.3 90/11/25 19:05:24 sharpe Exp $";#endif	lint#include "../h/mh.h"#include "../h/addrsbr.h"#include "../h/aliasbr.h"#include "../h/dropsbr.h"#include "../zotnet/tws.h"#ifndef	MMDFMTS#include <ctype.h>#include <errno.h>#include <setjmp.h>#include <stdio.h>#include <sys/types.h>#else	MMDFMTS#include "../mts/mmdf/util.h"#include "../mts/mmdf/mmdf.h"#endif	MMDFMTS#include "../zotnet/mts.h"#ifdef	MHMTS#ifndef	V7#include <sys/ioctl.h>#endif	not V7#include <sys/stat.h>#endif	MHMTS#ifdef  X400#include "../mts/x400s/x4mail.h"#endif  X400#ifdef	SENDMTS#include "../mts/sendmail/smail.h"#undef	MF#endif	SENDMTS#include <signal.h>#ifndef	MMDFMTS#define	uptolow(c)	(isupper (c) ? tolower (c) : (c))#endif	not MMDFMTS#define FCCS		10	/* max number of fccs allowed *//*  */#ifndef	TMA#define	TMAminc(a)	(a)#else	TMA#define	TMAminc(a)	0#endif	TMAstatic struct swit switches[] = {#define	ALIASW	0    "alias aliasfile", 0,#define	CHKSW	1    "check", -5,		/* interface from whom */#define	NCHKSW	2    "nocheck", -7,		/* interface from whom */#define	DEBUGSW	3    "debug", -5,#define	DISTSW	4    "dist", -4,			/* interface from dist */#define	ENCRSW	5    "encrypt", TMAminc (-7),#define	NENCRSW	6    "noencrypt", TMAminc (-9),#define	FILTSW	7    "filter filterfile", 0,#define	NFILTSW	8    "nofilter", 0,#define	FRMTSW	9    "format", 0,#define	NFRMTSW	10    "noformat", 0,#define	LIBSW	11		/* interface from send, whom */    "library directory", -7,#define	MSGDSW	12    "msgid", 0,#define	NMSGDSW	13    "nomsgid", 0,#define	VERBSW	14    "verbose", 0,#define	NVERBSW	15    "noverbose", 0,#define	WATCSW	16    "watch", 0,#define	NWATCSW	17    "nowatch", 0,#define	WHOMSW	18	/* interface from whom */    "whom", -4,		#define	WIDTHSW	19    "width columns", 0,#define	HELPSW	20    "help", 4,#define	MAILSW	21    "mail", -4,#define	SAMLSW	22    "saml", -4,#define	SENDSW	23    "send", -4,#define	SOMLSW	24    "soml", -4,#define	ANNOSW	25		/* interface from send */    "idanno number", -6,#define	DLVRSW	26    "deliver address-list", -7,#define	CLIESW	27    "client host", -6,#define	SERVSW	28    "server host", -6,#define	SNOOPSW	29    "snoop", -5,#define	FILLSW	30    "fill-in file", -7,#ifdef X400#define MTSSW   31    "mts smtp/x400", 0,#define NOTESW  32    "note", 0,#endif X400    NULL, NULL};/*  */struct headers {    char   *value;    unsigned int    flags;#define	HNOP	0x0000		/* just used to keep .set around */#define	HBAD	0x0001		/* bad header - don't let it through */#define	HADR	0x0002		/* header has an address field */#define	HSUB	0x0004		/* Subject: header */#define	HTRY	0x0008		/* try to send to addrs on header */#define	HBCC	0x0010		/* don't output this header */#define	HMNG	0x0020		/* munge this header */#define	HNGR	0x0040		/* no groups allowed in this header */#define	HFCC	0x0080		/* FCC: type header */#define	HNIL	0x0100		/* okay for this header not to have addrs */#define	HIGN	0x0200		/* ignore this header */#define	HDCC	0x0400		/* another undocumented feature */#define HXMTS   0x0800          /* X-Mts: header */#define HRMTS   0x1000          /* Resent-X-Mts: header */    unsigned int    set;#define	MFRM	0x0001		/* we've seen a From: */#define	MDAT	0x0002		/* we've seen a Date: */#define	MRFM	0x0004		/* we've seen a Resent-From: */#define	MVIS	0x0008		/* we've seen sighted addrs */#define	MINV	0x0010		/* we've seen blind addrs */#define MMTS    0x0020          /* we've seen X-Mts: */};/*  */#define NONEMTS -1#define SMTPMTS  0#ifdef X400#define X400MTS  1#define X4MTS    2#define DEFMTS SMTPMTS#endif X400static char *mts_vals[] = {    "smtp",#ifdef X400    "x400",    "x.400"#endif X400};static int get_mts_val ();static struct headers  NHeaders[] = {    "Return-Path", HBAD, NULL,    "Received", HBAD, NULL,    "Reply-To", HADR | HNGR, NULL,    "From", HADR | HNGR, MFRM,    "Sender", HADR | HBAD, NULL,    "Date", HBAD, NULL,    "Subject", HSUB, NULL,    "To", HADR | HTRY, MVIS,    "cc", HADR | HTRY, MVIS,    "Bcc", HADR | HTRY | HBCC | HNIL, MINV,    "Dcc", HADR | HTRY | HDCC | HNIL, MVIS,	/* sorta cc & bcc combined */    "Message-ID", HBAD, NULL,    "Fcc", HFCC, NULL,#ifdef X400    "X-Mts", HXMTS, NULL,#endif X400    NULL};static struct headers  RHeaders[] = {    "Resent-Reply-To", HADR | HNGR, NULL,    "Resent-From", HADR | HNGR, MRFM,    "Resent-Sender", HADR | HBAD, NULL,    "Resent-Date", HBAD, NULL,    "Resent-Subject", HSUB, NULL,    "Resent-To", HADR | HTRY, MVIS,    "Resent-cc", HADR | HTRY, MVIS,    "Resent-Bcc", HADR | HTRY | HBCC, MINV,    "Resent-Message-ID", HBAD, NULL,    "Resent-Fcc", HFCC, NULL,#ifdef X400    "Resent-XMts", HRMTS, NULL,#endif X400    "Reply-To", HADR, NULL,    "From", HADR | HNGR, MFRM,#ifdef	MMDFI    "Sender", HADR | HMNG | HNGR, NULL,#else	not MMFDI    "Sender", HADR | HNGR, NULL,#endif	not MMDFI    "Date", HNOP, MDAT,    "To", HADR | HNIL, NULL,    "cc", HADR | HNIL, NULL,    "Bcc", HADR | HTRY | HBCC | HNIL, NULL,    "Fcc", HIGN, NULL,#ifdef X400    "X-Mts", HXMTS, NULL,#endif X400    NULL};/*  */static short    fccind = 0;	/* index into fccfold[] */static short    outputlinelen = OUTPUTLINELEN;static int  pfd = NOTOK;	/* fd to write annotation list to */static int  myuid= -1;		/* my user id */static int  mygid= -1;		/* my group id */static int  recipients = 0;	/* how many people will get a copy */static int  unkadr = 0;		/* how many of those were unknown */static int  badadr = 0;		/* number of bad addrs */static int  badmsg = 0;		/* message has bad semantics */static int  verbose = 0;	/* spell it out */static int  format = 1;		/* format addresses */static int  msgid = 0;		/* add msgid */static int  debug = 0;		/* debugging post */static int  watch = 0;		/* watch the delivery process */static int  whomsw = 0;		/* we are whom not post */static int  checksw = 0;	/* whom -check */static int  linepos=0;		/* putadr()'s position on the line */static int  nameoutput=0;	/* putadr() has output header name */static unsigned msgflags = 0;	/* what we've seen */#define	NORMAL 0#define	RESENT 1static int msgstate = NORMAL;static long clock = 0L;		/* the time we started (more or less) */static TYPESIG  (*hstat) (), (*istat) (), (*qstat) (), (*tstat) ();static char tmpfil[BUFSIZ];static char bccfil[BUFSIZ];static char from[BUFSIZ];	/* my network address */static char signature[BUFSIZ];	/* my signature */static char *filter = NULL;	/* the filter for BCC'ing */static char *subject = NULL;	/* the subject field for BCC'ing */static char *fccfold[FCCS];	/* foldernames for FCC'ing */#ifdef  X400static int  msgxmts = NONEMTS;  /* holds value of mts from draft */static int  resent_mts = NONEMTS; /* holds value of resent mts */static int  argxmts = NONEMTS;  /* holds value of mts from command line */static int  mts_arg = DEFMTS;   /* holds value of mts being used, SMTP */                                /* being the default. */static int  note = 0;#endif  X400static int  mtsval  = NONEMTS;  /* used in checking if valid mts */static struct headers  *hdrtab;	/* table for the message we're doing */static struct mailname localaddrs={NULL};	/* local addrs */static struct mailname netaddrs={NULL};		/* network addrs */static struct mailname uuaddrs={NULL};		/* uucp addrs */static struct mailname tmpaddrs={NULL};		/* temporary queue *//*  */#ifdef	MMDFMTSstatic char *submitmode = "m";	/* deliver to mailbox only */static char submitopts[6] = "vl";/* initial options for submit */#endif	MMDFMTS#ifdef	MHMTSstatic char *deliver = NULL;extern char **environ;int	sigser ();#endif	MHMTS#ifdef	SENDMTSstatic int smtpmode = S_MAIL;static int snoop = 0;static char *clientsw = NULL;static char *serversw = NULL;extern struct smtp  sm_reply;#endif	SENDMTS#ifdef	TMA#define	post(a,b,c) \    if (encryptsw) postcipher ((a), (b), (c)); else postplain ((a), (b), (c))#ifndef	SENDMTS#define	tmasnoop	0#else	SENDMTS#define	tmasnoop	snoop#endif	SENDMTS#endif	TMAstatic int  encryptsw = 0;	/* encrypt it */#ifdef	WPextern int	do_wp;		/* fill-in white pages queries */#endifstatic char    *fill_in = NULLCP;long	lseek (), time ();static	putfmt(), start_headers(), finish_headers(), putgrp(), pl();static	anno(), insert_fcc(), make_bcc_file(), verify_all_addresses();static	chkadr(), do_addresses(), do_text(), do_an_address(), sigon();static 	sigoff(), p_refile(), fcc(), die();static int	get_header(), putadr(), insert(), annoaux();#ifdef TMAstatic	postplain();#elsestatic	post();#endif !TMA/*    MAIN *//* ARGSUSED */main (argc, argv)int     argc;char   *argv[];{    int     state,            compnum;    char   *cp,#ifdef X400           *mts = NULL,#endif X400           *msg = NULL,          **argp = argv + 1,            buf[BUFSIZ],            name[NAMESZ];    FILE   *in,	   *out;    invo_name = r1bindex (argv[0], '/');    m_foil (NULLCP);    mts_init (invo_name);#ifdef	MMDFMTS#ifdef	MMDFII    mmdf_init (invo_name);#endif	MMDFII#endif	MMDFMTS/*  */    while (cp = *argp++) {	if (*cp == '-')	    switch (smatch (++cp, switches)) {		case AMBIGSW: 		    ambigsw (cp, switches);		    done (1);		case UNKWNSW: 		    adios (NULLCP, "-%s unknown", cp);		case HELPSW: 		    (void) sprintf (buf, "%s [switches] file", invo_name);		    help (buf, switches);		    done (1);		case LIBSW:		    if (!(cp = *argp++) || *cp == '-')			adios (NULLCP, "missing argument to %s", argp[-2]);		    m_foil (cp);		    continue;		case ALIASW: 		    if (!(cp = *argp++) || *cp == '-')			adios (NULLCP, "missing argument to %s", argp[-2]);#ifdef	MHMTS		    if (access (libpath (cp), 04) == NOTOK)			adios (cp, "unable to read");#endif	MHMTS		    if ((state = alias (cp)) != AK_OK)			adios (NULLCP, "aliasing error in %s - %s",				cp, akerror (state));		    continue;		case CHKSW: 		    checksw++;		    continue;		case NCHKSW: 		    checksw = 0;		    continue;		case DEBUGSW: 		    debug++;		    continue;		case DISTSW:		    msgstate = RESENT;		    continue;		case FILTSW:		    if (!(filter = *argp++) || *filter == '-')			adios (NULLCP, "missing argument to %s", argp[-2]);		    continue;		case NFILTSW:		    filter = NULL;		    continue;				case FRMTSW: 		    format++;		    continue;		case NFRMTSW: 		    format = 0;		    continue;		case MSGDSW: 		    msgid++;		    continue;		case NMSGDSW: 		    msgid = 0;		    continue;		case VERBSW: 		    verbose++;		    continue;		case NVERBSW: 		    verbose = 0;		    continue;		case WATCSW: 		    watch++;		    continue;		case NWATCSW: 		    watch = 0;		    continue;		case WHOMSW: 		    whomsw++;		    continue;		case WIDTHSW: 		    if (!(cp = *argp++) || *cp == '-')			adios (NULLCP, "missing argument to %s", argp[-2]);		    if ((outputlinelen = atoi (cp)) < 10)			adios (NULLCP, "impossible width %d", outputlinelen);		    continue;		case ENCRSW:		    encryptsw++;		    continue;		case NENCRSW:		    encryptsw = 0;		    continue;		case ANNOSW: 		    if (!(cp = *argp++) || *cp == '-')			adios (NULLCP, "missing argument to %s", argp[-2]);		    if ((pfd = atoi (cp)) <= 2)			adios (NULLCP, "bad argument %s %s", argp[-2], cp);		    continue;#ifdef	MMDFMTS		case MAILSW:		    submitmode = "m";		    continue;		case SOMLSW:	/* for right now, sigh... */		case SAMLSW:		    submitmode = "b";		    continue;		case SENDSW:		    submitmode = "y";		    continue;#endif	MMDFMTS#ifndef	MHMTS		case DLVRSW:		    if (!(cp = *argp++) || *cp == '-')			adios (NULLCP, "missing argument to %s", argp[-2]);		    continue;#else	MHMTS		case MAILSW:		case SAMLSW:		case SOMLSW:		case SENDSW:		    continue;		case DLVRSW: 		    if (!(deliver = *argp++) || *deliver == '-')			adios (NULLCP, "missing argument to %s", argp[-2]);		    continue;#endif	MHMTS#ifndef	SENDMTS		case CLIESW:		case SERVSW:		    if (!(cp = *argp++) || *cp == '-')			adios (NULLCP, "missing argument to %s", argp[-2]);		    continue;		case SNOOPSW:		    continue;#else	SENDMTS		case MAILSW:		    smtpmode = S_MAIL;		    continue;		case SAMLSW:		    smtpmode = S_SAML;		    continue;		case SOMLSW:		    smtpmode = S_SOML;		    continue;		case SENDSW:		    smtpmode = S_SEND;		    continue;		case CLIESW:		    if (!(clientsw = *argp++) || *clientsw == '-')			adios (NULLCP, "missing argument to %s", argp[-2]);		    continue;		case SERVSW:		    if (!(serversw = *argp++) || *serversw == '-')			adios (NULLCP, "missing argument to %s", argp[-2]);		    continue;#ifdef X400                case MTSSW:                    if (!(mts = *argp++) || *mts == '-')                        adios (NULLCP, "missing argument to %s", argp[-2]);                    argxmts = get_mts_val (mts);                    if (argxmts == NONEMTS)                        adios (NULLCP, "unknown mts");                    mts_arg = argxmts;                    continue;                case NOTESW:                    note++;                    continue;#endif X400		case SNOOPSW:		    snoop++;		    continue;#endif	SENDMTS		case FILLSW:#ifdef	WP		    if (!(fill_in = *argp++) || *fill_in == '-')

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -