2 |
#define IMAPFILTER_H |
#define IMAPFILTER_H |
3 |
|
|
4 |
#include <stdio.h> |
#include <stdio.h> |
5 |
|
#include <unistd.h> |
6 |
|
#include <sys/stat.h> |
7 |
|
#include <sys/types.h> |
8 |
|
|
9 |
#ifndef DATA_H |
#ifndef DATA_H |
10 |
#include "data.h" |
#include "data.h" |
16 |
#define ERROR_FILE_OPEN 3 |
#define ERROR_FILE_OPEN 3 |
17 |
#define ERROR_CONFIG_PARSE 4 |
#define ERROR_CONFIG_PARSE 4 |
18 |
#define ERROR_MEMORY_ALLOCATION 5 |
#define ERROR_MEMORY_ALLOCATION 5 |
19 |
#define ERROR_NETWORK 6 |
#define ERROR_TERMIO 6 |
20 |
#define ERROR_SSL 7 |
#define ERROR_NETWORK 7 |
21 |
#define ERROR_UNDEFINED 8 |
#define ERROR_SSL 8 |
22 |
|
#define ERROR_UNDEFINED 9 |
23 |
|
|
24 |
/* Flags that control the program's options. */ |
/* Flags that control the program's options. */ |
25 |
#define OPTION_DETAILS_QUIET 0x01 |
#define OPTION_DETAILS_QUIET 0x01 |
27 |
#define OPTION_DETAILS_VERBOSE 0x04 |
#define OPTION_DETAILS_VERBOSE 0x04 |
28 |
#define OPTION_DETAILS_CLEAR 0xf8 |
#define OPTION_DETAILS_CLEAR 0xf8 |
29 |
#define OPTION_HEADERS 0x08 |
#define OPTION_HEADERS 0x08 |
30 |
|
#define OPTION_NAMESPACE 0x10 |
31 |
|
|
32 |
|
/* Capabilities of mail server. */ |
33 |
|
#define CAPABILITY_NONE 0x00 |
34 |
|
#define CAPABILITY_NAMESPACE 0x01 |
35 |
|
|
36 |
/* Flags for logger. */ |
/* Flags for logger. */ |
37 |
#define LOG_WRITE 0 |
#define LOG_WRITE 0 |
63 |
/* Buffer size of message's headers. */ |
/* Buffer size of message's headers. */ |
64 |
#define HEADERS_BUF 16384 |
#define HEADERS_BUF 16384 |
65 |
|
|
66 |
|
/* Length of mailbox namespace prefix. */ |
67 |
|
#define NAMESPACE_PREFIX_LEN 64 |
68 |
|
|
69 |
|
|
70 |
#define min(A, B) ((A) < (B) ? (A) : (B)) |
#define min(A, B) ((A) < (B) ? (A) : (B)) |
71 |
#define plural(A) ((A) == 1 ? "" : "s") |
#define plural(A) ((A) == 1 ? "" : "s") |
72 |
|
|
73 |
|
|
|
/* socket.c */ |
|
|
#ifndef SSL_TLS |
|
|
int init_connection(char *serv, unsigned short int port); |
|
|
#else |
|
|
int init_connection(char *serv, unsigned short int port, unsigned int protocol); |
|
|
#endif |
|
|
int ssl_init(unsigned int protocol); |
|
|
int close_connection(void); |
|
|
int socket_read(char *buf); |
|
|
int socket_write(char *data); |
|
|
|
|
74 |
/* file.c */ |
/* file.c */ |
75 |
int read_config(char *cfg); |
int create_homedir(void); |
76 |
|
int create_file(char *fname, mode_t mode); |
77 |
|
int create_dir(char *dname, mode_t mode); |
78 |
#ifdef CHECK_PERMISSIONS |
#ifdef CHECK_PERMISSIONS |
79 |
int check_permissions(char *cfg); |
int check_file_perms(char *fname, mode_t mode); |
80 |
|
int check_dir_perms(char *dname, mode_t mode); |
81 |
#endif |
#endif |
82 |
|
int read_config(char *cfg); |
83 |
int parse_config(FILE * fp); |
int parse_config(FILE * fp); |
84 |
void set_options(char *line, regmatch_t * match); |
void set_options(char *line, regmatch_t * match); |
85 |
|
|
92 |
int imap_noop(void); |
int imap_noop(void); |
93 |
#endif |
#endif |
94 |
int imap_capability(void); |
int imap_capability(void); |
95 |
|
int imap_namespace(void); |
96 |
int imap_logout(void); |
int imap_logout(void); |
97 |
int imap_login(char *user, char *pass); |
int imap_login(char *user, char *pass); |
98 |
/* int imap_examine(char *mbox); */ |
/* int imap_examine(char *mbox); */ |
129 |
char *ultostr(unsigned long int num, int base); |
char *ultostr(unsigned long int num, int base); |
130 |
char *xstrncpy(char *dest, const char *src, size_t size); |
char *xstrncpy(char *dest, const char *src, size_t size); |
131 |
|
|
132 |
|
/* passwd.c */ |
133 |
|
void get_password(char *user, char *serv, char *passwd); |
134 |
|
char *base64_encode(char *dest, char *src, int n); |
135 |
|
int base64_decode(char *dest, char *src); |
136 |
|
|
137 |
/* request.c */ |
/* request.c */ |
138 |
int test(void); |
int test(void); |
139 |
int check_capabilities(void); |
int check_capabilities(void); |
140 |
|
int check_namespace(void); |
141 |
int login(char *user, char *pass); |
int login(char *user, char *pass); |
142 |
int select_mailbox(char *mbox); |
int select_mailbox(char *mbox); |
143 |
int mailbox_status(char *mbox); |
int mailbox_status(char *mbox); |
167 |
int server_response(unsigned int tag); |
int server_response(unsigned int tag); |
168 |
int greeting_response(void); |
int greeting_response(void); |
169 |
int capability_response(unsigned int tag); |
int capability_response(unsigned int tag); |
170 |
|
int namespace_response(unsigned int tag, char *prefix, char delim); |
171 |
int status_response(unsigned int tag, char *mbox); |
int status_response(unsigned int tag, char *mbox); |
172 |
int select_response(unsigned int tag); |
int select_response(unsigned int tag); |
173 |
int search_response(unsigned int tag, char **mesgs); |
int search_response(unsigned int tag, char **mesgs); |
175 |
int copy_response(unsigned int tag); |
int copy_response(unsigned int tag); |
176 |
int analyze_response(char *buf); |
int analyze_response(char *buf); |
177 |
|
|
178 |
|
/* socket.c */ |
179 |
|
#ifndef SSL_TLS |
180 |
|
int init_connection(char *serv, unsigned short int port); |
181 |
|
#else |
182 |
|
int init_connection(char *serv, unsigned short int port, unsigned int protocol); |
183 |
|
#endif |
184 |
|
int ssl_init(unsigned int protocol); |
185 |
|
int close_connection(void); |
186 |
|
int socket_read(char *buf); |
187 |
|
int socket_write(char *data); |
188 |
|
|
189 |
|
/* tty.c */ |
190 |
|
int tty_store(void); |
191 |
|
int tty_disable_echo(void); |
192 |
|
int tty_restore(void); |
193 |
|
|
194 |
#endif /* IMAPFILTER_H */ |
#endif /* IMAPFILTER_H */ |