* *grml* always tried to avoid this, but can't live without...
[citadel.git] / libcitadel / lib / hash.c
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