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

Annotation of /imapfilter/imapfilter.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.24.2.2 - (hide annotations)
Mon Jun 17 12:01:00 2002 UTC (21 years, 10 months ago) by lefcha
Branch: release-0_7-patches
Changes since 1.24.2.1: +3 -0 lines
File MIME type: text/plain
Bug fix related to communication with some mail servers.

1 lefcha 1.9 #ifndef IMAPFILTER_H
2     #define IMAPFILTER_H
3    
4     #include <stdio.h>
5    
6     #ifndef DATA_H
7     #include "data.h"
8     #endif
9    
10 lefcha 1.11 /* Error codes returned by functions. */
11 lefcha 1.22 #define ERROR_SIGNAL 1
12     #define ERROR_TRIVIAL 2
13     #define ERROR_FILE_OPEN 3
14     #define ERROR_CONFIG_PARSE 4
15     #define ERROR_MEMORY_ALLOCATION 5
16     #define ERROR_NETWORK 6
17     #define ERROR_SSL 7
18     #define ERROR_UNDEFINED 8
19 lefcha 1.9
20     /* Flags that control the program's options. */
21 lefcha 1.16 #define OPTION_DETAILS_QUIET 0x01
22 lefcha 1.9 #define OPTION_DETAILS_NORMAL 0x02
23     #define OPTION_DETAILS_VERBOSE 0x04
24     #define OPTION_DETAILS_CLEAR 0xf8
25 lefcha 1.14 #define OPTION_HEADERS 0x08
26 lefcha 1.24.2.1 #define OPTION_NAMESPACE 0x10
27    
28     /* Capabilities of mail server. */
29     #define CAPABILITY_NONE 0x00
30     #define CAPABILITY_NAMESPACE 0x01
31 lefcha 1.9
32 lefcha 1.12 /* Flags for logger. */
33     #define LOG_WRITE 0
34     #define LOG_SERVER 1
35     #define LOG_USERNAME 2
36     #define LOG_MAILBOX 3
37     #define LOG_FILTER 4
38     #define LOG_ACTION 5
39     #define LOG_DESTINATION_MAILBOX 6
40    
41 lefcha 1.17 /* Buffer size of the IMAP command. */
42 lefcha 1.9 #define SMALL_CMD 64
43     #define MEDIUM_CMD 256
44     #define BIG_CMD 8192
45    
46     /* Buffer size of server's response. */
47 lefcha 1.21 #define RESPONSE_BUF (4096 + 1)
48 lefcha 1.20 #define RESULT_BUF 512
49 lefcha 1.9
50 lefcha 1.16 /* Response codes. */
51     #define RESPONSE_BAD -1
52     #define RESPONSE_OK 0
53     #define RESPONSE_NO 1
54     #define RESPONSE_BYE 2
55 lefcha 1.20 #define RESPONSE_PREAUTH 3
56     #define RESPONSE_READONLY 4
57     #define RESPONSE_TRYCREATE 5
58 lefcha 1.16
59 lefcha 1.9 /* Buffer size of message's headers. */
60 lefcha 1.19 #define HEADERS_BUF 16384
61 lefcha 1.9
62 lefcha 1.24.2.1 /* Length of mailbox namespace prefix. */
63     #define NAMESPACE_PREFIX_LEN 64
64    
65 lefcha 1.1
66     #define min(A, B) ((A) < (B) ? (A) : (B))
67 lefcha 1.15 #define plural(A) ((A) == 1 ? "" : "s")
68 lefcha 1.1
69    
70 lefcha 1.24.2.1 /* Namespace of mailboxes residing on mail server. */
71     struct namespace_t {
72     char prefix[NAMESPACE_PREFIX_LEN];
73     char delim;
74     };
75    
76 lefcha 1.9
77     /* file.c */
78     int read_config(char *cfg);
79     #ifdef CHECK_PERMISSIONS
80     int check_permissions(char *cfg);
81     #endif
82     int parse_config(FILE * fp);
83 lefcha 1.10 void set_options(char *line, regmatch_t * match);
84 lefcha 1.1
85 lefcha 1.9 /* imapfilter.c */
86     void usage(void);
87 lefcha 1.1
88 lefcha 1.9 /* imap.c */
89 lefcha 1.16 unsigned int send_command(char *cmd);
90 lefcha 1.9 #ifdef DEBUG
91     int imap_noop(void);
92     #endif
93 lefcha 1.16 int imap_capability(void);
94 lefcha 1.24.2.1 int imap_namespace(void);
95 lefcha 1.9 int imap_logout(void);
96     int imap_login(char *user, char *pass);
97 lefcha 1.16 /* int imap_examine(char *mbox); */
98 lefcha 1.9 int imap_select(char *mbox);
99     int imap_status(char *mbox, char *items);
100     int imap_create(char *mbox);
101     int imap_search(char *search);
102 lefcha 1.16 int imap_fetch(char *mesg, char *headers, int peek);
103 lefcha 1.9 int imap_store(char *mesg, char *flags);
104     int imap_copy(char *mesg, char *mbox);
105     int imap_close(void);
106 lefcha 1.23 /* int imap_expunge(void); */
107 lefcha 1.9
108     /* log.c */
109 lefcha 1.13 void info(const char *info,...);
110     void verbose(const char *info,...);
111     void error(const char *errmsg,...);
112     void fatal(unsigned int errnum, const char *fatal,...);
113 lefcha 1.22 void catch_signals(void);
114     void signal_handler(int sig);
115 lefcha 1.9 int open_logfile(void);
116     int create_logfile(void);
117     int close_logfile(void);
118 lefcha 1.12 void log_info(int flag, void *ptr);
119 lefcha 1.11 char *get_time(void);
120 lefcha 1.9
121 lefcha 1.13 /* memory.c */
122     void *xmalloc(size_t size);
123 lefcha 1.19 void *xrealloc(void *ptr, size_t size);
124 lefcha 1.13 char *xstrdup(const char *s);
125    
126 lefcha 1.16 /* misc.c */
127     char *strcasestr(const char *haystack, const char *needle);
128     char *ultostr(unsigned long int num, int base);
129 lefcha 1.24 char *xstrncpy(char *dest, const char *src, size_t size);
130 lefcha 1.16
131 lefcha 1.9 /* request.c */
132     int test(void);
133 lefcha 1.16 int check_capabilities(void);
134 lefcha 1.24.2.1 int check_namespace(void);
135 lefcha 1.9 int login(char *user, char *pass);
136     int select_mailbox(char *mbox);
137 lefcha 1.11 int mailbox_status(char *mbox);
138 lefcha 1.9 int close_mailbox(void);
139     int logout(void);
140    
141 lefcha 1.16 int apply_filters(filter_t ** filters);
142 lefcha 1.19 int match_filter(filter_t * filter, char **mesgs);
143 lefcha 1.9
144     void empty_fifo(mask_t ** mfifo);
145 lefcha 1.11 void queue_fifo(mask_t ** mfifo, mask_t * mask);
146     mask_t *dequeue_fifo(mask_t ** mfifo);
147 lefcha 1.9
148 lefcha 1.11 char *generate_filter_and(mask_t * mask, unsigned int masknum, unsigned int masklen);
149     char *generate_filter_or(mask_t * mask, unsigned int masknum, unsigned int masklen);
150 lefcha 1.9
151 lefcha 1.11 int apply_action(char *mesgs, unsigned int *type, char *destmbox, char *args);
152 lefcha 1.9 int action_delete(char *mesgs, char *args);
153 lefcha 1.11 int action_copy(char *mesgs, char *destmbox, char *args);
154     int action_move(char *mesgs, char *destmbox, char *args);
155     int action_list(char *mesgs, char *args);
156 lefcha 1.9
157     unsigned int convert_messages(char *mesgs);
158    
159 lefcha 1.11 /* response.c */
160 lefcha 1.20 void receive_response(char *buf);
161 lefcha 1.16 int server_response(unsigned int tag);
162     int greeting_response(void);
163     int capability_response(unsigned int tag);
164 lefcha 1.24.2.1 int namespace_response(unsigned int tag, struct namespace_t * namesp);
165 lefcha 1.23 int status_response(unsigned int tag, char *mbox);
166 lefcha 1.16 int select_response(unsigned int tag);
167 lefcha 1.19 int search_response(unsigned int tag, char **mesgs);
168 lefcha 1.16 int fetch_response(unsigned int tag);
169     int copy_response(unsigned int tag);
170 lefcha 1.20 int analyze_response(char *buf);
171 lefcha 1.24.2.2 void init_vbuf(void);
172     void reset_vbuf(void);
173     void check_vbuf(size_t s);
174 lefcha 1.24.2.1
175     /* socket.c */
176     #ifndef SSL_TLS
177     int init_connection(char *serv, unsigned short int port);
178     #else
179     int init_connection(char *serv, unsigned short int port,
180     unsigned int protocol);
181     #endif
182     int ssl_init(unsigned int protocol);
183     int close_connection(void);
184     int socket_read(char *buf);
185     int socket_write(char *data);
186 lefcha 1.11
187 lefcha 1.13 #endif /* IMAPFILTER_H */

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26