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
1 /* GNU mailutils - a suite of utilities for electronic mail 1 /* GNU mailutils - a suite of utilities for electronic mail
2 Copyright (C) 1999, 2000 Free Software Foundation, Inc. 2 Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3 3
4 This program is free software; you can redistribute it and/or modify 4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Library General Public License as published by 5 it under the terms of the GNU Library General Public License as published by
...@@ -69,6 +69,7 @@ struct _mailbox ...@@ -69,6 +69,7 @@ struct _mailbox
69 int (*_get_message) __P ((mailbox_t, size_t msgno, message_t *msg)); 69 int (*_get_message) __P ((mailbox_t, size_t msgno, message_t *msg));
70 int (*_append_message) __P ((mailbox_t, message_t msg)); 70 int (*_append_message) __P ((mailbox_t, message_t msg));
71 int (*_messages_count) __P ((mailbox_t, size_t *num)); 71 int (*_messages_count) __P ((mailbox_t, size_t *num));
72 int (*_recent_count) __P ((mailbox_t, size_t *num));
72 int (*_expunge) __P ((mailbox_t)); 73 int (*_expunge) __P ((mailbox_t));
73 74
74 int (*_scan) __P ((mailbox_t, size_t msgno, size_t *count)); 75 int (*_scan) __P ((mailbox_t, size_t msgno, size_t *count));
......
...@@ -220,6 +220,14 @@ mailbox_messages_count (mailbox_t mbox, size_t *num) ...@@ -220,6 +220,14 @@ mailbox_messages_count (mailbox_t mbox, size_t *num)
220 } 220 }
221 221
222 int 222 int
223 mailbox_recent_count (mailbox_t mbox, size_t *num)
224 {
225 if (mbox && mbox->_recent_count)
226 return mbox->_recent_count (mbox, num);
227 return mailbox_messages_count (mbox, num);
228 }
229
230 int
223 mailbox_expunge (mailbox_t mbox) 231 mailbox_expunge (mailbox_t mbox)
224 { 232 {
225 if (mbox == NULL || mbox->_expunge == NULL) 233 if (mbox == NULL || mbox->_expunge == NULL)
......
...@@ -122,6 +122,7 @@ static int mbox_close __P ((mailbox_t)); ...@@ -122,6 +122,7 @@ static int mbox_close __P ((mailbox_t));
122 static int mbox_get_message __P ((mailbox_t, size_t, message_t *)); 122 static int mbox_get_message __P ((mailbox_t, size_t, message_t *));
123 static int mbox_append_message __P ((mailbox_t, message_t)); 123 static int mbox_append_message __P ((mailbox_t, message_t));
124 static int mbox_messages_count __P ((mailbox_t, size_t *)); 124 static int mbox_messages_count __P ((mailbox_t, size_t *));
125 static int mbox_recent_count __P ((mailbox_t, size_t *));
125 static int mbox_expunge __P ((mailbox_t)); 126 static int mbox_expunge __P ((mailbox_t));
126 static int mbox_scan __P ((mailbox_t, size_t, size_t *)); 127 static int mbox_scan __P ((mailbox_t, size_t, size_t *));
127 static int mbox_is_updated __P ((mailbox_t)); 128 static int mbox_is_updated __P ((mailbox_t));
...@@ -209,6 +210,7 @@ _mailbox_mbox_init (mailbox_t mailbox) ...@@ -209,6 +210,7 @@ _mailbox_mbox_init (mailbox_t mailbox)
209 mailbox->_get_message = mbox_get_message; 210 mailbox->_get_message = mbox_get_message;
210 mailbox->_append_message = mbox_append_message; 211 mailbox->_append_message = mbox_append_message;
211 mailbox->_messages_count = mbox_messages_count; 212 mailbox->_messages_count = mbox_messages_count;
213 mailbox->_recent_count = mbox_recent_count;
212 mailbox->_expunge = mbox_expunge; 214 mailbox->_expunge = mbox_expunge;
213 215
214 mailbox->_scan = mbox_scan; 216 mailbox->_scan = mbox_scan;
...@@ -1534,6 +1536,25 @@ mbox_messages_count (mailbox_t mailbox, size_t *pcount) ...@@ -1534,6 +1536,25 @@ mbox_messages_count (mailbox_t mailbox, size_t *pcount)
1534 return 0; 1536 return 0;
1535 } 1537 }
1536 1538
1539 static int
1540 mbox_recent_count (mailbox_t mailbox, size_t *pcount)
1541 {
1542 mbox_data_t mud = mailbox->data;
1543 mbox_message_t mum;
1544 size_t j, total;
1545
1546 if (pcount)
1547 return EINVAL;
1548 for (total = j = 0; j < mud->messages_count; j++)
1549 {
1550 mum = mud->umessages[j];
1551 if (mum && mum->new_flags == 0)
1552 total++;
1553 }
1554 *pcount = total;
1555 return 0;
1556 }
1557
1537 #ifdef WITH_PTHREAD 1558 #ifdef WITH_PTHREAD
1538 static void 1559 static void
1539 mbox_cleanup (void *arg) 1560 mbox_cleanup (void *arg)
......