+/****f* silcutil/silc_list_find
+ *
+ * SYNOPSIS
+ *
+ * void *silc_list_find(SilcList list, void *entry1, SilcCompare compare,
+ * void *context);
+ *
+ * DESCRIPTION
+ *
+ * Find an entry from the `list'. The `compare' function will be called
+ * with `context' to do comparison between the entries. If `compare'
+ * returns 0 the `entry1' is considered to be equal to `entry2' and the
+ * found entry is returned. Returns NULL if the entry could not be found.
+ *
+ * The silc_list_start or silc_list_end must be called before calling this
+ * if the finding should be started from the beginning or from the end.
+ * Calling it however is not required. The founding can be started at
+ * any point of the list. The silc_list_find can be called many times
+ * to find more entries following the previously found entries.
+ *
+ * The list can be enumerated by calling silc_list_get after the found
+ * entry. The silc_list_get will return the next entry after the found
+ * entry.
+ *
+ ***/
+#define silc_list_find(x, e, comp, ctx) __silc_list_find(&(x), (e), comp, ctx)
+static inline
+void *__silc_list_find(SilcList *list, void *entry1, SilcCompare compare,
+ void *context)
+{
+ void *entry2;
+ int ret;
+ while ((entry2 = __silc_list_get(list))) {
+ ret = compare(entry1, entry2, context);
+ if (ret == SILC_COMPARE_EQUAL_TO)
+ return entry2;
+ if (ret == SILC_COMPARE_STOP)
+ break;
+ }
+ return NULL;
+}
+