1 |
lefcha |
1.9 |
#ifndef IMAPFILTER_H |
2 |
|
|
#define IMAPFILTER_H |
3 |
|
|
|
4 |
|
|
#include <stdio.h> |
5 |
|
|
|
6 |
|
|
#ifndef DATA_H |
7 |
|
|
#include "data.h" |
8 |
|
|
#endif |
9 |
|
|
|
10 |
lefcha |
1.11 |
/* Error codes returned by functions. */ |
11 |
|
|
#define ERROR_TRIVIAL 1 |
12 |
|
|
#define ERROR_FILE_OPEN 2 |
13 |
|
|
#define ERROR_CONFIG_PARSE 3 |
14 |
|
|
#define ERROR_MEMORY_ALLOCATION 4 |
15 |
|
|
#define ERROR_NETWORK 5 |
16 |
|
|
#define ERROR_UNDEFINED 6 |
17 |
lefcha |
1.9 |
|
18 |
|
|
/* Flags that control the program's options. */ |
19 |
|
|
#define OPTION_DETAILS_QUITE 0x01 |
20 |
|
|
#define OPTION_DETAILS_NORMAL 0x02 |
21 |
|
|
#define OPTION_DETAILS_VERBOSE 0x04 |
22 |
|
|
#define OPTION_DETAILS_CLEAR 0xf8 |
23 |
|
|
|
24 |
lefcha |
1.12 |
/* Flags for logger. */ |
25 |
|
|
#define LOG_WRITE 0 |
26 |
|
|
#define LOG_SERVER 1 |
27 |
|
|
#define LOG_USERNAME 2 |
28 |
|
|
#define LOG_MAILBOX 3 |
29 |
|
|
#define LOG_FILTER 4 |
30 |
|
|
#define LOG_ACTION 5 |
31 |
|
|
#define LOG_DESTINATION_MAILBOX 6 |
32 |
|
|
|
33 |
lefcha |
1.11 |
|
34 |
lefcha |
1.9 |
/* Buffer size of the the IMAP command. */ |
35 |
|
|
#define SMALL_CMD 64 |
36 |
|
|
#define MEDIUM_CMD 256 |
37 |
|
|
#define BIG_CMD 8192 |
38 |
|
|
|
39 |
|
|
/* Buffer size of server's response. */ |
40 |
|
|
#define RESPONSE_BUF 16384 |
41 |
|
|
#define RESULT_BUF 512 |
42 |
|
|
|
43 |
|
|
/* Buffer size of message's headers. */ |
44 |
|
|
#define HEADERS_BUF 8192 |
45 |
|
|
|
46 |
|
|
/* Buffer size of search results. */ |
47 |
|
|
#define SEARCH_MESSAGES_BUF 512 |
48 |
|
|
|
49 |
lefcha |
1.1 |
|
50 |
|
|
#define min(A, B) ((A) < (B) ? (A) : (B)) |
51 |
|
|
|
52 |
|
|
|
53 |
lefcha |
1.9 |
/* connect.c */ |
54 |
|
|
int init_connection(char *serv, unsigned int port); |
55 |
|
|
int close_connection(void); |
56 |
|
|
|
57 |
|
|
/* file.c */ |
58 |
|
|
int read_config(char *cfg); |
59 |
|
|
#ifdef CHECK_PERMISSIONS |
60 |
|
|
int check_permissions(char *cfg); |
61 |
|
|
#endif |
62 |
|
|
int parse_config(FILE * fp); |
63 |
lefcha |
1.10 |
void set_options(char *line, regmatch_t * match); |
64 |
lefcha |
1.1 |
|
65 |
lefcha |
1.9 |
/* imapfilter.c */ |
66 |
|
|
void usage(void); |
67 |
lefcha |
1.1 |
|
68 |
lefcha |
1.9 |
/* imap.c */ |
69 |
|
|
int send_command(char *cmd); |
70 |
|
|
#ifdef DEBUG |
71 |
|
|
int imap_noop(void); |
72 |
|
|
#endif |
73 |
|
|
int imap_logout(void); |
74 |
|
|
int imap_login(char *user, char *pass); |
75 |
lefcha |
1.11 |
/* int imap_examine(char *mbox); */ |
76 |
lefcha |
1.9 |
int imap_select(char *mbox); |
77 |
|
|
int imap_status(char *mbox, char *items); |
78 |
|
|
int imap_create(char *mbox); |
79 |
|
|
int imap_search(char *search); |
80 |
lefcha |
1.11 |
int imap_fetch(int peek, char *mesg, char *headers); |
81 |
lefcha |
1.9 |
int imap_store(char *mesg, char *flags); |
82 |
|
|
int imap_copy(char *mesg, char *mbox); |
83 |
|
|
int imap_close(void); |
84 |
|
|
int imap_expunge(void); |
85 |
|
|
|
86 |
|
|
/* log.c */ |
87 |
|
|
void info(const char *info, ...); |
88 |
|
|
void verbose(const char *info, ...); |
89 |
|
|
void error(const char *errmsg, ...); |
90 |
lefcha |
1.11 |
void fatal(unsigned int errnum, const char *fatal, ...); |
91 |
lefcha |
1.9 |
int open_logfile(void); |
92 |
|
|
int create_logfile(void); |
93 |
|
|
int close_logfile(void); |
94 |
lefcha |
1.12 |
void log_info(int flag, void *ptr); |
95 |
lefcha |
1.11 |
char *get_time(void); |
96 |
lefcha |
1.9 |
|
97 |
|
|
/* request.c */ |
98 |
|
|
int test(void); |
99 |
|
|
int login(char *user, char *pass); |
100 |
|
|
int select_mailbox(char *mbox); |
101 |
lefcha |
1.11 |
int mailbox_status(char *mbox); |
102 |
lefcha |
1.9 |
int close_mailbox(void); |
103 |
|
|
int logout(void); |
104 |
|
|
|
105 |
|
|
int apply_filters(filter_t ** filters, char *mbox); |
106 |
|
|
int match_filter(filter_t * filter, char *mesgs); |
107 |
|
|
|
108 |
|
|
void empty_fifo(mask_t ** mfifo); |
109 |
lefcha |
1.11 |
void queue_fifo(mask_t ** mfifo, mask_t * mask); |
110 |
|
|
mask_t *dequeue_fifo(mask_t ** mfifo); |
111 |
lefcha |
1.9 |
|
112 |
lefcha |
1.11 |
char *generate_filter_and(mask_t * mask, unsigned int masknum, unsigned int masklen); |
113 |
|
|
char *generate_filter_or(mask_t * mask, unsigned int masknum, unsigned int masklen); |
114 |
lefcha |
1.9 |
|
115 |
lefcha |
1.11 |
int apply_action(char *mesgs, unsigned int *type, char *destmbox, char *args); |
116 |
lefcha |
1.9 |
int action_delete(char *mesgs, char *args); |
117 |
lefcha |
1.11 |
int action_copy(char *mesgs, char *destmbox, char *args); |
118 |
|
|
int action_move(char *mesgs, char *destmbox, char *args); |
119 |
|
|
int action_list(char *mesgs, char *args); |
120 |
lefcha |
1.9 |
|
121 |
|
|
unsigned int convert_messages(char *mesgs); |
122 |
|
|
|
123 |
lefcha |
1.11 |
/* response.c */ |
124 |
|
|
int receive_response(char *buf); |
125 |
|
|
int server_response(char *cmd); |
126 |
|
|
int status_response(void); |
127 |
|
|
int search_response(char *mesgs); |
128 |
|
|
int fetch_response(void); |
129 |
|
|
int copy_response(void); |
130 |
|
|
int analyze_response(char *buf); |
131 |
|
|
|
132 |
|
|
#endif /* IMAPFILTER_H */ |