Commit 6c565ba7 6c565ba75329ff0edbc7a8ab56df9c2282591cd1 by Sergey Poznyakoff

(pop3d_fix_mark): Use expire_mark_message to

process expired messages. Apart from the new functionality, it
also fixes a bug: len was incorrectly used as a replace indicator
in header_set_value, thus each retrieval of the message was
resetting its expiration date.
1 parent dbbf165e
......@@ -57,37 +57,29 @@ pop3d_quit (const char *arg)
return err;
}
static void
pop3d_fix_mark ()
{
size_t i;
size_t total = 0;
char *value = NULL;
int len;
mailbox_messages_count (mbox, &total);
if (expire > 0)
len = asprintf (&value, "%lu", (unsigned long) time (NULL));
for (i = 1; i <= total; i++)
{
message_t msg = NULL;
attribute_t attr = NULL;
mailbox_get_message (mbox, i, &msg);
message_get_attribute (msg, &attr);
if (pop3d_is_deleted (attr))
attribute_set_deleted (attr);
/* Mark the message with a timestamp. */
if (expire >= 0 && pop3d_is_retr (attr))
{
header_t header = NULL;
message_get_header (msg, &header);
header_set_value (header, "X-Expire-Timestamp", value, len);
}
message_t msg = NULL;
attribute_t attr = NULL;
mailbox_get_message (mbox, i, &msg);
message_get_attribute (msg, &attr);
if (pop3d_is_deleted (attr))
attribute_set_deleted (attr);
expire_mark_message (msg, &value);
}
free (value);
free (value);
}
......