From ef8cc767b201e4798a060282d4a6f280094bb8cc Mon Sep 17 00:00:00 2001 From: Arthur de Jong Date: Sun, 13 Dec 2009 10:27:33 +0000 Subject: change dict and set API to perform loops with a list of strings instead of loop_first() and loop_next() functions git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1028 ef36b2f9-881f-0410-afb5-c4e39611909c --- common/set.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'common/set.c') diff --git a/common/set.c b/common/set.c index 7e82730..d36ce2d 100644 --- a/common/set.c +++ b/common/set.c @@ -2,7 +2,7 @@ set.c - set functions This file is part of the nss-pam-ldapd library. - Copyright (C) 2008 Arthur de Jong + Copyright (C) 2008, 2009 Arthur de Jong This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -30,6 +30,12 @@ #include "set.h" #include "dict.h" +/* + The SET object is just a DICT which is passed around. The value + for each entry in the dict is just the pointer to the dict. + Another API is provided to give it a more set-like interface. +*/ + SET *set_new(void) { return (SET *)dict_new(); @@ -50,15 +56,7 @@ void set_free(SET *set) dict_free((DICT *)set); } -void set_loop_first(SET *set) -{ - dict_loop_first((DICT *)set); -} - -const char *set_loop_next(SET *set) +const char **set_tolist(SET *set) { - const char *value=NULL; - if (dict_loop_next((DICT *)set,&value,NULL)==NULL) - return NULL; - return value; + return dict_keys((DICT *)set); } -- cgit v1.2.3