Commit | Line | Data |
---|---|---|
15637ed4 RG |
1 | /* |
2 | * Copyright (c) 1983 Eric P. Allman | |
6f14531a RG |
3 | * Copyright (c) 1988, 1993 |
4 | * The Regents of the University of California. All rights reserved. | |
15637ed4 RG |
5 | * |
6 | * Redistribution and use in source and binary forms, with or without | |
7 | * modification, are permitted provided that the following conditions | |
8 | * are met: | |
9 | * 1. Redistributions of source code must retain the above copyright | |
10 | * notice, this list of conditions and the following disclaimer. | |
11 | * 2. Redistributions in binary form must reproduce the above copyright | |
12 | * notice, this list of conditions and the following disclaimer in the | |
13 | * documentation and/or other materials provided with the distribution. | |
14 | * 3. All advertising materials mentioning features or use of this software | |
15 | * must display the following acknowledgement: | |
16 | * This product includes software developed by the University of | |
17 | * California, Berkeley and its contributors. | |
18 | * 4. Neither the name of the University nor the names of its contributors | |
19 | * may be used to endorse or promote products derived from this software | |
20 | * without specific prior written permission. | |
21 | * | |
22 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
23 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
24 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
25 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
26 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
27 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
28 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
29 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
30 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
31 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
32 | * SUCH DAMAGE. | |
33 | * | |
69fc843f | 34 | * @(#)sendmail.h 8.26 (Berkeley) 10/31/93 |
15637ed4 RG |
35 | */ |
36 | ||
37 | /* | |
38 | ** SENDMAIL.H -- Global definitions for sendmail. | |
39 | */ | |
40 | ||
41 | # ifdef _DEFINE | |
42 | # define EXTERN | |
43 | # ifndef lint | |
69fc843f | 44 | static char SmailSccsId[] = "@(#)sendmail.h 8.26 10/31/93"; |
6f14531a RG |
45 | # endif |
46 | # else /* _DEFINE */ | |
15637ed4 | 47 | # define EXTERN extern |
6f14531a | 48 | # endif /* _DEFINE */ |
15637ed4 | 49 | |
6f14531a RG |
50 | # include <unistd.h> |
51 | # include <stddef.h> | |
52 | # include <stdlib.h> | |
15637ed4 RG |
53 | # include <stdio.h> |
54 | # include <ctype.h> | |
55 | # include <setjmp.h> | |
6f14531a RG |
56 | # include <sysexits.h> |
57 | # include <string.h> | |
58 | # include <time.h> | |
59 | # include <errno.h> | |
69fc843f | 60 | # include <sys/un.h> |
6f14531a | 61 | |
15637ed4 RG |
62 | # include "conf.h" |
63 | # include "useful.h" | |
64 | ||
65 | # ifdef LOG | |
6f14531a RG |
66 | # include <syslog.h> |
67 | # endif /* LOG */ | |
15637ed4 RG |
68 | |
69 | # ifdef DAEMON | |
15637ed4 | 70 | # include <sys/socket.h> |
6f14531a RG |
71 | # endif |
72 | # ifdef NETINET | |
15637ed4 | 73 | # include <netinet/in.h> |
6f14531a RG |
74 | # endif |
75 | # ifdef NETISO | |
76 | # include <netiso/iso.h> | |
77 | # endif | |
78 | # ifdef NETNS | |
79 | # include <netns/ns.h> | |
80 | # endif | |
81 | # ifdef NETX25 | |
82 | # include <netccitt/x25.h> | |
83 | # endif | |
15637ed4 RG |
84 | |
85 | ||
15637ed4 RG |
86 | |
87 | ||
88 | /* | |
89 | ** Data structure for bit maps. | |
90 | ** | |
91 | ** Each bit in this map can be referenced by an ascii character. | |
92 | ** This is 128 possible bits, or 12 8-bit bytes. | |
93 | */ | |
94 | ||
95 | #define BITMAPBYTES 16 /* number of bytes in a bit map */ | |
96 | #define BYTEBITS 8 /* number of bits in a byte */ | |
97 | ||
98 | /* internal macros */ | |
99 | #define _BITWORD(bit) (bit / (BYTEBITS * sizeof (int))) | |
100 | #define _BITBIT(bit) (1 << (bit % (BYTEBITS * sizeof (int)))) | |
101 | ||
102 | typedef int BITMAP[BITMAPBYTES / sizeof (int)]; | |
103 | ||
104 | /* test bit number N */ | |
105 | #define bitnset(bit, map) ((map)[_BITWORD(bit)] & _BITBIT(bit)) | |
106 | ||
107 | /* set bit number N */ | |
108 | #define setbitn(bit, map) (map)[_BITWORD(bit)] |= _BITBIT(bit) | |
109 | ||
110 | /* clear bit number N */ | |
111 | #define clrbitn(bit, map) (map)[_BITWORD(bit)] &= ~_BITBIT(bit) | |
112 | ||
113 | /* clear an entire bit map */ | |
114 | #define clrbitmap(map) bzero((char *) map, BITMAPBYTES) | |
115 | \f/* | |
116 | ** Address structure. | |
117 | ** Addresses are stored internally in this structure. | |
118 | */ | |
119 | ||
120 | struct address | |
121 | { | |
122 | char *q_paddr; /* the printname for the address */ | |
123 | char *q_user; /* user name */ | |
124 | char *q_ruser; /* real user name, or NULL if q_user */ | |
125 | char *q_host; /* host name */ | |
126 | struct mailer *q_mailer; /* mailer to use */ | |
127 | u_short q_flags; /* status flags, see below */ | |
6f14531a RG |
128 | uid_t q_uid; /* user-id of receiver (if known) */ |
129 | gid_t q_gid; /* group-id of receiver (if known) */ | |
15637ed4 RG |
130 | char *q_home; /* home dir (local mailer only) */ |
131 | char *q_fullname; /* full name if known */ | |
132 | struct address *q_next; /* chain */ | |
133 | struct address *q_alias; /* address this results from */ | |
6f14531a | 134 | char *q_owner; /* owner of q_alias */ |
15637ed4 RG |
135 | struct address *q_tchain; /* temporary use chain */ |
136 | time_t q_timeout; /* timeout for this address */ | |
137 | }; | |
138 | ||
139 | typedef struct address ADDRESS; | |
140 | ||
141 | # define QDONTSEND 000001 /* don't send to this address */ | |
142 | # define QBADADDR 000002 /* this address is verified bad */ | |
143 | # define QGOODUID 000004 /* the q_uid q_gid fields are good */ | |
144 | # define QPRIMARY 000010 /* set from argv */ | |
145 | # define QQUEUEUP 000020 /* queue for later transmission */ | |
146 | # define QSENT 000040 /* has been successfully delivered */ | |
6f14531a RG |
147 | # define QNOTREMOTE 000100 /* not an address for remote forwarding */ |
148 | # define QSELFREF 000200 /* this address references itself */ | |
149 | # define QVERIFIED 000400 /* verified, but not expanded */ | |
3a363396 | 150 | # define QREPORT 001000 /* report this address in return message */ |
d747e748 JH |
151 | |
152 | # define NULLADDR ((ADDRESS *) NULL) | |
15637ed4 RG |
153 | \f/* |
154 | ** Mailer definition structure. | |
155 | ** Every mailer known to the system is declared in this | |
156 | ** structure. It defines the pathname of the mailer, some | |
157 | ** flags associated with it, and the argument vector to | |
158 | ** pass to it. The flags are defined in conf.c | |
159 | ** | |
160 | ** The argument vector is expanded before actual use. All | |
161 | ** words except the first are passed through the macro | |
162 | ** processor. | |
163 | */ | |
164 | ||
165 | struct mailer | |
166 | { | |
167 | char *m_name; /* symbolic name of this mailer */ | |
168 | char *m_mailer; /* pathname of the mailer to use */ | |
169 | BITMAP m_flags; /* status flags, see below */ | |
170 | short m_mno; /* mailer number internally */ | |
171 | char **m_argv; /* template argument vector */ | |
6f14531a RG |
172 | short m_sh_rwset; /* rewrite set: sender header addresses */ |
173 | short m_se_rwset; /* rewrite set: sender envelope addresses */ | |
174 | short m_rh_rwset; /* rewrite set: recipient header addresses */ | |
175 | short m_re_rwset; /* rewrite set: recipient envelope addresses */ | |
15637ed4 RG |
176 | char *m_eol; /* end of line string */ |
177 | long m_maxsize; /* size limit on message to this mailer */ | |
6f14531a RG |
178 | int m_linelimit; /* max # characters per line */ |
179 | char *m_execdir; /* directory to chdir to before execv */ | |
15637ed4 RG |
180 | }; |
181 | ||
182 | typedef struct mailer MAILER; | |
183 | ||
184 | /* bits for m_flags */ | |
6f14531a RG |
185 | # define M_ESMTP 'a' /* run Extended SMTP protocol */ |
186 | # define M_BLANKEND 'b' /* ensure blank line at end of message */ | |
187 | # define M_NOCOMMENT 'c' /* don't include comment part of address */ | |
15637ed4 | 188 | # define M_CANONICAL 'C' /* make addresses canonical "u@dom" */ |
6f14531a | 189 | /* 'D' /* CF: include Date: */ |
15637ed4 RG |
190 | # define M_EXPENSIVE 'e' /* it costs to use this mailer.... */ |
191 | # define M_ESCFROM 'E' /* escape From lines to >From */ | |
192 | # define M_FOPT 'f' /* mailer takes picky -f flag */ | |
6f14531a RG |
193 | /* 'F' /* CF: include From: or Resent-From: */ |
194 | # define M_NO_NULL_FROM 'g' /* sender of errors should be $g */ | |
15637ed4 | 195 | # define M_HST_UPPER 'h' /* preserve host case distinction */ |
d747e748 | 196 | # define M_PREHEAD 'H' /* MAIL11V3: preview headers */ |
15637ed4 | 197 | # define M_INTERNAL 'I' /* SMTP to another sendmail site */ |
6f14531a | 198 | # define M_LOCALMAILER 'l' /* delivery is to this host */ |
15637ed4 RG |
199 | # define M_LIMITS 'L' /* must enforce SMTP line limits */ |
200 | # define M_MUSER 'm' /* can handle multiple users at once */ | |
6f14531a | 201 | /* 'M' /* CF: include Message-Id: */ |
15637ed4 | 202 | # define M_NHDR 'n' /* don't insert From line */ |
d747e748 | 203 | # define M_MANYSTATUS 'N' /* MAIL11V3: DATA returns multi-status */ |
15637ed4 | 204 | # define M_FROMPATH 'p' /* use reverse-path in MAIL FROM: */ |
6f14531a | 205 | /* 'P' /* CF: include Return-Path: */ |
15637ed4 RG |
206 | # define M_ROPT 'r' /* mailer takes picky -r flag */ |
207 | # define M_SECURE_PORT 'R' /* try to send on a reserved TCP port */ | |
208 | # define M_STRIPQ 's' /* strip quote chars from user/host */ | |
209 | # define M_RESTR 'S' /* must be daemon to execute */ | |
210 | # define M_USR_UPPER 'u' /* preserve user case distinction */ | |
211 | # define M_UGLYUUCP 'U' /* this wants an ugly UUCP from line */ | |
6f14531a RG |
212 | /* 'V' /* UIUC: !-relativize all addresses */ |
213 | /* 'x' /* CF: include Full-Name: */ | |
15637ed4 | 214 | # define M_XDOT 'X' /* use hidden-dot algorithm */ |
6f14531a | 215 | # define M_7BITS '7' /* use 7-bit path */ |
15637ed4 RG |
216 | |
217 | EXTERN MAILER *Mailer[MAXMAILERS+1]; | |
218 | ||
219 | EXTERN MAILER *LocalMailer; /* ptr to local mailer */ | |
220 | EXTERN MAILER *ProgMailer; /* ptr to program mailer */ | |
6f14531a RG |
221 | EXTERN MAILER *FileMailer; /* ptr to *file* mailer */ |
222 | EXTERN MAILER *InclMailer; /* ptr to *include* mailer */ | |
15637ed4 RG |
223 | \f/* |
224 | ** Header structure. | |
225 | ** This structure is used internally to store header items. | |
226 | */ | |
227 | ||
228 | struct header | |
229 | { | |
230 | char *h_field; /* the name of the field */ | |
231 | char *h_value; /* the value of that field */ | |
232 | struct header *h_link; /* the next header */ | |
233 | u_short h_flags; /* status bits, see below */ | |
234 | BITMAP h_mflags; /* m_flags bits needed */ | |
235 | }; | |
236 | ||
237 | typedef struct header HDR; | |
238 | ||
239 | /* | |
240 | ** Header information structure. | |
241 | ** Defined in conf.c, this struct declares the header fields | |
242 | ** that have some magic meaning. | |
243 | */ | |
244 | ||
245 | struct hdrinfo | |
246 | { | |
247 | char *hi_field; /* the name of the field */ | |
248 | u_short hi_flags; /* status bits, see below */ | |
249 | }; | |
250 | ||
251 | extern struct hdrinfo HdrInfo[]; | |
252 | ||
253 | /* bits for h_flags and hi_flags */ | |
254 | # define H_EOH 00001 /* this field terminates header */ | |
255 | # define H_RCPT 00002 /* contains recipient addresses */ | |
256 | # define H_DEFAULT 00004 /* if another value is found, drop this */ | |
257 | # define H_RESENT 00010 /* this address is a "Resent-..." address */ | |
258 | # define H_CHECK 00020 /* check h_mflags against m_flags */ | |
259 | # define H_ACHECK 00040 /* ditto, but always (not just default) */ | |
260 | # define H_FORCE 00100 /* force this field, even if default */ | |
261 | # define H_TRACE 00200 /* this field contains trace information */ | |
262 | # define H_FROM 00400 /* this is a from-type field */ | |
263 | # define H_VALID 01000 /* this field has a validated value */ | |
6f14531a RG |
264 | # define H_RECEIPTTO 02000 /* this field has return receipt info */ |
265 | # define H_ERRORSTO 04000 /* this field has error address info */ | |
15637ed4 RG |
266 | \f/* |
267 | ** Envelope structure. | |
268 | ** This structure defines the message itself. There is usually | |
269 | ** only one of these -- for the message that we originally read | |
270 | ** and which is our primary interest -- but other envelopes can | |
271 | ** be generated during processing. For example, error messages | |
272 | ** will have their own envelope. | |
273 | */ | |
274 | ||
6f14531a RG |
275 | # define ENVELOPE struct envelope |
276 | ||
277 | ENVELOPE | |
15637ed4 RG |
278 | { |
279 | HDR *e_header; /* head of header list */ | |
280 | long e_msgpriority; /* adjusted priority of this message */ | |
281 | time_t e_ctime; /* time message appeared in the queue */ | |
282 | char *e_to; /* the target person */ | |
283 | char *e_receiptto; /* return receipt address */ | |
284 | ADDRESS e_from; /* the person it is from */ | |
6f14531a | 285 | char *e_sender; /* e_from.q_paddr w comments stripped */ |
15637ed4 RG |
286 | char **e_fromdomain; /* the domain part of the sender */ |
287 | ADDRESS *e_sendqueue; /* list of message recipients */ | |
288 | ADDRESS *e_errorqueue; /* the queue for error responses */ | |
289 | long e_msgsize; /* size of the message in bytes */ | |
290 | int e_nrcpts; /* number of recipients */ | |
291 | short e_class; /* msg class (priority, junk, etc.) */ | |
292 | short e_flags; /* flags, see below */ | |
293 | short e_hopcount; /* number of times processed */ | |
6f14531a RG |
294 | short e_nsent; /* number of sends since checkpoint */ |
295 | short e_sendmode; /* message send mode */ | |
296 | short e_errormode; /* error return mode */ | |
297 | int (*e_puthdr)__P((FILE *, MAILER *, ENVELOPE *)); | |
298 | /* function to put header of message */ | |
299 | int (*e_putbody)__P((FILE *, MAILER *, ENVELOPE *, char *)); | |
300 | /* function to put body of message */ | |
15637ed4 RG |
301 | struct envelope *e_parent; /* the message this one encloses */ |
302 | struct envelope *e_sibling; /* the next envelope of interest */ | |
6f14531a | 303 | char *e_bodytype; /* type of message body */ |
15637ed4 RG |
304 | char *e_df; /* location of temp file */ |
305 | FILE *e_dfp; /* temporary file */ | |
306 | char *e_id; /* code for this entry in queue */ | |
307 | FILE *e_xfp; /* transcript file */ | |
6f14531a | 308 | FILE *e_lockfp; /* the lock file for this message */ |
15637ed4 | 309 | char *e_message; /* error message */ |
6f14531a RG |
310 | char *e_statmsg; /* stat msg (changes per delivery) */ |
311 | char *e_msgboundary; /* MIME-style message part boundary */ | |
d747e748 | 312 | char *e_origrcpt; /* original recipient (one only) */ |
15637ed4 RG |
313 | char *e_macro[128]; /* macro definitions */ |
314 | }; | |
315 | ||
15637ed4 RG |
316 | /* values for e_flags */ |
317 | #define EF_OLDSTYLE 000001 /* use spaces (not commas) in hdrs */ | |
318 | #define EF_INQUEUE 000002 /* this message is fully queued */ | |
15637ed4 RG |
319 | #define EF_CLRQUEUE 000010 /* disk copy is no longer needed */ |
320 | #define EF_SENDRECEIPT 000020 /* send a return receipt */ | |
321 | #define EF_FATALERRS 000040 /* fatal errors occured */ | |
322 | #define EF_KEEPQUEUE 000100 /* keep queue files always */ | |
323 | #define EF_RESPONSE 000200 /* this is an error or return receipt */ | |
324 | #define EF_RESENT 000400 /* this message is being forwarded */ | |
6f14531a RG |
325 | #define EF_VRFYONLY 001000 /* verify only (don't expand aliases) */ |
326 | #define EF_WARNING 002000 /* warning message has been sent */ | |
327 | #define EF_QUEUERUN 004000 /* this envelope is from queue */ | |
d747e748 JH |
328 | #define EF_GLOBALERRS 010000 /* treat errors as global */ |
329 | #define EF_PM_NOTIFY 020000 /* send return mail to postmaster */ | |
330 | #define EF_METOO 040000 /* send to me too */ | |
15637ed4 RG |
331 | |
332 | EXTERN ENVELOPE *CurEnv; /* envelope currently being processed */ | |
333 | \f/* | |
334 | ** Message priority classes. | |
335 | ** | |
336 | ** The message class is read directly from the Priority: header | |
337 | ** field in the message. | |
338 | ** | |
339 | ** CurEnv->e_msgpriority is the number of bytes in the message plus | |
340 | ** the creation time (so that jobs ``tend'' to be ordered correctly), | |
341 | ** adjusted by the message class, the number of recipients, and the | |
342 | ** amount of time the message has been sitting around. This number | |
343 | ** is used to order the queue. Higher values mean LOWER priority. | |
344 | ** | |
345 | ** Each priority class point is worth WkClassFact priority points; | |
346 | ** each recipient is worth WkRecipFact priority points. Each time | |
347 | ** we reprocess a message the priority is adjusted by WkTimeFact. | |
348 | ** WkTimeFact should normally decrease the priority so that jobs | |
349 | ** that have historically failed will be run later; thanks go to | |
350 | ** Jay Lepreau at Utah for pointing out the error in my thinking. | |
351 | ** | |
352 | ** The "class" is this number, unadjusted by the age or size of | |
353 | ** this message. Classes with negative representations will have | |
354 | ** error messages thrown away if they are not local. | |
355 | */ | |
356 | ||
357 | struct priority | |
358 | { | |
359 | char *pri_name; /* external name of priority */ | |
360 | int pri_val; /* internal value for same */ | |
361 | }; | |
362 | ||
363 | EXTERN struct priority Priorities[MAXPRIORITIES]; | |
364 | EXTERN int NumPriorities; /* pointer into Priorities */ | |
365 | \f/* | |
366 | ** Rewrite rules. | |
367 | */ | |
368 | ||
369 | struct rewrite | |
370 | { | |
371 | char **r_lhs; /* pattern match */ | |
372 | char **r_rhs; /* substitution value */ | |
373 | struct rewrite *r_next;/* next in chain */ | |
374 | }; | |
375 | ||
376 | EXTERN struct rewrite *RewriteRules[MAXRWSETS]; | |
377 | ||
378 | /* | |
379 | ** Special characters in rewriting rules. | |
380 | ** These are used internally only. | |
381 | ** The COND* rules are actually used in macros rather than in | |
382 | ** rewriting rules, but are given here because they | |
383 | ** cannot conflict. | |
384 | */ | |
385 | ||
386 | /* left hand side items */ | |
6f14531a RG |
387 | # define MATCHZANY 0220 /* match zero or more tokens */ |
388 | # define MATCHANY 0221 /* match one or more tokens */ | |
389 | # define MATCHONE 0222 /* match exactly one token */ | |
390 | # define MATCHCLASS 0223 /* match one token in a class */ | |
391 | # define MATCHNCLASS 0224 /* match anything not in class */ | |
392 | # define MATCHREPL 0225 /* replacement on RHS for above */ | |
15637ed4 RG |
393 | |
394 | /* right hand side items */ | |
6f14531a RG |
395 | # define CANONNET 0226 /* canonical net, next token */ |
396 | # define CANONHOST 0227 /* canonical host, next token */ | |
397 | # define CANONUSER 0230 /* canonical user, next N tokens */ | |
398 | # define CALLSUBR 0231 /* call another rewriting set */ | |
15637ed4 RG |
399 | |
400 | /* conditionals in macros */ | |
6f14531a RG |
401 | # define CONDIF 0232 /* conditional if-then */ |
402 | # define CONDELSE 0233 /* conditional else */ | |
403 | # define CONDFI 0234 /* conditional fi */ | |
15637ed4 RG |
404 | |
405 | /* bracket characters for host name lookup */ | |
6f14531a RG |
406 | # define HOSTBEGIN 0235 /* hostname lookup begin */ |
407 | # define HOSTEND 0236 /* hostname lookup end */ | |
408 | ||
409 | /* bracket characters for generalized lookup */ | |
410 | # define LOOKUPBEGIN 0205 /* generalized lookup begin */ | |
411 | # define LOOKUPEND 0206 /* generalized lookup end */ | |
412 | ||
413 | /* macro substitution character */ | |
414 | # define MACROEXPAND 0201 /* macro expansion */ | |
415 | # define MACRODEXPAND 0202 /* deferred macro expansion */ | |
15637ed4 | 416 | |
6f14531a RG |
417 | /* to make the code clearer */ |
418 | # define MATCHZERO CANONHOST | |
419 | ||
420 | /* external <==> internal mapping table */ | |
421 | struct metamac | |
422 | { | |
423 | char metaname; /* external code (after $) */ | |
d747e748 | 424 | u_char metaval; /* internal code (as above) */ |
6f14531a | 425 | }; |
15637ed4 | 426 | \f/* |
6f14531a RG |
427 | ** Information about currently open connections to mailers, or to |
428 | ** hosts that we have looked up recently. | |
429 | */ | |
430 | ||
431 | # define MCI struct mailer_con_info | |
432 | ||
433 | MCI | |
434 | { | |
435 | short mci_flags; /* flag bits, see below */ | |
436 | short mci_errno; /* error number on last connection */ | |
3a363396 | 437 | short mci_herrno; /* h_errno from last DNS lookup */ |
6f14531a RG |
438 | short mci_exitstat; /* exit status from last connection */ |
439 | short mci_state; /* SMTP state */ | |
440 | long mci_maxsize; /* max size this server will accept */ | |
441 | FILE *mci_in; /* input side of connection */ | |
442 | FILE *mci_out; /* output side of connection */ | |
443 | int mci_pid; /* process id of subordinate proc */ | |
444 | char *mci_phase; /* SMTP phase string */ | |
445 | struct mailer *mci_mailer; /* ptr to the mailer for this conn */ | |
446 | char *mci_host; /* host name */ | |
447 | time_t mci_lastuse; /* last usage time */ | |
448 | }; | |
449 | ||
450 | ||
451 | /* flag bits */ | |
452 | #define MCIF_VALID 000001 /* this entry is valid */ | |
453 | #define MCIF_TEMP 000002 /* don't cache this connection */ | |
454 | #define MCIF_CACHED 000004 /* currently in open cache */ | |
455 | #define MCIF_ESMTP 000010 /* this host speaks ESMTP */ | |
456 | #define MCIF_EXPN 000020 /* EXPN command supported */ | |
457 | #define MCIF_SIZE 000040 /* SIZE option supported */ | |
458 | #define MCIF_8BITMIME 000100 /* BODY=8BITMIME supported */ | |
d747e748 | 459 | #define MCIF_MULTSTAT 000200 /* MAIL11V3: handles MULT status */ |
6f14531a RG |
460 | |
461 | /* states */ | |
462 | #define MCIS_CLOSED 0 /* no traffic on this connection */ | |
463 | #define MCIS_OPENING 1 /* sending initial protocol */ | |
464 | #define MCIS_OPEN 2 /* open, initial protocol sent */ | |
465 | #define MCIS_ACTIVE 3 /* message being sent */ | |
466 | #define MCIS_QUITING 4 /* running quit protocol */ | |
467 | #define MCIS_SSD 5 /* service shutting down */ | |
468 | #define MCIS_ERROR 6 /* I/O error on connection */ | |
469 | \f/* | |
470 | ** Name canonification short circuit. | |
15637ed4 | 471 | ** |
6f14531a RG |
472 | ** If the name server for a host is down, the process of trying to |
473 | ** canonify the name can hang. This is similar to (but alas, not | |
474 | ** identical to) looking up the name for delivery. This stab type | |
475 | ** caches the result of the name server lookup so we don't hang | |
476 | ** multiple times. | |
15637ed4 RG |
477 | */ |
478 | ||
6f14531a RG |
479 | #define NAMECANON struct _namecanon |
480 | ||
481 | NAMECANON | |
482 | { | |
483 | short nc_errno; /* cached errno */ | |
484 | short nc_herrno; /* cached h_errno */ | |
485 | short nc_stat; /* cached exit status code */ | |
486 | short nc_flags; /* flag bits */ | |
487 | char *nc_cname; /* the canonical name */ | |
488 | }; | |
489 | ||
490 | /* values for nc_flags */ | |
491 | #define NCF_VALID 0x0001 /* entry valid */ | |
492 | \f/* | |
493 | ** Mapping functions | |
494 | ** | |
495 | ** These allow arbitrary mappings in the config file. The idea | |
496 | ** (albeit not the implementation) comes from IDA sendmail. | |
497 | */ | |
498 | ||
499 | # define MAPCLASS struct _mapclass | |
500 | # define MAP struct _map | |
501 | ||
15637ed4 | 502 | |
6f14531a RG |
503 | /* |
504 | ** An actual map. | |
505 | */ | |
15637ed4 | 506 | |
6f14531a | 507 | MAP |
15637ed4 | 508 | { |
6f14531a RG |
509 | MAPCLASS *map_class; /* the class of this map */ |
510 | char *map_mname; /* name of this map */ | |
511 | int map_mflags; /* flags, see below */ | |
512 | char *map_file; /* the (nominal) filename */ | |
d747e748 JH |
513 | ARBPTR_T map_db1; /* the open database ptr */ |
514 | ARBPTR_T map_db2; /* an "extra" database pointer */ | |
6f14531a RG |
515 | char *map_app; /* to append to successful matches */ |
516 | char *map_domain; /* the (nominal) NIS domain */ | |
517 | char *map_rebuild; /* program to run to do auto-rebuild */ | |
d747e748 | 518 | time_t map_mtime; /* last database modification time */ |
15637ed4 RG |
519 | }; |
520 | ||
6f14531a RG |
521 | /* bit values for map_flags */ |
522 | # define MF_VALID 0x0001 /* this entry is valid */ | |
523 | # define MF_INCLNULL 0x0002 /* include null byte in key */ | |
524 | # define MF_OPTIONAL 0x0004 /* don't complain if map not found */ | |
525 | # define MF_NOFOLDCASE 0x0008 /* don't fold case in keys */ | |
526 | # define MF_MATCHONLY 0x0010 /* don't use the map value */ | |
527 | # define MF_OPEN 0x0020 /* this entry is open */ | |
528 | # define MF_WRITABLE 0x0040 /* open for writing */ | |
529 | # define MF_ALIAS 0x0080 /* this is an alias file */ | |
3a363396 NW |
530 | # define MF_TRY0NULL 0x0100 /* try with no null byte */ |
531 | # define MF_TRY1NULL 0x0200 /* try with the null byte */ | |
d747e748 JH |
532 | # define MF_LOCKED 0x0400 /* this map is currently locked */ |
533 | # define MF_ALIASWAIT 0x0800 /* alias map in aliaswait state */ | |
6f14531a RG |
534 | # define MF_IMPL_HASH 0x1000 /* implicit: underlying hash database */ |
535 | # define MF_IMPL_NDBM 0x2000 /* implicit: underlying NDBM database */ | |
15637ed4 | 536 | |
15637ed4 | 537 | |
6f14531a RG |
538 | /* |
539 | ** The class of a map -- essentially the functions to call | |
540 | */ | |
541 | ||
542 | MAPCLASS | |
543 | { | |
544 | char *map_cname; /* name of this map class */ | |
545 | char *map_ext; /* extension for database file */ | |
546 | short map_cflags; /* flag bits, see below */ | |
547 | bool (*map_parse)__P((MAP *, char *)); | |
548 | /* argument parsing function */ | |
549 | char *(*map_lookup)__P((MAP *, char *, char **, int *)); | |
550 | /* lookup function */ | |
551 | void (*map_store)__P((MAP *, char *, char *)); | |
552 | /* store function */ | |
553 | bool (*map_open)__P((MAP *, int)); | |
554 | /* open function */ | |
555 | void (*map_close)__P((MAP *)); | |
556 | /* close function */ | |
557 | }; | |
558 | ||
559 | /* bit values for map_cflags */ | |
560 | #define MCF_ALIASOK 0x0001 /* can be used for aliases */ | |
561 | #define MCF_ALIASONLY 0x0002 /* usable only for aliases */ | |
562 | #define MCF_REBUILDABLE 0x0004 /* can rebuild alias files */ | |
15637ed4 RG |
563 | \f/* |
564 | ** Symbol table definitions | |
565 | */ | |
566 | ||
567 | struct symtab | |
568 | { | |
569 | char *s_name; /* name to be entered */ | |
570 | char s_type; /* general type (see below) */ | |
571 | struct symtab *s_next; /* pointer to next in chain */ | |
572 | union | |
573 | { | |
574 | BITMAP sv_class; /* bit-map of word classes */ | |
575 | ADDRESS *sv_addr; /* pointer to address header */ | |
576 | MAILER *sv_mailer; /* pointer to mailer */ | |
577 | char *sv_alias; /* alias */ | |
6f14531a RG |
578 | MAPCLASS sv_mapclass; /* mapping function class */ |
579 | MAP sv_map; /* mapping function */ | |
580 | char *sv_hostsig; /* host signature */ | |
581 | MCI sv_mci; /* mailer connection info */ | |
582 | NAMECANON sv_namecanon; /* canonical name cache */ | |
15637ed4 RG |
583 | } s_value; |
584 | }; | |
585 | ||
586 | typedef struct symtab STAB; | |
587 | ||
588 | /* symbol types */ | |
589 | # define ST_UNDEF 0 /* undefined type */ | |
590 | # define ST_CLASS 1 /* class map */ | |
591 | # define ST_ADDRESS 2 /* an address in parsed format */ | |
592 | # define ST_MAILER 3 /* a mailer header */ | |
593 | # define ST_ALIAS 4 /* an alias */ | |
6f14531a RG |
594 | # define ST_MAPCLASS 5 /* mapping function class */ |
595 | # define ST_MAP 6 /* mapping function */ | |
596 | # define ST_HOSTSIG 7 /* host signature */ | |
597 | # define ST_NAMECANON 8 /* cached canonical name */ | |
598 | # define ST_MCI 16 /* mailer connection info (offset) */ | |
15637ed4 RG |
599 | |
600 | # define s_class s_value.sv_class | |
601 | # define s_address s_value.sv_addr | |
602 | # define s_mailer s_value.sv_mailer | |
603 | # define s_alias s_value.sv_alias | |
6f14531a RG |
604 | # define s_mci s_value.sv_mci |
605 | # define s_mapclass s_value.sv_mapclass | |
606 | # define s_hostsig s_value.sv_hostsig | |
607 | # define s_map s_value.sv_map | |
608 | # define s_namecanon s_value.sv_namecanon | |
15637ed4 | 609 | |
6f14531a RG |
610 | extern STAB *stab __P((char *, int, int)); |
611 | extern void stabapply __P((void (*)(STAB *, int), int)); | |
15637ed4 RG |
612 | |
613 | /* opcodes to stab */ | |
614 | # define ST_FIND 0 /* find entry */ | |
615 | # define ST_ENTER 1 /* enter if not there */ | |
616 | \f/* | |
617 | ** STRUCT EVENT -- event queue. | |
618 | ** | |
619 | ** Maintained in sorted order. | |
620 | ** | |
621 | ** We store the pid of the process that set this event to insure | |
622 | ** that when we fork we will not take events intended for the parent. | |
623 | */ | |
624 | ||
625 | struct event | |
626 | { | |
627 | time_t ev_time; /* time of the function call */ | |
6f14531a RG |
628 | int (*ev_func)__P((int)); |
629 | /* function to call */ | |
15637ed4 RG |
630 | int ev_arg; /* argument to ev_func */ |
631 | int ev_pid; /* pid that set this event */ | |
632 | struct event *ev_link; /* link to next item */ | |
633 | }; | |
634 | ||
635 | typedef struct event EVENT; | |
636 | ||
637 | EXTERN EVENT *EventQueue; /* head of event queue */ | |
638 | \f/* | |
639 | ** Operation, send, and error modes | |
640 | ** | |
641 | ** The operation mode describes the basic operation of sendmail. | |
642 | ** This can be set from the command line, and is "send mail" by | |
643 | ** default. | |
644 | ** | |
645 | ** The send mode tells how to send mail. It can be set in the | |
646 | ** configuration file. It's setting determines how quickly the | |
647 | ** mail will be delivered versus the load on your system. If the | |
648 | ** -v (verbose) flag is given, it will be forced to SM_DELIVER | |
649 | ** mode. | |
650 | ** | |
651 | ** The error mode tells how to return errors. | |
652 | */ | |
653 | ||
654 | EXTERN char OpMode; /* operation mode, see below */ | |
655 | ||
656 | #define MD_DELIVER 'm' /* be a mail sender */ | |
15637ed4 RG |
657 | #define MD_SMTP 's' /* run SMTP on standard input */ |
658 | #define MD_DAEMON 'd' /* run as a daemon */ | |
659 | #define MD_VERIFY 'v' /* verify: don't collect or deliver */ | |
660 | #define MD_TEST 't' /* test mode: resolve addrs only */ | |
661 | #define MD_INITALIAS 'i' /* initialize alias database */ | |
662 | #define MD_PRINT 'p' /* print the queue */ | |
663 | #define MD_FREEZE 'z' /* freeze the configuration file */ | |
664 | ||
665 | ||
6f14531a | 666 | /* values for e_sendmode -- send modes */ |
15637ed4 RG |
667 | #define SM_DELIVER 'i' /* interactive delivery */ |
668 | #define SM_QUICKD 'j' /* deliver w/o queueing */ | |
669 | #define SM_FORK 'b' /* deliver in background */ | |
670 | #define SM_QUEUE 'q' /* queue, don't deliver */ | |
671 | #define SM_VERIFY 'v' /* verify only (used internally) */ | |
672 | ||
673 | /* used only as a parameter to sendall */ | |
674 | #define SM_DEFAULT '\0' /* unspecified, use SendMode */ | |
675 | ||
676 | ||
6f14531a | 677 | /* values for e_errormode -- error handling modes */ |
15637ed4 RG |
678 | #define EM_PRINT 'p' /* print errors */ |
679 | #define EM_MAIL 'm' /* mail back errors */ | |
680 | #define EM_WRITE 'w' /* write back errors */ | |
681 | #define EM_BERKNET 'e' /* special berknet processing */ | |
682 | #define EM_QUIET 'q' /* don't print messages (stat only) */ | |
6f14531a RG |
683 | \f/* |
684 | ** Additional definitions | |
685 | */ | |
15637ed4 | 686 | |
6f14531a | 687 | |
6f14531a RG |
688 | /* |
689 | ** Privacy flags | |
690 | ** These are bit values for the PrivacyFlags word. | |
691 | */ | |
692 | ||
693 | #define PRIV_PUBLIC 0 /* what have I got to hide? */ | |
694 | #define PRIV_NEEDMAILHELO 00001 /* insist on HELO for MAIL, at least */ | |
695 | #define PRIV_NEEDEXPNHELO 00002 /* insist on HELO for EXPN */ | |
696 | #define PRIV_NEEDVRFYHELO 00004 /* insist on HELO for VRFY */ | |
697 | #define PRIV_NOEXPN 00010 /* disallow EXPN command entirely */ | |
698 | #define PRIV_NOVRFY 00020 /* disallow VRFY command entirely */ | |
699 | #define PRIV_AUTHWARNINGS 00040 /* flag possible authorization probs */ | |
d747e748 JH |
700 | #define PRIV_RESTRICTMAILQ 01000 /* restrict mailq command */ |
701 | #define PRIV_RESTRICTQRUN 02000 /* restrict queue run */ | |
6f14531a RG |
702 | #define PRIV_GOAWAY 00777 /* don't give no info, anyway, anyhow */ |
703 | ||
704 | /* struct defining such things */ | |
705 | struct prival | |
706 | { | |
707 | char *pv_name; /* name of privacy flag */ | |
708 | int pv_flag; /* numeric level */ | |
709 | }; | |
710 | ||
711 | ||
712 | /* | |
d747e748 | 713 | ** Flags passed to remotename, parseaddr, allocaddr, and buildaddr. |
6f14531a RG |
714 | */ |
715 | ||
716 | #define RF_SENDERADDR 0001 /* this is a sender address */ | |
717 | #define RF_HEADERADDR 0002 /* this is a header address */ | |
718 | #define RF_CANONICAL 0004 /* strip comment information */ | |
719 | #define RF_ADDDOMAIN 0010 /* OK to do domain extension */ | |
d747e748 JH |
720 | #define RF_COPYPARSE 0020 /* copy parsed user & host */ |
721 | #define RF_COPYPADDR 0040 /* copy print address */ | |
722 | #define RF_COPYALL (RF_COPYPARSE|RF_COPYPADDR) | |
723 | #define RF_COPYNONE 0 | |
6f14531a RG |
724 | |
725 | /* | |
726 | ** Regular UNIX sockaddrs are too small to handle ISO addresses, so | |
727 | ** we are forced to declare a supertype here. | |
728 | */ | |
729 | ||
730 | union bigsockaddr | |
731 | { | |
732 | struct sockaddr sa; /* general version */ | |
69fc843f | 733 | struct sockaddr_un sunix; /* UNIX family */ |
6f14531a RG |
734 | #ifdef NETINET |
735 | struct sockaddr_in sin; /* INET family */ | |
736 | #endif | |
737 | #ifdef NETISO | |
738 | struct sockaddr_iso siso; /* ISO family */ | |
739 | #endif | |
740 | #ifdef NETNS | |
741 | struct sockaddr_ns sns; /* XNS family */ | |
742 | #endif | |
743 | #ifdef NETX25 | |
744 | struct sockaddr_x25 sx25; /* X.25 family */ | |
745 | #endif | |
746 | }; | |
747 | ||
748 | #define SOCKADDR union bigsockaddr | |
15637ed4 RG |
749 | \f/* |
750 | ** Global variables. | |
751 | */ | |
752 | ||
753 | EXTERN bool FromFlag; /* if set, "From" person is explicit */ | |
15637ed4 RG |
754 | EXTERN bool MeToo; /* send to the sender also */ |
755 | EXTERN bool IgnrDot; /* don't let dot end messages */ | |
756 | EXTERN bool SaveFrom; /* save leading "From" lines */ | |
757 | EXTERN bool Verbose; /* set if blow-by-blow desired */ | |
758 | EXTERN bool GrabTo; /* if set, get recipients from msg */ | |
759 | EXTERN bool NoReturn; /* don't return letter to sender */ | |
760 | EXTERN bool SuprErrs; /* set if we are suppressing errors */ | |
15637ed4 RG |
761 | EXTERN bool HoldErrs; /* only output errors to transcript */ |
762 | EXTERN bool NoConnect; /* don't connect to non-local mailers */ | |
763 | EXTERN bool SuperSafe; /* be extra careful, even if expensive */ | |
764 | EXTERN bool ForkQueueRuns; /* fork for each job when running the queue */ | |
765 | EXTERN bool AutoRebuild; /* auto-rebuild the alias database as needed */ | |
766 | EXTERN bool CheckAliases; /* parse addresses during newaliases */ | |
6f14531a | 767 | EXTERN bool NoAlias; /* suppress aliasing */ |
15637ed4 | 768 | EXTERN bool UseNameServer; /* use internet domain name server */ |
6f14531a | 769 | EXTERN bool SevenBit; /* force 7-bit data */ |
69fc843f | 770 | EXTERN time_t SafeAlias; /* interval to wait until @:@ in alias file */ |
15637ed4 RG |
771 | EXTERN FILE *InChannel; /* input connection */ |
772 | EXTERN FILE *OutChannel; /* output connection */ | |
6f14531a RG |
773 | EXTERN uid_t RealUid; /* when Daemon, real uid of caller */ |
774 | EXTERN gid_t RealGid; /* when Daemon, real gid of caller */ | |
775 | EXTERN uid_t DefUid; /* default uid to run as */ | |
776 | EXTERN gid_t DefGid; /* default gid to run as */ | |
15637ed4 | 777 | EXTERN char *DefUser; /* default user to run as (from DefUid) */ |
15637ed4 RG |
778 | EXTERN int OldUmask; /* umask when sendmail starts up */ |
779 | EXTERN int Errors; /* set if errors (local to single pass) */ | |
780 | EXTERN int ExitStat; /* exit status code */ | |
781 | EXTERN int AliasLevel; /* depth of aliasing */ | |
15637ed4 | 782 | EXTERN int LineNumber; /* line number in current input */ |
15637ed4 RG |
783 | EXTERN int LogLevel; /* level of logging to perform */ |
784 | EXTERN int FileMode; /* mode on files */ | |
785 | EXTERN int QueueLA; /* load average starting forced queueing */ | |
786 | EXTERN int RefuseLA; /* load average refusing connections are */ | |
6f14531a RG |
787 | EXTERN int CurrentLA; /* current load average */ |
788 | EXTERN long QueueFactor; /* slope of queue function */ | |
15637ed4 | 789 | EXTERN time_t QueueIntvl; /* intervals between running the queue */ |
15637ed4 | 790 | EXTERN char *HelpFile; /* location of SMTP help file */ |
6f14531a | 791 | EXTERN char *ErrMsgFile; /* file to prepend to all error messages */ |
15637ed4 RG |
792 | EXTERN char *StatFile; /* location of statistics summary */ |
793 | EXTERN char *QueueDir; /* location of queue directory */ | |
794 | EXTERN char *FileName; /* name to print on error messages */ | |
795 | EXTERN char *SmtpPhase; /* current phase in SMTP processing */ | |
796 | EXTERN char *MyHostName; /* name of this host for SMTP messages */ | |
797 | EXTERN char *RealHostName; /* name of host we are talking to */ | |
6f14531a | 798 | EXTERN SOCKADDR RealHostAddr; /* address of host we are talking to */ |
15637ed4 RG |
799 | EXTERN char *CurHostName; /* current host we are dealing with */ |
800 | EXTERN jmp_buf TopFrame; /* branch-to-top-of-loop-on-error frame */ | |
801 | EXTERN bool QuickAbort; /* .... but only if we want a quick abort */ | |
6f14531a RG |
802 | EXTERN bool LogUsrErrs; /* syslog user errors (e.g., SMTP RCPT cmd) */ |
803 | EXTERN bool SendMIMEErrors; /* send error messages in MIME format */ | |
804 | EXTERN bool MatchGecos; /* look for user names in gecos field */ | |
805 | EXTERN bool UseErrorsTo; /* use Errors-To: header (back compat) */ | |
d747e748 JH |
806 | EXTERN bool TryNullMXList; /* if we are the best MX, try host directly */ |
807 | EXTERN bool CheckLoopBack; /* check for loopback on HELO packet */ | |
808 | EXTERN bool InChild; /* true if running in an SMTP subprocess */ | |
6f14531a RG |
809 | EXTERN char SpaceSub; /* substitution for <lwsp> */ |
810 | EXTERN int PrivacyFlags; /* privacy flags */ | |
d747e748 | 811 | EXTERN char *ConfFile; /* location of configuration file [conf.c] */ |
6f14531a | 812 | extern char *PidFile; /* location of proc id file [conf.c] */ |
15637ed4 | 813 | extern ADDRESS NullAddress; /* a null (template) address [main.c] */ |
6f14531a RG |
814 | EXTERN long WkClassFact; /* multiplier for message class -> priority */ |
815 | EXTERN long WkRecipFact; /* multiplier for # of recipients -> priority */ | |
816 | EXTERN long WkTimeFact; /* priority offset each time this job is run */ | |
817 | EXTERN char *UdbSpec; /* user database source spec */ | |
818 | EXTERN int MaxHopCount; /* max # of hops until bounce */ | |
819 | EXTERN int ConfigLevel; /* config file level */ | |
820 | EXTERN char *TimeZoneSpec; /* override time zone specification */ | |
821 | EXTERN char *ForwardPath; /* path to search for .forward files */ | |
822 | EXTERN long MinBlocksFree; /* min # of blocks free on queue fs */ | |
823 | EXTERN char *FallBackMX; /* fall back MX host */ | |
824 | EXTERN long MaxMessageSize; /* advertised max size we will accept */ | |
15637ed4 | 825 | EXTERN char *PostMasterCopy; /* address to get errs cc's */ |
15637ed4 | 826 | EXTERN int CheckpointInterval; /* queue file checkpoint interval */ |
6f14531a | 827 | EXTERN bool DontPruneRoutes; /* don't prune source routes */ |
d747e748 | 828 | EXTERN bool BrokenSmtpPeers; /* peers can't handle 2-line greeting */ |
6f14531a RG |
829 | EXTERN int MaxMciCache; /* maximum entries in MCI cache */ |
830 | EXTERN time_t MciCacheTimeout; /* maximum idle time on connections */ | |
831 | EXTERN char *QueueLimitRecipient; /* limit queue runs to this recipient */ | |
832 | EXTERN char *QueueLimitSender; /* limit queue runs to this sender */ | |
833 | EXTERN char *QueueLimitId; /* limit queue runs to this id */ | |
3a363396 | 834 | EXTERN FILE *TrafficLogFile; /* file in which to log all traffic */ |
6f14531a RG |
835 | |
836 | ||
837 | /* | |
838 | ** Timeouts | |
839 | ** | |
840 | ** Indicated values are the MINIMUM per RFC 1123 section 5.3.2. | |
841 | */ | |
842 | ||
843 | EXTERN struct | |
844 | { | |
d747e748 | 845 | /* RFC 1123-specified timeouts [minimum value] */ |
6f14531a RG |
846 | time_t to_initial; /* initial greeting timeout [5m] */ |
847 | time_t to_mail; /* MAIL command [5m] */ | |
848 | time_t to_rcpt; /* RCPT command [5m] */ | |
849 | time_t to_datainit; /* DATA initiation [2m] */ | |
850 | time_t to_datablock; /* DATA block [3m] */ | |
851 | time_t to_datafinal; /* DATA completion [10m] */ | |
852 | time_t to_nextcommand; /* next command [5m] */ | |
853 | /* following timeouts are not mentioned in RFC 1123 */ | |
854 | time_t to_rset; /* RSET command */ | |
855 | time_t to_helo; /* HELO command */ | |
856 | time_t to_quit; /* QUIT command */ | |
857 | time_t to_miscshort; /* misc short commands (NOOP, VERB, etc) */ | |
d747e748 | 858 | time_t to_ident; /* IDENT protocol requests */ |
6f14531a RG |
859 | /* following are per message */ |
860 | time_t to_q_return; /* queue return timeout */ | |
861 | time_t to_q_warning; /* queue warning timeout */ | |
862 | } TimeOuts; | |
863 | ||
864 | ||
865 | /* | |
15637ed4 RG |
866 | ** Trace information |
867 | */ | |
868 | ||
869 | /* trace vector and macros for debugging flags */ | |
870 | EXTERN u_char tTdvect[100]; | |
871 | # define tTd(flag, level) (tTdvect[flag] >= level) | |
872 | # define tTdlevel(flag) (tTdvect[flag]) | |
873 | \f/* | |
874 | ** Miscellaneous information. | |
875 | */ | |
876 | ||
15637ed4 RG |
877 | |
878 | ||
879 | /* | |
880 | ** Some in-line functions | |
881 | */ | |
882 | ||
883 | /* set exit status */ | |
884 | #define setstat(s) { \ | |
885 | if (ExitStat == EX_OK || ExitStat == EX_TEMPFAIL) \ | |
886 | ExitStat = s; \ | |
887 | } | |
888 | ||
889 | /* make a copy of a string */ | |
890 | #define newstr(s) strcpy(xalloc(strlen(s) + 1), s) | |
891 | ||
892 | #define STRUCTCOPY(s, d) d = s | |
893 | ||
894 | ||
895 | /* | |
896 | ** Declarations of useful functions | |
897 | */ | |
898 | ||
6f14531a RG |
899 | extern ADDRESS *parseaddr __P((char *, ADDRESS *, int, int, char **, ENVELOPE *)); |
900 | extern char *xalloc __P((int)); | |
901 | extern bool sameaddr __P((ADDRESS *, ADDRESS *)); | |
902 | extern FILE *dfopen __P((char *, int, int)); | |
903 | extern EVENT *setevent __P((time_t, int(*)(), int)); | |
904 | extern char *sfgets __P((char *, int, FILE *, time_t, char *)); | |
905 | extern char *queuename __P((ENVELOPE *, int)); | |
906 | extern time_t curtime __P(()); | |
907 | extern bool transienterror __P((int)); | |
908 | extern const char *errstring __P((int)); | |
909 | extern void expand __P((char *, char *, char *, ENVELOPE *)); | |
910 | extern void define __P((int, char *, ENVELOPE *)); | |
911 | extern char *macvalue __P((int, ENVELOPE *)); | |
912 | extern char **prescan __P((char *, int, char[], char **)); | |
913 | extern char *fgetfolded __P((char *, int, FILE *)); | |
914 | extern ADDRESS *recipient __P((ADDRESS *, ADDRESS **, ENVELOPE *)); | |
915 | extern ENVELOPE *newenvelope __P((ENVELOPE *, ENVELOPE *)); | |
916 | extern void dropenvelope __P((ENVELOPE *)); | |
917 | extern void clearenvelope __P((ENVELOPE *, int)); | |
918 | extern char *username __P(()); | |
919 | extern MCI *mci_get __P((char *, MAILER *)); | |
920 | extern char *pintvl __P((time_t, int)); | |
921 | extern char *map_rewrite __P((MAP *, char *, int, char **)); | |
922 | extern ADDRESS *getctladdr __P((ADDRESS *)); | |
923 | extern char *anynet_ntoa __P((SOCKADDR *)); | |
924 | extern char *remotename __P((char *, MAILER *, int, int *, ENVELOPE *)); | |
925 | extern bool shouldqueue __P((long, time_t)); | |
d747e748 | 926 | extern bool lockfile __P((int, char *, char *, int)); |
6f14531a RG |
927 | extern char *hostsignature __P((MAILER *, char *, ENVELOPE *)); |
928 | extern void openxscript __P((ENVELOPE *)); | |
929 | extern void closexscript __P((ENVELOPE *)); | |
d747e748 | 930 | extern sigfunc_t setsignal __P((int, sigfunc_t)); |
6f14531a RG |
931 | |
932 | /* ellipsis is a different case though */ | |
933 | #ifdef __STDC__ | |
934 | extern void auth_warning(ENVELOPE *, const char *, ...); | |
935 | extern void syserr(const char *, ...); | |
936 | extern void usrerr(const char *, ...); | |
937 | extern void message(const char *, ...); | |
938 | extern void nmessage(const char *, ...); | |
939 | #else | |
940 | extern void auth_warning(); | |
941 | extern void syserr(); | |
942 | extern void usrerr(); | |
943 | extern void message(); | |
944 | extern void nmessage(); | |
945 | #endif |