Commit a3ea3ecc a3ea3eccdbbdfee33c52525d6db00bbd0c5624db by Alain Magloire

* mailbox/folder_imap.c (imap_use): Check return value.

	* mailbox/mailbox.c (mailbox_get_debug): Get the mu_debug_t
	object from the folder if available.
	* mailbox/mbx_imap.c (imap_append_message): Check for
	EAGAIN.
	(imap_header_get_value): If the operation return 0, set
	error to ENOENT.
1 parent 8b262f17
2001-09-03 Alain Magloire
* mailbox/folder_imap.c (imap_use): Check return value.
* mailbox/mailbox.c (mailbox_get_debug): Get the mu_debug_t
object from the folder if available.
* mailbox/mbx_imap.c (imap_append_message): Check for
EAGAIN.
(imap_header_get_value): If the operation return 0, set
error to ENOENT.
2001-09-03 Alain Magloire
* configure.in: AC_REPLACE_FUNCS(fgetpwent);
* include/mailutils/parse822.h: Add a prototype for
......
......@@ -196,7 +196,7 @@ imap_user (authority_t auth)
case IMAP_LOGIN:
/* Send it across. */
imap_send (f_imap);
status = imap_send (f_imap);
CHECK_EAGAIN (f_imap, status);
/* Clear the buffer it contains the passwd. */
memset (f_imap->buffer, '\0', f_imap->buflen);
......
......@@ -454,13 +454,11 @@ mailbox_get_property (mailbox_t mbox, property_t *pproperty)
int
mailbox_set_debug (mailbox_t mbox, mu_debug_t debug)
{
int status = 0;
if (mbox == NULL)
return EINVAL;
if (mbox->folder)
{
status = folder_set_debug (mbox->folder, debug);
int status = folder_set_debug (mbox->folder, debug);
if (status)
return status;
}
......@@ -475,6 +473,17 @@ mailbox_get_debug (mailbox_t mbox, mu_debug_t *pdebug)
{
if (mbox == NULL || pdebug == NULL)
return EINVAL;
if (mbox->folder)
{
int status = folder_get_debug (mbox->folder, pdebug);
if (status == 0)
{
if (mbox->debug)
mu_debug_destroy (&(mbox->debug), mbox);
mbox->debug = *pdebug;
}
return status;
}
if (mbox->debug == NULL)
{
int status = mu_debug_create (&(mbox->debug), mbox);
......
......@@ -829,7 +829,7 @@ imap_append_message (mailbox_t mailbox, message_t msg)
size_t n = 0;
char buffer[255];
message_get_stream (msg, &stream);
while (stream_readline (stream, buffer, sizeof (buffer), off, &n) == 0
while (stream_readline (stream, buffer, sizeof buffer, off, &n) == 0
&& n > 0)
{
if (buffer[n - 1] == '\n')
......@@ -841,12 +841,14 @@ imap_append_message (mailbox_t mailbox, message_t msg)
imap_writeline (f_imap, "%s", buffer);
off += n;
status = imap_send (f_imap);
CHECK_EAGAIN (f_imap, status);
}
f_imap->state = IMAP_APPEND_ACK;
}
/* !@#%$ UW-IMAP server hack: insists on the last line. */
imap_writeline (f_imap, "\n");
imap_send (f_imap);
status = imap_send (f_imap);
CHECK_EAGAIN (f_imap, status);
case IMAP_APPEND_ACK:
status = imap_parse (f_imap);
......@@ -1241,7 +1243,7 @@ imap_envelope_date (envelope_t envelope, char *buffer, size_t buflen,
MAILBOX_DEBUG0 (m_imap->mailbox, MU_DEBUG_PROT, f_imap->buffer);
f_imap->state = IMAP_FETCH;
}
status = message_operation (f_imap, msg_imap, datebuf, sizeof(datebuf), NULL);
status = message_operation (f_imap, msg_imap, datebuf, sizeof datebuf, NULL);
if (status != 0)
return status;
......@@ -1257,9 +1259,7 @@ imap_envelope_date (envelope_t envelope, char *buffer, size_t buflen,
struct tm* gmt;
time(&now);
gmt = gmtime(&now);
tm = *gmt;
}
......@@ -1491,10 +1491,11 @@ imap_header_get_value (header_t header, const char *field, char * buffer,
if (status == 0)
{
char *colon;
/* The field-matching is case-insensitive. In all cases, the delimiting
newline between the header and the body is always included.
Nuke it */
value[len - 1] = '\0';
/* The field-matching is case-insensitive. In all cases, the
delimiting newline between the header and the body is always
included. Nuke it */
if (len)
value[len - 1] = '\0';
/* Move pass the field-name. */
colon = strchr (value, ':');
......@@ -1507,7 +1508,7 @@ imap_header_get_value (header_t header, const char *field, char * buffer,
else
colon = value;
while (colon[strlen (colon) - 1] == '\n')
while (*colon && colon[strlen (colon) - 1] == '\n')
colon[strlen (colon) - 1] = '\0';
if (buffer && buflen)
......