1 /* 2 * wzdftpd - a modular and cool ftp server 3 * Copyright (C) 2002-2004 Pierre Chifflier 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * 19 * As a special exemption, Pierre Chifflier 20 * and other respective copyright holders give permission to link this program 21 * with OpenSSL, and distribute the resulting executable, without including 22 * the source code for OpenSSL in the source distribution. 23 */ 24 25 #ifndef __LIST__ 26 #define __LIST__ 27 28 /*! \addtogroup libwzd_base 29 * Base functions for wzdftpd 30 * @{ 31 */ 32 33 typedef struct ListElmt_ { 34 void * data; 35 struct ListElmt_ * next; 36 } ListElmt; 37 38 typedef struct List_ { 39 int size; 40 41 int (*test)(const void *val1, const void *val2); 42 void (*destroy)(void *data); 43 44 ListElmt *head; 45 ListElmt *tail; 46 } List; 47 48 /* INTERFACE */ 49 void list_init(List *list, void (*destroy)(void *data)); 50 51 void list_destroy(List *list); 52 53 int list_ins_next(List *list, ListElmt *element, const void *data); 54 55 /** \brief Sorted insertion 56 * 57 * Use List#test to insert data 58 */ 59 int list_ins_sorted(List *list, const void *data); 60 61 int list_rem_next(List *list, ListElmt *element, void **data); 62 63 /** \brief Removes \a element from list. 64 */ 65 int list_remove(List *list, ListElmt *element, void **data); 66 67 /** \brief Find list node associated to \a data 68 */ 69 ListElmt * list_lookup_node(List *list, void *data); 70 71 #define list_size(list) ((list)->size) 72 73 #define list_head(list) ((list)->head) 74 75 #define list_tail(list) ((list)->tail) 76 77 #define list_is_head(list,element) \ 78 ((element) == (list)->head ? 1 : 0) 79 80 #define list_is_tail(list,element) \ 81 ((element) == (list)->tail ? 1 : 0) 82 83 #define list_data(element) ((element)->data) 84 85 #define list_next(element) ((element)->next) 86 87 /*! @} */ 88 89 #endif /* __LIST__ */ 90