/[imapfilter]/imapfilter/imapfilter.h
ViewVC logotype

Annotation of /imapfilter/imapfilter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.81 - (hide annotations)
Fri Feb 13 12:17:16 2004 UTC (20 years, 1 month ago) by lefcha
Branch: MAIN
Changes since 1.80: +119 -123 lines
File MIME type: text/plain
Stylistic changes.

1 lefcha 1.9 #ifndef IMAPFILTER_H
2     #define IMAPFILTER_H
3    
4    
5 lefcha 1.68 #include <stdio.h>
6     #include <sys/types.h>
7 lefcha 1.80 #include <limits.h>
8 lefcha 1.68
9 lefcha 1.54 #include "config.h"
10 lefcha 1.65 #include "account.h"
11     #include "filter.h"
12 lefcha 1.54
13     #ifdef SSL_TLS
14     #include <openssl/ssl.h>
15     #endif
16    
17 lefcha 1.43
18 lefcha 1.11 /* Error codes returned by functions. */
19 lefcha 1.81 #define ERROR_UNDEFINED 1
20     #define ERROR_TRIVIAL 2
21     #define ERROR_SIGNAL 3
22     #define ERROR_FILEOPEN 4
23     #define ERROR_LOCKFILE 5
24     #define ERROR_PARSER 6
25     #define ERROR_MEMALLOC 7
26     #define ERROR_SETUID 8
27     #define ERROR_TERMIO 9
28     #define ERROR_NETWORK 10
29     #define ERROR_SSL 11
30     #define ERROR_PASSPHRASE 12
31     #define ERROR_ENCRYPT 13
32     #define ERROR_DECRYPT 14
33     #define ERROR_FORK 15
34 lefcha 1.9
35 lefcha 1.54 /* SSL/TLS certificate status for the server. */
36 lefcha 1.81 #define CERT_OK 0
37     #define CERT_NONE 1
38     #define CERT_MISMATCH 2
39 lefcha 1.54
40     /* Action to be applied, concerning the SSL/TLS certificate. */
41 lefcha 1.81 #define CERT_ACTION_ACCEPT 0
42     #define CERT_ACTION_REJECT 1
43     #define CERT_ACTION_CONTINUE 0
44     #define CERT_ACTION_ABORT 1
45 lefcha 1.54
46 lefcha 1.30 /* Other flags. */
47 lefcha 1.81 #define FLAG_DAEMON 0x01
48     #define FLAG_TTY 0x02
49     #define FLAG_TTYMOD 0x04
50     #define FLAG_BLANKPASS 0x08
51     #define FLAG_SIGUSR1 0x10
52 lefcha 1.25
53     /* Capabilities of mail server. */
54 lefcha 1.81 #define CAPS_NONE 0x00
55     #define CAPS_NAMESPACE 0x01
56     #define CAPS_CRAMMD5 0x02
57     #define CAPS_STARTTLS 0x04
58 lefcha 1.9
59 lefcha 1.12 /* Flags for logger. */
60 lefcha 1.81 #define LOG_PREAMBLE 0
61     #define LOG_ACCOUNT 1
62     #define LOG_MBOX 2
63     #define LOG_FILTER 3
64     #define LOG_ACTION 4
65     #define LOG_DEST_ACCOUNT 5
66     #define LOG_DEST_MBOX 6
67     #define LOG_HEADER 7
68    
69     /* Response codes. */
70     #define RESPONSE_NULLBODY -2
71     #define RESPONSE_NONE -1
72     #define RESPONSE_OK 0
73     #define RESPONSE_NO 1
74     #define RESPONSE_BAD 2
75     #define RESPONSE_BYE 3
76     #define RESPONSE_PREAUTH 4
77     #define RESPONSE_READONLY 5
78     #define RESPONSE_TRYCREATE 6
79 lefcha 1.35
80 lefcha 1.9 /* Buffer size of server's response. */
81 lefcha 1.81 #define RESPONSE_BUF 4096
82     #define RESULT_BUF 512
83 lefcha 1.16
84 lefcha 1.26 /* Encryption and decryption buffers. */
85 lefcha 1.81 #define ENCRYPT_BUF 1024
86     #define DECRYPT_BUF 4096
87 lefcha 1.26
88 lefcha 1.35 /* Buffer to save flags of the store IMAP command. */
89 lefcha 1.81 #define STORE_FLAGS_BUF 64
90 lefcha 1.35
91 lefcha 1.69 /* Length of charset for IMAP SEARCH requests. */
92 lefcha 1.81 #define CHARSET_LEN 64
93 lefcha 1.47
94 lefcha 1.65 /* String lengths of master password and encrypted passwords. */
95 lefcha 1.81 #define PASSPHRASE_LEN 256
96 lefcha 1.65
97     /* Length of mailbox namespace prefix. */
98 lefcha 1.81 #define NAMESPACE_PREFIX_LEN 64
99 lefcha 1.65
100 lefcha 1.1
101 lefcha 1.81 #define min(A, B) ((A) < (B) ? (A) : (B))
102     #define plural(A) ((A) == 1 ? "" : "s")
103 lefcha 1.1
104    
105 lefcha 1.80 /* Program's options. */
106 lefcha 1.81 typedef struct options {
107 lefcha 1.80 int debug; /* Debugging level (1..2). */
108     int verbosity; /* Verbosity level (-2..2). */
109     int timeout; /* Server non-response timeout in seconds. */
110     int daemon; /* Daemon mode interval. */
111     int headers; /* Print messages headers to stdout. */
112     int errors; /* Errors appended to logfile. */
113     int namespace; /* Apply mailbox namespace automatically. */
114     int expunge; /* Expunge messages after they are marked
115     * deleted. */
116     int subscribe; /* Subscribe newly created mailboxes. */
117 lefcha 1.81 int peek; /* Do not mark messages seen when their headers
118     * are received. */
119 lefcha 1.80 int passwd_editor; /* Enter interactive password editor. */
120     char charset[CHARSET_LEN]; /* Search criteria character set. */
121     char logfile[PATH_MAX]; /* Log file for filtering information. */
122 lefcha 1.81 } options_t;
123 lefcha 1.80
124 lefcha 1.64 /* IMAP connection. */
125 lefcha 1.81 typedef struct connection {
126 lefcha 1.64 int sock; /* Socket. */
127     #ifdef SSL_TLS
128     SSL *ssl; /* SSL socket. */
129     #endif
130     unsigned int caps; /* Capabilities of the mail server. */
131 lefcha 1.65 struct { /* Namespace of the mail server's mailboxes. */
132     char prefix[NAMESPACE_PREFIX_LEN]; /* Namespace prefix. */
133     char delim; /* Namespace delimiter. */
134 lefcha 1.81 } ns;
135     } connection_t;
136 lefcha 1.64
137    
138 lefcha 1.65 /* action.c */
139 lefcha 1.79 int apply_action(char *mbox, char *mesgs, unsigned int *type, account_t * raccount, char *destmbox, unsigned int *msgflags, char *args);
140 lefcha 1.65
141 lefcha 1.61 /* auth.c */
142 lefcha 1.62 #ifdef CRAM_MD5
143 lefcha 1.81 int auth_cram_md5(connection_t * conn, char *user, char *pass);
144 lefcha 1.65 #endif
145 lefcha 1.61
146 lefcha 1.65 /* cert.c */
147     #ifdef SSL_TLS
148 lefcha 1.81 int get_cert(connection_t * conn);
149 lefcha 1.62 #endif
150    
151 lefcha 1.65 /* destroy.c */
152     void destroy_all(void);
153     void destroy_unneeded(void);
154 lefcha 1.63
155 lefcha 1.9 /* file.c */
156 lefcha 1.25 int create_homedir(void);
157 lefcha 1.26 int exists_file(char *fname);
158     int exists_dir(char *fname);
159 lefcha 1.25 int create_file(char *fname, mode_t mode);
160     int check_file_perms(char *fname, mode_t mode);
161 lefcha 1.75 int check_dir_perms(char *dname, mode_t mode);
162 lefcha 1.54
163 lefcha 1.9 /* imap.c */
164 lefcha 1.81 int imap_noop(connection_t * conn);
165     int imap_capability(connection_t * conn);
166     int imap_namespace(connection_t * conn);
167     int imap_logout(connection_t * conn);
168 lefcha 1.62 #ifdef SSL_TLS
169 lefcha 1.81 int imap_starttls(connection_t * conn);
170 lefcha 1.62 #endif
171 lefcha 1.81 int imap_authenticate(connection_t * conn, char *auth, int cont);
172     int imap_login(connection_t * conn, char *user, char *pass);
173     /* int imap_list(connection_t *conn, char *refer, char *mbox); */
174     int imap_subscribe(connection_t * conn, char *mbox);
175     /* int imap_examine(connection_t *conn, char *mbox); */
176     int imap_select(connection_t * conn, char *mbox);
177     int imap_status(connection_t * conn, char *mbox, char *items);
178     int imap_create(connection_t * conn, char *mbox);
179     int imap_search(connection_t * conn, char *charset, char *search);
180     int imap_fetch(connection_t * conn, char *mesg, char *items);
181     int imap_store(connection_t * conn, char *mesg, unsigned int mode, char *flags);
182     int imap_copy(connection_t * conn, char *mesg, char *mbox);
183     int imap_append(connection_t * conn, char *mbox, char *flags, char *date, unsigned int size);
184     int imap_close(connection_t * conn);
185     int imap_expunge(connection_t * conn);
186 lefcha 1.29
187     /* lock.c */
188     void lockfile_create(void);
189     void lockfile_check(void);
190     int lockfile_remove(void);
191 lefcha 1.30 void kill_imapfilter(void);
192 lefcha 1.9
193     /* log.c */
194 lefcha 1.13 void info(const char *info,...);
195     void verbose(const char *info,...);
196 lefcha 1.74 void debug(const char *debug,...);
197 lefcha 1.13 void error(const char *errmsg,...);
198     void fatal(unsigned int errnum, const char *fatal,...);
199 lefcha 1.22 void catch_signals(void);
200 lefcha 1.74 int debug_start(void);
201     int debug_stop(void);
202     int log_start(void);
203     int log_stop(void);
204 lefcha 1.12 void log_info(int flag, void *ptr);
205 lefcha 1.65
206     /* match.c */
207     int apply_filters(char *mbox, filter_t ** filters);
208 lefcha 1.9
209 lefcha 1.13 /* memory.c */
210     void *xmalloc(size_t size);
211 lefcha 1.19 void *xrealloc(void *ptr, size_t size);
212 lefcha 1.26 void xfree(void *ptr);
213 lefcha 1.13 char *xstrdup(const char *s);
214    
215 lefcha 1.27 void *smalloc(size_t size);
216     void *srealloc(void *ptr, size_t size);
217     void sfree(void *ptr);
218     char *sstrdup(const char *s);
219 lefcha 1.81
220 lefcha 1.27 void secmem_clear(void);
221 lefcha 1.49
222 lefcha 1.27 void corefile_disable(void);
223    
224 lefcha 1.16 /* misc.c */
225     char *strcasestr(const char *haystack, const char *needle);
226     char *ultostr(unsigned long int num, int base);
227 lefcha 1.24 char *xstrncpy(char *dest, const char *src, size_t size);
228 lefcha 1.16
229 lefcha 1.65 /* parse.c */
230     int read_config(char *cfg);
231     void reread_config(char *cfg);
232     int read_passwords(void);
233    
234 lefcha 1.25 /* passwd.c */
235 lefcha 1.26 void get_password(char *passwd, size_t pwlen);
236     #ifdef ENCRYPTED_PASSWORDS
237 lefcha 1.60 int encrypt_passwords(FILE * fd, account_t ** accts);
238 lefcha 1.34 int decrypt_passwords(unsigned char **buf, FILE * fd);
239 lefcha 1.26 void password_editor(void);
240     #endif
241 lefcha 1.25
242 lefcha 1.9 /* request.c */
243 lefcha 1.81 int test(connection_t * conn);
244     int check_capabilities(connection_t * conn);
245     int check_namespace(connection_t * conn);
246 lefcha 1.62 #ifdef SSL_TLS
247 lefcha 1.81 int negotiate_tls(connection_t * conn);
248 lefcha 1.62 #endif
249 lefcha 1.81 int login(connection_t * conn, char *user, char *pass);
250     int check_mailbox(connection_t * conn, char *mbox);
251     int select_mailbox(connection_t * conn, char *mbox);
252     int mailbox_status(connection_t * conn, char *mbox);
253     int close_mailbox(connection_t * conn);
254     int logout(connection_t * conn);
255 lefcha 1.9
256 lefcha 1.65 /* response.c */
257 lefcha 1.81 int response_generic(connection_t * conn, unsigned int tag);
258     int response_greeting(connection_t * conn);
259     int response_logout(connection_t * conn, unsigned int tag);
260     int response_capability(connection_t * conn, unsigned int tag);
261     int response_authenticate(connection_t * conn, unsigned int tag, unsigned char **cont);
262     int response_namespace(connection_t * conn, unsigned int tag);
263     int response_status(connection_t * conn, unsigned int tag, char *mbox);
264     int response_select(connection_t * conn, unsigned int tag);
265     int response_search(connection_t * conn, unsigned int tag, char **mesgs);
266     int response_fetch(connection_t * conn, unsigned int tag, int reset, char *fetch);
267     int response_fetchfast(connection_t * conn, char **flags, char **date, unsigned int *size, unsigned int tag);
268     int response_append(connection_t * conn, unsigned int tag);
269     int response_copy(connection_t * conn, unsigned int tag);
270 lefcha 1.25
271     /* socket.c */
272 lefcha 1.80 int
273 lefcha 1.81 init_connection(connection_t * conn, char *serv, unsigned short int port, unsigned int protocol);
274 lefcha 1.62 #ifdef SSL_TLS
275 lefcha 1.81 int init_secure_connection(connection_t * conn, unsigned int protocol);
276 lefcha 1.62 #endif
277 lefcha 1.81 int close_connection(connection_t * conn);
278     int socket_read(connection_t * conn, char *buf);
279     int socket_write(connection_t * conn, char *data);
280 lefcha 1.25
281     /* tty.c */
282     int tty_store(void);
283 lefcha 1.81 int tty_noecho(void);
284 lefcha 1.25 int tty_restore(void);
285 lefcha 1.65
286 lefcha 1.11
287 lefcha 1.13 #endif /* IMAPFILTER_H */

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26