* Get optional "reason" text stored in list element.
*
* @param list_elem List element.
- * @return Pointer to "reason" text or NULL.
+ * @return Pointer to "reason" text or empty string ("").
*/
GLOBAL const char *
Lists_GetReason(const struct list_elem *e)
{
assert(e != NULL);
- return e->reason;
+ return e->reason ? e->reason : "";
}
/**
assert(h != NULL);
assert(Mask != NULL);
- if (Lists_CheckDupeMask(h, Mask))
+ e = Lists_CheckDupeMask(h, Mask);
+ if (e) {
+ e->valid_until = ValidUntil;
+ if (Reason) {
+ free(e->reason);
+ e->reason = strdup(Reason);
+ }
return true;
+ }
e = Lists_GetFirst(h);
* @param Mask IRC mask to test.
* @return true if mask is already stored in the list, false otherwise.
*/
-GLOBAL bool
+GLOBAL struct list_elem *
Lists_CheckDupeMask(const struct list_head *h, const char *Mask )
{
struct list_elem *e;
e = h->first;
while (e) {
if (strcasecmp(e->mask, Mask) == 0)
- return true;
+ return e;
e = e->next;
}
- return false;
+ return NULL;
}
/**
Lists_Check( struct list_head *h, CLIENT *Client)
{
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;