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

Diff of /imapfilter/imapfilter.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.80 by lefcha, Tue Feb 10 22:21:09 2004 UTC revision 1.81 by lefcha, Fri Feb 13 12:17:16 2004 UTC
# Line 16  Line 16 
16    
17    
18  /* Error codes returned by functions. */  /* Error codes returned by functions. */
19  #define ERROR_UNDEFINED                 1  #define ERROR_UNDEFINED         1
20  #define ERROR_SIGNAL                    2  #define ERROR_TRIVIAL           2
21  #define ERROR_TRIVIAL                   3  #define ERROR_SIGNAL            3
22  #define ERROR_FILE_OPEN                 4  #define ERROR_FILEOPEN          4
23  #define ERROR_LOCKFILE                  5  #define ERROR_LOCKFILE          5
24  #define ERROR_CONFIG_PARSE              6  #define ERROR_PARSER            6
25  #define ERROR_MEMORY_ALLOCATION         7  #define ERROR_MEMALLOC          7
26  #define ERROR_SETUID                    8  #define ERROR_SETUID            8
27  #define ERROR_TERMIO                    9  #define ERROR_TERMIO            9
28  #define ERROR_NETWORK                   10  #define ERROR_NETWORK           10
29  #define ERROR_SSL                       11  #define ERROR_SSL               11
30  #define ERROR_PASSPHRASE                12  #define ERROR_PASSPHRASE        12
31  #define ERROR_ENCRYPT                   13  #define ERROR_ENCRYPT           13
32  #define ERROR_DECRYPT                   14  #define ERROR_DECRYPT           14
33  #define ERROR_FORK                      15  #define ERROR_FORK              15
34    
35  /* SSL/TLS certificate status for the server. */  /* SSL/TLS certificate status for the server. */
36  #define SSL_CERT_OK                     0  #define CERT_OK                 0
37  #define SSL_CERT_NONEXISTENT            1  #define CERT_NONE               1
38  #define SSL_CERT_MISMATCH               2  #define CERT_MISMATCH           2
39    
40  /* Action to be applied, concerning the SSL/TLS certificate. */  /* Action to be applied, concerning the SSL/TLS certificate. */
41  #define SSL_CERT_ACTION_ACCEPT          0  #define CERT_ACTION_ACCEPT      0
42  #define SSL_CERT_ACTION_REJECT          1  #define CERT_ACTION_REJECT      1
43  #define SSL_CERT_ACTION_CONTINUE        0  #define CERT_ACTION_CONTINUE    0
44  #define SSL_CERT_ACTION_ABORT           1  #define CERT_ACTION_ABORT       1
45    
46  /* Other flags. */  /* Other flags. */
47  #define FLAG_DAEMON_MODE                0x01  #define FLAG_DAEMON             0x01
48  #define FLAG_TTY                        0x02  #define FLAG_TTY                0x02
49  #define FLAG_TTY_MODIFIED               0x04  #define FLAG_TTYMOD             0x04
50  #define FLAG_BLANK_PASSWORD             0x08  #define FLAG_BLANKPASS          0x08
51  #define FLAG_SIGUSR1_RECEIVED           0x10  #define FLAG_SIGUSR1            0x10
52    
53  /* Capabilities of mail server. */  /* Capabilities of mail server. */
54  #define CAPABILITY_NONE                 0x00  #define CAPS_NONE               0x00
55  #define CAPABILITY_NAMESPACE            0x01  #define CAPS_NAMESPACE          0x01
56  #define CAPABILITY_AUTH_CRAM_MD5        0x02  #define CAPS_CRAMMD5            0x02
57  #define CAPABILITY_STARTTLS             0x04  #define CAPS_STARTTLS           0x04
58    
59  /* Flags for logger. */  /* Flags for logger. */
60  #define LOG_PREAMBLE                    0  #define LOG_PREAMBLE            0
61  #define LOG_ACCOUNT                     1  #define LOG_ACCOUNT             1
62  #define LOG_MAILBOX                     2  #define LOG_MBOX                2
63  #define LOG_FILTER                      3  #define LOG_FILTER              3
64  #define LOG_ACTION                      4  #define LOG_ACTION              4
65  #define LOG_DESTINATION_ACCOUNT         5  #define LOG_DEST_ACCOUNT        5
66  #define LOG_DESTINATION_MAILBOX         6  #define LOG_DEST_MBOX           6
67  #define LOG_HEADER                      7  #define LOG_HEADER              7
   
 /* Store IMAP command type may replace,add or remove flags. */  
 #define STORE_FLAG_REPLACE              1  
 #define STORE_FLAG_ADD                  2  
 #define STORE_FLAG_REMOVE               3  
   
 /* Buffer size of server's response. */  
 #define RESPONSE_BUF                    4096  
 #define RESULT_BUF                      512  
68    
69  /* Response codes. */  /* Response codes. */
70  #define RESPONSE_NULLBODY               -2  #define RESPONSE_NULLBODY       -2
71  #define RESPONSE_NONE                   -1  #define RESPONSE_NONE           -1
72  #define RESPONSE_OK                     0  #define RESPONSE_OK             0
73  #define RESPONSE_NO                     1  #define RESPONSE_NO             1
74  #define RESPONSE_BAD                    2  #define RESPONSE_BAD            2
75  #define RESPONSE_BYE                    3  #define RESPONSE_BYE            3
76  #define RESPONSE_PREAUTH                4  #define RESPONSE_PREAUTH        4
77  #define RESPONSE_READONLY               5  #define RESPONSE_READONLY       5
78  #define RESPONSE_TRYCREATE              6  #define RESPONSE_TRYCREATE      6
79    
80    /* Buffer size of server's response. */
81    #define RESPONSE_BUF            4096
82    #define RESULT_BUF              512
83    
84  /* Encryption and decryption buffers. */  /* Encryption and decryption buffers. */
85  #define ENCRYPTION_BUF                  1024  #define ENCRYPT_BUF             1024
86  #define DECRYPTION_BUF                  4096  #define DECRYPT_BUF             4096
87    
88  /* Buffer to save flags of the store IMAP command. */  /* Buffer to save flags of the store IMAP command. */
89  #define STORE_FLAGS_BUF                 64  #define STORE_FLAGS_BUF         64
90    
91  /* Length of charset for IMAP SEARCH requests. */  /* Length of charset for IMAP SEARCH requests. */
92  #define CHARSET_LEN                     64  #define CHARSET_LEN             64
93    
94  /* String lengths of master password and encrypted passwords. */  /* String lengths of master password and encrypted passwords. */
95  #define PASSPHRASE_LEN                  256  #define PASSPHRASE_LEN          256
96    
97  /* Length of mailbox namespace prefix. */  /* Length of mailbox namespace prefix. */
98  #define NAMESPACE_PREFIX_LEN            64  #define NAMESPACE_PREFIX_LEN    64
99    
100    
101  #define min(A, B)                       ((A) < (B) ? (A) : (B))  #define min(A, B)               ((A) < (B) ? (A) : (B))
102  #define plural(A)                       ((A) == 1 ? "" : "s")  #define plural(A)               ((A) == 1 ? "" : "s")
103    
104    
105  /* Program's options. */  /* Program's options. */
106  typedef struct opts {  typedef struct options {
107          int debug;              /* Debugging level (1..2). */          int debug;              /* Debugging level (1..2). */
108          int verbosity;          /* Verbosity level (-2..2). */          int verbosity;          /* Verbosity level (-2..2). */
109          int timeout;            /* Server non-response timeout in seconds. */          int timeout;            /* Server non-response timeout in seconds. */
# Line 119  typedef struct opts { Line 114  typedef struct opts {
114          int expunge;            /* Expunge messages after they are marked          int expunge;            /* Expunge messages after they are marked
115                                   * deleted. */                                   * deleted. */
116          int subscribe;          /* Subscribe newly created mailboxes. */          int subscribe;          /* Subscribe newly created mailboxes. */
117          int peek;               /* Do not mark messages seen when their          int peek;               /* Do not mark messages seen when their headers
118                                   * headers are received. */                                   * are received. */
119          int passwd_editor;      /* Enter interactive password editor. */          int passwd_editor;      /* Enter interactive password editor. */
120          char charset[CHARSET_LEN];      /* Search criteria character set. */          char charset[CHARSET_LEN];      /* Search criteria character set. */
121          char logfile[PATH_MAX]; /* Log file for filtering information. */          char logfile[PATH_MAX]; /* Log file for filtering information. */
122  } opts_t;  } options_t;
123    
124  /* IMAP connection. */  /* IMAP connection. */
125  typedef struct conn {  typedef struct connection {
126          int sock;               /* Socket. */          int sock;               /* Socket. */
127  #ifdef SSL_TLS  #ifdef SSL_TLS
128          SSL *ssl;               /* SSL socket. */          SSL *ssl;               /* SSL socket. */
# Line 136  typedef struct conn { Line 131  typedef struct conn {
131          struct {                /* Namespace of the mail server's mailboxes. */          struct {                /* Namespace of the mail server's mailboxes. */
132                  char prefix[NAMESPACE_PREFIX_LEN];      /* Namespace prefix. */                  char prefix[NAMESPACE_PREFIX_LEN];      /* Namespace prefix. */
133                  char delim;     /* Namespace delimiter. */                  char delim;     /* Namespace delimiter. */
134          } nsp;          } ns;
135  } conn_t;  } connection_t;
136    
137    
138  /*      action.c        */  /*      action.c        */
# Line 145  int apply_action(char *mbox, char *mesgs Line 140  int apply_action(char *mbox, char *mesgs
140    
141  /*      auth.c          */  /*      auth.c          */
142  #ifdef CRAM_MD5  #ifdef CRAM_MD5
143  int auth_cram_md5(conn_t * conn, char *user, char *pass);  int auth_cram_md5(connection_t * conn, char *user, char *pass);
144  #endif  #endif
145    
146  /*      cert.c          */  /*      cert.c          */
147  #ifdef SSL_TLS  #ifdef SSL_TLS
148  int get_cert(conn_t * conn);  int get_cert(connection_t * conn);
149  #endif  #endif
150    
151  /*      destroy.c       */  /*      destroy.c       */
# Line 166  int check_file_perms(char *fname, mode_t Line 161  int check_file_perms(char *fname, mode_t
161  int check_dir_perms(char *dname, mode_t mode);  int check_dir_perms(char *dname, mode_t mode);
162    
163  /*      imap.c          */  /*      imap.c          */
164  int imap_noop(conn_t * conn);  int imap_noop(connection_t * conn);
165  int imap_capability(conn_t * conn);  int imap_capability(connection_t * conn);
166  int imap_namespace(conn_t * conn);  int imap_namespace(connection_t * conn);
167  int imap_logout(conn_t * conn);  int imap_logout(connection_t * conn);
168  #ifdef SSL_TLS  #ifdef SSL_TLS
169  int imap_starttls(conn_t * conn);  int imap_starttls(connection_t * conn);
170  #endif  #endif
171  int imap_authenticate(conn_t * conn, char *auth, int cont);  int imap_authenticate(connection_t * conn, char *auth, int cont);
172  int imap_login(conn_t * conn, char *user, char *pass);  int imap_login(connection_t * conn, char *user, char *pass);
173  /* int imap_list(conn_t *conn, char *refer, char *mbox); */  /* int imap_list(connection_t *conn, char *refer, char *mbox); */
174  int imap_subscribe(conn_t * conn, char *mbox);  int imap_subscribe(connection_t * conn, char *mbox);
175  /* int imap_examine(conn_t *conn, char *mbox); */  /* int imap_examine(connection_t *conn, char *mbox); */
176  int imap_select(conn_t * conn, char *mbox);  int imap_select(connection_t * conn, char *mbox);
177  int imap_status(conn_t * conn, char *mbox, char *items);  int imap_status(connection_t * conn, char *mbox, char *items);
178  int imap_create(conn_t * conn, char *mbox);  int imap_create(connection_t * conn, char *mbox);
179  int imap_search(conn_t * conn, char *charset, char *search);  int imap_search(connection_t * conn, char *charset, char *search);
180  int imap_fetch(conn_t * conn, char *mesg, char *items);  int imap_fetch(connection_t * conn, char *mesg, char *items);
181  int imap_store(conn_t * conn, char *mesg, unsigned int mode, char *flags);  int imap_store(connection_t * conn, char *mesg, unsigned int mode, char *flags);
182  int imap_copy(conn_t * conn, char *mesg, char *mbox);  int imap_copy(connection_t * conn, char *mesg, char *mbox);
183  int imap_append(conn_t * conn, char *mbox, char *flags, char *date, unsigned int size);  int imap_append(connection_t * conn, char *mbox, char *flags, char *date, unsigned int size);
184  int imap_close(conn_t * conn);  int imap_close(connection_t * conn);
185  int imap_expunge(conn_t * conn);  int imap_expunge(connection_t * conn);
186    
187  /*      lock.c          */  /*      lock.c          */
188  void lockfile_create(void);  void lockfile_create(void);
# Line 221  void *smalloc(size_t size); Line 216  void *smalloc(size_t size);
216  void *srealloc(void *ptr, size_t size);  void *srealloc(void *ptr, size_t size);
217  void sfree(void *ptr);  void sfree(void *ptr);
218  char *sstrdup(const char *s);  char *sstrdup(const char *s);
219    
220  void secmem_clear(void);  void secmem_clear(void);
221    
222  void corefile_disable(void);  void corefile_disable(void);
# Line 244  void password_editor(void); Line 240  void password_editor(void);
240  #endif  #endif
241    
242  /*      request.c       */  /*      request.c       */
243  int test(conn_t * conn);  int test(connection_t * conn);
244  int check_capabilities(conn_t * conn);  int check_capabilities(connection_t * conn);
245  int check_namespace(conn_t * conn);  int check_namespace(connection_t * conn);
246  #ifdef SSL_TLS  #ifdef SSL_TLS
247  int negotiate_tls(conn_t * conn);  int negotiate_tls(connection_t * conn);
248  #endif  #endif
249  int login(conn_t * conn, char *user, char *pass);  int login(connection_t * conn, char *user, char *pass);
250  int check_mailbox(conn_t * conn, char *mbox);  int check_mailbox(connection_t * conn, char *mbox);
251  int select_mailbox(conn_t * conn, char *mbox);  int select_mailbox(connection_t * conn, char *mbox);
252  int mailbox_status(conn_t * conn, char *mbox);  int mailbox_status(connection_t * conn, char *mbox);
253  int close_mailbox(conn_t * conn);  int close_mailbox(connection_t * conn);
254  int logout(conn_t * conn);  int logout(connection_t * conn);
255    
256  /*      response.c      */  /*      response.c      */
257  int server_response(conn_t * conn, unsigned int tag);  int response_generic(connection_t * conn, unsigned int tag);
258  int greeting_response(conn_t * conn);  int response_greeting(connection_t * conn);
259  int logout_response(conn_t * conn, unsigned int tag);  int response_logout(connection_t * conn, unsigned int tag);
260  int capability_response(conn_t * conn, unsigned int tag);  int response_capability(connection_t * conn, unsigned int tag);
261  int authenticate_response(conn_t * conn, unsigned int tag, unsigned char **cont);  int response_authenticate(connection_t * conn, unsigned int tag, unsigned char **cont);
262  int namespace_response(conn_t * conn, unsigned int tag);  int response_namespace(connection_t * conn, unsigned int tag);
263  int status_response(conn_t * conn, unsigned int tag, char *mbox);  int response_status(connection_t * conn, unsigned int tag, char *mbox);
264  int select_response(conn_t * conn, unsigned int tag);  int response_select(connection_t * conn, unsigned int tag);
265  int search_response(conn_t * conn, unsigned int tag, char **mesgs);  int response_search(connection_t * conn, unsigned int tag, char **mesgs);
266  int fetch_response(conn_t * conn, unsigned int tag, int reset, char *fetch);  int response_fetch(connection_t * conn, unsigned int tag, int reset, char *fetch);
267  int fetchfast_response(conn_t * conn, char **flags, char **date, unsigned int *size, unsigned int tag);  int response_fetchfast(connection_t * conn, char **flags, char **date, unsigned int *size, unsigned int tag);
268  int append_response(conn_t * conn, unsigned int tag);  int response_append(connection_t * conn, unsigned int tag);
269  int copy_response(conn_t * conn, unsigned int tag);  int response_copy(connection_t * conn, unsigned int tag);
270    
271  /*      socket.c        */  /*      socket.c        */
272  int  int
273   init_connection(conn_t * conn, char *serv, unsigned short int port, unsigned int protocol);   init_connection(connection_t * conn, char *serv, unsigned short int port, unsigned int protocol);
274  #ifdef SSL_TLS  #ifdef SSL_TLS
275  int init_secure_connection(conn_t * conn, unsigned int protocol);  int init_secure_connection(connection_t * conn, unsigned int protocol);
276  #endif  #endif
277  int close_connection(conn_t * conn);  int close_connection(connection_t * conn);
278  int socket_read(conn_t * conn, char *buf);  int socket_read(connection_t * conn, char *buf);
279  int socket_write(conn_t * conn, char *data);  int socket_write(connection_t * conn, char *data);
280    
281  /*      tty.c           */  /*      tty.c           */
282  int tty_store(void);  int tty_store(void);
283  int tty_disable_echo(void);  int tty_noecho(void);
284  int tty_restore(void);  int tty_restore(void);
285    
286    

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.81

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26