Update version number and copyright year.
[exim.git] / src / src / local_scan.h
CommitLineData
184e8823 1/* $Cambridge: exim/src/src/local_scan.h,v 1.10 2007/01/08 10:50:18 ph10 Exp $ */
059ec3d9
PH
2
3/*************************************************
4* Exim - an Internet mail transport agent *
5*************************************************/
6
184e8823 7/* Copyright (c) University of Cambridge 1995 - 2007 */
059ec3d9
PH
8/* See the file NOTICE for conditions of use and distribution. */
9
10/* This file is the header that is the only Exim header to be included in the
11source for the local_scan.c() function. It contains definitions that are made
1a46a8c5
PH
12available for use in that function, and which are documented.
13
14This API is also used for functions called by the ${dlfunc expansion item. */
059ec3d9
PH
15
16
750af86e
PH
17/* Some basic types that make some things easier, the Exim configuration
18settings, and the store functions. */
059ec3d9
PH
19
20#include <sys/types.h>
750af86e 21#include "config.h"
059ec3d9
PH
22#include "mytypes.h"
23#include "store.h"
24
25
26/* The function and its return codes. */
27
28extern int local_scan(int, uschar **);
29
30enum {
31 LOCAL_SCAN_ACCEPT, /* Accept */
32 LOCAL_SCAN_ACCEPT_FREEZE, /* Accept, but freeze */
33 LOCAL_SCAN_ACCEPT_QUEUE, /* Accept, but no immediate delivery */
34 LOCAL_SCAN_REJECT, /* Permanent rejection */
35 LOCAL_SCAN_REJECT_NOLOGHDR, /* Permanent rejection, no log header */
36 LOCAL_SCAN_TEMPREJECT, /* Temporary rejection */
37 LOCAL_SCAN_TEMPREJECT_NOLOGHDR /* Temporary rejection, no log header */
38};
39
40
1a46a8c5
PH
41/* Functions called by ${dlfunc{file}{func}{arg}...} return one of the five
42status codes defined immediately below. The function's first argument is either
43the result of expansion, or the error message in case of failure. The second
44and third arguments are standard argument count and vector, comprising the
45{arg} values specified in the expansion item. */
46
47typedef int exim_dlfunc_t(uschar **yield, int argc, uschar *argv[]);
48
49
50/* Return codes from the support functions lss_match_xxx(). These are also the
51codes that dynamically-loaded ${dlfunc functions must return. */
059ec3d9
PH
52
53#define OK 0 /* Successful match */
54#define DEFER 1 /* Defer - some problem */
55#define FAIL 2 /* Matching failed */
56#define ERROR 3 /* Internal or config error */
57
1a46a8c5
PH
58/* Extra return code for ${dlfunc functions */
59
60#define FAIL_FORCED 4 /* "Forced" failure */
61
059ec3d9
PH
62
63/* Available logging destinations */
64
65#define LOG_MAIN 1 /* Write to the main log */
66#define LOG_PANIC 2 /* Write to the panic log */
67#define LOG_REJECT 16 /* Write to the reject log, with headers */
68
69
70/* Accessible debugging bits */
71
72#define D_v 0x00000001
73#define D_local_scan 0x00000002
74
75
76/* Option types that can be used for local_scan_options. The boolean ones
77MUST be last so that they are contiguous with the internal boolean specials. */
78
79enum { opt_stringptr, opt_int, opt_octint, opt_mkint, opt_Kint, opt_fixed,
80 opt_time, opt_bool };
81
82
83/* The length of message identification strings. This is the id used internally
84by exim. The external version for use in Received: strings has a leading 'E'
85added to ensure it starts with a letter. */
86
87#define MESSAGE_ID_LENGTH 16
88
89/* The offset to the start of the data in the data file - this allows for
90the name of the data file to be present in the first line. */
91
92#define SPOOL_DATA_START_OFFSET (MESSAGE_ID_LENGTH+3)
93
94/* Some people (Marc Merlin et al) are maintaining a patch that allows for
95dynamic local_scan() libraries. This code is not yet in Exim proper, but it
96helps the maintainers if we keep their ABI version numbers here. This may
97mutate into more general support later. The major number is increased when the
98ABI is changed in a non backward compatible way. The minor number is increased
99each time a new feature is added (in a way that doesn't break backward
100compatibility). */
101
102#define LOCAL_SCAN_ABI_VERSION_MAJOR 1
ea2c01d2 103#define LOCAL_SCAN_ABI_VERSION_MINOR 1
e57faad2
MH
104#define LOCAL_SCAN_ABI_VERSION \
105 LOCAL_SCAN_ABI_VERSION_MAJOR.LOCAL_SCAN_ABI_VERSION_MINOR
059ec3d9
PH
106
107/* Structure definitions that are documented as visible in the function. */
108
109typedef struct header_line {
110 struct header_line *next;
111 int type;
112 int slen;
113 uschar *text;
114} header_line;
115
116/* Entries in lists options are in this form. */
117
118typedef struct {
119 char *name;
120 int type;
121 void *value;
122} optionlist;
123
124/*Structure for holding information about an envelope address. The errors_to
125field is always NULL except for one_time aliases that had errors_to on the
126routers that generated them. */
127
128typedef struct recipient_item {
129 uschar *address; /* the recipient address */
130 int pno; /* parent number for "one_time" alias, or -1 */
131 uschar *errors_to; /* the errors_to address or NULL */
8523533c
TK
132#ifdef EXPERIMENTAL_BRIGHTMAIL
133 uschar *bmi_optin;
134#endif
059ec3d9
PH
135} recipient_item;
136
137
138/* Global variables that are documented as visible in the function. */
139
140extern unsigned int debug_selector; /* Debugging bits */
141
142extern uschar *expand_string_message; /* Error info for failing expansion */
143extern uschar *headers_charset; /* Charset for RFC 2047 decoding */
144extern header_line *header_last; /* Final header */
145extern header_line *header_list; /* First header */
146extern BOOL host_checking; /* Set when checking a host */
147extern uschar *interface_address; /* Interface for incoming call */
148extern int interface_port; /* Port number for incoming call */
149extern uschar *message_id; /* Internal id of message being handled */
150extern uschar *received_protocol; /* Name of incoming protocol */
151extern int recipients_count; /* Number of recipients */
152extern recipient_item *recipients_list;/* List of recipient addresses */
153extern unsigned char *sender_address; /* Sender address */
154extern uschar *sender_host_address; /* IP address of sender, as chars */
155extern uschar *sender_host_authenticated; /* Name of authentication mechanism */
156extern uschar *sender_host_name; /* Host name from lookup */
157extern int sender_host_port; /* Port number of sender */
158extern BOOL smtp_batched_input; /* TRUE if SMTP batch (no interaction) */
159extern BOOL smtp_input; /* TRUE if input is via SMTP */
160
161
162/* Functions that are documented as visible in local_scan(). */
163
164extern int child_close(pid_t, int);
165extern pid_t child_open(uschar **, uschar **, int, int *, int *, BOOL);
166extern pid_t child_open_exim(int *);
5977a0b3 167extern pid_t child_open_exim2(int *, uschar *, uschar *);
059ec3d9
PH
168extern void debug_printf(char *, ...) PRINTF_FUNCTION;
169extern uschar *expand_string(uschar *);
170extern void header_add(int, char *, ...);
171extern void header_add_at_position(BOOL, uschar *, BOOL, int, char *, ...);
172extern void header_remove(int, uschar *);
173extern BOOL header_testname(header_line *, uschar *, int, BOOL);
8523533c 174extern BOOL header_testname_incomplete(header_line *, uschar *, int, BOOL);
059ec3d9
PH
175extern void log_write(unsigned int, int, char *format, ...);
176extern int lss_b64decode(uschar *, uschar **);
177extern uschar *lss_b64encode(uschar *, int);
178extern int lss_match_domain(uschar *, uschar *);
179extern int lss_match_local_part(uschar *, uschar *, BOOL);
180extern int lss_match_address(uschar *, uschar *, BOOL);
181extern int lss_match_host(uschar *, uschar *, uschar *);
182extern void receive_add_recipient(uschar *, int);
183extern BOOL receive_remove_recipient(uschar *);
184extern uschar *rfc2047_decode(uschar *, BOOL, uschar *, int, int *, uschar **);
185extern int smtp_fflush(void);
186extern void smtp_printf(char *, ...) PRINTF_FUNCTION;
187extern uschar *string_copy(uschar *);
188extern uschar *string_copyn(uschar *, int);
189extern uschar *string_sprintf(char *, ...);
190
191/* End of local_scan.h */