1 /* 2 ** SENDMAIL.H -- Global definitions for sendmail. 3 ** 4 ** @(#)sendmail.h 3.24 08/17/81 5 */ 6 7 8 9 10 # include "useful.h" 11 12 /* 13 ** Manifest constants. 14 */ 15 16 # define MAXLINE 256 /* maximum line length */ 17 # define MAXNAME 128 /* maximum length of a name */ 18 # define MAXFIELD 2500 /* maximum total length of a header field */ 19 # define MAXPV 40 /* maximum # of parms to mailers */ 20 # define MAXHOP 30 /* maximum value of HopCount */ 21 # define MAXATOM 15 /* max atoms per address */ 22 # define MAXMAILERS 10 /* maximum mailers known to system */ 23 # define ALIASFILE "/usr/lib/aliases" /* location of alias file */ 24 # define CONFFILE "/usr/lib/sendmail.cf" /* configuration file */ 25 26 27 28 29 30 31 /* 32 ** Address structure. 33 ** Addresses are stored internally in this structure. 34 */ 35 36 struct address 37 { 38 char *q_paddr; /* the printname for the address */ 39 char *q_user; /* user name */ 40 char *q_host; /* host name */ 41 short q_mailer; /* mailer to use */ 42 short q_rmailer; /* real mailer (before mapping) */ 43 u_short q_flags; /* status flags, see below */ 44 char *q_home; /* home dir (local mailer only) */ 45 struct address *q_next; /* chain */ 46 }; 47 48 typedef struct address ADDRESS; 49 50 # define QDONTSEND 000001 /* don't send to this address */ 51 # define QBADADDR 000002 /* this address is verified bad */ 52 53 54 55 56 57 /* 58 ** Mailer definition structure. 59 ** Every mailer known to the system is declared in this 60 ** structure. It defines the pathname of the mailer, some 61 ** flags associated with it, and the argument vector to 62 ** pass to it. The flags are defined in conf.c 63 ** 64 ** The host map is a list of lists of strings. Within each 65 ** list, any host is mapped to the last host in the list. 66 ** This allows multiple names, as well as doing clever 67 ** mail grouping in point-to-point networks. Note: this 68 ** is only used internally, so the apparent host is still 69 ** kept around. 70 ** 71 ** The argument vector is expanded before actual use. Every- 72 ** thing is passed through except for things starting with "$". 73 ** "$x" defines some interpolation, as described in conf.c 74 ** "$x" where x is unknown expands to "x", so use "$$" to get "$". 75 */ 76 77 struct mailer 78 { 79 char *m_name; /* symbolic name of this mailer */ 80 char *m_mailer; /* pathname of the mailer to use */ 81 u_long m_flags; /* status flags, see below */ 82 short m_badstat; /* the status code to use on unknown error */ 83 char *m_from; /* pattern for From: header */ 84 char **m_argv; /* template argument vector */ 85 ADDRESS *m_sendq; /* list of addresses to send to */ 86 }; 87 88 typedef struct mailer MAILER; 89 90 # define M_FOPT 000001 /* mailer takes picky -f flag */ 91 # define M_ROPT 000002 /* mailer takes picky -r flag */ 92 # define M_QUIET 000004 /* don't print error on bad status */ 93 # define M_RESTR 000010 /* must be daemon to execute */ 94 # define M_NHDR 000020 /* don't insert From line */ 95 # define M_NOHOST 000040 /* ignore host in comparisons */ 96 # define M_STRIPQ 000100 /* strip quote characters from user/host */ 97 # define M_MUSER 000200 /* mailer can handle multiple users at once */ 98 # define M_NEEDFROM 000400 /* need arpa-style From: line */ 99 # define M_NEEDDATE 001000 /* need arpa-style Date: line */ 100 # define M_MSGID 002000 /* need Message-Id: field */ 101 # define M_FINAL 004000 /* mailing will effect final delivery */ 102 # define M_USR_UPPER 010000 /* preserve user case distinction */ 103 # define M_HST_UPPER 020000 /* preserve host case distinction */ 104 # define M_FULLNAME 040000 /* want Full-Name field */ 105 106 # define M_ARPAFMT (M_NEEDDATE|M_NEEDFROM|M_NEEDDATE) 107 108 extern MAILER *Mailer[]; 109 110 /* special mailer numbers */ 111 # define M_LOCAL 0 /* local mailer */ 112 # define M_PROG 1 /* program mailer */ 113 /* mailers from 2 on are arbitrary */ 114 115 116 117 /* 118 ** Header structure. 119 ** This structure is used internally to store header items. 120 */ 121 122 struct header 123 { 124 char *h_field; /* the name of the field */ 125 char *h_value; /* the value of that field */ 126 struct header *h_link; /* the next header */ 127 u_short h_flags; /* status bits, see below */ 128 u_long h_mflags; /* m_flags bits needed */ 129 }; 130 131 typedef struct header HDR; 132 133 extern HDR *Header; /* head of header list */ 134 135 /* 136 ** Header information structure. 137 ** Defined in conf.c, this struct declares the header fields 138 ** that have some magic meaning. 139 */ 140 141 struct hdrinfo 142 { 143 char *hi_field; /* the name of the field */ 144 u_short hi_flags; /* status bits, see below */ 145 u_short hi_mflags; /* m_flags needed for this field */ 146 }; 147 148 extern struct hdrinfo HdrInfo[]; 149 150 /* bits for h_flags and hi_flags */ 151 # define H_EOH 00001 /* this field terminates header */ 152 # define H_DELETE 00002 /* don't send this field */ 153 # define H_DEFAULT 00004 /* if another value is found, drop this */ 154 # define H_USED 00010 /* indicates that this has been output */ 155 # define H_CHECK 00020 /* check h_mflags against m_flags */ 156 # define H_ACHECK 00040 /* ditto, but always (not just default) */ 157 # define H_FORCE 00100 /* force this field, even if default */ 158 159 160 /* 161 ** Rewrite rules. 162 */ 163 164 struct rewrite 165 { 166 char **r_lhs; /* pattern match */ 167 char **r_rhs; /* substitution value */ 168 struct rewrite *r_next;/* next in chain */ 169 }; 170 171 extern struct rewrite *RewriteRules[]; 172 173 # define MATCHANY '\020' /* match one or more tokens */ 174 # define MATCHONE '\021' /* match exactly one token */ 175 # define MATCHCLASS '\022' /* match one token in a class */ 176 177 # define CANONNET '\025' /* canonical net, next token */ 178 # define CANONHOST '\026' /* canonical host, next token */ 179 # define CANONUSER '\027' /* canonical user, next N tokens */ 180 181 182 183 /* 184 ** Symbol table definitions 185 */ 186 187 struct symtab 188 { 189 char *s_name; /* name to be entered */ 190 char s_type; /* general type (see below) */ 191 struct symtab *s_next; /* pointer to next in chain */ 192 union 193 { 194 long sv_class; /* bit-map of word classes */ 195 ADDRESS *sv_addr; /* pointer to address header */ 196 MAILER *sv_mailer; /* pointer to mailer */ 197 char *sv_alias; /* alias */ 198 } s_value; 199 }; 200 201 typedef struct symtab STAB; 202 203 /* symbol types */ 204 # define ST_UNDEF 0 /* undefined type */ 205 # define ST_CLASS 1 /* class map */ 206 # define ST_ADDRESS 2 /* an address in parsed format */ 207 # define ST_MAILER 3 /* a mailer header */ 208 # define ST_ALIAS 4 /* an alias */ 209 210 # define s_class s_value.sv_class 211 # define s_addr s_value.sv_addr 212 # define s_mailer s_value.sv_mailer 213 # define s_alias s_value.sv_alias 214 215 extern STAB *stab(); 216 217 /* opcodes to stab */ 218 # define ST_FIND 0 /* find entry */ 219 # define ST_ENTER 1 /* enter if not there */ 220 221 222 223 224 /* 225 ** Global variables. 226 */ 227 228 extern bool ArpaFmt; /* if set, message is in arpanet fmt */ 229 extern bool FromFlag; /* if set, "From" person is explicit */ 230 extern bool MailBack; /* mail back response on error */ 231 extern bool BerkNet; /* called from BerkNet */ 232 extern bool WriteBack; /* write back response on error */ 233 extern bool NoAlias; /* if set, don't do any aliasing */ 234 extern bool ForceMail; /* if set, mail even if already got a copy */ 235 extern bool MeToo; /* send to the sender also */ 236 extern bool IgnrDot; /* don't let dot end messages */ 237 extern bool SaveFrom; /* save leading "From" lines */ 238 extern bool Verbose; /* set if blow-by-blow desired */ 239 extern int Debug; /* debugging level */ 240 extern int Errors; /* set if errors */ 241 extern int ExitStat; /* exit status code */ 242 extern char InFileName[]; /* input file name */ 243 extern char Transcript[]; /* the transcript file name */ 244 extern ADDRESS From; /* the person it is from */ 245 extern char *To; /* the target person */ 246 extern int HopCount; /* hop count */ 247 extern long CurTime; /* time of this message */ 248 extern char FromLine[]; /* a UNIX-style From line for this message */ 249 extern int AliasLevel; /* depth of aliasing */ 250 251 252 # include <sysexits.h> 253 254 # define setstat(s) { if (ExitStat == EX_OK) ExitStat = s; } 255 256 257 /* useful functions */ 258 259 extern char *newstr(); 260 extern ADDRESS *parse(); 261 extern char *xalloc(); 262 extern char *expand(); 263 extern bool sameaddr(); 264