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

Annotation of /imapfilter/imapfilter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.37 - (hide annotations)
Fri Jul 26 18:18:42 2002 UTC (21 years, 8 months ago) by lefcha
Branch: MAIN
CVS Tags: release-0_8
Branch point for: release-0_8-patches
Changes since 1.36: +3 -2 lines
File MIME type: text/plain
New variable about mlock() warning.

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26