1295Seric /* 23313Seric ** SENDMAIL.H -- Global definitions for sendmail. 3295Seric ** 4*4317Seric ** @(#)sendmail.h 3.37 09/06/81 5295Seric */ 6295Seric 7295Seric 8295Seric 9295Seric 104183Seric # include <stdio.h> 114183Seric # include <ctype.h> 121390Seric # include "useful.h" 131390Seric 14295Seric /* 154284Seric ** Configuration constants. 164284Seric ** There shouldn't be much need to change these.... 17295Seric */ 18295Seric 19295Seric # define MAXLINE 256 /* maximum line length */ 20295Seric # define MAXNAME 128 /* maximum length of a name */ 211379Seric # define MAXFIELD 2500 /* maximum total length of a header field */ 223234Seric # define MAXPV 40 /* maximum # of parms to mailers */ 23295Seric # define MAXHOP 30 /* maximum value of HopCount */ 243153Seric # define MAXATOM 15 /* max atoms per address */ 254094Seric # define MAXMAILERS 10 /* maximum mailers known to system */ 26295Seric 274162Seric /* values for ArpaMode -- these are ordered!! */ 284162Seric # define ARPA_NONE 0 /* not in arpanet mode */ 294162Seric # define ARPA_OLD 1 /* in old arpanet mode */ 304162Seric # define ARPA_MAIL 2 /* in regular arpanet mail */ 314162Seric # define ARPA_FILE 3 /* reading over data connection */ 32295Seric 334167Seric extern char Arpa_Info[]; /* the message number for Arpanet info */ 34295Seric 35295Seric 36295Seric 373190Seric 384162Seric 394167Seric 40295Seric /* 413190Seric ** Address structure. 423190Seric ** Addresses are stored internally in this structure. 433190Seric */ 443190Seric 453190Seric struct address 463190Seric { 473190Seric char *q_paddr; /* the printname for the address */ 483190Seric char *q_user; /* user name */ 493190Seric char *q_host; /* host name */ 503190Seric short q_mailer; /* mailer to use */ 513190Seric short q_rmailer; /* real mailer (before mapping) */ 524149Seric u_short q_flags; /* status flags, see below */ 534213Seric short q_uid; /* user-id of receiver (if known) */ 544079Seric char *q_home; /* home dir (local mailer only) */ 553190Seric struct address *q_next; /* chain */ 563190Seric }; 573190Seric 583190Seric typedef struct address ADDRESS; 593190Seric 603190Seric # define QDONTSEND 000001 /* don't send to this address */ 614068Seric # define QBADADDR 000002 /* this address is verified bad */ 623190Seric 633190Seric 643190Seric 653190Seric 663190Seric 673190Seric /* 68295Seric ** Mailer definition structure. 69295Seric ** Every mailer known to the system is declared in this 70295Seric ** structure. It defines the pathname of the mailer, some 71295Seric ** flags associated with it, and the argument vector to 721390Seric ** pass to it. The flags are defined in conf.c 73295Seric ** 742899Seric ** The host map is a list of lists of strings. Within each 752899Seric ** list, any host is mapped to the last host in the list. 762899Seric ** This allows multiple names, as well as doing clever 772899Seric ** mail grouping in point-to-point networks. Note: this 782899Seric ** is only used internally, so the apparent host is still 792899Seric ** kept around. 802899Seric ** 814171Seric ** The argument vector is expanded before actual use. All 824171Seric ** words except the first are passed through the macro 834171Seric ** processor. 84295Seric */ 85295Seric 86295Seric struct mailer 87295Seric { 883190Seric char *m_name; /* symbolic name of this mailer */ 89295Seric char *m_mailer; /* pathname of the mailer to use */ 904149Seric u_long m_flags; /* status flags, see below */ 91295Seric short m_badstat; /* the status code to use on unknown error */ 922899Seric char *m_from; /* pattern for From: header */ 933049Seric char **m_argv; /* template argument vector */ 943190Seric ADDRESS *m_sendq; /* list of addresses to send to */ 95295Seric }; 96295Seric 974100Seric typedef struct mailer MAILER; 984100Seric 992899Seric # define M_FOPT 000001 /* mailer takes picky -f flag */ 1002899Seric # define M_ROPT 000002 /* mailer takes picky -r flag */ 1012899Seric # define M_QUIET 000004 /* don't print error on bad status */ 1022899Seric # define M_RESTR 000010 /* must be daemon to execute */ 1033190Seric # define M_NHDR 000020 /* don't insert From line */ 1044192Seric # define M_LOCAL 000040 /* delivery is to this host */ 1052899Seric # define M_STRIPQ 000100 /* strip quote characters from user/host */ 1063190Seric # define M_MUSER 000200 /* mailer can handle multiple users at once */ 1072899Seric # define M_NEEDFROM 000400 /* need arpa-style From: line */ 1082899Seric # define M_NEEDDATE 001000 /* need arpa-style Date: line */ 1092899Seric # define M_MSGID 002000 /* need Message-Id: field */ 1103153Seric # define M_USR_UPPER 010000 /* preserve user case distinction */ 1113153Seric # define M_HST_UPPER 020000 /* preserve host case distinction */ 1123390Seric # define M_FULLNAME 040000 /* want Full-Name field */ 113295Seric 114*4317Seric # define M_ARPAFMT (M_NEEDDATE|M_NEEDFROM|M_MSGID) 1152899Seric 1164100Seric extern MAILER *Mailer[]; 117295Seric 1184079Seric /* special mailer numbers */ 1194192Seric # define MN_LOCAL 0 /* local mailer */ 1204192Seric # define MN_PROG 1 /* program mailer */ 1214100Seric /* mailers from 2 on are arbitrary */ 122295Seric 123295Seric 1244079Seric 1252899Seric /* 1262899Seric ** Header structure. 1272899Seric ** This structure is used internally to store header items. 1282899Seric */ 129295Seric 1302899Seric struct header 1312899Seric { 1322899Seric char *h_field; /* the name of the field */ 1332899Seric char *h_value; /* the value of that field */ 1342899Seric struct header *h_link; /* the next header */ 1354149Seric u_short h_flags; /* status bits, see below */ 1364149Seric u_long h_mflags; /* m_flags bits needed */ 1372899Seric }; 138295Seric 1392899Seric typedef struct header HDR; 1402899Seric 1412899Seric extern HDR *Header; /* head of header list */ 1422899Seric 143295Seric /* 1442899Seric ** Header information structure. 1452899Seric ** Defined in conf.c, this struct declares the header fields 1462899Seric ** that have some magic meaning. 1472899Seric */ 1482899Seric 1492899Seric struct hdrinfo 1502899Seric { 1512899Seric char *hi_field; /* the name of the field */ 1524149Seric u_short hi_flags; /* status bits, see below */ 1534149Seric u_short hi_mflags; /* m_flags needed for this field */ 1542899Seric }; 1552899Seric 1562899Seric extern struct hdrinfo HdrInfo[]; 1572899Seric 1582899Seric /* bits for h_flags and hi_flags */ 1593060Seric # define H_EOH 00001 /* this field terminates header */ 1602899Seric # define H_DEFAULT 00004 /* if another value is found, drop this */ 1612899Seric # define H_USED 00010 /* indicates that this has been output */ 1623386Seric # define H_CHECK 00020 /* check h_mflags against m_flags */ 1633390Seric # define H_ACHECK 00040 /* ditto, but always (not just default) */ 1644149Seric # define H_FORCE 00100 /* force this field, even if default */ 1654222Seric # define H_ADDR 00200 /* this field contains addresses */ 1662899Seric 1672899Seric 1683153Seric /* 1693153Seric ** Rewrite rules. 1703153Seric */ 1712899Seric 1723153Seric struct rewrite 1733153Seric { 1743153Seric char **r_lhs; /* pattern match */ 1753153Seric char **r_rhs; /* substitution value */ 1763153Seric struct rewrite *r_next;/* next in chain */ 1773153Seric }; 1782899Seric 1794090Seric extern struct rewrite *RewriteRules[]; 1803153Seric 1814060Seric # define MATCHANY '\020' /* match one or more tokens */ 1824060Seric # define MATCHONE '\021' /* match exactly one token */ 1834060Seric # define MATCHCLASS '\022' /* match one token in a class */ 1843153Seric 1853153Seric # define CANONNET '\025' /* canonical net, next token */ 1863153Seric # define CANONHOST '\026' /* canonical host, next token */ 1873153Seric # define CANONUSER '\027' /* canonical user, next N tokens */ 1883153Seric 1893153Seric 1903153Seric 1914056Seric /* 1924056Seric ** Symbol table definitions 1934056Seric */ 1943153Seric 1954056Seric struct symtab 1964056Seric { 1974056Seric char *s_name; /* name to be entered */ 1984100Seric char s_type; /* general type (see below) */ 1994056Seric struct symtab *s_next; /* pointer to next in chain */ 2004100Seric union 2014100Seric { 2024100Seric long sv_class; /* bit-map of word classes */ 2034100Seric ADDRESS *sv_addr; /* pointer to address header */ 2044100Seric MAILER *sv_mailer; /* pointer to mailer */ 2054100Seric char *sv_alias; /* alias */ 2064100Seric } s_value; 2074056Seric }; 2084056Seric 2094056Seric typedef struct symtab STAB; 2104056Seric 2114100Seric /* symbol types */ 2124100Seric # define ST_UNDEF 0 /* undefined type */ 2134100Seric # define ST_CLASS 1 /* class map */ 2144100Seric # define ST_ADDRESS 2 /* an address in parsed format */ 2154100Seric # define ST_MAILER 3 /* a mailer header */ 2164100Seric # define ST_ALIAS 4 /* an alias */ 2174100Seric 2184100Seric # define s_class s_value.sv_class 2194100Seric # define s_addr s_value.sv_addr 2204100Seric # define s_mailer s_value.sv_mailer 2214100Seric # define s_alias s_value.sv_alias 2224100Seric 2234056Seric extern STAB *stab(); 2244056Seric 2254056Seric /* opcodes to stab */ 2264056Seric # define ST_FIND 0 /* find entry */ 2274056Seric # define ST_ENTER 1 /* enter if not there */ 2284056Seric 2294056Seric 2304056Seric 2314056Seric 2322899Seric /* 2334284Seric ** Statistics structure. 2344284Seric */ 2354284Seric 2364284Seric struct statistics 2374284Seric { 2384284Seric time_t stat_itime; /* file initialization time */ 2394284Seric short stat_size; /* size of this structure */ 2404284Seric long stat_nf[MAXMAILERS]; /* # msgs from each mailer */ 2414284Seric long stat_bf[MAXMAILERS]; /* kbytes from each mailer */ 2424284Seric long stat_nt[MAXMAILERS]; /* # msgs to each mailer */ 2434284Seric long stat_bt[MAXMAILERS]; /* kbytes to each mailer */ 2444284Seric }; 2454284Seric 2464284Seric extern struct statistics Stat; 2474284Seric extern long kbytes(); /* for _bf, _bt */ 2484284Seric 2494284Seric 2504284Seric 2514284Seric 2524284Seric /* 253295Seric ** Global variables. 254295Seric */ 255295Seric 2561390Seric extern bool FromFlag; /* if set, "From" person is explicit */ 2571390Seric extern bool MailBack; /* mail back response on error */ 2581390Seric extern bool BerkNet; /* called from BerkNet */ 2591390Seric extern bool WriteBack; /* write back response on error */ 2601390Seric extern bool NoAlias; /* if set, don't do any aliasing */ 2611390Seric extern bool ForceMail; /* if set, mail even if already got a copy */ 2621390Seric extern bool MeToo; /* send to the sender also */ 2631390Seric extern bool IgnrDot; /* don't let dot end messages */ 2641390Seric extern bool SaveFrom; /* save leading "From" lines */ 2654064Seric extern bool Verbose; /* set if blow-by-blow desired */ 2664222Seric extern bool GrabTo; /* if set, get recipients from msg */ 2674245Seric extern bool DontSend; /* mark recipients as QDONTSEND */ 2684289Seric extern bool NoReturn; /* don't return letter to sender */ 2694073Seric extern int Debug; /* debugging level */ 2701516Seric extern int Errors; /* set if errors */ 271295Seric extern int ExitStat; /* exit status code */ 2724284Seric extern int ArpaMode; /* ARPANET handling mode */ 2734284Seric extern long MsgSize; /* size of the message in bytes */ 274295Seric extern char InFileName[]; /* input file name */ 275295Seric extern char Transcript[]; /* the transcript file name */ 2764183Seric extern FILE *TempFile; /* mail temp file */ 2772979Seric extern ADDRESS From; /* the person it is from */ 278295Seric extern char *To; /* the target person */ 279295Seric extern int HopCount; /* hop count */ 2803190Seric extern long CurTime; /* time of this message */ 2814100Seric extern int AliasLevel; /* depth of aliasing */ 282295Seric 283295Seric 284295Seric # include <sysexits.h> 285295Seric 286295Seric # define setstat(s) { if (ExitStat == EX_OK) ExitStat = s; } 2874085Seric 2884085Seric 2894085Seric /* useful functions */ 2904085Seric 2914085Seric extern char *newstr(); 2924085Seric extern ADDRESS *parse(); 2934085Seric extern char *xalloc(); 2944085Seric extern char *expand(); 2954085Seric extern bool sameaddr(); 296