From bb392b3a8e5a330677e322547d91baaab2515421 Mon Sep 17 00:00:00 2001 From: Johan Danielsson Date: Fri, 8 Aug 1997 22:05:22 +0000 Subject: [PATCH] hdb_foreach. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@2817 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hdb/hdb.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/hdb/hdb.c b/lib/hdb/hdb.c index 2a0fda4d3..8b9435a02 100644 --- a/lib/hdb/hdb.c +++ b/lib/hdb/hdb.c @@ -191,7 +191,25 @@ hdb_free_entry(krb5_context context, hdb_entry *ent) free_hdb_entry(ent); } - +krb5_error_code +hdb_foreach(krb5_context context, + HDB *db, + hdb_foreach_func_t func, + void *data) +{ + krb5_error_code ret; + hdb_entry entry; + ret = db->firstkey(context, db, &entry); + while(ret == 0){ + ret = (*func)(context, db, &entry, data); + hdb_free_entry(context, &entry); + if(ret == 0) + ret = db->nextkey(context, db, &entry); + } + if(ret == HDB_ERR_NOENTRY) + ret = 0; + return ret; +} krb5_error_code hdb_open(krb5_context context, HDB **db,