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