blob: 023f809ecf24b309b0703dedc4651e54b1943fe9 [file] [log] [blame]
Igor Sysoev59cf56c2004-09-07 15:29:22 +00001#ifndef _NGX_IMAP_H_INCLUDED_
2#define _NGX_IMAP_H_INCLUDED_
3
4
5#include <ngx_config.h>
6#include <ngx_core.h>
Igor Sysoev2e6ba932004-09-09 15:40:48 +00007#include <ngx_event.h>
8#include <ngx_event_connect.h>
Igor Sysoev59cf56c2004-09-07 15:29:22 +00009
10
11typedef struct {
Igor Sysoev2e6ba932004-09-09 15:40:48 +000012 ngx_peer_connection_t upstream;
Igor Sysoev0d9da9b2004-09-08 05:18:51 +000013
Igor Sysoev2e6ba932004-09-09 15:40:48 +000014 ngx_buf_t *buffer;
Igor Sysoev0d9da9b2004-09-08 05:18:51 +000015} ngx_imap_proxy_ctx_t;
Igor Sysoev59cf56c2004-09-07 15:29:22 +000016
17
Igor Sysoev10778352004-09-10 14:32:02 +000018typedef enum {
19 ngx_pop3_start = 0,
20 ngx_pop3_user
21} ngx_imap_state_e;
22
23
Igor Sysoev0d9da9b2004-09-08 05:18:51 +000024typedef struct {
Igor Sysoev2e6ba932004-09-09 15:40:48 +000025 uint32_t signature; /* "IMAP" */
Igor Sysoev0d9da9b2004-09-08 05:18:51 +000026
Igor Sysoev2e6ba932004-09-09 15:40:48 +000027 ngx_connection_t *connection;
28 ngx_buf_t *buffer;
29
Igor Sysoev10778352004-09-10 14:32:02 +000030 ngx_imap_state_e imap_state;
31
Igor Sysoev2e6ba932004-09-09 15:40:48 +000032 ngx_imap_proxy_ctx_t *proxy;
33
Igor Sysoev32e57712004-09-11 20:22:11 +000034 ngx_str_t login;
35 ngx_str_t passwd;
36
Igor Sysoev2e6ba932004-09-09 15:40:48 +000037 ngx_uint_t command;
38 ngx_array_t args;
39
40 /* used to parse IMAP/POP3 command */
41
42 ngx_uint_t state;
43 u_char *arg_start;
44 u_char *arg_end;
Igor Sysoev0d9da9b2004-09-08 05:18:51 +000045} ngx_imap_session_t;
46
47
Igor Sysoev2e6ba932004-09-09 15:40:48 +000048#define NGX_POP3_USER 1
49#define NGX_POP3_PASS 2
50#define NGX_POP3_APOP 3
51#define NGX_POP3_STAT 4
52#define NGX_POP3_LIST 5
53#define NGX_POP3_RETR 6
54#define NGX_POP3_DELE 7
55#define NGX_POP3_NOOP 8
56#define NGX_POP3_RSET 9
57#define NGX_POP3_TOP 10
58#define NGX_POP3_UIDL 11
59#define NGX_POP3_QUIT 12
60
61
62#define NGX_IMAP_PARSE_INVALID_COMMAND 10
63
64
65#define NGX_IMAP_PROXY_INVALID 10
66#define NGX_IMAP_PROXY_ERROR 11
Igor Sysoev59cf56c2004-09-07 15:29:22 +000067
68
Igor Sysoev562626a2004-09-14 05:45:22 +000069#define NGX_IMAP_MODULE 0x50414D49 /* "IMAP" */
Igor Sysoev0292cbb2004-09-13 16:18:09 +000070
Igor Sysoev562626a2004-09-14 05:45:22 +000071#define NGX_IMAP_SRV_CONF 0x02000000
72#define NGX_IMAP_IMAP_CONF 0x04000000
73#define NGX_IMAP_POP3_CONF 0x08000000
Igor Sysoev0292cbb2004-09-13 16:18:09 +000074
75
Igor Sysoev59cf56c2004-09-07 15:29:22 +000076void ngx_imap_init_connection(ngx_connection_t *c);
77void ngx_imap_close_connection(ngx_connection_t *c);
78
Igor Sysoev2e6ba932004-09-09 15:40:48 +000079void ngx_imap_proxy_init(ngx_imap_session_t *s);
80
81ngx_int_t ngx_pop3_parse_command(ngx_imap_session_t *s);
82
Igor Sysoev59cf56c2004-09-07 15:29:22 +000083
84#endif /* _NGX_IMAP_H_INCLUDED_ */