Commit fb600737 fb6007379f8fbea3701fd9ce083db448a36d1957 by Sean 'Shaleh' Perry

began implementing scan() and is_updated()

1 parent 1ada3043
1999-11-07 Sean 'Shaleh' Perry <shaleh@debian.org>
* TODO: restructuring, now split into sections
* libmailbox/*: added two new functions to the api and began implementing
them in unixmbox
is_updated() => has this mailbox been updated externally?
scan() => build info on mailbox, removing old data as needed
currently not implemented
1999-11-06 Sean 'Shaleh' Perry <shaleh@debian.org>
* libmailbox/*: more work on expunge
......
......@@ -3,19 +3,28 @@
= --> on hold
* --> in progress
[libmailbox]
* autogen.sh (libtool) complains about libmailbox.la in noinst (JB Oct 08/99)
- added more includes to libmailbox, make sure autoconf finds them
- added more includes, make sure autoconf finds them
- libmailbox needs an interface to set flags for each message
- need an interface to set flags for each message
- libmailbox needs an interface to set and create values in the header
- need an interface to set and create values in the header
- libmailbox/unixmbox the open function needs to be split into an open and a
parse function
- unixmbox's open function needs to be split into an open and a parse function
- clean up 'mail''s compilation
- needs a search ability
- unixmbox needs expunge working
+ libmailbox has a nasty bug -- if the mailbox is empty, the library has no idea
what to do (Shaleh Oct 07/99)
[mail]
- clean up 'mail''s compilation, why is there a mail script?
[pop3]
- find out why the pop3 server quits on a signal when the 'quit' command is
given
......@@ -23,16 +32,14 @@
- test network code
+ crypt is linked even if pam was detected, it should be one or the other (JB Oct 08/99)
[all]
- add more features
- optimize everything
- test everything
+ libmailbox has a nasty bug -- if the mailbox is empty, the library has no idea
what to do (Shaleh Oct 07/99)
+ crypt is linked even if pam was detected, it should be one or the other (JB Oct 08/99)
+ add imap server code (JB && Shaleh Oct 11/99)
......
......@@ -78,8 +78,10 @@ mbox_open (const char *name)
mbox->_delete = _mbox_dummy2;
mbox->_undelete = _mbox_dummy2;
mbox->_expunge = _mbox_dummy1;
mbox->_scan = _mbox_dummy1;
mbox->_add_message = _mbox_dummy3;
mbox->_is_deleted = _mbox_dummy2;
mbox->_is_updated = _mbox_dummy1;
mbox->_lock = _mbox_dummy2;
mbox->_get_body = _mbox_dummy4;
mbox->_get_header = _mbox_dummy4;
......
......@@ -31,7 +31,9 @@
#define mbox_delete(m,n) m->_delete(m,n)
#define mbox_undelete(m,n) m->_undelete(m,n)
#define mbox_expunge(m) m->_expunge(m)
#define mbox_scan(m) m->_scan(m)
#define mbox_is_deleted(m,n) m->_is_deleted(m,n)
#define mbox_is_updated(m) m->_is_updated(m)
#define mbox_add_message(m,s) m->_add_message(m,s)
#define mbox_get_body(m,n) m->_get_body(m,n)
#define mbox_get_header(m,n) m->_get_header(m,n)
......@@ -64,7 +66,9 @@ typedef struct _mailbox
int (*_undelete) __P ((struct _mailbox *, unsigned int));
int (*_expunge) __P ((struct _mailbox *));
int (*_add_message) __P ((struct _mailbox *, char *));
int (*_scan) __P ((struct _mailbox *));
int (*_is_deleted) __P ((struct _mailbox *, unsigned int));
int (*_is_updated) __P ((struct mailbox *));
int (*_lock) __P((struct _mailbox *, mailbox_lock_t));
char *(*_get_body) __P ((struct _mailbox *, unsigned int));
char *(*_get_header) __P ((struct _mailbox *, unsigned int));
......
......@@ -31,6 +31,7 @@ unixmbox_open (mailbox * mbox)
unsigned int max_count = 10;
int mess = 0;
unixmbox_data *data;
struct stat st;
if (mbox == NULL)
{
......@@ -63,6 +64,12 @@ unixmbox_open (mailbox * mbox)
errno = ENOMEM;
return -1;
}
if (stat (mbox->name, &st) == -1)
{
unixmbox_close (mbox);
return -1;
}
data->last_mod_time = st.st_mtime;
if (fgets (buf, 80, data->file) == NULL)
{
......@@ -316,6 +323,23 @@ unixmbox_is_deleted (mailbox * mbox, unsigned int num)
return (data->messages[num].deleted == 1);
}
int
unixmbox_is_updated (mailbox *mbox)
{
struct stat st;
unixmbox_data *data;
if (mbox == NULL)
{
errno = EINVAL;
return -1;
}
if (stat (mbox->name, &st) == -1)
return -1;
data = mbox->_data;
return (st.st_mtime > data->last_mod_time);
}
/*
* Adds a message to the mailbox
*/
......@@ -434,6 +458,14 @@ unixmbox_lock (mailbox *mbox, mailbox_lock_t mode)
return 0;
}
/* FIXME: not implemented */
int
unixmbox_scan (mailbox *mbox)
{
errno = ENOSYS;
return -1;
}
#ifdef TESTING
void unixmbox_tester (mailbox *mbox, unsigned int num)
{
......
......@@ -28,6 +28,12 @@
#include <stdlib.h>
#endif
/* FIXME need auto* wrapper */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
......@@ -42,10 +48,6 @@
#include <strings.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
typedef struct _unixmbox_message
{
off_t header;
......@@ -60,6 +62,7 @@ typedef struct _unixmbox_data
unixmbox_message *messages;
FILE *file;
mailbox_lock_t lockmode;
time_t last_mod_time;
}
unixmbox_data;
......@@ -68,7 +71,9 @@ int unixmbox_close (mailbox *mbox);
int unixmbox_delete (mailbox *mbox, unsigned int num);
int unixmbox_undelete (mailbox *mbox, unsigned int num);
int unixmbox_expunge (mailbox *mbox);
int unixmbox_scan (mailbox *mbox);
int unixmbox_is_deleted (mailbox *mbox, unsigned int num);
int unixmbox_is_updated (mailbox *mbox);
int unixmbox_lock (mailbox *mbox, mailbox_lock_t mode);
int unixmbox_add_message (mailbox *mbox, char *message);
char *unixmbox_get_body (mailbox *mbox, unsigned int num);
......