* *grml* always tried to avoid this, but can't live without...
authorWilfried Göesgens <willi@citadel.org>
Sun, 7 Dec 2008 23:25:04 +0000 (23:25 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 7 Dec 2008 23:25:04 +0000 (23:25 +0000)
libcitadel/lib/hash.c
libcitadel/lib/libcitadel.h

index fd8916f1757988627045b9dca75f7088e5b6025f..b3c75795bd1438ac130240a054cc9df5e885b055 100644 (file)
@@ -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
index cff82af47d738c3d2a60061781a1f4369f3de898..bdb40d34a44b35711a797a34c540cea4be758033 100644 (file)
@@ -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);