+/**
+ * Add a new mask to a list.
+ *
+ * @param h List head.
+ * @param Mask The IRC mask to add to the list.
+ * @param ValidUntil 0: unlimited, 1: only once, t>1: until given time_t.
+ * @param Reason Reason string or NULL, if no reason should be saved.
+ * @return true on success, false otherwise.
+ */
+bool
+Lists_Add(struct list_head *h, const char *Mask, time_t ValidUntil,
+ const char *Reason)
+{
+ struct list_elem *e, *newelem;
+
+ assert(h != NULL);
+ assert(Mask != NULL);
+
+ e = Lists_CheckDupeMask(h, Mask);
+ if (e) {
+ e->valid_until = ValidUntil;
+ if (e->reason)
+ free(e->reason);
+ e->reason = malloc(strlen(Reason) + 1);
+ if (e->reason)
+ strlcpy(e->reason, Reason, strlen(Reason) + 1);
+ else
+ Log(LOG_EMERG,
+ "Can't allocate memory for new list reason text!");
+ return true;
+ }