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