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

Annotation of /imapfilter/imapfilter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.46 - (hide annotations)
Sun Feb 2 22:53:39 2003 UTC (21 years, 1 month ago) by lefcha
Branch: MAIN
Changes since 1.45: +1 -1 lines
File MIME type: text/plain
Updated for 0.8.5.

1 lefcha 1.9 #ifndef IMAPFILTER_H
2     #define IMAPFILTER_H
3    
4     #include <stdio.h>
5 lefcha 1.25 #include <unistd.h>
6     #include <sys/stat.h>
7     #include <sys/types.h>
8 lefcha 1.29 #include <dirent.h>
9 lefcha 1.9
10     #ifndef DATA_H
11     #include "data.h"
12     #endif
13    
14 lefcha 1.43 /* Program's version number. */
15 lefcha 1.46 #define IMAPFILTER_VERSION "0.8.5"
16 lefcha 1.43
17 lefcha 1.11 /* Error codes returned by functions. */
18 lefcha 1.22 #define ERROR_SIGNAL 1
19     #define ERROR_TRIVIAL 2
20     #define ERROR_FILE_OPEN 3
21 lefcha 1.32 #define ERROR_LOCKFILE 4
22 lefcha 1.29 #define ERROR_CONFIG_PARSE 5
23     #define ERROR_MEMORY_ALLOCATION 6
24     #define ERROR_SETUID 7
25     #define ERROR_TERMIO 8
26     #define ERROR_NETWORK 9
27     #define ERROR_SSL 10
28     #define ERROR_PASSPHRASE 11
29     #define ERROR_ENCRYPT 12
30     #define ERROR_DECRYPT 13
31 lefcha 1.30 #define ERROR_FORK 14
32     #define ERROR_UNDEFINED 15
33 lefcha 1.9
34 lefcha 1.30 /* Flags that control the program's execution options. */
35 lefcha 1.36 #define OPTION_DETAILS_QUIET 0x0001
36     #define OPTION_DETAILS_NORMAL 0x0002
37     #define OPTION_DETAILS_VERBOSE 0x0004
38     #define OPTION_DETAILS_CLEAR 0xfff8
39 lefcha 1.38 #define OPTION_ERRORS 0x0008
40     #define OPTION_EXPUNGE 0x0010
41     #define OPTION_HEADERS 0x0020
42     #define OPTION_NAMESPACE 0x0040
43     #define OPTION_SUBSCRIBE 0x0080
44     #define OPTION_WARNING 0x0100
45     #define OPTION_PASSWORD_EDITOR 0x0200
46     #define OPTION_DAEMON_MODE 0x0400
47 lefcha 1.30
48     /* Other flags. */
49 lefcha 1.45 #define FLAG_TTY 0x01
50     #define FLAG_TTY_MODIFIED 0x02
51     #define FLAG_BLANK_PASSWORD 0x04
52 lefcha 1.25
53     /* Capabilities of mail server. */
54     #define CAPABILITY_NONE 0x00
55     #define CAPABILITY_NAMESPACE 0x01
56 lefcha 1.9
57 lefcha 1.12 /* Flags for logger. */
58     #define LOG_WRITE 0
59     #define LOG_SERVER 1
60     #define LOG_USERNAME 2
61     #define LOG_MAILBOX 3
62     #define LOG_FILTER 4
63     #define LOG_ACTION 5
64     #define LOG_DESTINATION_MAILBOX 6
65    
66 lefcha 1.17 /* Buffer size of the IMAP command. */
67 lefcha 1.9 #define SMALL_CMD 64
68 lefcha 1.32 #define MEDIUM_CMD 512
69     #define BIG_CMD 32768
70 lefcha 1.9
71 lefcha 1.35 /* Store IMAP command type may replace,add or remove flags. */
72     #define STORE_FLAG_REPLACE 1
73     #define STORE_FLAG_ADD 2
74     #define STORE_FLAG_REMOVE 3
75    
76 lefcha 1.9 /* Buffer size of server's response. */
77 lefcha 1.21 #define RESPONSE_BUF (4096 + 1)
78 lefcha 1.20 #define RESULT_BUF 512
79 lefcha 1.9
80 lefcha 1.16 /* Response codes. */
81 lefcha 1.44 #define RESPONSE_NULLBODY -2
82     #define RESPONSE_NONE -1
83 lefcha 1.16 #define RESPONSE_OK 0
84     #define RESPONSE_NO 1
85 lefcha 1.44 #define RESPONSE_BAD 2
86     #define RESPONSE_BYE 3
87     #define RESPONSE_PREAUTH 4
88     #define RESPONSE_READONLY 5
89     #define RESPONSE_TRYCREATE 6
90 lefcha 1.16
91 lefcha 1.39 /* Size virtual buffer. */
92     #define VIRTUAL_BUF 4096
93 lefcha 1.9
94 lefcha 1.25 /* Length of mailbox namespace prefix. */
95     #define NAMESPACE_PREFIX_LEN 64
96    
97 lefcha 1.26 /* Encryption and decryption buffers. */
98     #define ENCRYPTION_BUF 1024
99     #define DECRYPTION_BUF 4096
100    
101 lefcha 1.35 /* Buffer to save flags of the store IMAP command. */
102     #define STORE_FLAGS_BUF 64
103    
104 lefcha 1.27 /* Maximum passwords the password editor can handle. */
105 lefcha 1.32 #define EDITOR_PASSWORDS_MAX 64
106 lefcha 1.27
107 lefcha 1.1
108     #define min(A, B) ((A) < (B) ? (A) : (B))
109 lefcha 1.15 #define plural(A) ((A) == 1 ? "" : "s")
110 lefcha 1.1
111    
112 lefcha 1.27 /* Secure memory information. */
113     typedef struct secmem {
114     void *buf; /* Allocated memory buffer. */
115     size_t size; /* Size of the buffer. */
116     struct secmem *prev, *next; /* Previous/next node of doubly linked list. */
117     } secmem_t;
118    
119    
120 lefcha 1.32 /* Namespace of IMAP mailboxes. */
121     typedef struct namesp {
122     char prefix[NAMESPACE_PREFIX_LEN];
123     char delim;
124     } namesp_t;
125    
126    
127 lefcha 1.9 /* file.c */
128 lefcha 1.27 int read_config(char *cfg);
129     int parse_config(FILE * fd);
130     void set_options(char *line, regmatch_t * match);
131    
132     int read_passwords(void);
133     int parse_passwords(FILE * fd);
134     int store_passwords(account_t * accts[]);
135    
136 lefcha 1.25 int create_homedir(void);
137 lefcha 1.26 int exists_file(char *fname);
138     int exists_dir(char *fname);
139 lefcha 1.25 int create_file(char *fname, mode_t mode);
140 lefcha 1.9 #ifdef CHECK_PERMISSIONS
141 lefcha 1.25 int check_file_perms(char *fname, mode_t mode);
142     int check_dir_perms(char *dname, mode_t mode);
143 lefcha 1.9 #endif
144 lefcha 1.1
145 lefcha 1.9 /* imapfilter.c */
146     void usage(void);
147 lefcha 1.43 void version(void);
148 lefcha 1.1
149 lefcha 1.9 /* imap.c */
150 lefcha 1.32 unsigned int send_command(int *sock, char *cmd);
151 lefcha 1.9 #ifdef DEBUG
152 lefcha 1.32 int imap_noop(int *sock);
153 lefcha 1.9 #endif
154 lefcha 1.32 int imap_capability(int *sock);
155     int imap_namespace(int *sock);
156     int imap_logout(int *sock);
157     int imap_login(int *sock, char *user, char *pass);
158     /* int imap_list(int *sock, char *refer, char *mbox); */
159     int imap_subscribe(int *sock, char *mbox);
160     int imap_examine(int *sock, char *mbox);
161     int imap_select(int *sock, char *mbox);
162     int imap_status(int *sock, char *mbox, char *items);
163     int imap_create(int *sock, char *mbox);
164     int imap_search(int *sock, char *search);
165     int imap_fetch(int *sock, char *mesg, char *items);
166 lefcha 1.35 int imap_store(int *sock, char *mesg, unsigned int mode, char *flags);
167 lefcha 1.32 int imap_copy(int *sock, char *mesg, char *mbox);
168     int imap_append(int *sock, char *mbox, unsigned int size);
169     int imap_close(int *sock);
170 lefcha 1.34 int imap_expunge(int *sock);
171 lefcha 1.29
172     /* lock.c */
173     void lockfile_create(void);
174     void lockfile_check(void);
175 lefcha 1.30 pid_t lockfile_pid(void);
176 lefcha 1.29 int lockfile_remove(void);
177 lefcha 1.30 void kill_imapfilter(void);
178 lefcha 1.9
179     /* log.c */
180 lefcha 1.13 void info(const char *info,...);
181     void verbose(const char *info,...);
182     void error(const char *errmsg,...);
183     void fatal(unsigned int errnum, const char *fatal,...);
184 lefcha 1.22 void catch_signals(void);
185     void signal_handler(int sig);
186 lefcha 1.9 int open_logfile(void);
187     int create_logfile(void);
188     int close_logfile(void);
189 lefcha 1.12 void log_info(int flag, void *ptr);
190 lefcha 1.11 char *get_time(void);
191 lefcha 1.9
192 lefcha 1.13 /* memory.c */
193     void *xmalloc(size_t size);
194 lefcha 1.19 void *xrealloc(void *ptr, size_t size);
195 lefcha 1.26 void xfree(void *ptr);
196 lefcha 1.13 char *xstrdup(const char *s);
197    
198 lefcha 1.27 void *smalloc(size_t size);
199     void *srealloc(void *ptr, size_t size);
200     void sfree(void *ptr);
201     char *sstrdup(const char *s);
202 lefcha 1.34 void secmem_append(secmem_t * node);
203 lefcha 1.27 secmem_t *secmem_find(void *ptr);
204 lefcha 1.34 void secmem_remove(secmem_t * node);
205 lefcha 1.27 void secmem_clear(void);
206 lefcha 1.41 #ifdef MEMORY_LOCK
207 lefcha 1.30 void secmem_lock(void);
208 lefcha 1.41 #endif
209 lefcha 1.27 void corefile_disable(void);
210    
211 lefcha 1.16 /* misc.c */
212     char *strcasestr(const char *haystack, const char *needle);
213     char *ultostr(unsigned long int num, int base);
214 lefcha 1.24 char *xstrncpy(char *dest, const char *src, size_t size);
215 lefcha 1.16
216 lefcha 1.25 /* passwd.c */
217 lefcha 1.26 void get_password(char *passwd, size_t pwlen);
218     #ifdef ENCRYPTED_PASSWORDS
219 lefcha 1.34 int encrypt_passwords(FILE * fd, account_t * accts[]);
220     int decrypt_passwords(unsigned char **buf, FILE * fd);
221 lefcha 1.26 void password_editor(void);
222     #endif
223 lefcha 1.25
224 lefcha 1.9 /* request.c */
225 lefcha 1.32 int test(int *sock);
226     int check_capabilities(int *sock);
227 lefcha 1.34 int check_namespace(int *sock, namesp_t * nsp);
228 lefcha 1.32 int login(int *sock, char *user, char *pass);
229 lefcha 1.34 int check_mailbox(int *sock, char *mbox, namesp_t * nsp);
230     int select_mailbox(int *sock, char *mbox, namesp_t * nsp);
231     int mailbox_status(int *sock, char *mbox, namesp_t * nsp);
232 lefcha 1.32 int close_mailbox(int *sock);
233     int logout(int *sock);
234 lefcha 1.9
235 lefcha 1.16 int apply_filters(filter_t ** filters);
236 lefcha 1.19 int match_filter(filter_t * filter, char **mesgs);
237 lefcha 1.9
238     void empty_fifo(mask_t ** mfifo);
239 lefcha 1.11 void queue_fifo(mask_t ** mfifo, mask_t * mask);
240     mask_t *dequeue_fifo(mask_t ** mfifo);
241 lefcha 1.9
242 lefcha 1.32 char *generate_filter_and(mask_t * mask, unsigned int masknum,
243 lefcha 1.34 unsigned int masklen);
244     char *generate_filter_or(mask_t * mask, unsigned int masknum,
245 lefcha 1.32 unsigned int masklen);
246 lefcha 1.9
247 lefcha 1.34 int apply_action(char *mesgs, unsigned int *type, account_t * raccount,
248 lefcha 1.35 char *destmbox, unsigned int *msgflags, char *args);
249 lefcha 1.9 int action_delete(char *mesgs, char *args);
250 lefcha 1.11 int action_copy(char *mesgs, char *destmbox, char *args);
251     int action_move(char *mesgs, char *destmbox, char *args);
252 lefcha 1.34 int action_rcopy(char *mesgs, account_t * destacc, char *destmbox, char *args);
253     int action_rmove(char *mesgs, account_t * destacc, char *destmbox, char *args);
254 lefcha 1.35 int action_flag(char *mesgs, unsigned int *type, unsigned int *msgflags, char *args);
255 lefcha 1.11 int action_list(char *mesgs, char *args);
256 lefcha 1.9
257 lefcha 1.32 unsigned int count_messages(char *mesgs);
258 lefcha 1.33 char *convert_messages(char *mesgs);
259 lefcha 1.32
260 lefcha 1.9
261 lefcha 1.11 /* response.c */
262 lefcha 1.32 void receive_response(int *sock, char *buf);
263     int server_response(int *sock, unsigned int tag);
264 lefcha 1.40 void bye_response(char *buf);
265 lefcha 1.32 int greeting_response(int *sock);
266 lefcha 1.39 int logout_response(int *sock, unsigned int tag);
267 lefcha 1.32 int capability_response(int *sock, unsigned int tag);
268 lefcha 1.34 int namespace_response(int *sock, unsigned int tag, namesp_t * nsp);
269 lefcha 1.32 int status_response(int *sock, unsigned int tag, char *mbox);
270     int select_response(int *sock, unsigned int tag);
271     int search_response(int *sock, unsigned int tag, char **mesgs);
272 lefcha 1.43 int fetch_response(int *sock, unsigned int tag, int reset, char *fetch);
273 lefcha 1.32 int fetchsize_response(int *sock, unsigned int *size, unsigned int tag);
274     int append_response(int *sock, unsigned int tag);
275     int copy_response(int *sock, unsigned int tag);
276 lefcha 1.20 int analyze_response(char *buf);
277 lefcha 1.32 void init_vbuf(void);
278     void reset_vbuf(void);
279     void check_vbuf(size_t n);
280 lefcha 1.25
281     /* socket.c */
282 lefcha 1.32 int init_connection(int *sock, char *serv, unsigned short int port,
283 lefcha 1.34 unsigned int protocol);
284 lefcha 1.32 int ssl_init(int *sock, unsigned int protocol);
285     int close_connection(int *sock);
286     int socket_read(int *sock, char *buf);
287     int socket_write(int *sock, char *data);
288 lefcha 1.25
289     /* tty.c */
290     int tty_store(void);
291     int tty_disable_echo(void);
292     int tty_restore(void);
293 lefcha 1.11
294 lefcha 1.13 #endif /* IMAPFILTER_H */

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26