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