1 /* 2 ** SENDMAIL.H -- Global definitions for sendmail. 3 ** 4 ** @(#)sendmail.h 3.35 08/31/81 5 */ 6 7 8 9 10 # include <stdio.h> 11 # include <ctype.h> 12 # include "useful.h" 13 14 /* 15 ** Configuration constants. 16 ** There shouldn't be much need to change these.... 17 */ 18 19 # define MAXLINE 256 /* maximum line length */ 20 # define MAXNAME 128 /* maximum length of a name */ 21 # define MAXFIELD 2500 /* maximum total length of a header field */ 22 # define MAXPV 40 /* maximum # of parms to mailers */ 23 # define MAXHOP 30 /* maximum value of HopCount */ 24 # define MAXATOM 15 /* max atoms per address */ 25 # define MAXMAILERS 10 /* maximum mailers known to system */ 26 27 /* values for ArpaMode -- these are ordered!! */ 28 # define ARPA_NONE 0 /* not in arpanet mode */ 29 # define ARPA_OLD 1 /* in old arpanet mode */ 30 # define ARPA_MAIL 2 /* in regular arpanet mail */ 31 # define ARPA_FILE 3 /* reading over data connection */ 32 33 extern char Arpa_Info[]; /* the message number for Arpanet info */ 34 35 36 37 38 39 40 /* 41 ** Address structure. 42 ** Addresses are stored internally in this structure. 43 */ 44 45 struct address 46 { 47 char *q_paddr; /* the printname for the address */ 48 char *q_user; /* user name */ 49 char *q_host; /* host name */ 50 short q_mailer; /* mailer to use */ 51 short q_rmailer; /* real mailer (before mapping) */ 52 u_short q_flags; /* status flags, see below */ 53 short q_uid; /* user-id of receiver (if known) */ 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_LOCAL 000040 /* delivery is to this host */ 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_USR_UPPER 010000 /* preserve user case distinction */ 111 # define M_HST_UPPER 020000 /* preserve host case distinction */ 112 # define M_FULLNAME 040000 /* want Full-Name field */ 113 114 # define M_ARPAFMT (M_NEEDDATE|M_NEEDFROM|M_NEEDDATE) 115 116 extern MAILER *Mailer[]; 117 118 /* special mailer numbers */ 119 # define MN_LOCAL 0 /* local mailer */ 120 # define MN_PROG 1 /* program mailer */ 121 /* mailers from 2 on are arbitrary */ 122 123 124 125 /* 126 ** Header structure. 127 ** This structure is used internally to store header items. 128 */ 129 130 struct header 131 { 132 char *h_field; /* the name of the field */ 133 char *h_value; /* the value of that field */ 134 struct header *h_link; /* the next header */ 135 u_short h_flags; /* status bits, see below */ 136 u_long h_mflags; /* m_flags bits needed */ 137 }; 138 139 typedef struct header HDR; 140 141 extern HDR *Header; /* head of header list */ 142 143 /* 144 ** Header information structure. 145 ** Defined in conf.c, this struct declares the header fields 146 ** that have some magic meaning. 147 */ 148 149 struct hdrinfo 150 { 151 char *hi_field; /* the name of the field */ 152 u_short hi_flags; /* status bits, see below */ 153 u_short hi_mflags; /* m_flags needed for this field */ 154 }; 155 156 extern struct hdrinfo HdrInfo[]; 157 158 /* bits for h_flags and hi_flags */ 159 # define H_EOH 00001 /* this field terminates header */ 160 # define H_DEFAULT 00004 /* if another value is found, drop this */ 161 # define H_USED 00010 /* indicates that this has been output */ 162 # define H_CHECK 00020 /* check h_mflags against m_flags */ 163 # define H_ACHECK 00040 /* ditto, but always (not just default) */ 164 # define H_FORCE 00100 /* force this field, even if default */ 165 # define H_ADDR 00200 /* this field contains addresses */ 166 167 168 /* 169 ** Rewrite rules. 170 */ 171 172 struct rewrite 173 { 174 char **r_lhs; /* pattern match */ 175 char **r_rhs; /* substitution value */ 176 struct rewrite *r_next;/* next in chain */ 177 }; 178 179 extern struct rewrite *RewriteRules[]; 180 181 # define MATCHANY '\020' /* match one or more tokens */ 182 # define MATCHONE '\021' /* match exactly one token */ 183 # define MATCHCLASS '\022' /* match one token in a class */ 184 185 # define CANONNET '\025' /* canonical net, next token */ 186 # define CANONHOST '\026' /* canonical host, next token */ 187 # define CANONUSER '\027' /* canonical user, next N tokens */ 188 189 190 191 /* 192 ** Symbol table definitions 193 */ 194 195 struct symtab 196 { 197 char *s_name; /* name to be entered */ 198 char s_type; /* general type (see below) */ 199 struct symtab *s_next; /* pointer to next in chain */ 200 union 201 { 202 long sv_class; /* bit-map of word classes */ 203 ADDRESS *sv_addr; /* pointer to address header */ 204 MAILER *sv_mailer; /* pointer to mailer */ 205 char *sv_alias; /* alias */ 206 } s_value; 207 }; 208 209 typedef struct symtab STAB; 210 211 /* symbol types */ 212 # define ST_UNDEF 0 /* undefined type */ 213 # define ST_CLASS 1 /* class map */ 214 # define ST_ADDRESS 2 /* an address in parsed format */ 215 # define ST_MAILER 3 /* a mailer header */ 216 # define ST_ALIAS 4 /* an alias */ 217 218 # define s_class s_value.sv_class 219 # define s_addr s_value.sv_addr 220 # define s_mailer s_value.sv_mailer 221 # define s_alias s_value.sv_alias 222 223 extern STAB *stab(); 224 225 /* opcodes to stab */ 226 # define ST_FIND 0 /* find entry */ 227 # define ST_ENTER 1 /* enter if not there */ 228 229 230 231 232 /* 233 ** Statistics structure. 234 */ 235 236 struct statistics 237 { 238 time_t stat_itime; /* file initialization time */ 239 short stat_size; /* size of this structure */ 240 long stat_nf[MAXMAILERS]; /* # msgs from each mailer */ 241 long stat_bf[MAXMAILERS]; /* kbytes from each mailer */ 242 long stat_nt[MAXMAILERS]; /* # msgs to each mailer */ 243 long stat_bt[MAXMAILERS]; /* kbytes to each mailer */ 244 }; 245 246 extern struct statistics Stat; 247 extern long kbytes(); /* for _bf, _bt */ 248 249 250 251 252 /* 253 ** Global variables. 254 */ 255 256 extern bool FromFlag; /* if set, "From" person is explicit */ 257 extern bool MailBack; /* mail back response on error */ 258 extern bool BerkNet; /* called from BerkNet */ 259 extern bool WriteBack; /* write back response on error */ 260 extern bool NoAlias; /* if set, don't do any aliasing */ 261 extern bool ForceMail; /* if set, mail even if already got a copy */ 262 extern bool MeToo; /* send to the sender also */ 263 extern bool IgnrDot; /* don't let dot end messages */ 264 extern bool SaveFrom; /* save leading "From" lines */ 265 extern bool Verbose; /* set if blow-by-blow desired */ 266 extern bool GrabTo; /* if set, get recipients from msg */ 267 extern bool DontSend; /* mark recipients as QDONTSEND */ 268 extern int Debug; /* debugging level */ 269 extern int Errors; /* set if errors */ 270 extern int ExitStat; /* exit status code */ 271 extern int ArpaMode; /* ARPANET handling mode */ 272 extern long MsgSize; /* size of the message in bytes */ 273 extern char InFileName[]; /* input file name */ 274 extern char Transcript[]; /* the transcript file name */ 275 extern FILE *TempFile; /* mail temp file */ 276 extern ADDRESS From; /* the person it is from */ 277 extern char *To; /* the target person */ 278 extern int HopCount; /* hop count */ 279 extern long CurTime; /* time of this message */ 280 extern int AliasLevel; /* depth of aliasing */ 281 282 283 # include <sysexits.h> 284 285 # define setstat(s) { if (ExitStat == EX_OK) ExitStat = s; } 286 287 288 /* useful functions */ 289 290 extern char *newstr(); 291 extern ADDRESS *parse(); 292 extern char *xalloc(); 293 extern char *expand(); 294 extern bool sameaddr(); 295