15 |
#define ERROR_SIGNAL 1 |
#define ERROR_SIGNAL 1 |
16 |
#define ERROR_TRIVIAL 2 |
#define ERROR_TRIVIAL 2 |
17 |
#define ERROR_FILE_OPEN 3 |
#define ERROR_FILE_OPEN 3 |
18 |
#define ERROR_LOCK_FILE 4 |
#define ERROR_LOCKFILE 4 |
19 |
#define ERROR_CONFIG_PARSE 5 |
#define ERROR_CONFIG_PARSE 5 |
20 |
#define ERROR_MEMORY_ALLOCATION 6 |
#define ERROR_MEMORY_ALLOCATION 6 |
21 |
#define ERROR_SETUID 7 |
#define ERROR_SETUID 7 |
39 |
#define OPTION_DAEMON_MODE 0x40 |
#define OPTION_DAEMON_MODE 0x40 |
40 |
|
|
41 |
/* Other flags. */ |
/* Other flags. */ |
42 |
#define FLAG_BLANK_PASSWORD 0x01 |
#define FLAG_TTY_MODIFIED 0x01 |
43 |
|
#define FLAG_BLANK_PASSWORD 0x02 |
44 |
|
|
45 |
/* Capabilities of mail server. */ |
/* Capabilities of mail server. */ |
46 |
#define CAPABILITY_NONE 0x00 |
#define CAPABILITY_NONE 0x00 |
57 |
|
|
58 |
/* Buffer size of the IMAP command. */ |
/* Buffer size of the IMAP command. */ |
59 |
#define SMALL_CMD 64 |
#define SMALL_CMD 64 |
60 |
#define MEDIUM_CMD 256 |
#define MEDIUM_CMD 512 |
61 |
#define BIG_CMD 8192 |
#define BIG_CMD 32768 |
62 |
|
|
63 |
/* Buffer size of server's response. */ |
/* Buffer size of server's response. */ |
64 |
#define RESPONSE_BUF (4096 + 1) |
#define RESPONSE_BUF (4096 + 1) |
65 |
#define RESULT_BUF 512 |
#define RESULT_BUF 512 |
66 |
|
|
67 |
/* Response codes. */ |
/* Response codes. */ |
68 |
|
#define RESPONSE_NONE -2 |
69 |
#define RESPONSE_BAD -1 |
#define RESPONSE_BAD -1 |
70 |
#define RESPONSE_OK 0 |
#define RESPONSE_OK 0 |
71 |
#define RESPONSE_NO 1 |
#define RESPONSE_NO 1 |
85 |
#define DECRYPTION_BUF 4096 |
#define DECRYPTION_BUF 4096 |
86 |
|
|
87 |
/* Maximum passwords the password editor can handle. */ |
/* Maximum passwords the password editor can handle. */ |
88 |
#define EDITOR_PASSWORDS_MAX 64 |
#define EDITOR_PASSWORDS_MAX 64 |
89 |
|
|
90 |
|
|
91 |
#define min(A, B) ((A) < (B) ? (A) : (B)) |
#define min(A, B) ((A) < (B) ? (A) : (B)) |
100 |
} secmem_t; |
} secmem_t; |
101 |
|
|
102 |
|
|
103 |
|
/* Namespace of IMAP mailboxes. */ |
104 |
|
typedef struct namesp { |
105 |
|
char prefix[NAMESPACE_PREFIX_LEN]; |
106 |
|
char delim; |
107 |
|
} namesp_t; |
108 |
|
|
109 |
|
|
110 |
/* file.c */ |
/* file.c */ |
111 |
int read_config(char *cfg); |
int read_config(char *cfg); |
112 |
int parse_config(FILE * fd); |
int parse_config(FILE * fd); |
120 |
int exists_file(char *fname); |
int exists_file(char *fname); |
121 |
int exists_dir(char *fname); |
int exists_dir(char *fname); |
122 |
int create_file(char *fname, mode_t mode); |
int create_file(char *fname, mode_t mode); |
|
int create_dir(char *dname, mode_t mode); |
|
123 |
#ifdef CHECK_PERMISSIONS |
#ifdef CHECK_PERMISSIONS |
124 |
int check_file_perms(char *fname, mode_t mode); |
int check_file_perms(char *fname, mode_t mode); |
125 |
int check_dir_perms(char *dname, mode_t mode); |
int check_dir_perms(char *dname, mode_t mode); |
129 |
void usage(void); |
void usage(void); |
130 |
|
|
131 |
/* imap.c */ |
/* imap.c */ |
132 |
unsigned int send_command(char *cmd); |
unsigned int send_command(int *sock, char *cmd); |
133 |
#ifdef DEBUG |
#ifdef DEBUG |
134 |
int imap_noop(void); |
int imap_noop(int *sock); |
135 |
#endif |
#endif |
136 |
int imap_capability(void); |
int imap_capability(int *sock); |
137 |
int imap_namespace(void); |
int imap_namespace(int *sock); |
138 |
int imap_logout(void); |
int imap_logout(int *sock); |
139 |
int imap_login(char *user, char *pass); |
int imap_login(int *sock, char *user, char *pass); |
140 |
/* int imap_examine(char *mbox); */ |
/* int imap_list(int *sock, char *refer, char *mbox); */ |
141 |
int imap_select(char *mbox); |
int imap_subscribe(int *sock, char *mbox); |
142 |
int imap_status(char *mbox, char *items); |
int imap_examine(int *sock, char *mbox); |
143 |
int imap_create(char *mbox); |
int imap_select(int *sock, char *mbox); |
144 |
int imap_search(char *search); |
int imap_status(int *sock, char *mbox, char *items); |
145 |
int imap_fetch(char *mesg, char *headers, int peek); |
int imap_create(int *sock, char *mbox); |
146 |
int imap_store(char *mesg, char *flags); |
int imap_search(int *sock, char *search); |
147 |
int imap_copy(char *mesg, char *mbox); |
int imap_fetch(int *sock, char *mesg, char *items); |
148 |
int imap_close(void); |
int imap_store(int *sock, char *mesg, char *flags); |
149 |
/* int imap_expunge(void); */ |
int imap_copy(int *sock, char *mesg, char *mbox); |
150 |
|
int imap_append(int *sock, char *mbox, unsigned int size); |
151 |
|
int imap_close(int *sock); |
152 |
|
/* int imap_expunge(int *sock); */ |
153 |
|
|
154 |
/* lock.c */ |
/* lock.c */ |
155 |
void lockfile_create(void); |
void lockfile_create(void); |
203 |
#endif |
#endif |
204 |
|
|
205 |
/* request.c */ |
/* request.c */ |
206 |
int test(void); |
int test(int *sock); |
207 |
int check_capabilities(void); |
int check_capabilities(int *sock); |
208 |
int check_namespace(void); |
int check_namespace(int *sock, namesp_t *nsp); |
209 |
int login(char *user, char *pass); |
int login(int *sock, char *user, char *pass); |
210 |
int select_mailbox(char *mbox); |
int check_mailbox(int *sock, char *mbox, namesp_t *nsp); |
211 |
int mailbox_status(char *mbox); |
int select_mailbox(int *sock, char *mbox, namesp_t *nsp); |
212 |
int close_mailbox(void); |
int mailbox_status(int *sock, char *mbox, namesp_t *nsp); |
213 |
int logout(void); |
int close_mailbox(int *sock); |
214 |
|
int logout(int *sock); |
215 |
|
|
216 |
int apply_filters(filter_t ** filters); |
int apply_filters(filter_t ** filters); |
217 |
int match_filter(filter_t * filter, char **mesgs); |
int match_filter(filter_t * filter, char **mesgs); |
220 |
void queue_fifo(mask_t ** mfifo, mask_t * mask); |
void queue_fifo(mask_t ** mfifo, mask_t * mask); |
221 |
mask_t *dequeue_fifo(mask_t ** mfifo); |
mask_t *dequeue_fifo(mask_t ** mfifo); |
222 |
|
|
223 |
char *generate_filter_and(mask_t * mask, unsigned int masknum, unsigned int masklen); |
char *generate_filter_and(mask_t * mask, unsigned int masknum, |
224 |
char *generate_filter_or(mask_t * mask, unsigned int masknum, unsigned int masklen); |
unsigned int masklen); |
225 |
|
char *generate_filter_or(mask_t * mask, unsigned int masknum, |
226 |
|
unsigned int masklen); |
227 |
|
|
228 |
int apply_action(char *mesgs, unsigned int *type, char *destmbox, char *args); |
int apply_action(char *mesgs, unsigned int *type, account_t *raccount, |
229 |
|
char *destmbox, char *args); |
230 |
int action_delete(char *mesgs, char *args); |
int action_delete(char *mesgs, char *args); |
231 |
int action_copy(char *mesgs, char *destmbox, char *args); |
int action_copy(char *mesgs, char *destmbox, char *args); |
232 |
int action_move(char *mesgs, char *destmbox, char *args); |
int action_move(char *mesgs, char *destmbox, char *args); |
233 |
|
int action_rcopy(char *mesgs, account_t *destacc, char *destmbox, char *args); |
234 |
|
int action_rmove(char *mesgs, account_t *destacc, char *destmbox, char *args); |
235 |
int action_list(char *mesgs, char *args); |
int action_list(char *mesgs, char *args); |
236 |
|
|
237 |
unsigned int convert_messages(char *mesgs); |
unsigned int count_messages(char *mesgs); |
238 |
|
void convert_messages(char *mesgs); |
239 |
|
|
240 |
|
|
241 |
/* response.c */ |
/* response.c */ |
242 |
void receive_response(char *buf); |
void receive_response(int *sock, char *buf); |
243 |
int server_response(unsigned int tag); |
int server_response(int *sock, unsigned int tag); |
244 |
int greeting_response(void); |
int greeting_response(int *sock); |
245 |
int capability_response(unsigned int tag); |
int capability_response(int *sock, unsigned int tag); |
246 |
int namespace_response(unsigned int tag, char *prefix, char delim); |
int namespace_response(int *sock, unsigned int tag, namesp_t *nsp); |
247 |
int status_response(unsigned int tag, char *mbox); |
int status_response(int *sock, unsigned int tag, char *mbox); |
248 |
int select_response(unsigned int tag); |
int select_response(int *sock, unsigned int tag); |
249 |
int search_response(unsigned int tag, char **mesgs); |
int search_response(int *sock, unsigned int tag, char **mesgs); |
250 |
int fetch_response(unsigned int tag); |
int fetch_response(int *sock, int reset, char *fetch, unsigned int tag); |
251 |
int copy_response(unsigned int tag); |
int fetchsize_response(int *sock, unsigned int *size, unsigned int tag); |
252 |
|
int append_response(int *sock, unsigned int tag); |
253 |
|
int copy_response(int *sock, unsigned int tag); |
254 |
int analyze_response(char *buf); |
int analyze_response(char *buf); |
255 |
|
void init_vbuf(void); |
256 |
|
void reset_vbuf(void); |
257 |
|
void check_vbuf(size_t n); |
258 |
|
|
259 |
/* socket.c */ |
/* socket.c */ |
260 |
int init_connection(char *serv, unsigned short int port, |
int init_connection(int *sock, char *serv, unsigned short int port, |
261 |
unsigned int protocol); |
unsigned int protocol); |
262 |
int ssl_init(unsigned int protocol); |
int ssl_init(int *sock, unsigned int protocol); |
263 |
int close_connection(void); |
int close_connection(int *sock); |
264 |
int socket_read(char *buf); |
int socket_read(int *sock, char *buf); |
265 |
int socket_write(char *data); |
int socket_write(int *sock, char *data); |
266 |
|
|
267 |
/* tty.c */ |
/* tty.c */ |
268 |
int tty_store(void); |
int tty_store(void); |