| 1 | /* $Cambridge: exim/src/src/local_scan.h,v 1.2 2004/12/16 15:11:47 tom 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 | #ifdef EXPERIMENTAL_BRIGHTMAIL |
| 113 | uschar *bmi_optin; |
| 114 | #endif |
| 115 | } recipient_item; |
| 116 | |
| 117 | |
| 118 | /* Global variables that are documented as visible in the function. */ |
| 119 | |
| 120 | extern unsigned int debug_selector; /* Debugging bits */ |
| 121 | |
| 122 | extern uschar *expand_string_message; /* Error info for failing expansion */ |
| 123 | extern uschar *headers_charset; /* Charset for RFC 2047 decoding */ |
| 124 | extern header_line *header_last; /* Final header */ |
| 125 | extern header_line *header_list; /* First header */ |
| 126 | extern BOOL host_checking; /* Set when checking a host */ |
| 127 | extern uschar *interface_address; /* Interface for incoming call */ |
| 128 | extern int interface_port; /* Port number for incoming call */ |
| 129 | extern uschar *message_id; /* Internal id of message being handled */ |
| 130 | extern uschar *received_protocol; /* Name of incoming protocol */ |
| 131 | extern int recipients_count; /* Number of recipients */ |
| 132 | extern recipient_item *recipients_list;/* List of recipient addresses */ |
| 133 | extern unsigned char *sender_address; /* Sender address */ |
| 134 | extern uschar *sender_host_address; /* IP address of sender, as chars */ |
| 135 | extern uschar *sender_host_authenticated; /* Name of authentication mechanism */ |
| 136 | extern uschar *sender_host_name; /* Host name from lookup */ |
| 137 | extern int sender_host_port; /* Port number of sender */ |
| 138 | extern BOOL smtp_batched_input; /* TRUE if SMTP batch (no interaction) */ |
| 139 | extern BOOL smtp_input; /* TRUE if input is via SMTP */ |
| 140 | |
| 141 | |
| 142 | /* Functions that are documented as visible in local_scan(). */ |
| 143 | |
| 144 | extern int child_close(pid_t, int); |
| 145 | extern pid_t child_open(uschar **, uschar **, int, int *, int *, BOOL); |
| 146 | extern pid_t child_open_exim(int *); |
| 147 | extern void debug_printf(char *, ...) PRINTF_FUNCTION; |
| 148 | extern uschar *expand_string(uschar *); |
| 149 | extern void header_add(int, char *, ...); |
| 150 | extern void header_add_at_position(BOOL, uschar *, BOOL, int, char *, ...); |
| 151 | extern void header_remove(int, uschar *); |
| 152 | extern BOOL header_testname(header_line *, uschar *, int, BOOL); |
| 153 | extern BOOL header_testname_incomplete(header_line *, uschar *, int, BOOL); |
| 154 | extern void log_write(unsigned int, int, char *format, ...); |
| 155 | extern int lss_b64decode(uschar *, uschar **); |
| 156 | extern uschar *lss_b64encode(uschar *, int); |
| 157 | extern int lss_match_domain(uschar *, uschar *); |
| 158 | extern int lss_match_local_part(uschar *, uschar *, BOOL); |
| 159 | extern int lss_match_address(uschar *, uschar *, BOOL); |
| 160 | extern int lss_match_host(uschar *, uschar *, uschar *); |
| 161 | extern void receive_add_recipient(uschar *, int); |
| 162 | extern BOOL receive_remove_recipient(uschar *); |
| 163 | extern uschar *rfc2047_decode(uschar *, BOOL, uschar *, int, int *, uschar **); |
| 164 | extern int smtp_fflush(void); |
| 165 | extern void smtp_printf(char *, ...) PRINTF_FUNCTION; |
| 166 | extern uschar *string_copy(uschar *); |
| 167 | extern uschar *string_copyn(uschar *, int); |
| 168 | extern uschar *string_sprintf(char *, ...); |
| 169 | |
| 170 | /* End of local_scan.h */ |