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