diff options
author | Sean 'Shaleh' Perry <shaleh@debian.org> | 1999-11-07 20:21:19 +0000 |
---|---|---|
committer | Sean 'Shaleh' Perry <shaleh@debian.org> | 1999-11-07 20:21:19 +0000 |
commit | fb6007379f8fbea3701fd9ce083db448a36d1957 (patch) | |
tree | 416173f19a90addd2d31bcd2bb09290cc2b6b65a /libmailbox | |
parent | 1ada30438d3b1f6055b2257c7962355e2ba905e0 (diff) | |
download | mailutils-fb6007379f8fbea3701fd9ce083db448a36d1957.tar.gz mailutils-fb6007379f8fbea3701fd9ce083db448a36d1957.tar.bz2 |
began implementing scan() and is_updated()
Diffstat (limited to 'libmailbox')
-rw-r--r-- | libmailbox/mailbox.c | 2 | ||||
-rw-r--r-- | libmailbox/mailbox.h | 4 | ||||
-rw-r--r-- | libmailbox/unixmbox.c | 32 | ||||
-rw-r--r-- | libmailbox/unixmbox.h | 13 |
4 files changed, 47 insertions, 4 deletions
diff --git a/libmailbox/mailbox.c b/libmailbox/mailbox.c index 61d3df80c..597bc8f5f 100644 --- a/libmailbox/mailbox.c +++ b/libmailbox/mailbox.c @@ -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; diff --git a/libmailbox/mailbox.h b/libmailbox/mailbox.h index 145cd0808..d712836c8 100644 --- a/libmailbox/mailbox.h +++ b/libmailbox/mailbox.h @@ -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)); diff --git a/libmailbox/unixmbox.c b/libmailbox/unixmbox.c index 0a43eec12..a650a4d06 100644 --- a/libmailbox/unixmbox.c +++ b/libmailbox/unixmbox.c @@ -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) { diff --git a/libmailbox/unixmbox.h b/libmailbox/unixmbox.h index 6c35a4dd8..71127d877 100644 --- a/libmailbox/unixmbox.h +++ b/libmailbox/unixmbox.h @@ -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); |