Mercurial > hg > nginx
comparison src/mail/ngx_mail_parse.c @ 1621:ed9cd1702f7a stable-0.5
r1477, r1478, r1479, r1480, r1481, r1482, r1483, r1484, r1485, r1486,
r1487, r1488, r1494, r1495, r1499 merge:
*) ngx_mail_pop3_module, ngx_mail_imap_module, and ngx_mail_smtp_module
*) smtp_client_buffer and smtp_greeting_delay
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 07 Nov 2007 14:24:55 +0000 |
parents | b19709ee1f52 |
children |
comparison
equal
deleted
inserted
replaced
1620:54377021b936 | 1621:ed9cd1702f7a |
---|---|
8 #include <ngx_core.h> | 8 #include <ngx_core.h> |
9 #include <ngx_event.h> | 9 #include <ngx_event.h> |
10 #include <ngx_mail.h> | 10 #include <ngx_mail.h> |
11 | 11 |
12 | 12 |
13 ngx_int_t ngx_pop3_parse_command(ngx_mail_session_t *s) | 13 ngx_int_t |
14 ngx_mail_pop3_parse_command(ngx_mail_session_t *s) | |
14 { | 15 { |
15 u_char ch, *p, *c, c0, c1, c2, c3; | 16 u_char ch, *p, *c, c0, c1, c2, c3; |
16 ngx_str_t *arg; | 17 ngx_str_t *arg; |
17 enum { | 18 enum { |
18 sw_start = 0, | 19 sw_start = 0, |
205 | 206 |
206 return NGX_MAIL_PARSE_INVALID_COMMAND; | 207 return NGX_MAIL_PARSE_INVALID_COMMAND; |
207 } | 208 } |
208 | 209 |
209 | 210 |
210 ngx_int_t ngx_imap_parse_command(ngx_mail_session_t *s) | 211 ngx_int_t |
212 ngx_mail_imap_parse_command(ngx_mail_session_t *s) | |
211 { | 213 { |
212 u_char ch, *p, *c; | 214 u_char ch, *p, *c; |
213 ngx_str_t *arg; | 215 ngx_str_t *arg; |
214 enum { | 216 enum { |
215 sw_start = 0, | 217 sw_start = 0, |
611 | 613 |
612 return NGX_MAIL_PARSE_INVALID_COMMAND; | 614 return NGX_MAIL_PARSE_INVALID_COMMAND; |
613 } | 615 } |
614 | 616 |
615 | 617 |
616 ngx_int_t ngx_smtp_parse_command(ngx_mail_session_t *s) | 618 ngx_int_t |
619 ngx_mail_smtp_parse_command(ngx_mail_session_t *s) | |
617 { | 620 { |
618 u_char ch, *p, *c, c0, c1, c2, c3; | 621 u_char ch, *p, *c, c0, c1, c2, c3; |
619 ngx_str_t *arg; | 622 ngx_str_t *arg; |
620 enum { | 623 enum { |
621 sw_start = 0, | 624 sw_start = 0, |
820 s->state = sw_start; | 823 s->state = sw_start; |
821 s->arg_start = NULL; | 824 s->arg_start = NULL; |
822 | 825 |
823 return NGX_MAIL_PARSE_INVALID_COMMAND; | 826 return NGX_MAIL_PARSE_INVALID_COMMAND; |
824 } | 827 } |
828 | |
829 | |
830 ngx_int_t | |
831 ngx_mail_auth_parse(ngx_mail_session_t *s, ngx_connection_t *c) | |
832 { | |
833 ngx_str_t *arg; | |
834 | |
835 #if (NGX_MAIL_SSL) | |
836 if (ngx_mail_starttls_only(s, c)) { | |
837 return NGX_MAIL_PARSE_INVALID_COMMAND; | |
838 } | |
839 #endif | |
840 | |
841 arg = s->args.elts; | |
842 | |
843 if (arg[0].len == 5) { | |
844 | |
845 if (ngx_strncasecmp(arg[0].data, (u_char *) "LOGIN", 5) == 0) { | |
846 | |
847 if (s->args.nelts == 1) { | |
848 return NGX_MAIL_AUTH_LOGIN; | |
849 } | |
850 | |
851 return NGX_MAIL_PARSE_INVALID_COMMAND; | |
852 } | |
853 | |
854 if (ngx_strncasecmp(arg[0].data, (u_char *) "PLAIN", 5) == 0) { | |
855 | |
856 if (s->args.nelts == 1) { | |
857 return NGX_MAIL_AUTH_PLAIN; | |
858 } | |
859 | |
860 if (s->args.nelts == 2) { | |
861 return ngx_mail_auth_plain(s, c, 1); | |
862 } | |
863 } | |
864 | |
865 return NGX_MAIL_PARSE_INVALID_COMMAND; | |
866 } | |
867 | |
868 if (arg[0].len == 8) { | |
869 | |
870 if (s->args.nelts != 1) { | |
871 return NGX_MAIL_PARSE_INVALID_COMMAND; | |
872 } | |
873 | |
874 if (ngx_strncasecmp(arg[0].data, (u_char *) "CRAM-MD5", 8) == 0) { | |
875 return NGX_MAIL_AUTH_CRAM_MD5; | |
876 } | |
877 } | |
878 | |
879 return NGX_MAIL_PARSE_INVALID_COMMAND; | |
880 } |