smf_list.h
Go to the documentation of this file.
1 /* spmfilter - mail filtering framework
2  * Copyright (C) 2009-2012 Axel Steiner and SpaceNet AG
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 3 of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
32 #ifndef _SMF_LIST_H
33 #define _SMF_LIST_H
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #include <cmime.h>
40 
45 typedef CMimeListElem_T SMFListElem_T;
46 
51 typedef CMimeList_T SMFList_T;
52 
60 int smf_list_new(SMFList_T **list, void (*destroy)(void *data));
61 
68 int smf_list_free(SMFList_T *list);
69 
78 int smf_list_remove(SMFList_T *list, SMFListElem_T *elem, void **data);
79 
87 int smf_list_append(SMFList_T *list, void *data);
88 
96 int smf_list_prepend(SMFList_T *list, void *data);
97 
104 void *smf_list_pop_tail(SMFList_T *list);
105 
112 void *smf_list_pop_head(SMFList_T *list);
113 
122 int smf_list_insert_next(SMFList_T *list, SMFListElem_T *elem, void *data);
123 
132 int smf_list_insert_prev(SMFList_T *list, SMFListElem_T *elem, void *data);
133 
141 void smf_list_map(SMFList_T *list, void(*func)(SMFListElem_T *elem,void *args), void *args);
142 
152 int smf_list_map_new(SMFList_T *list, SMFList_T **new, void *(*func)(SMFListElem_T *elem, void *args), void *args);
153 
158 #define smf_list_size(list) ((list)->size)
159 
164 #define smf_list_head(list) ((list)->head)
165 
170 #define smf_list_tail(list) ((list)->tail)
171 
176 #define smf_list_is_head(elem) ((elem)->prev == NULL ? 1 : 0)
177 
182 #define smf_list_is_tail(elem) ((elem)->next == NULL ? 1 : 0)
183 
188 #define smf_list_data(elem) ((elem)->data)
189 
194 #define smf_list_next(elem) ((elem)->next)
195 
200 #define smf_list_prev(elem) ((elem)->prev)
201 
202 #ifdef __cplusplus
203 }
204 #endif
205 
206 #endif /* _SMF_LIST_H */