Commit 3eda93f5 3eda93f5a70e12851d9ba73e701c0d89ba272d8b by Alain Magloire

* mailbox/header.c (header_get_fvalue): When it fails set the number

	of byte written to 0.
	(header_get_value): Likewised.
	* mailbox/mbx_imap.c (imap_envelope_sender): Go through
	header_get_value() to fetch the "Sender" field, it may be cache.
	(imap_header_get_fvalue): Put parenthesies around the FETCH, the
	WU-IMAPD likes it that way.
1 parent ae520dbf
2001-10-11 Alain Magloire
* mailbox/header.c (header_get_fvalue): When it fails set the number
of byte written to 0.
(header_get_value): Likewised.
* mailbox/mbx_imap.c (imap_envelope_sender): Go through
header_get_value() to fetch the "Sender" field, it may be cache.
(imap_header_get_fvalue): Put parenthesies around the FETCH, the
WU-IMAPD likes it that way.
2001-10-10 Alain Magloire
* mailbox/mbx_pop.c (_mbox_pop_init): Authority is set on the folder.
......
......@@ -409,24 +409,26 @@ header_get_fvalue (header_t header, const char *name, char *buffer,
for (i = 0, name_len = strlen (name); i < header->fhdr_count; i++)
{
fn_len = header->fhdr[i].fn_end - header->fhdr[i].fn;
if (fn_len == name_len && strcasecmp (header->fhdr[i].fn, name) == 0)
if (fn_len == name_len
&& strcasecmp (header->fhdr[i].fn, name) == 0)
{
fv_len = header->fhdr[i].fv_end - header->fhdr[i].fv;
/* Permanent failure: If the field exist but the value is NULL
It is a way to notify that the field dow not exist.
The value EINVAL is return no ENOENT to let header_get_value()
know about the error. */
/* Permanent failure. */
if (fv_len == 0)
err = EINVAL;
else if (buffer && buflen > 0)
{
err = EINVAL;
break;
}
if (buffer && buflen > 0)
{
buflen--;
fv_len = (fv_len < buflen) ? fv_len : buflen;
memcpy (buffer, header->fhdr[i].fv, fv_len);
buffer[fv_len] = '\0';
err = 0;
}
err = 0;
break;
}
}
......@@ -453,13 +455,12 @@ header_get_value (header_t header, const char *name, char *buffer,
err = header_get_fvalue (header, name, buffer, buflen, pn);
switch (err)
{
case ENOENT:
break; /* Do not give up just yet. */
case EINVAL: /* Permanent failure. */
err = ENOENT;
default:
if (err && pn)
case ENOMEM:
if (pn)
*pn = 0;
case 0:
return err;
}
......
......@@ -1206,13 +1206,11 @@ imap_envelope_sender (envelope_t envelope, char *buffer, size_t buflen,
return 0;
message_get_header (msg, &header);
status = imap_header_get_value (header, MU_HEADER_SENDER, buffer,
buflen, plen);
status = header_get_value (header, MU_HEADER_SENDER, buffer, buflen, plen);
if (status == EAGAIN)
return status;
else if (status != 0)
status = imap_header_get_value (header, MU_HEADER_FROM, buffer,
buflen, plen);
status = header_get_value (header, MU_HEADER_FROM, buffer, buflen, plen);
if (status == 0)
{
address_t address;
......@@ -1595,7 +1593,7 @@ imap_header_get_fvalue (header_t header, const char *field, char * buffer,
return status;
#define MU_IMAP_CACHE_HEADERS "Bcc Cc Content-Language Content-Transfer-Encoding Content-Type Date From In-Reply-To Message-ID Reference Reply-To Sender Subject To X-UIDL"
status = imap_writeline (f_imap,
"g%d FETCH %d FLAGS RFC822.SIZE BODY.PEEK[HEADER.FIELDS (%s)]\r\n",
"g%d FETCH %d (FLAGS RFC822.SIZE BODY.PEEK[HEADER.FIELDS (%s)])\r\n",
f_imap->seq++, msg_imap->num,
MU_IMAP_CACHE_HEADERS);
CHECK_ERROR (f_imap, status);
......