diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2008-04-17 23:12:21 +0200 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2008-04-17 23:12:21 +0200 |
commit | 2e48b85903b04117f9314b9ed69f0ac2d4d78356 (patch) | |
tree | 3414b0f55788c52c3ed8da25977ddb632a3f0c4e /common/dict.c | |
parent | 15b3f8bc5a757d984e5510fdaec46196d8939a56 (diff) |
change dict_values_first() and dict_values_next() into dict_loop_first() and dict_loop_next() to have a looping mechanism over keys and values
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-ldapd@675 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'common/dict.c')
-rw-r--r-- | common/dict.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/common/dict.c b/common/dict.c index b6e54cf..70c746a 100644 --- a/common/dict.c +++ b/common/dict.c @@ -2,7 +2,7 @@ dict.c - dictionary functions This file is part of the nss-ldapd library. - Copyright (C) 2007 Arthur de Jong + Copyright (C) 2007, 2008 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 @@ -141,12 +141,12 @@ void dict_free(DICT *dict) free(dict); } -void dict_values_first(DICT *dict) +void dict_loop_first(DICT *dict) { dict->ptr=dict->head; } -void *dict_values_next(DICT *dict) +const char *dict_loop_next(DICT *dict,const char **key,void **value) { struct dict_entry *ptr; ptr=dict->ptr; @@ -157,8 +157,12 @@ void *dict_values_next(DICT *dict) if (ptr==NULL) { dict->ptr=NULL; + if (key!=NULL) *key=NULL; + if (value!=NULL) *value=NULL; return NULL; } dict->ptr=ptr->next; - return ptr->value; + if (key!=NULL) *key=ptr->key; + if (value!=NULL) *value=ptr->value; + return ptr->key; } |