1*295Seric /* 2*295Seric ** DELIVERMAIL.H -- Global definitions for delivermail. 3*295Seric ** 4*295Seric ** Most of these are actually allocated in globals.c 5*295Seric ** 6*295Seric ** History: 7*295Seric ** 12/26/79 -- written. 8*295Seric */ 9*295Seric 10*295Seric 11*295Seric 12*295Seric 13*295Seric /* 14*295Seric ** Manifest constants. 15*295Seric */ 16*295Seric 17*295Seric # define MAXLINE 256 /* maximum line length */ 18*295Seric # define MAXNAME 128 /* maximum length of a name */ 19*295Seric # define MAXPV 15 /* maximum # of parms to mailers */ 20*295Seric # define MAXHOP 30 /* maximum value of HopCount */ 21*295Seric 22*295Seric 23*295Seric 24*295Seric 25*295Seric 26*295Seric /* 27*295Seric ** Mailer definition structure. 28*295Seric ** Every mailer known to the system is declared in this 29*295Seric ** structure. It defines the pathname of the mailer, some 30*295Seric ** flags associated with it, and the argument vector to 31*295Seric ** pass to it. 32*295Seric ** 33*295Seric ** The flags are as follows: 34*295Seric ** M_FOPT -- if set, the mailer has a picky "-f" 35*295Seric ** option. In this mode, the mailer will only 36*295Seric ** accept the "-f" option if the sender is 37*295Seric ** actually "root", "network", and possibly 38*295Seric ** (but not necessarily) if the -f argument 39*295Seric ** matches the real sender. The effect is 40*295Seric ** that if the "-f" option is given to 41*295Seric ** delivermail then it will be passed through 42*295Seric ** (as arguments 1 & 2) to the mailer. 43*295Seric ** M_ROPT -- identical to M_FOPT, except uses -r instead. 44*295Seric ** UGH! 45*295Seric ** M_QUIET -- if set, don't print a message if the mailer 46*295Seric ** returns bad status. 47*295Seric ** M_RESTR -- if set, this mailer is restricted to use 48*295Seric ** by "daemon"; otherwise, we do a 49*295Seric ** setuid(getuid()) before calling the mailer. 50*295Seric ** M_HDR -- if set, the mailer wants us to insert a 51*295Seric ** UNIX "From" line before outputting. 52*295Seric ** M_NOHOST -- if set, this mailer doesn't care about 53*295Seric ** the host part (e.g., the local mailer). 54*295Seric ** M_STRIPQ -- if set, strip quote (`"') characters 55*295Seric ** out of parameters as you transliterate them 56*295Seric ** into the argument vector. For example, the 57*295Seric ** local mailer is called directly, so these 58*295Seric ** should be stripped, but the program-mailer 59*295Seric ** (i.e., csh) should leave them in. 60*295Seric ** 61*295Seric ** The argument vector is expanded before actual use. Every- 62*295Seric ** thing is passed through except for things starting with "$". 63*295Seric ** "$x" defines some interpolation, as defined by x: 64*295Seric ** $f The "from" person. 65*295Seric ** $h The host being sent to. 66*295Seric ** $u The user being sent to. 67*295Seric ** $c The current hop count. 68*295Seric ** "$x" where x is unknown expands to "x", so use "$$" to get "$". 69*295Seric */ 70*295Seric 71*295Seric struct mailer 72*295Seric { 73*295Seric char *m_mailer; /* pathname of the mailer to use */ 74*295Seric short m_flags; /* status flags, see below */ 75*295Seric short m_badstat; /* the status code to use on unknown error */ 76*295Seric char **m_local; /* list of local names for this host */ 77*295Seric char *m_argv[MAXPV]; /* template argument vector */ 78*295Seric }; 79*295Seric 80*295Seric # define M_FOPT 0001 /* mailer takes picky -f flag */ 81*295Seric # define M_ROPT 0002 /* mailer takes picky -r flag */ 82*295Seric # define M_QUIET 0004 /* don't print error on bad status */ 83*295Seric # define M_RESTR 0010 /* must be daemon to execute */ 84*295Seric # define M_HDR 0020 /* insert From line */ 85*295Seric # define M_NOHOST 0040 /* ignore host in comparisons */ 86*295Seric # define M_STRIPQ 0100 /* strip quote characters from user/host */ 87*295Seric 88*295Seric extern struct mailer Mailer[]; 89*295Seric 90*295Seric 91*295Seric /* 92*295Seric ** Address structure. 93*295Seric ** Addresses are stored internally in this structure. 94*295Seric */ 95*295Seric 96*295Seric struct address 97*295Seric { 98*295Seric char *q_paddr; /* the printname for the address */ 99*295Seric char *q_user; /* user name */ 100*295Seric char *q_host; /* host name */ 101*295Seric struct mailer *q_mailer; /* mailer to use */ 102*295Seric struct address *q_next; /* chain */ 103*295Seric struct address *q_prev; /* back pointer */ 104*295Seric }; 105*295Seric 106*295Seric typedef struct address addrq; 107*295Seric 108*295Seric /* some other primitives */ 109*295Seric # define nxtinq(q) ((q)->q_next) 110*295Seric # define clearq(q) (q)->q_next = (q)->q_prev = NULL 111*295Seric 112*295Seric extern addrq SendQ; /* queue of people to send to */ 113*295Seric extern addrq AliasQ; /* queue of people that are aliases */ 114*295Seric 115*295Seric 116*295Seric /* 117*295Seric ** Parse structure. 118*295Seric ** This table drives the parser which determines the network 119*295Seric ** to send the mail to. 120*295Seric */ 121*295Seric 122*295Seric struct parsetab 123*295Seric { 124*295Seric char p_char; /* trigger character */ 125*295Seric char p_mailer; /* the index of the mailer to call */ 126*295Seric short p_flags; /* see below */ 127*295Seric char *p_arg; /* extra info needed for some flags */ 128*295Seric }; 129*295Seric 130*295Seric # define P_MAP 0001 /* map p_char -> p_arg[0] */ 131*295Seric # define P_HLAST 0002 /* host is last, & right associative */ 132*295Seric # define P_ONE 0004 /* can only be one p_char in addr */ 133*295Seric # define P_MOVE 0010 /* send untouched to host p_arg */ 134*295Seric # define P_USR_UPPER 0020 /* don't map UPPER->lower in user names */ 135*295Seric # define P_HST_UPPER 0040 /* don't map UPPER->lower in host names */ 136*295Seric 137*295Seric 138*295Seric 139*295Seric 140*295Seric /* 141*295Seric ** Global variables. 142*295Seric */ 143*295Seric 144*295Seric extern char ArpaFmt; /* if set, message is in arpanet fmt */ 145*295Seric extern char FromFlag; /* if set, "From" person is explicit */ 146*295Seric extern char Debug; /* if set, debugging info */ 147*295Seric extern char MailBack; /* mail back response on error */ 148*295Seric extern char EchoBack; /* echo the message on error */ 149*295Seric extern char WriteBack; /* write back response on error */ 150*295Seric extern char NoAlias; /* if set, don't do any aliasing */ 151*295Seric extern char ForceMail; /* if set, mail even if already got a copy */ 152*295Seric extern char MeToo; /* send to the sender also */ 153*295Seric extern char Error; /* set if errors */ 154*295Seric extern int ExitStat; /* exit status code */ 155*295Seric extern char InFileName[]; /* input file name */ 156*295Seric extern char Transcript[]; /* the transcript file name */ 157*295Seric extern addrq From; /* the person it is from */ 158*295Seric extern char *To; /* the target person */ 159*295Seric extern int HopCount; /* hop count */ 160*295Seric 161*295Seric 162*295Seric # include <sysexits.h> 163*295Seric 164*295Seric # define flagset(bits, word) ((bits) & (word)) 165*295Seric # define setstat(s) { if (ExitStat == EX_OK) ExitStat = s; } 166*295Seric 167*295Seric # include "useful.h" 168*295Seric 169*295Seric # define BADMAIL YES /* mail doesn't know about new returncodes */ 170