Commit b9355608 b93556087280eab726c507486415385f996ebf54 by Sergey Poznyakoff

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.
1 parent d22b2199
......@@ -502,7 +502,7 @@ com_capa (int argc, char **argv)
for (; i < argc; i++)
{
const char *elt;
int rc = pop3_capa_test (pop3, argv[i], &elt);
int rc = mu_pop3_capa_test (pop3, argv[i], &elt);
switch (rc)
{
case 0:
......@@ -677,7 +677,7 @@ com_pass (int argc, char **argv)
int
com_stat (int argc MU_ARG_UNUSED, char **argv MU_ARG_UNUSED)
{
unsigned count = 0;
size_t count = 0;
size_t size = 0;
int status = 0;
......
......@@ -62,6 +62,10 @@ size_t mu_opool_size (mu_opool_t opool);
mu_opool_create, above). */
int mu_opool_coalesce (mu_opool_t opool, size_t *psize);
/* Copy at most SIZE bytes of collected data into BUF. Return the
actual number of bytes copied. */
size_t mu_opool_copy (mu_opool_t opool, void *buf, size_t size);
/* Return the pointer to the current object head chunk. If mu_opool_coalesce
was called before, the returned value points to the entire object.
If PSIZE is not NULL, store the size of the head chunk to *PSIZE. */
......
......@@ -60,7 +60,7 @@ int mu_pop3_stls (mu_pop3_t pop3);
"const char *", no processing is done on the item except the removal of
the trailing newline. */
int mu_pop3_capa (mu_pop3_t pop3, int reread, mu_iterator_t *piter);
int pop3_capa_test (mu_pop3_t pop3, const char *name, const char **pret);
int mu_pop3_capa_test (mu_pop3_t pop3, const char *name, const char **pret);
int mu_pop3_dele (mu_pop3_t pop3, unsigned int mesgno);
......@@ -89,7 +89,7 @@ int mu_pop3_retr (mu_pop3_t pop3, unsigned int mesgno,
int mu_pop3_rset (mu_pop3_t pop3);
int mu_pop3_stat (mu_pop3_t pop3, unsigned int *count, size_t *octets);
int mu_pop3_stat (mu_pop3_t pop3, size_t *count, mu_off_t *octets);
/* A stream is returned with the multi-line answer. It is the responsability
of the caller to call mu_stream_destroy() to dipose of the stream. */
......
......@@ -24,10 +24,10 @@ lib_LTLIBRARIES = libmu_pop.la
libmu_pop_la_LDFLAGS=-version-info @VI_CURRENT@:@VI_REVISION@:@VI_AGE@
libmu_pop_la_LIBADD = ${MU_LIB_AUTH} ${MU_LIB_MAILUTILS} @INTLLIBS@
# folder.c\
# url.c\
# mbox.c
libmu_pop_la_SOURCES = \
mbox.c \
folder.c\
url.c\
\
pop3_apop.c \
pop3_capa.c \
......
......@@ -26,7 +26,7 @@
#include <mailutils/sys/pop3.h>
int
pop3_capa_test (mu_pop3_t pop3, const char *name, const char **pret)
mu_pop3_capa_test (mu_pop3_t pop3, const char *name, const char **pret)
{
int rc;
......
......@@ -27,10 +27,10 @@
#include <mailutils/sys/pop3.h>
int
mu_pop3_stat (mu_pop3_t pop3, unsigned *msg_count, size_t *size)
mu_pop3_stat (mu_pop3_t pop3, size_t *msg_count, mu_off_t *size)
{
int status;
unsigned long lv;
unsigned long lv, count;
if (pop3 == NULL || msg_count == NULL)
return EINVAL;
......@@ -55,7 +55,8 @@ mu_pop3_stat (mu_pop3_t pop3, unsigned *msg_count, size_t *size)
*msg_count = 0;
lv = 0;
/* FIXME: Error checking */
sscanf (pop3->ackbuf, "+OK %d %lu", msg_count, &lv);
sscanf (pop3->ackbuf, "+OK %lu %lu", &count, &lv);
*msg_count = count;
*size = lv;
break;
......
......@@ -205,6 +205,25 @@ mu_opool_size (mu_opool_t opool)
return size;
}
size_t
mu_opool_copy (mu_opool_t opool, void *buf, size_t size)
{
char *cp = buf;
size_t total = 0;
struct mu_opool_bucket *p;
for (p = opool->head; p && total < size; p = p->next)
{
size_t cpsize = size - total;
if (cpsize > p->level)
cpsize = p->level;
memcpy (cp, p->buf, cpsize);
cp += cpsize;
total += cpsize;
}
return total;
}
int
mu_opool_coalesce (mu_opool_t opool, size_t *psize)
{
......
......@@ -201,6 +201,9 @@ _xscript_ctl (struct _mu_stream *str, int op, void *arg)
case MU_IOCTL_SWAP_STREAM:
if (!arg)
return EINVAL;
if (!sp->transport)
status = ENOSYS;
else
status = mu_stream_ioctl (sp->transport, op, arg);
if (status == EINVAL || status == ENOSYS)
{
......