Index: list.c
===================================================================
RCS file: /home/cvs/gateway/gwlib/list.c,v
retrieving revision 1.42
diff -u -r1.42 list.c
--- list.c	11 Feb 2005 15:35:48 -0000	1.42
+++ list.c	22 Feb 2005 02:41:10 -0000
@@ -649,3 +649,42 @@
         list->len -= count;
     }
 }
+
+/**	\brief enumerate items of a list
+ *
+ * enumerate thru the items of the list, calling the user supplied function 
+ * with each item, plus optionally some environment structure.
+ * if user fn returns 0, the enumeration can prematurely abort
+ * 
+ * eg
+ * int prntmsgs(void *env, void * _msg);
+ * ...
+ * list_enumfn(list,env,prntmsgs);
+ * \param list pointer to gw list
+ * \param env pointer to your defined data
+ * \param fn pointer to your function
+ */
+void gwlist_enumfn(List *list, void * env, int (*fn)(void *env,void *item) )
+{
+    long i;
+    void *item;
+
+    lock(list);
+    item = NULL;
+    for (i = 0; i < list->len; ++i) 
+    {
+        item = GET(list, i);
+
+        if (fn(env,item)) 
+            break;
+        
+    }
+    if (i == list->len) 
+    {
+        item = NULL;
+    }
+    unlock(list);
+
+    return item;
+}
+
