-#endif /* POP3_ENABLE */
-
-/* return a pointer to the last element of the list to help the quick,
- * constant-time addition to the list, NOTE: this function does not dup
- * the string, the caller must do that. */
-/*@shared@*/ static struct idlist **save_str_quick(/*@shared@*/ struct idlist **idl,
- /*@only@*/ char *str, flag status)
-/* save a number/UID pair on the given UID list */
-{
- 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)->val.status.mark = status;
- (*end)->id = (unsigned char *)str;
- (*end)->next = NULL;
-
- return end;
-}
-
-/* return the end list element for direct modification */
-struct idlist *save_str(struct idlist **idl, const char *str, flag st)
-{
- return *save_str_quick(idl, str ? xstrdup(str) : NULL, st);
-}
-
-void free_str_list(struct idlist **idl)
-/* free the given UID list */
-{
- struct idlist *i = *idl;
-
- while(i) {
- struct idlist *t = i->next;
- free(i->id);
- free(i);
- i = t;
- }
- *idl = 0;
-}
-
-void save_str_pair(struct idlist **idl, const char *str1, const char *str2)
-/* save an ID pair on the given list */
-{
- 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
-
-struct idlist *str_in_list(struct idlist **idl, const char *str, const flag caseblind)
-/* is a given ID in the given list? (comparison may be caseblind) */
-{
- struct idlist *walk;
- if (caseblind) {
- for( walk = *idl; walk; walk = walk->next )
- if( strcasecmp( str, (char *)walk->id) == 0 )
- return walk;
- } else {
- for( walk = *idl; walk; walk = walk->next )
- if( strcmp( str, (char *)walk->id) == 0 )
- return walk;
- }
- return NULL;
-}
-
-int str_nr_in_list( struct idlist **idl, const char *str )
- /* return the position of str in idl */
-{
- 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;
-}
-
-int str_nr_last_in_list( struct idlist **idl, const char *str)
-/* return the last position of str in idl */
-{
- 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;
-}
-
-void str_set_mark( struct idlist **idl, const char *str, const flag val)
-/* update the mark on an of an id to given value */
-{
- 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;
-}
-
-int count_list( struct idlist **idl)
-/* count the number of elements in the list */
-{
- if( !*idl )
- return 0;
- return 1 + count_list( &(*idl)->next );
-}
-
-/*@null@*/ char *str_from_nr_list(struct idlist **idl, long number)
-/* return the number'th string in idl */
-{
- if( !*idl || number < 0)
- return 0;
- if( number == 0 )
- return (*idl)->id;
- return str_from_nr_list(&(*idl)->next, number-1);
-}
-