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