+/**
+ * Check list and purge expired entries.
+ *
+ * @param h List head.
+ */
+GLOBAL void
+Lists_Expire(struct list_head *h, const char *ListName)
+{
+ struct list_elem *e, *last, *next;
+ time_t now;
+
+ assert(h != NULL);
+
+ e = h->first;
+ last = NULL;
+ now = time(NULL);
+
+ while (e) {
+ next = e->next;
+ if (e->valid_until > 1 && e->valid_until < now) {
+ /* Entry is expired, delete it */
+ if (e->reason)
+ Log(LOG_INFO,
+ "Deleted \"%s\" (\"%s\") from %s list (expired).",
+ e->mask, e->reason, ListName);
+ else
+ Log(LOG_INFO,
+ "Deleted \"%s\" from %s list (expired).",
+ e->mask, ListName);
+ Lists_Unlink(h, last, e);
+ e = next;
+ continue;
+ }
+ last = e;
+ e = next;
+ }
+}
+
+/**
+ * Return the number of entries of a list.
+ *
+ * @param h List head.
+ * @return Number of items.
+ */
+GLOBAL unsigned long
+Lists_Count(struct list_head *h)
+{
+ struct list_elem *e;
+ unsigned long count = 0;
+
+ assert(h != NULL);
+
+ e = h->first;
+ while (e) {
+ count++;
+ e = e->next;
+ }
+ return count;
+}
+