From 7218848cd779f370a4932be9c459259f70707983 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Wilfried=20G=C3=B6esgens?= Date: Sun, 7 Dec 2008 23:25:04 +0000 Subject: [PATCH] * *grml* always tried to avoid this, but can't live without... --- libcitadel/lib/hash.c | 22 ++++++++++++++++++++++ libcitadel/lib/libcitadel.h | 1 + 2 files changed, 23 insertions(+) diff --git a/libcitadel/lib/hash.c b/libcitadel/lib/hash.c index fd8916f17..b3c75795b 100644 --- a/libcitadel/lib/hash.c +++ b/libcitadel/lib/hash.c @@ -634,6 +634,28 @@ int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, const char **HashKe return 1; } +/** + * \brief Get the data located where At points to + * note: you should prefer iterator operations instead of using me. + * \param Hash your Hashlist peek from + * \param HKLen returns Length of Hashkey Returned + * \param HashKey returns the Hashkey corrosponding to HashPos + * \param Data returns the Data found at HashPos + * \returns whether the item was found or not. + */ +int GetHashAt(HashList *Hash,long At, long *HKLen, const char **HashKey, void **Data) +{ + long PayloadPos; + + if ((Hash == NULL) || (At >= Hash->nMembersUsed)) + return 0; + *HKLen = Hash->LookupTable[At]->HKLen; + *HashKey = Hash->LookupTable[At]->HashKey; + PayloadPos = Hash->LookupTable[At]->Position; + *Data = Hash->Members[PayloadPos]->Data; + return 1; +} + /** * \brief sorting function for sorting the Hash alphabeticaly by their strings * \param Key1 first item diff --git a/libcitadel/lib/libcitadel.h b/libcitadel/lib/libcitadel.h index cff82af47..bdb40d34a 100644 --- a/libcitadel/lib/libcitadel.h +++ b/libcitadel/lib/libcitadel.h @@ -406,6 +406,7 @@ HashPos *GetNewHashPos(HashList *Hash, int StepWidth); int GetHashPosCounter(HashPos *At); void DeleteHashPos(HashPos **DelMe); int GetNextHashPos(HashList *Hash, HashPos *At, long *HKLen, const char **HashKey, void **Data); +int GetHashAt(HashList *Hash,long At, long *HKLen, const char **HashKey, void **Data); void SortByHashKey(HashList *Hash, int Order); void SortByHashKeyStr(HashList *Hash); int GetCount(HashList *Hash); -- 2.30.2