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

Annotation of /imapfilter/imapfilter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.29 - (hide annotations)
Wed Jan 30 19:19:00 2002 UTC (22 years, 2 months ago) by lefcha
Branch: MAIN
Changes since 1.28: +17 -10 lines
File MIME type: text/plain
Added lockfile to prevent many imapfilters from running simultaneously.

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.29 #define ERROR_LOCK_FILE 4
19     #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     #define ERROR_UNDEFINED 14
29 lefcha 1.9
30     /* Flags that control the program's options. */
31 lefcha 1.16 #define OPTION_DETAILS_QUIET 0x01
32 lefcha 1.9 #define OPTION_DETAILS_NORMAL 0x02
33     #define OPTION_DETAILS_VERBOSE 0x04
34     #define OPTION_DETAILS_CLEAR 0xf8
35 lefcha 1.14 #define OPTION_HEADERS 0x08
36 lefcha 1.25 #define OPTION_NAMESPACE 0x10
37 lefcha 1.26 #define OPTION_PASSWORD_EDITOR 0x20
38 lefcha 1.25
39     /* Capabilities of mail server. */
40     #define CAPABILITY_NONE 0x00
41     #define CAPABILITY_NAMESPACE 0x01
42 lefcha 1.9
43 lefcha 1.12 /* Flags for logger. */
44     #define LOG_WRITE 0
45     #define LOG_SERVER 1
46     #define LOG_USERNAME 2
47     #define LOG_MAILBOX 3
48     #define LOG_FILTER 4
49     #define LOG_ACTION 5
50     #define LOG_DESTINATION_MAILBOX 6
51    
52 lefcha 1.17 /* Buffer size of the IMAP command. */
53 lefcha 1.9 #define SMALL_CMD 64
54     #define MEDIUM_CMD 256
55     #define BIG_CMD 8192
56    
57     /* Buffer size of server's response. */
58 lefcha 1.21 #define RESPONSE_BUF (4096 + 1)
59 lefcha 1.20 #define RESULT_BUF 512
60 lefcha 1.9
61 lefcha 1.16 /* Response codes. */
62     #define RESPONSE_BAD -1
63     #define RESPONSE_OK 0
64     #define RESPONSE_NO 1
65     #define RESPONSE_BYE 2
66 lefcha 1.20 #define RESPONSE_PREAUTH 3
67     #define RESPONSE_READONLY 4
68     #define RESPONSE_TRYCREATE 5
69 lefcha 1.16
70 lefcha 1.9 /* Buffer size of message's headers. */
71 lefcha 1.19 #define HEADERS_BUF 16384
72 lefcha 1.9
73 lefcha 1.25 /* Length of mailbox namespace prefix. */
74     #define NAMESPACE_PREFIX_LEN 64
75    
76 lefcha 1.26 /* Encryption and decryption buffers. */
77     #define ENCRYPTION_BUF 1024
78     #define DECRYPTION_BUF 4096
79    
80 lefcha 1.27 /* Maximum passwords the password editor can handle. */
81     #define EDITOR_PASSWORDS_MAX 64
82    
83 lefcha 1.1
84     #define min(A, B) ((A) < (B) ? (A) : (B))
85 lefcha 1.15 #define plural(A) ((A) == 1 ? "" : "s")
86 lefcha 1.1
87    
88 lefcha 1.27 /* Secure memory information. */
89     typedef struct secmem {
90     void *buf; /* Allocated memory buffer. */
91     size_t size; /* Size of the buffer. */
92     struct secmem *prev, *next; /* Previous/next node of doubly linked list. */
93     } secmem_t;
94    
95    
96 lefcha 1.9 /* file.c */
97 lefcha 1.27 int read_config(char *cfg);
98     int parse_config(FILE * fd);
99     void set_options(char *line, regmatch_t * match);
100    
101     int read_passwords(void);
102     int parse_passwords(FILE * fd);
103     int store_passwords(account_t * accts[]);
104    
105 lefcha 1.25 int create_homedir(void);
106 lefcha 1.26 int exists_file(char *fname);
107     int exists_dir(char *fname);
108 lefcha 1.25 int create_file(char *fname, mode_t mode);
109     int create_dir(char *dname, mode_t mode);
110 lefcha 1.9 #ifdef CHECK_PERMISSIONS
111 lefcha 1.25 int check_file_perms(char *fname, mode_t mode);
112     int check_dir_perms(char *dname, mode_t mode);
113 lefcha 1.9 #endif
114 lefcha 1.1
115 lefcha 1.9 /* imapfilter.c */
116     void usage(void);
117 lefcha 1.1
118 lefcha 1.9 /* imap.c */
119 lefcha 1.16 unsigned int send_command(char *cmd);
120 lefcha 1.9 #ifdef DEBUG
121     int imap_noop(void);
122     #endif
123 lefcha 1.16 int imap_capability(void);
124 lefcha 1.25 int imap_namespace(void);
125 lefcha 1.9 int imap_logout(void);
126     int imap_login(char *user, char *pass);
127 lefcha 1.16 /* int imap_examine(char *mbox); */
128 lefcha 1.9 int imap_select(char *mbox);
129     int imap_status(char *mbox, char *items);
130     int imap_create(char *mbox);
131     int imap_search(char *search);
132 lefcha 1.16 int imap_fetch(char *mesg, char *headers, int peek);
133 lefcha 1.9 int imap_store(char *mesg, char *flags);
134     int imap_copy(char *mesg, char *mbox);
135     int imap_close(void);
136 lefcha 1.23 /* int imap_expunge(void); */
137 lefcha 1.29
138     /* lock.c */
139     void lockfile_create(void);
140     void lockfile_check(void);
141     int lockfile_remove(void);
142 lefcha 1.9
143     /* log.c */
144 lefcha 1.13 void info(const char *info,...);
145     void verbose(const char *info,...);
146     void error(const char *errmsg,...);
147     void fatal(unsigned int errnum, const char *fatal,...);
148 lefcha 1.22 void catch_signals(void);
149     void signal_handler(int sig);
150 lefcha 1.9 int open_logfile(void);
151     int create_logfile(void);
152     int close_logfile(void);
153 lefcha 1.12 void log_info(int flag, void *ptr);
154 lefcha 1.11 char *get_time(void);
155 lefcha 1.9
156 lefcha 1.13 /* memory.c */
157     void *xmalloc(size_t size);
158 lefcha 1.19 void *xrealloc(void *ptr, size_t size);
159 lefcha 1.26 void xfree(void *ptr);
160 lefcha 1.13 char *xstrdup(const char *s);
161    
162 lefcha 1.27 void *smalloc(size_t size);
163     void *srealloc(void *ptr, size_t size);
164     void sfree(void *ptr);
165     char *sstrdup(const char *s);
166     void secmem_append(secmem_t *node);
167     secmem_t *secmem_find(void *ptr);
168     void secmem_remove(secmem_t *node);
169     void secmem_clear(void);
170    
171     void corefile_disable(void);
172    
173 lefcha 1.16 /* misc.c */
174     char *strcasestr(const char *haystack, const char *needle);
175     char *ultostr(unsigned long int num, int base);
176 lefcha 1.24 char *xstrncpy(char *dest, const char *src, size_t size);
177 lefcha 1.16
178 lefcha 1.25 /* passwd.c */
179 lefcha 1.26 void get_password(char *passwd, size_t pwlen);
180     #ifdef ENCRYPTED_PASSWORDS
181     int encrypt_passwords(FILE *fd, account_t *accts[]);
182 lefcha 1.27 int decrypt_passwords(unsigned char **buf, FILE *fd);
183 lefcha 1.26 void password_editor(void);
184     #endif
185 lefcha 1.25
186 lefcha 1.9 /* request.c */
187     int test(void);
188 lefcha 1.16 int check_capabilities(void);
189 lefcha 1.25 int check_namespace(void);
190 lefcha 1.9 int login(char *user, char *pass);
191     int select_mailbox(char *mbox);
192 lefcha 1.11 int mailbox_status(char *mbox);
193 lefcha 1.9 int close_mailbox(void);
194     int logout(void);
195    
196 lefcha 1.16 int apply_filters(filter_t ** filters);
197 lefcha 1.19 int match_filter(filter_t * filter, char **mesgs);
198 lefcha 1.9
199     void empty_fifo(mask_t ** mfifo);
200 lefcha 1.11 void queue_fifo(mask_t ** mfifo, mask_t * mask);
201     mask_t *dequeue_fifo(mask_t ** mfifo);
202 lefcha 1.9
203 lefcha 1.11 char *generate_filter_and(mask_t * mask, unsigned int masknum, unsigned int masklen);
204     char *generate_filter_or(mask_t * mask, unsigned int masknum, unsigned int masklen);
205 lefcha 1.9
206 lefcha 1.11 int apply_action(char *mesgs, unsigned int *type, char *destmbox, char *args);
207 lefcha 1.9 int action_delete(char *mesgs, char *args);
208 lefcha 1.11 int action_copy(char *mesgs, char *destmbox, char *args);
209     int action_move(char *mesgs, char *destmbox, char *args);
210     int action_list(char *mesgs, char *args);
211 lefcha 1.9
212     unsigned int convert_messages(char *mesgs);
213    
214 lefcha 1.11 /* response.c */
215 lefcha 1.20 void receive_response(char *buf);
216 lefcha 1.16 int server_response(unsigned int tag);
217     int greeting_response(void);
218     int capability_response(unsigned int tag);
219 lefcha 1.25 int namespace_response(unsigned int tag, char *prefix, char delim);
220 lefcha 1.23 int status_response(unsigned int tag, char *mbox);
221 lefcha 1.16 int select_response(unsigned int tag);
222 lefcha 1.19 int search_response(unsigned int tag, char **mesgs);
223 lefcha 1.16 int fetch_response(unsigned int tag);
224     int copy_response(unsigned int tag);
225 lefcha 1.20 int analyze_response(char *buf);
226 lefcha 1.25
227     /* socket.c */
228     #ifndef SSL_TLS
229     int init_connection(char *serv, unsigned short int port);
230     #else
231     int init_connection(char *serv, unsigned short int port, unsigned int protocol);
232     #endif
233     int ssl_init(unsigned int protocol);
234     int close_connection(void);
235     int socket_read(char *buf);
236     int socket_write(char *data);
237    
238     /* tty.c */
239     int tty_store(void);
240     int tty_disable_echo(void);
241     int tty_restore(void);
242 lefcha 1.11
243 lefcha 1.13 #endif /* IMAPFILTER_H */

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26