piler/src/defs.h

273 lines
4.9 KiB
C
Raw Normal View History

2011-11-14 15:57:52 +01:00
/*
* defs.h, SJ
*/
#ifndef _DEFS_H
#define _DEFS_H
#ifdef NEED_MYSQL
#include <mysql.h>
#endif
#ifdef NEED_SQLITE3
#include <sqlite3.h>
/* for older versions of sqlite3 do not have the sqlite3_prepare_v2() function, 2009.12.30, SJ */
#if SQLITE_VERSION_NUMBER < 3006000
#define sqlite3_prepare_v2 sqlite3_prepare
#endif
#endif
#ifdef HAVE_TRE
#include <tre/tre.h>
#include <tre/regex.h>
#endif
#ifdef HAVE_LIBWRAP
#include <tcpd.h>
#endif
2011-11-14 15:57:52 +01:00
#include <openssl/sha.h>
2012-10-27 14:40:25 +02:00
#include <openssl/ssl.h>
#include "tai.h"
2011-11-14 15:57:52 +01:00
#include "config.h"
#define MSG_UNDEF -1
#define MSG_BODY 0
#define MSG_RECEIVED 1
#define MSG_FROM 2
#define MSG_TO 3
#define MSG_CC 4
#define MSG_SUBJECT 5
#define MSG_CONTENT_TYPE 6
#define MSG_CONTENT_TRANSFER_ENCODING 7
#define MSG_CONTENT_DISPOSITION 8
#define MSG_MESSAGE_ID 9
2012-02-08 23:14:28 +01:00
#define MSG_REFERENCES 10
2012-09-03 10:06:34 +02:00
#define MSG_RECIPIENT 11
2011-11-14 15:57:52 +01:00
#define MAXHASH 8171
#define BASE64_RATIO 1.33333333
#define DIGEST_LENGTH SHA256_DIGEST_LENGTH
#define UNDEF 0
#define READY 1
#define BUSY 2
#define MAXCHILDREN 64
typedef void signal_func (int);
struct child {
pid_t pid;
int messages;
int status;
};
2011-11-14 15:57:52 +01:00
struct attachment {
int size;
2011-11-16 14:47:47 +01:00
char type[TINYBUFSIZE];
char shorttype[TINYBUFSIZE];
2012-09-07 15:08:50 +02:00
char aname[TINYBUFSIZE];
2011-11-16 14:47:47 +01:00
char filename[TINYBUFSIZE];
2011-11-19 21:25:44 +01:00
char internalname[TINYBUFSIZE];
char digest[2*DIGEST_LENGTH+1];
2012-09-07 15:08:50 +02:00
char dumped;
2011-11-14 15:57:52 +01:00
};
2011-11-19 21:25:44 +01:00
struct ptr_array {
uint64 ptr;
char piler_id[RND_STR_LEN+2];
int attachment_id;
};
2011-11-16 14:47:47 +01:00
struct list {
char s[SMALLBUFSIZE];
struct list *r;
2011-11-14 15:57:52 +01:00
};
2011-11-19 21:25:44 +01:00
struct rule {
#ifdef HAVE_TRE
regex_t from;
regex_t to;
regex_t subject;
2011-11-23 12:24:21 +01:00
regex_t attachment_type;
2011-11-19 21:25:44 +01:00
#endif
2012-02-19 22:59:47 +01:00
int spam;
2011-11-19 21:25:44 +01:00
int size;
char _size[4];
2011-11-23 12:24:21 +01:00
int attachment_size;
char _attachment_size[4];
2012-02-19 22:59:47 +01:00
int days;
2011-11-19 21:25:44 +01:00
char *rulestr;
char compiled;
2012-02-19 22:59:47 +01:00
2011-11-19 21:25:44 +01:00
struct rule *r;
};
2011-11-14 15:57:52 +01:00
struct _state {
2011-11-16 14:47:47 +01:00
int line_num;
2011-11-14 15:57:52 +01:00
int message_state;
int is_header;
2011-11-22 12:31:54 +01:00
int is_1st_header;
2011-11-14 15:57:52 +01:00
int textplain;
int texthtml;
int message_rfc822;
int base64;
int utf8;
int qp;
int htmltag;
int style;
int skip_html;
int has_to_dump;
int fd;
2012-09-07 15:08:50 +02:00
int b64fd;
2011-11-19 21:25:44 +01:00
int mfd;
2011-11-16 14:47:47 +01:00
int octetstream;
2011-11-14 15:57:52 +01:00
int realbinary;
int content_type_is_set;
2011-11-19 21:25:44 +01:00
int pushed_pointer;
int saved_size;
2012-08-21 21:57:39 +02:00
int writebufpos;
int abufpos;
2011-11-14 15:57:52 +01:00
char attachedfile[RND_STR_LEN+SMALLBUFSIZE];
char message_id[SMALLBUFSIZE];
2011-11-16 14:47:47 +01:00
char miscbuf[MAX_TOKEN_LEN];
2011-12-07 15:24:52 +01:00
char qpbuf[MAX_TOKEN_LEN];
2011-11-14 15:57:52 +01:00
unsigned long n_token;
unsigned long n_subject_token;
unsigned long n_body_token;
unsigned long n_chain_token;
2011-11-22 12:31:54 +01:00
char filename[TINYBUFSIZE];
char type[TINYBUFSIZE];
2011-11-16 14:47:47 +01:00
struct list *boundaries;
2011-11-28 14:21:14 +01:00
struct list *rcpt;
struct list *rcpt_domain;
struct list *journal_recipient;
2011-11-14 15:57:52 +01:00
int n_attachments;
struct attachment attachments[MAX_ATTACHMENTS];
2012-02-08 23:14:28 +01:00
char reference[SMALLBUFSIZE];
char b_from[SMALLBUFSIZE], b_from_domain[SMALLBUFSIZE], b_to[MAXBUFSIZE], b_to_domain[SMALLBUFSIZE], b_subject[MAXBUFSIZE], b_body[BIGBUFSIZE];
char b_journal_to[MAXBUFSIZE];
2012-08-21 21:57:39 +02:00
int bodylen;
int tolen;
int journaltolen;
2011-11-14 15:57:52 +01:00
};
struct session_data {
char filename[SMALLBUFSIZE];
2011-12-13 17:05:22 +01:00
char ttmpfile[SMALLBUFSIZE], tmpframe[SMALLBUFSIZE], tre, restored_copy;
2011-11-14 15:57:52 +01:00
char mailfrom[SMALLBUFSIZE], rcptto[MAX_RCPT_TO][SMALLBUFSIZE], client_addr[SMALLBUFSIZE];
char fromemail[SMALLBUFSIZE];
2011-11-14 15:57:52 +01:00
char acceptbuf[SMALLBUFSIZE];
2011-12-30 15:52:59 +01:00
char attachments[SMALLBUFSIZE];
char internal_sender, internal_recipient, external_recipient;
int direction;
2012-10-28 20:36:46 +01:00
int tls;
2012-01-26 14:35:51 +01:00
int spam_message;
2011-11-14 15:57:52 +01:00
int fd, hdr_len, tot_len, num_of_rcpt_to, rav;
int need_scan;
float __acquire, __parsed, __av, __store, __compress, __encrypt;
char bodydigest[2*DIGEST_LENGTH+1];
2011-11-22 12:31:54 +01:00
char digest[2*DIGEST_LENGTH+1];
time_t now, sent, delivered, retained;
2013-01-27 21:43:42 +01:00
char ms_journal;
2012-09-28 21:48:20 +02:00
int journal_envelope_length, journal_bottom_length;
2011-11-14 15:57:52 +01:00
#ifdef NEED_MYSQL
MYSQL mysql;
#endif
#ifdef NEED_SQLITE3
sqlite3 *db;
#endif
};
#ifdef HAVE_MEMCACHED
#include <stdbool.h>
#include <netinet/in.h>
struct flags {
bool no_block:1;
bool no_reply:1;
bool tcp_nodelay:1;
bool tcp_keepalive:1;
};
struct memcached_server {
struct flags flags;
int fd;
unsigned int snd_timeout;
unsigned int rcv_timeout;
int send_size;
int recv_size;
unsigned int tcp_keepidle;
int last_read_bytes;
char *result;
char buf[MAXBUFSIZE];
struct sockaddr_in addr;
char server_ip[IPLEN];
2011-11-14 15:57:52 +01:00
int server_port;
char initialised;
};
#endif
struct __data {
int folder;
2012-09-03 10:06:34 +02:00
char recursive_folder_names;
2012-10-28 20:36:46 +01:00
char starttls[TINYBUFSIZE];
2013-01-06 22:16:21 +01:00
char mydomains[MAXBUFSIZE];
2012-10-28 20:36:46 +01:00
2011-11-14 15:57:52 +01:00
#ifdef HAVE_TRE
2012-02-19 22:59:47 +01:00
struct rule *archiving_rules;
struct rule *retention_rules;
2011-11-14 15:57:52 +01:00
#endif
#ifdef HAVE_MEMCACHED
struct memcached_server memc;
#endif
2012-10-27 14:40:25 +02:00
SSL_CTX *ctx;
SSL *ssl;
2011-11-14 15:57:52 +01:00
};
struct __counters {
unsigned long long c_rcvd;
unsigned long long c_virus;
unsigned long long c_duplicate;
2011-12-27 20:51:56 +01:00
unsigned long long c_ignore;
2012-02-10 13:57:04 +01:00
unsigned long long c_size;
2011-11-14 15:57:52 +01:00
};
#endif /* _DEFS_H */