Begin rewriting pop3 mailbox support. Several bugfixes.
* examples/pop3client.c (com_capa): Call mu_pop3_capa_test. (com_stat): Count is size_t. * include/mailutils/opool.h (mu_opool_copy): New proto. * mailbox/opool.c (mu_opool_copy): New function. * mailbox/xscript-stream.c (_xscript_ctl) <MU_IOCTL_SWAP_STREAM>: Avoid coredumping if sp->transport is NULL. * include/mailutils/pop3.h (pop3_capa_test): Rename to mu_pop3_capa_test. (mu_pop3_stat): Third argument is a pointer to mu_off_t. * libproto/pop/pop3_capatst.c (pop3_capa_test): Rename to mu_pop3_capa_test. * libproto/pop/pop3_stat.c (mu_pop3_stat): Third argument is a pointer to mu_off_t. * libproto/pop/Makefile.am (libmu_pop_la_SOURCES): Put back folder.c, url.c and mbox.c. * libproto/pop/mbox.c: Begin rewriting.
Showing
9 changed files
with
40 additions
and
13 deletions
... | @@ -502,7 +502,7 @@ com_capa (int argc, char **argv) | ... | @@ -502,7 +502,7 @@ com_capa (int argc, char **argv) |
502 | for (; i < argc; i++) | 502 | for (; i < argc; i++) |
503 | { | 503 | { |
504 | const char *elt; | 504 | const char *elt; |
505 | int rc = pop3_capa_test (pop3, argv[i], &elt); | 505 | int rc = mu_pop3_capa_test (pop3, argv[i], &elt); |
506 | switch (rc) | 506 | switch (rc) |
507 | { | 507 | { |
508 | case 0: | 508 | case 0: |
... | @@ -677,7 +677,7 @@ com_pass (int argc, char **argv) | ... | @@ -677,7 +677,7 @@ com_pass (int argc, char **argv) |
677 | int | 677 | int |
678 | com_stat (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED) | 678 | com_stat (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED) |
679 | { | 679 | { |
680 | unsigned count = 0; | 680 | size_t count = 0; |
681 | size_t size = 0; | 681 | size_t size = 0; |
682 | int status = 0; | 682 | int status = 0; |
683 | 683 | ... | ... |
... | @@ -62,6 +62,10 @@ size_t mu_opool_size (mu_opool_t opool); | ... | @@ -62,6 +62,10 @@ size_t mu_opool_size (mu_opool_t opool); |
62 | mu_opool_create, above). */ | 62 | mu_opool_create, above). */ |
63 | int mu_opool_coalesce (mu_opool_t opool, size_t *psize); | 63 | int mu_opool_coalesce (mu_opool_t opool, size_t *psize); |
64 | 64 | ||
65 | /* Copy at most SIZE bytes of collected data into BUF. Return the | ||
66 | actual number of bytes copied. */ | ||
67 | size_t mu_opool_copy (mu_opool_t opool, void *buf, size_t size); | ||
68 | |||
65 | /* Return the pointer to the current object head chunk. If mu_opool_coalesce | 69 | /* Return the pointer to the current object head chunk. If mu_opool_coalesce |
66 | was called before, the returned value points to the entire object. | 70 | was called before, the returned value points to the entire object. |
67 | If PSIZE is not NULL, store the size of the head chunk to *PSIZE. */ | 71 | If PSIZE is not NULL, store the size of the head chunk to *PSIZE. */ | ... | ... |
... | @@ -59,8 +59,8 @@ int mu_pop3_stls (mu_pop3_t pop3); | ... | @@ -59,8 +59,8 @@ int mu_pop3_stls (mu_pop3_t pop3); |
59 | done with the iterator. The items returned by the iterator are of type | 59 | done with the iterator. The items returned by the iterator are of type |
60 | "const char *", no processing is done on the item except the removal of | 60 | "const char *", no processing is done on the item except the removal of |
61 | the trailing newline. */ | 61 | the trailing newline. */ |
62 | int mu_pop3_capa (mu_pop3_t pop3, int reread, mu_iterator_t *piter); | 62 | int mu_pop3_capa (mu_pop3_t pop3, int reread, mu_iterator_t *piter); |
63 | int pop3_capa_test (mu_pop3_t pop3, const char *name, const char **pret); | 63 | int mu_pop3_capa_test (mu_pop3_t pop3, const char *name, const char **pret); |
64 | 64 | ||
65 | int mu_pop3_dele (mu_pop3_t pop3, unsigned int mesgno); | 65 | int mu_pop3_dele (mu_pop3_t pop3, unsigned int mesgno); |
66 | 66 | ||
... | @@ -89,7 +89,7 @@ int mu_pop3_retr (mu_pop3_t pop3, unsigned int mesgno, | ... | @@ -89,7 +89,7 @@ int mu_pop3_retr (mu_pop3_t pop3, unsigned int mesgno, |
89 | 89 | ||
90 | int mu_pop3_rset (mu_pop3_t pop3); | 90 | int mu_pop3_rset (mu_pop3_t pop3); |
91 | 91 | ||
92 | int mu_pop3_stat (mu_pop3_t pop3, unsigned int *count, size_t *octets); | 92 | int mu_pop3_stat (mu_pop3_t pop3, size_t *count, mu_off_t *octets); |
93 | 93 | ||
94 | /* A stream is returned with the multi-line answer. It is the responsability | 94 | /* A stream is returned with the multi-line answer. It is the responsability |
95 | of the caller to call mu_stream_destroy() to dipose of the stream. */ | 95 | of the caller to call mu_stream_destroy() to dipose of the stream. */ | ... | ... |
... | @@ -24,10 +24,10 @@ lib_LTLIBRARIES = libmu_pop.la | ... | @@ -24,10 +24,10 @@ lib_LTLIBRARIES = libmu_pop.la |
24 | libmu_pop_la_LDFLAGS=-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@ | 24 | libmu_pop_la_LDFLAGS=-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@ |
25 | libmu_pop_la_LIBADD = ${MU_LIB_AUTH} ${MU_LIB_MAILUTILS} @INTLLIBS@ | 25 | libmu_pop_la_LIBADD = ${MU_LIB_AUTH} ${MU_LIB_MAILUTILS} @INTLLIBS@ |
26 | 26 | ||
27 | # folder.c\ | ||
28 | # url.c\ | ||
29 | # mbox.c | ||
30 | libmu_pop_la_SOURCES = \ | 27 | libmu_pop_la_SOURCES = \ |
28 | mbox.c \ | ||
29 | folder.c\ | ||
30 | url.c\ | ||
31 | \ | 31 | \ |
32 | pop3_apop.c \ | 32 | pop3_apop.c \ |
33 | pop3_capa.c \ | 33 | pop3_capa.c \ | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -26,7 +26,7 @@ | ... | @@ -26,7 +26,7 @@ |
26 | #include <mailutils/sys/pop3.h> | 26 | #include <mailutils/sys/pop3.h> |
27 | 27 | ||
28 | int | 28 | int |
29 | pop3_capa_test (mu_pop3_t pop3, const char *name, const char **pret) | 29 | mu_pop3_capa_test (mu_pop3_t pop3, const char *name, const char **pret) |
30 | { | 30 | { |
31 | int rc; | 31 | int rc; |
32 | 32 | ... | ... |
... | @@ -27,10 +27,10 @@ | ... | @@ -27,10 +27,10 @@ |
27 | #include <mailutils/sys/pop3.h> | 27 | #include <mailutils/sys/pop3.h> |
28 | 28 | ||
29 | int | 29 | int |
30 | mu_pop3_stat (mu_pop3_t pop3, unsigned *msg_count, size_t *size) | 30 | mu_pop3_stat (mu_pop3_t pop3, size_t *msg_count, mu_off_t *size) |
31 | { | 31 | { |
32 | int status; | 32 | int status; |
33 | unsigned long lv; | 33 | unsigned long lv, count; |
34 | 34 | ||
35 | if (pop3 == NULL || msg_count == NULL) | 35 | if (pop3 == NULL || msg_count == NULL) |
36 | return EINVAL; | 36 | return EINVAL; |
... | @@ -55,7 +55,8 @@ mu_pop3_stat (mu_pop3_t pop3, unsigned *msg_count, size_t *size) | ... | @@ -55,7 +55,8 @@ mu_pop3_stat (mu_pop3_t pop3, unsigned *msg_count, size_t *size) |
55 | *msg_count = 0; | 55 | *msg_count = 0; |
56 | lv = 0; | 56 | lv = 0; |
57 | /* FIXME: Error checking */ | 57 | /* FIXME: Error checking */ |
58 | sscanf (pop3->ackbuf, "+OK %d %lu", msg_count, &lv); | 58 | sscanf (pop3->ackbuf, "+OK %lu %lu", &count, &lv); |
59 | *msg_count = count; | ||
59 | *size = lv; | 60 | *size = lv; |
60 | break; | 61 | break; |
61 | 62 | ... | ... |
... | @@ -205,6 +205,25 @@ mu_opool_size (mu_opool_t opool) | ... | @@ -205,6 +205,25 @@ mu_opool_size (mu_opool_t opool) |
205 | return size; | 205 | return size; |
206 | } | 206 | } |
207 | 207 | ||
208 | size_t | ||
209 | mu_opool_copy (mu_opool_t opool, void *buf, size_t size) | ||
210 | { | ||
211 | char *cp = buf; | ||
212 | size_t total = 0; | ||
213 | struct mu_opool_bucket *p; | ||
214 | |||
215 | for (p = opool->head; p && total < size; p = p->next) | ||
216 | { | ||
217 | size_t cpsize = size - total; | ||
218 | if (cpsize > p->level) | ||
219 | cpsize = p->level; | ||
220 | memcpy (cp, p->buf, cpsize); | ||
221 | cp += cpsize; | ||
222 | total += cpsize; | ||
223 | } | ||
224 | return total; | ||
225 | } | ||
226 | |||
208 | int | 227 | int |
209 | mu_opool_coalesce (mu_opool_t opool, size_t *psize) | 228 | mu_opool_coalesce (mu_opool_t opool, size_t *psize) |
210 | { | 229 | { | ... | ... |
... | @@ -201,7 +201,10 @@ _xscript_ctl (struct _mu_stream *str, int op, void *arg) | ... | @@ -201,7 +201,10 @@ _xscript_ctl (struct _mu_stream *str, int op, void *arg) |
201 | case MU_IOCTL_SWAP_STREAM: | 201 | case MU_IOCTL_SWAP_STREAM: |
202 | if (!arg) | 202 | if (!arg) |
203 | return EINVAL; | 203 | return EINVAL; |
204 | status = mu_stream_ioctl (sp->transport, op, arg); | 204 | if (!sp->transport) |
205 | status = ENOSYS; | ||
206 | else | ||
207 | status = mu_stream_ioctl (sp->transport, op, arg); | ||
205 | if (status == EINVAL || status == ENOSYS) | 208 | if (status == EINVAL || status == ENOSYS) |
206 | { | 209 | { |
207 | mu_stream_t *pstr = arg; | 210 | mu_stream_t *pstr = arg; | ... | ... |
-
Please register or sign in to post a comment