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

Annotation of /imapfilter/imapfilter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.27 - (hide annotations)
Tue Jan 29 21:23:42 2002 UTC (22 years, 2 months ago) by lefcha
Branch: MAIN
Changes since 1.26: +40 -14 lines
File MIME type: text/plain
Added secure memory allocation subsystem.

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

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26