diff options
author | Eric S. Raymond <esr@thyrsus.com> | 1998-03-13 20:20:19 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 1998-03-13 20:20:19 +0000 |
commit | d3833f31da28808274c6d08804646116be7dabb8 (patch) | |
tree | 985ae69fd971dffb43a300f92f3b4867857267ab /uid.c | |
parent | 8517cf573fdb368fa69d776bc113cd95c6646edb (diff) | |
download | fetchmail-d3833f31da28808274c6d08804646116be7dabb8.tar.gz fetchmail-d3833f31da28808274c6d08804646116be7dabb8.tar.bz2 fetchmail-d3833f31da28808274c6d08804646116be7dabb8.zip |
Re-engineer the UIDL stuff to avoid having the status flag collide
with message numbers.
svn path=/trunk/; revision=1699
Diffstat (limited to 'uid.c')
-rw-r--r-- | uid.c | 37 |
1 files changed, 11 insertions, 26 deletions
@@ -93,14 +93,14 @@ void initialize_saved_lists(struct query *hostlist, const char *idfile) strcasecmp(host, ctl->server.truename) == 0 && strcasecmp(user, ctl->remotename) == 0) { - save_str(&ctl->oldsaved, UID_KEPT, id); + save_str(&ctl->oldsaved, id, UID_SEEN); break; } } /* if it's not in a host we're querying, save it anyway */ if (ctl == (struct query *)NULL) - save_str(&scratchlist, UID_KEPT, buf); + save_str(&scratchlist, buf, UID_SEEN); } } fclose(tmpfp); @@ -108,7 +108,7 @@ void initialize_saved_lists(struct query *hostlist, const char *idfile) } #endif /* POP3_ENABLE */ -struct idlist *save_str(struct idlist **idl, int num, const char *str) +struct idlist *save_str(struct idlist **idl, const char *str, flag status) /* save a number/UID pair on the given UID list */ { struct idlist **end; @@ -118,7 +118,7 @@ struct idlist *save_str(struct idlist **idl, int num, const char *str) continue; *end = (struct idlist *)xmalloc(sizeof(struct idlist)); - (*end)->val.num = num; + (*end)->val.status.mark = status; (*end)->id = str ? xstrdup(str) : (char *)NULL; (*end)->next = NULL; @@ -231,7 +231,7 @@ char *str_find(struct idlist **idl, int number) { if (*idl == (struct idlist *) 0) return((char *) 0); - else if (number == (*idl)->val.num) + else if (number == (*idl)->val.status.num) return((*idl)->id); else return(str_find(&(*idl)->next, number)); @@ -251,31 +251,15 @@ char *idpair_find(struct idlist **idl, const char *id) int delete_str(struct idlist **idl, int num) /* delete given message from given list */ { -#ifdef HARD_DELETE /* not used */ - if (*idl == (struct idlist *)NULL) - return(0); - else if ((*idl)->val.num == num) - { - struct idlist *next = (*idl)->next; - - free ((*idl)->id); - free(*idl); - *idl = next; - return(1); - } - else - return(delete_str(&(*idl)->next, num)); -#else struct idlist *idp; for (idp = *idl; idp; idp = idp->next) - if (idp->val.num == num) + if (idp->val.status.num == num) { - idp->val.num = UID_DELETED; + idp->val.status.mark = UID_DELETED; return(1); } return(0); -#endif /* HARD_DELETE */ } void append_str_list(struct idlist **idl, struct idlist **nidl) @@ -296,8 +280,8 @@ void expunge_uids(struct query *ctl) struct idlist *idl; for (idl = ctl->newsaved; idl; idl = idl->next) - if (idl->val.num == UID_DELETED) - idl->val.num = UID_EXPUNGED; + if (idl->val.status.mark == UID_DELETED) + idl->val.status.mark = UID_EXPUNGED; } void update_str_lists(struct query *ctl) @@ -330,7 +314,8 @@ void write_saved_lists(struct query *hostlist, const char *idfile) if ((tmpfp = fopen(idfile, "w")) != (FILE *)NULL) { for (ctl = hostlist; ctl; ctl = ctl->next) { for (idp = ctl->oldsaved; idp; idp = idp->next) - if (SAVE_UID(idp->val.num)) + if (idp->val.status.mark == UID_SEEN + || idp->val.status.mark == UID_DELETED) fprintf(tmpfp, "%s@%s %s\n", ctl->remotename, ctl->server.truename, idp->id); } |