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 |
|
|
|
11 |
|
|
/* Flags that control the program's options. */ |
12 |
|
|
#define OPTION_DETAILS_QUITE 0x01 |
13 |
|
|
#define OPTION_DETAILS_NORMAL 0x02 |
14 |
|
|
#define OPTION_DETAILS_VERBOSE 0x04 |
15 |
|
|
#define OPTION_DETAILS_CLEAR 0xf8 |
16 |
|
|
|
17 |
|
|
/* Buffer size of the the IMAP command. */ |
18 |
|
|
#define SMALL_CMD 64 |
19 |
|
|
#define MEDIUM_CMD 256 |
20 |
|
|
#define BIG_CMD 8192 |
21 |
|
|
|
22 |
|
|
/* Buffer size of server's response. */ |
23 |
|
|
#define RESPONSE_BUF 16384 |
24 |
|
|
#define RESULT_BUF 512 |
25 |
|
|
|
26 |
|
|
/* Buffer size of message's headers. */ |
27 |
|
|
#define HEADERS_BUF 8192 |
28 |
|
|
|
29 |
|
|
/* Maximum items in FIFO inventory. */ |
30 |
|
|
#define FIFO_MAX 512 |
31 |
|
|
|
32 |
|
|
/* Buffer size of filter's search string. */ |
33 |
|
|
#define SEARCH_BUF 2048 |
34 |
|
|
|
35 |
|
|
/* Buffer size of search results. */ |
36 |
|
|
#define SEARCH_MESSAGES_BUF 512 |
37 |
|
|
|
38 |
lefcha |
1.1 |
|
39 |
|
|
#define min(A, B) ((A) < (B) ? (A) : (B)) |
40 |
|
|
|
41 |
|
|
|
42 |
lefcha |
1.9 |
/* connect.c */ |
43 |
|
|
int init_connection(char *serv, unsigned int port); |
44 |
|
|
int close_connection(void); |
45 |
|
|
|
46 |
|
|
/* file.c */ |
47 |
|
|
int read_config(char *cfg); |
48 |
|
|
#ifdef CHECK_PERMISSIONS |
49 |
|
|
int check_permissions(char *cfg); |
50 |
|
|
#endif |
51 |
|
|
int parse_config(FILE * fp); |
52 |
lefcha |
1.10 |
void set_options(char *line, regmatch_t * match); |
53 |
lefcha |
1.1 |
|
54 |
lefcha |
1.9 |
/* imapfilter.c */ |
55 |
|
|
void usage(void); |
56 |
lefcha |
1.1 |
|
57 |
lefcha |
1.9 |
/* imap.c */ |
58 |
|
|
int send_command(char *cmd); |
59 |
|
|
#ifdef DEBUG |
60 |
|
|
int imap_noop(void); |
61 |
|
|
#endif |
62 |
|
|
int imap_logout(void); |
63 |
|
|
int imap_login(char *user, char *pass); |
64 |
|
|
int imap_examine(char *mbox); |
65 |
|
|
int imap_select(char *mbox); |
66 |
|
|
int imap_status(char *mbox, char *items); |
67 |
|
|
int imap_create(char *mbox); |
68 |
|
|
int imap_search(char *search); |
69 |
|
|
int imap_fetch(char *mesg, char *headers); |
70 |
|
|
int imap_store(char *mesg, char *flags); |
71 |
|
|
int imap_copy(char *mesg, char *mbox); |
72 |
|
|
int imap_close(void); |
73 |
|
|
int imap_expunge(void); |
74 |
|
|
|
75 |
|
|
/* log.c */ |
76 |
|
|
void info(const char *info, ...); |
77 |
|
|
void verbose(const char *info, ...); |
78 |
|
|
void error(const char *errmsg, ...); |
79 |
|
|
int open_logfile(void); |
80 |
|
|
int create_logfile(void); |
81 |
|
|
int close_logfile(void); |
82 |
|
|
void log_info(const char *info, ...); |
83 |
|
|
|
84 |
|
|
/* response.c */ |
85 |
|
|
int receive_response(char *buf); |
86 |
|
|
int server_response(void); |
87 |
|
|
int status_response(void); |
88 |
|
|
int search_response(char *mesgs); |
89 |
|
|
int fetch_response(char *headers); |
90 |
|
|
int copy_response(void); |
91 |
|
|
int analyze_response(char *buf); |
92 |
|
|
|
93 |
|
|
/* request.c */ |
94 |
|
|
int test(void); |
95 |
|
|
int login(char *user, char *pass); |
96 |
|
|
int examine_mailbox(char *mbox); |
97 |
|
|
int select_mailbox(char *mbox); |
98 |
|
|
int close_mailbox(void); |
99 |
|
|
int logout(void); |
100 |
|
|
|
101 |
|
|
int apply_filters(filter_t ** filters, char *mbox); |
102 |
|
|
int match_filter(filter_t * filter, char *mesgs); |
103 |
|
|
|
104 |
|
|
void empty_fifo(mask_t ** mfifo); |
105 |
|
|
void to_fifo(mask_t ** mfifo, mask_t * mask); |
106 |
|
|
mask_t *from_fifo(mask_t ** mfifo); |
107 |
|
|
|
108 |
|
|
void generate_filter_and(char *search, mask_t * mask); |
109 |
|
|
void generate_filter_or(char *search, mask_t * mask); |
110 |
|
|
|
111 |
|
|
int apply_action(char *mesgs, unsigned int type, char *args); |
112 |
|
|
int action_delete(char *mesgs, char *args); |
113 |
|
|
int action_copy(char *mesgs, char *args); |
114 |
|
|
int action_move(char *mesgs, char *mbox); |
115 |
|
|
int action_list(char *mesgs, char *mbox); |
116 |
|
|
|
117 |
|
|
unsigned int convert_messages(char *mesgs); |
118 |
|
|
|
119 |
|
|
#endif |