piler/src/defs.h

206 lines
3.6 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
#include <openssl/sha.h>
#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
#define MAXHASH 8171
#define BASE64_RATIO 1.33333333
#define DIGEST_LENGTH SHA256_DIGEST_LENGTH
#define UNDEF 0
#define READY 1
#define BUSY 2
#define PROCESSED 3
struct attachment {
int size;
char type[SMALLBUFSIZE];
char filename[SMALLBUFSIZE];
};
struct url {
char url_str[URL_LEN];
struct url *r;
};
struct boundary {
char boundary_str[BOUNDARY_LEN];
struct boundary *r;
};
struct _state {
int message_state;
int is_header;
int textplain;
int texthtml;
int octetstream;
int message_rfc822;
int base64;
int has_base64;
int utf8;
int qp;
int htmltag;
int style;
int skip_html;
int ipcnt;
int has_to_dump;
int fd;
int num_of_msword;
int num_of_images;
int realbinary;
int content_type_is_set;
int train_mode;
unsigned long c_shit;
unsigned long l_shit;
unsigned long line_num;
char ip[SMALLBUFSIZE];
char hostname[SMALLBUFSIZE];
char miscbuf[MAX_TOKEN_LEN];
char qpbuf[MAX_TOKEN_LEN];
char attachedfile[RND_STR_LEN+SMALLBUFSIZE];
char from[SMALLBUFSIZE];
char message_id[SMALLBUFSIZE];
unsigned long n_token;
unsigned long n_subject_token;
unsigned long n_body_token;
unsigned long n_chain_token;
struct url *urls;
int found_our_signo;
struct boundary *boundaries;
int n_attachments;
struct attachment attachments[MAX_ATTACHMENTS];
char b_from[SMALLBUFSIZE], b_to[SMALLBUFSIZE], b_subject[MAXBUFSIZE], b_body[BIGBUFSIZE];
};
struct session_data {
char ttmpfile[SMALLBUFSIZE], tre;
char mailfrom[SMALLBUFSIZE], rcptto[MAX_RCPT_TO][SMALLBUFSIZE], client_addr[SMALLBUFSIZE];
char acceptbuf[SMALLBUFSIZE];
char whitelist[MAXBUFSIZE], blacklist[MAXBUFSIZE];
int fd, hdr_len, tot_len, num_of_rcpt_to, rav;
int need_scan;
float __acquire, __parsed, __av, __store, __compress, __encrypt;
SHA256_CTX context;
unsigned char md[DIGEST_LENGTH];
char bodydigest[2*DIGEST_LENGTH+1];
time_t now, sent;
#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[16];
int server_port;
char initialised;
};
#endif
struct __data {
struct url *blackhole;
#ifdef HAVE_LIBCLAMAV
struct cl_engine *engine;
#endif
#ifdef HAVE_TRE
regex_t pregs[NUM_OF_REGEXES];
int n_regex;
#endif
#ifdef HAVE_MEMCACHED
struct memcached_server memc;
#endif
};
struct __counters {
unsigned long long c_rcvd;
unsigned long long c_virus;
unsigned long long c_duplicate;
};
#endif /* _DEFS_H */