OSSP CVS Repository

ossp - Difference in ossp-pkg/lmtp2nntp/lmtp2nntp_lh.c versions 1.2 and 1.3
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [History

ossp-pkg/lmtp2nntp/lmtp2nntp_lh.c 1.2 -> 1.3

--- lmtp2nntp_lh.c       2002/01/15 11:57:31     1.2
+++ lmtp2nntp_lh.c       2002/01/16 09:46:52     1.3
@@ -87,13 +87,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE !FALSE
-#endif
-
 #include "lmtp2nntp_lh.h"
 
 /* fixed size (number of pointers) of the directory and of each segment */
@@ -513,6 +506,35 @@
     return rv;
 }
 
+/* apply a callback for all elements in the hash table */
+int lh_apply(lh_t *h, lh_cb_t cb, void *ctx)
+{
+    element_t *el, **pel;
+    unsigned int i, j;
+
+    /* argument consistency check */
+    if (h == NULL || cb == NULL)
+        return FALSE;
+
+    /* interate over all segment's entries */
+    for (i = 0; i < h->h_dirsize; i++) {
+        if (h->h_dir[i] == NULL)
+            continue;
+        /* interate over all collision chains */
+        for (j = 0; j < SEGMENTSIZE; j++) {
+            if (h->h_dir[i]->s_element[j] == NULL)
+                continue;
+            /* interate over all elements in collision chain */
+            el = h->h_dir[i]->s_element[j];
+            for (; el != NULL; el = el->e_next) {
+                if (!cb(ctx, el->e_keyptr, el_keylen(el), el->e_datptr, el_datlen(el)))
+                    return;
+            }
+        }
+    }
+    return TRUE;
+}
+
 /* destroy the whole hash table */
 int lh_destroy(lh_t *h)
 {

CVSTrac 2.0.1