diff options
author | rsc <devnull@localhost> | 2006-02-15 12:39:09 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-02-15 12:39:09 +0000 |
commit | 941e17134e92de7f12977f1899860b57bbf83330 (patch) | |
tree | e0c7dc5b23b603b24c2ec0cb8d3544f91bb36101 /src/cmd/upas/nfs/mbox.c | |
parent | 1ea614ffaf9378df45410995d0a8c13042bba123 (diff) | |
download | plan9port-941e17134e92de7f12977f1899860b57bbf83330.tar.gz plan9port-941e17134e92de7f12977f1899860b57bbf83330.tar.bz2 plan9port-941e17134e92de7f12977f1899860b57bbf83330.zip |
imap-based new upas/fs
Diffstat (limited to 'src/cmd/upas/nfs/mbox.c')
-rw-r--r-- | src/cmd/upas/nfs/mbox.c | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/cmd/upas/nfs/mbox.c b/src/cmd/upas/nfs/mbox.c new file mode 100644 index 00000000..5f90f0a2 --- /dev/null +++ b/src/cmd/upas/nfs/mbox.c @@ -0,0 +1,68 @@ +#include "a.h" + +Mailbox *hash[123]; +Mailbox **box; +uint nbox; + +static void +markboxes(int mark) +{ + Mailbox *b; + + for(i=0; i<nbox; i++) + if(box[i]) + box[i]->mark = mark; +} + +static void +sweepboxes(void) +{ + Mailbox *b; + + for(i=0; i<nbox; i++) + if(box[i] && box[i]->mark){ + freembox(box[i]); + box[i] = nil; + } +} + +static Mailbox* +mboxbyname(char *name) +{ + int i; + + for(i=0; i<nbox; i++) + if(box[i] && strcmp(box[i]->name, name) == 0) + return box[i]; + return nil; +} + +static Mailbox* +mboxbyid(int id) +{ + if(id < 0 || id >= nbox) + return nil; + return box[id]; +} + +static Mailbox* +mboxcreate(char *name) +{ + Mailbox *b; + + b = emalloc(sizeof *b); + b->name = estrdup(name); + if(nbox%64 == 0) + box = erealloc(box, (nbox+64)*sizeof box[0]); + box[nbox++] = b; + return b; +} + +void +mboxupdate(void) +{ + markboxes(); + if(imapcmd("LIST \"\" *") < 0) + return; + sweepboxes(); +} |