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