From 2e48b85903b04117f9314b9ed69f0ac2d4d78356 Mon Sep 17 00:00:00 2001
From: Arthur de Jong <arthur@arthurdejong.org>
Date: Thu, 17 Apr 2008 21:12:21 +0000
Subject: 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
---
 common/dict.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

(limited to 'common/dict.c')

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;
 }
-- 
cgit v1.2.3