Commit 8c2c480c 8c2c480c8c0a39164c699591f5ec5062a22ac5ab by Alain Magloire

add new function to mailbox_t mailbox_recent_count()

This was usefull to implement SELECT/EXAMINE for imap4
1 parent 883cb1b1
/* GNU mailutils - a suite of utilities for electronic mail
Copyright (C) 1999, 2000 Free Software Foundation, Inc.
Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
......@@ -69,6 +69,7 @@ struct _mailbox
int (*_get_message) __P ((mailbox_t, size_t msgno, message_t *msg));
int (*_append_message) __P ((mailbox_t, message_t msg));
int (*_messages_count) __P ((mailbox_t, size_t *num));
int (*_recent_count) __P ((mailbox_t, size_t *num));
int (*_expunge) __P ((mailbox_t));
int (*_scan) __P ((mailbox_t, size_t msgno, size_t *count));
......
......@@ -220,6 +220,14 @@ mailbox_messages_count (mailbox_t mbox, size_t *num)
}
int
mailbox_recent_count (mailbox_t mbox, size_t *num)
{
if (mbox && mbox->_recent_count)
return mbox->_recent_count (mbox, num);
return mailbox_messages_count (mbox, num);
}
int
mailbox_expunge (mailbox_t mbox)
{
if (mbox == NULL || mbox->_expunge == NULL)
......
......@@ -122,6 +122,7 @@ static int mbox_close __P ((mailbox_t));
static int mbox_get_message __P ((mailbox_t, size_t, message_t *));
static int mbox_append_message __P ((mailbox_t, message_t));
static int mbox_messages_count __P ((mailbox_t, size_t *));
static int mbox_recent_count __P ((mailbox_t, size_t *));
static int mbox_expunge __P ((mailbox_t));
static int mbox_scan __P ((mailbox_t, size_t, size_t *));
static int mbox_is_updated __P ((mailbox_t));
......@@ -209,6 +210,7 @@ _mailbox_mbox_init (mailbox_t mailbox)
mailbox->_get_message = mbox_get_message;
mailbox->_append_message = mbox_append_message;
mailbox->_messages_count = mbox_messages_count;
mailbox->_recent_count = mbox_recent_count;
mailbox->_expunge = mbox_expunge;
mailbox->_scan = mbox_scan;
......@@ -1534,6 +1536,25 @@ mbox_messages_count (mailbox_t mailbox, size_t *pcount)
return 0;
}
static int
mbox_recent_count (mailbox_t mailbox, size_t *pcount)
{
mbox_data_t mud = mailbox->data;
mbox_message_t mum;
size_t j, total;
if (pcount)
return EINVAL;
for (total = j = 0; j < mud->messages_count; j++)
{
mum = mud->umessages[j];
if (mum && mum->new_flags == 0)
total++;
}
*pcount = total;
return 0;
}
#ifdef WITH_PTHREAD
static void
mbox_cleanup (void *arg)
......