aboutsummaryrefslogtreecommitdiffstats
path: root/NEWS
pre { line-height: 125%; } td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } .highlight .hll { background-color: #ffffcc } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
/**
 * \file idlist.c -- string list handling
 *
 * For license terms, see the file COPYING in this directory.
 */

#include "config.h"

#include <sys/stat.h>
#include <errno.h>
#include <stdio.h>
#include <limits.h>
#if defined(STDC_HEADERS)
#include <stdlib.h>
#include <string.h>
#endif
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif

#include "fetchmail.h"

/** Save string \a str to idlist \a idl with status \a status.
 * \return Pointer to the last element of the list to help the quick,
 * constant-time addition to the list. */
/*
Commit message (Expand)AuthorAgeFilesLines
...
* Better octet-message parsing.Eric S. Raymond1996-10-191-0/+2
* Catch another rewrite case.Eric S. Raymond1996-10-181-0/+2
* Use seteuid(2) during MDA execution.Eric S. Raymond1996-10-181-1/+5
* Allow C-style escapes in strings.Eric S. Raymond1996-10-171-0/+3
* Give up on privilege change.Eric S. Raymond1996-10-171-3/+0
* Fix Johan Vromans's keep bug.Eric S. Raymond1996-10-151-0/+4
* Typo fix.Eric S. Raymond1996-10-151-1/+1
* Accept RFC822 headers with tabs in them.Eric S. Raymond1996-10-141-0/+2
* Added `to' keyword, changed local-user default.Eric S. Raymond1996-10-141-2/+5
* Try to change permissions when delivering from root.Eric S. Raymond1996-10-141-0/+10
* Password is now shrouded when -v is on.Eric S. Raymond1996-10-141-1/+3
* Add settable server-nonresponse timeoutEric S. Raymond1996-10-131-0/+2
* Added wakeup feature.Eric S. Raymond1996-10-131-0/+4
* Ready to ship 1.9.Eric S. Raymond1996-10-131-4/+15
* Fixes for UIDL and Kerberos problems.Eric S. Raymond1996-10-131-14/+0
* Ready to ship.Eric S. Raymond1996-10-111-1/+1
* AAdd untested-feature warning.Eric S. Raymond1996-10-111-0/+16
* Permanent changes to NEWS etc.Eric S. Raymond1996-10-111-12/+0
* Ship IMAP passwords as quoted strings.Eric S. Raymond1996-10-101-0/+2
* UIDs are back in.Eric S. Raymond1996-10-101-0/+2
* Chris Hanson's Kerberos support, plus documentation.Eric S. Raymond1996-10-101-0/+5
* Ready to ship.Eric S. Raymond1996-10-091-4/+4
* Add capability to generate RPM specfile.Eric S. Raymond1996-10-091-0/+2
* RC file syntax change, folder->mailbox, remote->remotename.Eric S. Raymond1996-10-041-0/+7
* Allow no run control file.Eric S. Raymond1996-10-041-1/+3
* We can specify smtphost in the defaults line now.Eric S. Raymond1996-10-041-2/+5
* Restore --mda, with cleaner implementation this time.Eric S. Raymond1996-10-041-0/+3
* Avoid SPARC bug.Eric S. Raymond1996-10-041-0/+3
* Minor makefile fixes.Eric S. Raymond1996-10-041-0/+5
* Fixed that core-dump bug.Eric S. Raymond1996-10-031-2/+13
* Amplify the design notes.Eric S. Raymond1996-10-021-1/+7
n>->val.status.num = 0; (*end)->next = NULL; return end; } /** Save string \a str to idlist \a idl with status \a status. * \return the end list element for direct modification. */ struct idlist *save_str(struct idlist **idl, const char *str /** implicitly strdup()ed */, flag status) { return *save_str_quick(idl, str ? xstrdup(str) : NULL, status); } /** Free string list \a idl and free each of the id members. */ void free_str_list(struct idlist **idl) { struct idlist *i = *idl; while(i) { struct idlist *t = i->next; free(i->id); free(i); i = t; } *idl = 0; } /** Save an ID pair made of \a str1 and \a str2 on the given idlist \a idl. */ void save_str_pair(struct idlist **idl, const char *str1, const char *str2) { struct idlist **end; /* do it nonrecursively so the list is in the right order */ for (end = idl; *end; end = &(*end)->next) continue; *end = (struct idlist *)xmalloc(sizeof(struct idlist)); (*end)->id = str1 ? xstrdup(str1) : (char *)NULL; if (str2) (*end)->val.id2 = xstrdup(str2); else (*end)->val.id2 = (char *)NULL; (*end)->next = (struct idlist *)NULL; } #ifdef __UNUSED__ void free_str_pair_list(struct idlist **idl) /* free the given ID pair list */ { if (*idl == (struct idlist *)NULL) return; free_idpair_list(&(*idl)->next); free ((*idl)->id); free ((*idl)->val.id2); free(*idl); *idl = (struct idlist *)NULL; } #endif /** Check if ID \a str is in idlist \a idl. \return idlist entry if found, * NULL if not found. */ struct idlist *str_in_list(struct idlist **idl, const char *str, const flag caseblind /** if true, use strcasecmp, if false, use strcmp */) { struct idlist *walk; if (caseblind) { for( walk = *idl; walk; walk = walk->next ) if( strcasecmp( str, walk->id) == 0 ) return walk; } else { for( walk = *idl; walk; walk = walk->next ) if( strcmp( str, walk->id) == 0 ) return walk; } return NULL; } /** \return position of first occurrence of \a str in idlist \a idl */ int str_nr_in_list(struct idlist **idl, const char *str) { int nr; struct idlist *walk; if (!str) return -1; for (walk = *idl, nr = 0; walk; nr ++, walk = walk->next) if (strcmp(str, walk->id) == 0) return nr; return -1; } /** \return position of last occurrence of \a str in idlist \a idl */ int str_nr_last_in_list( struct idlist **idl, const char *str) { int nr, ret = -1; struct idlist *walk; if ( !str ) return -1; for( walk = *idl, nr = 0; walk; nr ++, walk = walk->next ) if( strcmp( str, walk->id) == 0 ) ret = nr; return ret; } /** Update the mark of an id \a str in idlist \a idl to given value \a val. */ void str_set_mark( struct idlist **idl, const char *str, const flag val) { int nr; struct idlist *walk; if (!str) return; for(walk = *idl, nr = 0; walk; nr ++, walk = walk->next) if (strcmp(str, walk->id) == 0) walk->val.status.mark = val; } /** Count the number of elements in the idlist \a idl. * \return number of elements */ int count_list(struct idlist **idl) { int i = 0; struct idlist *it; for (it = *idl ; it ; it = it->next) ++i; return i; } /** return the \a number'th id string on idlist \a idl */ /*@null@*/ char *str_from_nr_list(struct idlist **idl, long number) { if( !*idl || number < 0) return 0; if( number == 0 ) return (*idl)->id; return str_from_nr_list(&(*idl)->next, number-1); } /** Search idlist \a idl for entry with given \a number. * \return id member of idlist entry. */ char *str_find(struct idlist **idl, long number) { if (*idl == (struct idlist *) 0) return((char *) 0); else if (number == (*idl)->val.status.num) return((*idl)->id); else return(str_find(&(*idl)->next, number)); } /** Search idlist \a idl for entry with given \a number. * \return idlist entry. */ struct idlist *id_find(struct idlist **idl, long number) { struct idlist *idp; for (idp = *idl; idp; idp = idp->next) if (idp->val.status.num == number) return(idp); return(0); } /** Return the id of the given \a id in the given idlist \a idl, comparing * case insensitively. \returns the respective other \a idlist member (the one * that was not searched for). */ char *idpair_find(struct idlist **idl, const char *id) { if (*idl == (struct idlist *) 0) return((char *) 0); else if (strcasecmp(id, (*idl)->id) == 0) return((*idl)->val.id2 ? (*idl)->val.id2 : (*idl)->id); else return(idpair_find(&(*idl)->next, id)); } /** Mark message number \a num on given idlist \a idl as deleted. * \return 1 if found, 0 if not found. */ int delete_str(struct idlist **idl, long num) { struct idlist *idp; for (idp = *idl; idp; idp = idp->next) if (idp->val.status.num == num) { idp->val.status.mark = UID_DELETED; return(1); } return(0); } /** Copy the given UID list \a idl. \return A newly malloc()ed copy of the list. */ struct idlist *copy_str_list(struct idlist *idl) { struct idlist *newnode ; if (idl == (struct idlist *)NULL) return(NULL); else { newnode = (struct idlist *)xmalloc(sizeof(struct idlist)); memcpy(newnode, idl, sizeof(struct idlist)); newnode->next = copy_str_list(idl->next); return(newnode); } } /** Append \a nidl to \a idl (does not copy *) */ void append_str_list(struct idlist **idl, struct idlist **nidl) { if ((*nidl) == (struct idlist *)NULL || *nidl == *idl) return; else if ((*idl) == (struct idlist *)NULL) *idl = *nidl; else if ((*idl)->next == (struct idlist *)NULL) (*idl)->next = *nidl; else if ((*idl)->next != *nidl) append_str_list(&(*idl)->next, nidl); } /* idlist.c ends here */