Update the pop3/* diretory.
Showing
23 changed files
with
160 additions
and
64 deletions
1 | 2001-06-09 18:44 sroberts | 1 | 2001-06-09 Alain Magloire |
2 | |||
3 | * mailbox2/pop3/pop3_open.c: Remove for pop3_connect.c | ||
4 | * mailbox2/pop3/pop3_close.c: Remove for pop3_disconnect.c | ||
5 | * mailbox2/pop3/pop3_connect.c: New. | ||
6 | * mailbox2/pop3/pop3_disconnect.c: New. | ||
7 | * mailbox2/include/mailutiils/error.h: New macro | ||
8 | MU_ERROR_OPERATION_CANCELED | ||
9 | * mailbox2/include/mailutils/pop3.h: Move the enum state in sys/pop3.h | ||
10 | |||
11 | 2001-06-09 Sam Roberts | ||
2 | 12 | ||
3 | * rfc1738.txt, rfc2045.txt, rfc2046.txt, rfc2047.txt, rfc2049.txt, | 13 | * rfc1738.txt, rfc2045.txt, rfc2046.txt, rfc2047.txt, rfc2049.txt, |
4 | rfc2088.txt, rfc2111.txt, rfc2192.txt, rfc2193.txt, rfc2221.txt, | 14 | rfc2088.txt, rfc2111.txt, rfc2192.txt, rfc2193.txt, rfc2221.txt, | ... | ... |
... | @@ -113,6 +113,12 @@ extern "C" { | ... | @@ -113,6 +113,12 @@ extern "C" { |
113 | # define MU_ERROR_INVALID_SEEK (MU_ERROR_RANGE + 12) | 113 | # define MU_ERROR_INVALID_SEEK (MU_ERROR_RANGE + 12) |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | #if defined (ECANCELED) | ||
117 | # define MU_ERROR_OPERATION_CANCELED ECANCELED | ||
118 | #else | ||
119 | # define MU_ERROR_OPERATION_CANCELED (MU_ERROR_RANGE + 13) | ||
120 | #endif | ||
121 | |||
116 | typedef int (*error_pfn_t) __P ((const char *fmt, va_list ap)); | 122 | typedef int (*error_pfn_t) __P ((const char *fmt, va_list ap)); |
117 | 123 | ||
118 | extern int mu_error __P ((const char *fmt, ...)); | 124 | extern int mu_error __P ((const char *fmt, ...)); | ... | ... |
... | @@ -26,34 +26,13 @@ __MAILUTILS_BEGIN_DECLS | ... | @@ -26,34 +26,13 @@ __MAILUTILS_BEGIN_DECLS |
26 | struct _pop3; | 26 | struct _pop3; |
27 | typedef struct _pop3* pop3_t; | 27 | typedef struct _pop3* pop3_t; |
28 | 28 | ||
29 | enum pop3_state | 29 | struct pop3_list_item |
30 | { | ||
31 | POP3_NO_STATE, | ||
32 | POP3_OPEN, POP3_GREETINGS, | ||
33 | POP3_APOP, POP3_APOP_ACK, | ||
34 | POP3_AUTH, POP3_AUTH_ACK, | ||
35 | POP3_CAPA, POP3_CAPA_ACK, POP3_CAPA_RX, | ||
36 | POP3_DELE, POP3_DELE_ACK, | ||
37 | POP3_LIST, POP3_LIST_ACK, POP3_LIST_RX, | ||
38 | POP3_NOOP, POP3_NOOP_ACK, | ||
39 | POP3_PASS, POP3_PASS_ACK, | ||
40 | POP3_QUIT, POP3_QUIT_ACK, | ||
41 | POP3_RETR, POP3_RETR_ACK, POP3_RETR_RX, | ||
42 | POP3_RSET, POP3_RSET_ACK, | ||
43 | POP3_STAT, POP3_STAT_ACK, | ||
44 | POP3_TOP, POP3_TOP_ACK, POP3_TOP_RX, | ||
45 | POP3_UIDL, POP3_UIDL_ACK, POP3_UIDL_RX, | ||
46 | POP3_USER, POP3_USER_ACK, | ||
47 | POP3_DONE, POP3_UNKNOWN, POP3_ERROR | ||
48 | }; | ||
49 | |||
50 | struct list_item | ||
51 | { | 30 | { |
52 | unsigned int msgno; | 31 | unsigned int msgno; |
53 | unsigned int size; | 32 | unsigned int size; |
54 | }; | 33 | }; |
55 | 34 | ||
56 | struct uidl_item | 35 | struct pop3_uidl_item |
57 | { | 36 | { |
58 | unsigned int msgno; | 37 | unsigned int msgno; |
59 | char *uidl; | 38 | char *uidl; |
... | @@ -62,8 +41,8 @@ struct uidl_item | ... | @@ -62,8 +41,8 @@ struct uidl_item |
62 | extern int pop3_create __P ((pop3_t *)); | 41 | extern int pop3_create __P ((pop3_t *)); |
63 | extern void pop3_destroy __P ((pop3_t)); | 42 | extern void pop3_destroy __P ((pop3_t)); |
64 | 43 | ||
65 | extern int pop3_open __P ((pop3_t, const char *, unsigned int, int)); | 44 | extern int pop3_connect __P ((pop3_t, const char *, unsigned int)); |
66 | extern int pop3_close __P ((pop3_t)); | 45 | extern int pop3_disconnect __P ((pop3_t)); |
67 | 46 | ||
68 | extern int pop3_set_stream __P ((pop3_t, stream_t)); | 47 | extern int pop3_set_stream __P ((pop3_t, stream_t)); |
69 | extern int pop3_get_stream __P ((pop3_t, stream_t *)); | 48 | extern int pop3_get_stream __P ((pop3_t, stream_t *)); |
... | @@ -71,8 +50,6 @@ extern int pop3_get_stream __P ((pop3_t, stream_t *)); | ... | @@ -71,8 +50,6 @@ extern int pop3_get_stream __P ((pop3_t, stream_t *)); |
71 | extern int pop3_set_timeout __P ((pop3_t, unsigned int)); | 50 | extern int pop3_set_timeout __P ((pop3_t, unsigned int)); |
72 | extern int pop3_get_timeout __P ((pop3_t, unsigned int *)); | 51 | extern int pop3_get_timeout __P ((pop3_t, unsigned int *)); |
73 | 52 | ||
74 | extern int pop3_get_state __P ((pop3_t, enum pop3_state *)); | ||
75 | |||
76 | extern int pop3_apop __P ((pop3_t, const char *, const char *)); | 53 | extern int pop3_apop __P ((pop3_t, const char *, const char *)); |
77 | extern int pop3_capa __P ((pop3_t, iterator_t *)); | 54 | extern int pop3_capa __P ((pop3_t, iterator_t *)); |
78 | extern int pop3_dele __P ((pop3_t, unsigned int)); | 55 | extern int pop3_dele __P ((pop3_t, unsigned int)); | ... | ... |
... | @@ -25,8 +25,33 @@ | ... | @@ -25,8 +25,33 @@ |
25 | #include <mailutils/sys/iterator.h> | 25 | #include <mailutils/sys/iterator.h> |
26 | #include <mailutils/error.h> | 26 | #include <mailutils/error.h> |
27 | 27 | ||
28 | #ifdef DMALLOC | ||
29 | # include <dmalloc.h> | ||
30 | #endif | ||
31 | |||
28 | __MAILUTILS_BEGIN_DECLS | 32 | __MAILUTILS_BEGIN_DECLS |
29 | 33 | ||
34 | enum pop3_state | ||
35 | { | ||
36 | POP3_NO_STATE, | ||
37 | POP3_CONNECT, POP3_GREETINGS, | ||
38 | POP3_APOP, POP3_APOP_ACK, | ||
39 | POP3_AUTH, POP3_AUTH_ACK, | ||
40 | POP3_CAPA, POP3_CAPA_ACK, POP3_CAPA_RX, | ||
41 | POP3_DELE, POP3_DELE_ACK, | ||
42 | POP3_LIST, POP3_LIST_ACK, POP3_LIST_RX, | ||
43 | POP3_NOOP, POP3_NOOP_ACK, | ||
44 | POP3_PASS, POP3_PASS_ACK, | ||
45 | POP3_QUIT, POP3_QUIT_ACK, | ||
46 | POP3_RETR, POP3_RETR_ACK, POP3_RETR_RX, | ||
47 | POP3_RSET, POP3_RSET_ACK, | ||
48 | POP3_STAT, POP3_STAT_ACK, | ||
49 | POP3_TOP, POP3_TOP_ACK, POP3_TOP_RX, | ||
50 | POP3_UIDL, POP3_UIDL_ACK, POP3_UIDL_RX, | ||
51 | POP3_USER, POP3_USER_ACK, | ||
52 | POP3_DONE, POP3_UNKNOWN, POP3_ERROR | ||
53 | }; | ||
54 | |||
30 | struct p_iterator | 55 | struct p_iterator |
31 | { | 56 | { |
32 | struct _iterator base; | 57 | struct _iterator base; | ... | ... |
... | @@ -25,6 +25,10 @@ | ... | @@ -25,6 +25,10 @@ |
25 | #include <mailutils/sys/pop3.h> | 25 | #include <mailutils/sys/pop3.h> |
26 | #include <mailutils/md5-rsa.h> | 26 | #include <mailutils/md5-rsa.h> |
27 | 27 | ||
28 | /* | ||
29 | APOP name digest | ||
30 | a string identifying a mailbox and a MD5 digest string (both required) | ||
31 | */ | ||
28 | int | 32 | int |
29 | pop3_apop (pop3_t pop3, const char *user, const char *secret) | 33 | pop3_apop (pop3_t pop3, const char *user, const char *secret) |
30 | { | 34 | { |
... | @@ -33,12 +37,13 @@ pop3_apop (pop3_t pop3, const char *user, const char *secret) | ... | @@ -33,12 +37,13 @@ pop3_apop (pop3_t pop3, const char *user, const char *secret) |
33 | if (pop3 == NULL) | 37 | if (pop3 == NULL) |
34 | return MU_ERROR_INVALID_PARAMETER; | 38 | return MU_ERROR_INVALID_PARAMETER; |
35 | 39 | ||
36 | /* The server did not offer a time stamp, bail early. */ | 40 | /* The server did not offer a time stamp in the greeting, bailout early. */ |
37 | if (pop3->timestamp == NULL) | 41 | if (pop3->timestamp == NULL) |
38 | return MU_ERROR_NOT_SUPPORTED; | 42 | return MU_ERROR_NOT_SUPPORTED; |
39 | 43 | ||
40 | switch (pop3->state) | 44 | switch (pop3->state) |
41 | { | 45 | { |
46 | /* Generate the md5 from the secret and timestamp. */ | ||
42 | case POP3_NO_STATE: | 47 | case POP3_NO_STATE: |
43 | { | 48 | { |
44 | MD5_CTX md5context; | 49 | MD5_CTX md5context; |
... | @@ -50,7 +55,6 @@ pop3_apop (pop3_t pop3, const char *user, const char *secret) | ... | @@ -50,7 +55,6 @@ pop3_apop (pop3_t pop3, const char *user, const char *secret) |
50 | if (user == NULL || secret == NULL) | 55 | if (user == NULL || secret == NULL) |
51 | return MU_ERROR_INVALID_PARAMETER; | 56 | return MU_ERROR_INVALID_PARAMETER; |
52 | 57 | ||
53 | /* Generate md5 digest. */ | ||
54 | MD5Init (&md5context); | 58 | MD5Init (&md5context); |
55 | MD5Update (&md5context, (unsigned char *)pop3->timestamp, | 59 | MD5Update (&md5context, (unsigned char *)pop3->timestamp, |
56 | strlen (pop3->timestamp)); | 60 | strlen (pop3->timestamp)); |
... | @@ -78,6 +82,11 @@ pop3_apop (pop3_t pop3, const char *user, const char *secret) | ... | @@ -78,6 +82,11 @@ pop3_apop (pop3_t pop3, const char *user, const char *secret) |
78 | pop3->state = POP3_NO_STATE; | 82 | pop3->state = POP3_NO_STATE; |
79 | break; | 83 | break; |
80 | 84 | ||
85 | /* They must deal with the error first by reopening. */ | ||
86 | case POP3_ERROR: | ||
87 | status = MU_ERROR_OPERATION_CANCELED; | ||
88 | break; | ||
89 | |||
81 | default: | 90 | default: |
82 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 91 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
83 | } | 92 | } | ... | ... |
... | @@ -56,6 +56,11 @@ pop3_capa (pop3_t pop3, iterator_t *piterator) | ... | @@ -56,6 +56,11 @@ pop3_capa (pop3_t pop3, iterator_t *piterator) |
56 | POP3_CHECK_ERROR (pop3, status); | 56 | POP3_CHECK_ERROR (pop3, status); |
57 | break; | 57 | break; |
58 | 58 | ||
59 | /* They must deal with the error first by reopening. */ | ||
60 | case POP3_ERROR: | ||
61 | status = MU_ERROR_OPERATION_CANCELED; | ||
62 | break; | ||
63 | |||
59 | default: | 64 | default: |
60 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 65 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
61 | } | 66 | } | ... | ... |
... | @@ -28,9 +28,10 @@ | ... | @@ -28,9 +28,10 @@ |
28 | 28 | ||
29 | static int pop3_sleep (int seconds); | 29 | static int pop3_sleep (int seconds); |
30 | 30 | ||
31 | /* Open the connection to the server. */ | 31 | /* Open the connection to the server. The server sends an affirmative greeting |
32 | that may contain a timestamp for APOP. */ | ||
32 | int | 33 | int |
33 | pop3_open (pop3_t pop3, const char *host, unsigned int port, int flags) | 34 | pop3_connect (pop3_t pop3, const char *host, unsigned int port) |
34 | { | 35 | { |
35 | int status = 0; | 36 | int status = 0; |
36 | 37 | ||
... | @@ -47,7 +48,6 @@ pop3_open (pop3_t pop3, const char *host, unsigned int port, int flags) | ... | @@ -47,7 +48,6 @@ pop3_open (pop3_t pop3, const char *host, unsigned int port, int flags) |
47 | { | 48 | { |
48 | default: | 49 | default: |
49 | /* __Fallthrough__, they want to clear an error. */ | 50 | /* __Fallthrough__, they want to clear an error. */ |
50 | /* status = MU_ERROR_OPERATION_IN_PROGRESS; */ | ||
51 | case POP3_NO_STATE: | 51 | case POP3_NO_STATE: |
52 | /* Create the networking stack. */ | 52 | /* Create the networking stack. */ |
53 | if (pop3->stream == NULL) | 53 | if (pop3->stream == NULL) |
... | @@ -62,19 +62,21 @@ pop3_open (pop3_t pop3, const char *host, unsigned int port, int flags) | ... | @@ -62,19 +62,21 @@ pop3_open (pop3_t pop3, const char *host, unsigned int port, int flags) |
62 | /* This is sudden death: for many pop servers, it is important to | 62 | /* This is sudden death: for many pop servers, it is important to |
63 | let them time to remove locks or move the .user.pop files. This | 63 | let them time to remove locks or move the .user.pop files. This |
64 | happen when we do close() and immediately open(). For example, | 64 | happen when we do close() and immediately open(). For example, |
65 | the user does not want to read the entire file, and wants start | 65 | the user does not want to read the entire file, and wants to start |
66 | to read a new message, closing the connection and immediately | 66 | to read a new message, closing the connection and immediately |
67 | contacting the server again, and he'll end up having | 67 | contacting the server again, and he'll end up having |
68 | "-ERR Mail Lock busy" or something similar. To prevent this race | 68 | "-ERR Mail Lock busy" or something similar. To prevent this race |
69 | condition we sleep 2 seconds. */ | 69 | condition we sleep 2 seconds. This really obvious for in |
70 | stream_close (pop3->stream); | 70 | environment where QPopper is use, the user as a big mailbox. */ |
71 | pop3_disconnect (pop3); | ||
71 | pop3_sleep (2); | 72 | pop3_sleep (2); |
72 | } | 73 | } |
73 | pop3->state = POP3_OPEN; | 74 | pop3->state = POP3_CONNECT; |
74 | 75 | ||
75 | case POP3_OPEN: | 76 | case POP3_CONNECT: |
76 | /* Establish the connection. */ | 77 | /* Establish the connection. */ |
77 | status = stream_open (pop3->stream, host, port, flags); | 78 | status = stream_open (pop3->stream, host, port, |
79 | MU_STREAM_READ|MU_STREAM_WRITE); | ||
78 | POP3_CHECK_EAGAIN (pop3, status); | 80 | POP3_CHECK_EAGAIN (pop3, status); |
79 | pop3->acknowledge = 0; | 81 | pop3->acknowledge = 0; |
80 | pop3->state = POP3_GREETINGS; | 82 | pop3->state = POP3_GREETINGS; | ... | ... |
... | @@ -54,6 +54,11 @@ pop3_dele (pop3_t pop3, unsigned msgno) | ... | @@ -54,6 +54,11 @@ pop3_dele (pop3_t pop3, unsigned msgno) |
54 | pop3->state = POP3_NO_STATE; | 54 | pop3->state = POP3_NO_STATE; |
55 | break; | 55 | break; |
56 | 56 | ||
57 | /* They must deal with the error first by reopening. */ | ||
58 | case POP3_ERROR: | ||
59 | status = MU_ERROR_OPERATION_CANCELED; | ||
60 | break; | ||
61 | |||
57 | default: | 62 | default: |
58 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 63 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
59 | } | 64 | } | ... | ... |
... | @@ -162,7 +162,7 @@ p_next (iterator_t iterator) | ... | @@ -162,7 +162,7 @@ p_next (iterator_t iterator) |
162 | if (buf == NULL) | 162 | if (buf == NULL) |
163 | return MU_ERROR_NO_MEMORY; | 163 | return MU_ERROR_NO_MEMORY; |
164 | 164 | ||
165 | p_iterator->item = calloc (1, sizeof (struct list_item)); | 165 | p_iterator->item = calloc (1, sizeof (struct pop3_uidl_item)); |
166 | if (p_iterator->item == NULL) | 166 | if (p_iterator->item == NULL) |
167 | return MU_ERROR_NO_MEMORY; | 167 | return MU_ERROR_NO_MEMORY; |
168 | 168 | ||
... | @@ -179,8 +179,8 @@ p_next (iterator_t iterator) | ... | @@ -179,8 +179,8 @@ p_next (iterator_t iterator) |
179 | space[strlen (space) - 1] = '\0'; | 179 | space[strlen (space) - 1] = '\0'; |
180 | if (space == NULL) | 180 | if (space == NULL) |
181 | space = (char *)""; | 181 | space = (char *)""; |
182 | ((struct uidl_item *)(p_iterator->item))->msgno = msgno; | 182 | ((struct pop3_uidl_item *)(p_iterator->item))->msgno = msgno; |
183 | ((struct uidl_item *)(p_iterator->item))->uidl = strdup (space); | 183 | ((struct pop3_uidl_item *)(p_iterator->item))->uidl = strdup (space); |
184 | free (buf); | 184 | free (buf); |
185 | } | 185 | } |
186 | break; | 186 | break; |
... | @@ -194,7 +194,7 @@ p_next (iterator_t iterator) | ... | @@ -194,7 +194,7 @@ p_next (iterator_t iterator) |
194 | if (buf == NULL) | 194 | if (buf == NULL) |
195 | return MU_ERROR_NO_MEMORY; | 195 | return MU_ERROR_NO_MEMORY; |
196 | 196 | ||
197 | p_iterator->item = calloc (1, sizeof (struct list_item)); | 197 | p_iterator->item = calloc (1, sizeof (struct pop3_list_item)); |
198 | if (p_iterator->item == NULL) | 198 | if (p_iterator->item == NULL) |
199 | return MU_ERROR_NO_MEMORY; | 199 | return MU_ERROR_NO_MEMORY; |
200 | 200 | ||
... | @@ -202,8 +202,8 @@ p_next (iterator_t iterator) | ... | @@ -202,8 +202,8 @@ p_next (iterator_t iterator) |
202 | pop3_readline (p_iterator->pop3, buf, n + 1, NULL); | 202 | pop3_readline (p_iterator->pop3, buf, n + 1, NULL); |
203 | size = msgno = 0; | 203 | size = msgno = 0; |
204 | sscanf (buf, "%d %d", &msgno, &size); | 204 | sscanf (buf, "%d %d", &msgno, &size); |
205 | ((struct list_item *)(p_iterator->item))->msgno = msgno; | 205 | ((struct pop3_list_item *)(p_iterator->item))->msgno = msgno; |
206 | ((struct list_item *)(p_iterator->item))->size = size; | 206 | ((struct pop3_list_item *)(p_iterator->item))->size = size; |
207 | free (buf); | 207 | free (buf); |
208 | } | 208 | } |
209 | break; | 209 | break; |
... | @@ -235,7 +235,7 @@ p_current (iterator_t iterator, void *item) | ... | @@ -235,7 +235,7 @@ p_current (iterator_t iterator, void *item) |
235 | break; | 235 | break; |
236 | 236 | ||
237 | case POP3_LIST_RX: | 237 | case POP3_LIST_RX: |
238 | *((struct list_item **)item) = p_iterator->item; | 238 | *((struct pop3_list_item **)item) = p_iterator->item; |
239 | break; | 239 | break; |
240 | 240 | ||
241 | default: | 241 | default: | ... | ... |
... | @@ -62,6 +62,11 @@ pop3_list (pop3_t pop3, unsigned msgno, size_t *psize) | ... | @@ -62,6 +62,11 @@ pop3_list (pop3_t pop3, unsigned msgno, size_t *psize) |
62 | sscanf (pop3->ack.buf, "+OK %d %d", &msgno, psize); | 62 | sscanf (pop3->ack.buf, "+OK %d %d", &msgno, psize); |
63 | break; | 63 | break; |
64 | 64 | ||
65 | /* They must deal with the error first by reopening. */ | ||
66 | case POP3_ERROR: | ||
67 | status = MU_ERROR_OPERATION_CANCELED; | ||
68 | break; | ||
69 | |||
65 | default: | 70 | default: |
66 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 71 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
67 | } | 72 | } | ... | ... |
... | @@ -61,6 +61,11 @@ pop3_list_all (pop3_t pop3, iterator_t *piterator) | ... | @@ -61,6 +61,11 @@ pop3_list_all (pop3_t pop3, iterator_t *piterator) |
61 | POP3_CHECK_ERROR (pop3, status); | 61 | POP3_CHECK_ERROR (pop3, status); |
62 | break; | 62 | break; |
63 | 63 | ||
64 | /* They must deal with the error first by reopening. */ | ||
65 | case POP3_ERROR: | ||
66 | status = MU_ERROR_OPERATION_CANCELED; | ||
67 | break; | ||
68 | |||
64 | default: | 69 | default: |
65 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 70 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
66 | } | 71 | } | ... | ... |
... | @@ -54,6 +54,11 @@ pop3_noop (pop3_t pop3) | ... | @@ -54,6 +54,11 @@ pop3_noop (pop3_t pop3) |
54 | pop3->state = POP3_NO_STATE; | 54 | pop3->state = POP3_NO_STATE; |
55 | break; | 55 | break; |
56 | 56 | ||
57 | /* They must deal with the error first by reopening. */ | ||
58 | case POP3_ERROR: | ||
59 | status = MU_ERROR_OPERATION_CANCELED; | ||
60 | break; | ||
61 | |||
57 | default: | 62 | default: |
58 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 63 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
59 | } | 64 | } | ... | ... |
... | @@ -56,6 +56,11 @@ pop3_pass (pop3_t pop3, const char *passwd) | ... | @@ -56,6 +56,11 @@ pop3_pass (pop3_t pop3, const char *passwd) |
56 | pop3->state = POP3_NO_STATE; | 56 | pop3->state = POP3_NO_STATE; |
57 | break; | 57 | break; |
58 | 58 | ||
59 | /* They must deal with the error first by reopening. */ | ||
60 | case POP3_ERROR: | ||
61 | status = MU_ERROR_OPERATION_CANCELED; | ||
62 | break; | ||
63 | |||
59 | default: | 64 | default: |
60 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 65 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
61 | } | 66 | } | ... | ... |
... | @@ -59,6 +59,11 @@ pop3_retr (pop3_t pop3, unsigned msgno, stream_t *pstream) | ... | @@ -59,6 +59,11 @@ pop3_retr (pop3_t pop3, unsigned msgno, stream_t *pstream) |
59 | POP3_CHECK_ERROR (pop3, status); | 59 | POP3_CHECK_ERROR (pop3, status); |
60 | break; | 60 | break; |
61 | 61 | ||
62 | /* They must deal with the error first by reopening. */ | ||
63 | case POP3_ERROR: | ||
64 | status = MU_ERROR_OPERATION_CANCELED; | ||
65 | break; | ||
66 | |||
62 | default: | 67 | default: |
63 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 68 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
64 | } | 69 | } | ... | ... |
... | @@ -54,6 +54,11 @@ pop3_rset (pop3_t pop3) | ... | @@ -54,6 +54,11 @@ pop3_rset (pop3_t pop3) |
54 | pop3->state = POP3_NO_STATE; | 54 | pop3->state = POP3_NO_STATE; |
55 | break; | 55 | break; |
56 | 56 | ||
57 | /* They must deal with the error first by reopening. */ | ||
58 | case POP3_ERROR: | ||
59 | status = MU_ERROR_OPERATION_CANCELED; | ||
60 | break; | ||
61 | |||
57 | default: | 62 | default: |
58 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 63 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
59 | } | 64 | } | ... | ... |
... | @@ -62,6 +62,11 @@ pop3_stat (pop3_t pop3, unsigned *msg_count, size_t *size) | ... | @@ -62,6 +62,11 @@ pop3_stat (pop3_t pop3, unsigned *msg_count, size_t *size) |
62 | sscanf (pop3->ack.buf, "+OK %d %d", msg_count, size); | 62 | sscanf (pop3->ack.buf, "+OK %d %d", msg_count, size); |
63 | break; | 63 | break; |
64 | 64 | ||
65 | /* They must deal with the error first by reopening. */ | ||
66 | case POP3_ERROR: | ||
67 | status = MU_ERROR_OPERATION_CANCELED; | ||
68 | break; | ||
69 | |||
65 | default: | 70 | default: |
66 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 71 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
67 | } | 72 | } | ... | ... |
... | @@ -163,14 +163,15 @@ static int | ... | @@ -163,14 +163,15 @@ static int |
163 | p_open (stream_t stream, const char *h, int p, int f) | 163 | p_open (stream_t stream, const char *h, int p, int f) |
164 | { | 164 | { |
165 | struct p_stream *p_stream = (struct p_stream *)stream; | 165 | struct p_stream *p_stream = (struct p_stream *)stream; |
166 | return pop3_open (p_stream->pop3, h, p, f); | 166 | (void)f; |
167 | return pop3_connect (p_stream->pop3, h, p); | ||
167 | } | 168 | } |
168 | 169 | ||
169 | static int | 170 | static int |
170 | p_close (stream_t stream) | 171 | p_close (stream_t stream) |
171 | { | 172 | { |
172 | struct p_stream *p_stream = (struct p_stream *)stream; | 173 | struct p_stream *p_stream = (struct p_stream *)stream; |
173 | return pop3_close (p_stream->pop3); | 174 | return pop3_disconnect (p_stream->pop3); |
174 | } | 175 | } |
175 | 176 | ||
176 | static int | 177 | static int | ... | ... |
... | @@ -60,6 +60,11 @@ pop3_top (pop3_t pop3, unsigned msgno, size_t lines, stream_t *pstream) | ... | @@ -60,6 +60,11 @@ pop3_top (pop3_t pop3, unsigned msgno, size_t lines, stream_t *pstream) |
60 | POP3_CHECK_ERROR (pop3, status); | 60 | POP3_CHECK_ERROR (pop3, status); |
61 | break; | 61 | break; |
62 | 62 | ||
63 | /* They must deal with the error first by reopening. */ | ||
64 | case POP3_ERROR: | ||
65 | status = MU_ERROR_OPERATION_CANCELED; | ||
66 | break; | ||
67 | |||
63 | default: | 68 | default: |
64 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 69 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
65 | } | 70 | } | ... | ... |
... | @@ -89,6 +89,11 @@ pop3_uidl (pop3_t pop3, unsigned msgno, char **uidl) | ... | @@ -89,6 +89,11 @@ pop3_uidl (pop3_t pop3, unsigned msgno, char **uidl) |
89 | } | 89 | } |
90 | break; | 90 | break; |
91 | 91 | ||
92 | /* They must deal with the error first by reopening. */ | ||
93 | case POP3_ERROR: | ||
94 | status = MU_ERROR_OPERATION_CANCELED; | ||
95 | break; | ||
96 | |||
92 | default: | 97 | default: |
93 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 98 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
94 | } | 99 | } | ... | ... |
... | @@ -61,6 +61,11 @@ pop3_uidl_all (pop3_t pop3, iterator_t *piterator) | ... | @@ -61,6 +61,11 @@ pop3_uidl_all (pop3_t pop3, iterator_t *piterator) |
61 | POP3_CHECK_ERROR (pop3, status); | 61 | POP3_CHECK_ERROR (pop3, status); |
62 | break; | 62 | break; |
63 | 63 | ||
64 | /* They must deal with the error first by reopening. */ | ||
65 | case POP3_ERROR: | ||
66 | status = MU_ERROR_OPERATION_CANCELED; | ||
67 | break; | ||
68 | |||
64 | default: | 69 | default: |
65 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 70 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
66 | } | 71 | } | ... | ... |
... | @@ -56,6 +56,11 @@ pop3_user (pop3_t pop3, const char *user) | ... | @@ -56,6 +56,11 @@ pop3_user (pop3_t pop3, const char *user) |
56 | pop3->state = POP3_NO_STATE; | 56 | pop3->state = POP3_NO_STATE; |
57 | break; | 57 | break; |
58 | 58 | ||
59 | /* They must deal with the error first by reopening. */ | ||
60 | case POP3_ERROR: | ||
61 | status = MU_ERROR_OPERATION_CANCELED; | ||
62 | break; | ||
63 | |||
59 | default: | 64 | default: |
60 | status = MU_ERROR_OPERATION_IN_PROGRESS; | 65 | status = MU_ERROR_OPERATION_IN_PROGRESS; |
61 | } | 66 | } | ... | ... |
... | @@ -31,13 +31,13 @@ typedef struct { | ... | @@ -31,13 +31,13 @@ typedef struct { |
31 | 31 | ||
32 | /* The names of functions that actually do the manipulation. */ | 32 | /* The names of functions that actually do the manipulation. */ |
33 | int com_apop (char *); | 33 | int com_apop (char *); |
34 | int com_close (char *); | 34 | int com_disconnect (char *); |
35 | int com_dele (char *); | 35 | int com_dele (char *); |
36 | int com_exit (char *); | 36 | int com_exit (char *); |
37 | int com_help (char *); | 37 | int com_help (char *); |
38 | int com_list (char *); | 38 | int com_list (char *); |
39 | int com_noop (char *); | 39 | int com_noop (char *); |
40 | int com_open (char *); | 40 | int com_connect (char *); |
41 | int com_pass (char *); | 41 | int com_pass (char *); |
42 | int com_quit (char *); | 42 | int com_quit (char *); |
43 | int com_retr (char *); | 43 | int com_retr (char *); |
... | @@ -58,7 +58,7 @@ int valid_argument (const char *, char *); | ... | @@ -58,7 +58,7 @@ int valid_argument (const char *, char *); |
58 | 58 | ||
59 | COMMAND commands[] = { | 59 | COMMAND commands[] = { |
60 | { "apop", com_apop, "Authenticate with APOP: APOP user secret" }, | 60 | { "apop", com_apop, "Authenticate with APOP: APOP user secret" }, |
61 | { "close", com_close, "Close connection: close" }, | 61 | { "disconnect", com_disconnect, "Close connection: disconnect" }, |
62 | { "dele", com_dele, "Mark message: DELE msgno" }, | 62 | { "dele", com_dele, "Mark message: DELE msgno" }, |
63 | { "exit", com_exit, "exit program" }, | 63 | { "exit", com_exit, "exit program" }, |
64 | { "help", com_help, "Display this text" }, | 64 | { "help", com_help, "Display this text" }, |
... | @@ -66,7 +66,7 @@ COMMAND commands[] = { | ... | @@ -66,7 +66,7 @@ COMMAND commands[] = { |
66 | { "list", com_list, "List messages: LIST [msgno]" }, | 66 | { "list", com_list, "List messages: LIST [msgno]" }, |
67 | { "noop", com_noop, "Send no operation: NOOP" }, | 67 | { "noop", com_noop, "Send no operation: NOOP" }, |
68 | { "pass", com_pass, "Send passwd: PASS [passwd]" }, | 68 | { "pass", com_pass, "Send passwd: PASS [passwd]" }, |
69 | { "open", com_open, "Open connection: open hostname [port]" }, | 69 | { "connect", com_connect, "Open connection: connect hostname [port]" }, |
70 | { "quit", com_quit, "Go to Update state : QUIT" }, | 70 | { "quit", com_quit, "Go to Update state : QUIT" }, |
71 | { "retr", com_retr, "Dowload message: RETR msgno" }, | 71 | { "retr", com_retr, "Dowload message: RETR msgno" }, |
72 | { "rset", com_rset, "Unmark all messages: RSET" }, | 72 | { "rset", com_rset, "Unmark all messages: RSET" }, |
... | @@ -301,7 +301,7 @@ print_response () | ... | @@ -301,7 +301,7 @@ print_response () |
301 | fprintf (stderr, "%s\n", response); | 301 | fprintf (stderr, "%s\n", response); |
302 | } | 302 | } |
303 | else | 303 | else |
304 | fprintf (stderr, "Not connected, try `open' first\n"); | 304 | fprintf (stderr, "Not connected, try `connect' first\n"); |
305 | return 0; | 305 | return 0; |
306 | } | 306 | } |
307 | 307 | ||
... | @@ -342,7 +342,7 @@ com_uidl (char *arg) | ... | @@ -342,7 +342,7 @@ com_uidl (char *arg) |
342 | !iterator_is_done (uidl_iterator); | 342 | !iterator_is_done (uidl_iterator); |
343 | iterator_next (uidl_iterator)) | 343 | iterator_next (uidl_iterator)) |
344 | { | 344 | { |
345 | struct uidl_item *pl; | 345 | struct pop3_uidl_item *pl; |
346 | iterator_current (uidl_iterator, (void *)&pl); | 346 | iterator_current (uidl_iterator, (void *)&pl); |
347 | printf ("Msg: %d UIDL: %s\n", pl->msgno, pl->uidl); | 347 | printf ("Msg: %d UIDL: %s\n", pl->msgno, pl->uidl); |
348 | free (pl); | 348 | free (pl); |
... | @@ -375,7 +375,7 @@ com_list (char *arg) | ... | @@ -375,7 +375,7 @@ com_list (char *arg) |
375 | !iterator_is_done (list_iterator); | 375 | !iterator_is_done (list_iterator); |
376 | iterator_next (list_iterator)) | 376 | iterator_next (list_iterator)) |
377 | { | 377 | { |
378 | struct list_item *pl; | 378 | struct pop3_list_item *pl; |
379 | iterator_current (list_iterator, (void *)&pl); | 379 | iterator_current (list_iterator, (void *)&pl); |
380 | printf ("Msg: %d Size: %d\n", pl->msgno, pl->size); | 380 | printf ("Msg: %d Size: %d\n", pl->msgno, pl->size); |
381 | free (pl); | 381 | free (pl); |
... | @@ -576,23 +576,23 @@ com_retr (char *arg) | ... | @@ -576,23 +576,23 @@ com_retr (char *arg) |
576 | } | 576 | } |
577 | 577 | ||
578 | int | 578 | int |
579 | com_open (char *arg) | 579 | com_connect (char *arg) |
580 | { | 580 | { |
581 | char host[256]; | 581 | char host[256]; |
582 | int port = 0; | 582 | int port = 0; |
583 | int status; | 583 | int status; |
584 | if (!valid_argument ("open", arg)) | 584 | if (!valid_argument ("connect", arg)) |
585 | return 1; | 585 | return 1; |
586 | *host = '\0'; | 586 | *host = '\0'; |
587 | sscanf (arg, "%256s %d", host, &port); | 587 | sscanf (arg, "%256s %d", host, &port); |
588 | if (!valid_argument ("open", host)) | 588 | if (!valid_argument ("connect", host)) |
589 | return 1; | 589 | return 1; |
590 | if (pop3) | 590 | if (pop3) |
591 | com_close (NULL); | 591 | com_disconnect (NULL); |
592 | status = pop3_create (&pop3); | 592 | status = pop3_create (&pop3); |
593 | if (status == 0) | 593 | if (status == 0) |
594 | { | 594 | { |
595 | pop3_open (pop3, host, port, MU_STREAM_RDWR); | 595 | pop3_connect (pop3, host, port); |
596 | print_response (); | 596 | print_response (); |
597 | } | 597 | } |
598 | else | 598 | else |
... | @@ -601,12 +601,12 @@ com_open (char *arg) | ... | @@ -601,12 +601,12 @@ com_open (char *arg) |
601 | } | 601 | } |
602 | 602 | ||
603 | int | 603 | int |
604 | com_close (char *arg) | 604 | com_disconnect (char *arg) |
605 | { | 605 | { |
606 | (void) arg; | 606 | (void) arg; |
607 | if (pop3) | 607 | if (pop3) |
608 | { | 608 | { |
609 | pop3_close (pop3); | 609 | pop3_disconnect (pop3); |
610 | pop3_destroy (pop3); | 610 | pop3_destroy (pop3); |
611 | pop3 = NULL; | 611 | pop3 = NULL; |
612 | } | 612 | } |
... | @@ -620,6 +620,7 @@ com_quit (char *arg) | ... | @@ -620,6 +620,7 @@ com_quit (char *arg) |
620 | if (pop3) | 620 | if (pop3) |
621 | { | 621 | { |
622 | pop3_quit (pop3); | 622 | pop3_quit (pop3); |
623 | pop3_disconnect (pop3); | ||
623 | print_response (); | 624 | print_response (); |
624 | } | 625 | } |
625 | return 0; | 626 | return 0; |
... | @@ -631,7 +632,7 @@ com_exit (char *arg) | ... | @@ -631,7 +632,7 @@ com_exit (char *arg) |
631 | (void)arg; | 632 | (void)arg; |
632 | if (pop3) | 633 | if (pop3) |
633 | { | 634 | { |
634 | pop3_close (pop3); | 635 | pop3_disconnect (pop3); |
635 | pop3_destroy (pop3); | 636 | pop3_destroy (pop3); |
636 | } | 637 | } |
637 | done = 1; | 638 | done = 1; | ... | ... |
-
Please register or sign in to post a comment