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