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