mirror of
https://github.com/moparisthebest/imapfilter
synced 2024-08-13 16:53:51 -04:00
2cafede975
Instead of the account details, a pointer to the C structure is used in Lua, stored as light userdata. The 1.x deprecated configuration format has been removed, partly due to the above change, and partly because it has been included for long enough now.
64 lines
787 B
C
64 lines
787 B
C
#include <stdio.h>
|
|
|
|
#include "imapfilter.h"
|
|
#include "list.h"
|
|
|
|
|
|
/*
|
|
* Add a new element at the end of the list.
|
|
*/
|
|
list *
|
|
list_append(list *lst, void *data)
|
|
{
|
|
list *l, *nl;
|
|
|
|
nl = (list *)xmalloc(sizeof(list));
|
|
nl->data = data;
|
|
nl->prev = nl->next = NULL;
|
|
|
|
if (lst != NULL) {
|
|
for (l = lst; l->next != NULL; l = l->next);
|
|
l->next = nl;
|
|
nl->prev = l;
|
|
|
|
return lst;
|
|
} else {
|
|
return nl;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
* Remove an element from the list.
|
|
*/
|
|
list *
|
|
list_remove(list *lst, void *data)
|
|
{
|
|
list *l;
|
|
|
|
if (!lst)
|
|
return NULL;
|
|
|
|
l = lst;
|
|
while (l != NULL) {
|
|
if (l->data != data)
|
|
l = l->next;
|
|
else {
|
|
if (l->prev)
|
|
l->prev->next = l->next;
|
|
if (l->next)
|
|
l->next->prev = l->prev;
|
|
if (lst == l)
|
|
lst = lst->next;
|
|
|
|
xfree(l);
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
return lst;
|
|
}
|
|
|