| 1 | /** @file list.h |
| 2 | Declarations for a doubly linked list. |
| 3 | |
| 4 | This program is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU General Public License |
| 6 | as published by the Free Software Foundation; either version 2 |
| 7 | 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 |
| 12 | GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License |
| 15 | along with this program; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | |
| 18 | This program is released under the GPL with the additional exemption |
| 19 | that compiling, linking, and/or using OpenSSL is allowed. |
| 20 | |
| 21 | Copyright (C) 2008 Bertrand Mesot <http://www.objectif-securite.ch> |
| 22 | */ |
| 23 | |
| 24 | #ifndef LIST_H |
| 25 | #define LIST_Hcxx . . $ `list.h:25:9`! |
| 26 | |
| 27 | #ifdef __cplusplus |
| 28 | extern "C" { |
| 29 | #endif |
| 30 | |
| 31 | /** A list node. */ |
| 32 | |
| 33 | typedef struct list_nd_t_cxx . . $ list_nd_t_# { |
| 34 | void *datacxx . . $ list_nd_t_#data.; /**< The element to be stored. */ |
| 35 | struct list_nd_t_cxx . . $ list_nd_t_# *prevcxx . . $ list_nd_t_#prev.; /**< A pointer to the previous node. */ |
| 36 | struct list_nd_t_cxx . . $ list_nd_t_# *nextcxx . . $ list_nd_t_#next.; /**< A pointer to the following node. */ |
| 37 | } list_nd_tcxx . . $ list_nd_t#; |
| 38 | |
| 39 | /** A doubly linked list. */ |
| 40 | |
| 41 | typedef struct list_t_cxx . . $ list_t_# { |
| 42 | int sizecxx . . $ list_t_#size.; /**< The size of the list */ |
| 43 | list_nd_tcxx . . $ list_nd_t# *headcxx . . $ list_t_#head.; /**< A pointer to the head of the list. */ |
| 44 | list_nd_tcxx . . $ list_nd_t# *tailcxx . . $ list_t_#tail.; /**< A pointer to the tail of the list. */ |
| 45 | } list_tcxx . . $ list_t#; |
| 46 | |
| 47 | /** Allocate memory for a list. */ |
| 48 | |
| 49 | list_tcxx . . $ list_t# *list_alloccxx . . $ list_alloc(a211c0eefd2c4fb9).(void); |
| 50 | |
| 51 | /** Free the memory used by the list. |
| 52 | * |
| 53 | * The memory used by the element is not freed. It is therefore your |
| 54 | * responsability to clean up that part of the memory. |
| 55 | * |
| 56 | * @param l A pointer to the list to be cleared. |
| 57 | */ |
| 58 | |
| 59 | void list_freecxx . . $ list_free(873e96cd268b28a2).(list_tcxx . . $ list_t# *l); |
| 60 | |
| 61 | /** Empty the list. */ |
| 62 | |
| 63 | void list_cleancxx . . $ list_clean(873e96cd268b28a2).(list_tcxx . . $ list_t# *l); |
| 64 | |
| 65 | /** Add an element to the head of the list. |
| 66 | * @param l A pointer to the list. |
| 67 | * @param data A pointer to the element. |
| 68 | */ |
| 69 | |
| 70 | void list_add_headcxx . . $ list_add_head(a17800064bb915b4).(list_tcxx . . $ list_t# *l, void *data); |
| 71 | |
| 72 | /** Add an element to the tail of the list. |
| 73 | * @param l A pointer to the list. |
| 74 | * @param data A pointer to the element. |
| 75 | */ |
| 76 | |
| 77 | void list_add_tailcxx . . $ list_add_tail(a17800064bb915b4).(list_tcxx . . $ list_t# *l, void *data); |
| 78 | |
| 79 | /** Remove an element from the head of the list. |
| 80 | * @param l A pointer to the list. |
| 81 | * @return A pointer to the element stored in the head. |
| 82 | */ |
| 83 | |
| 84 | void *list_rem_headcxx . . $ list_rem_head(e3a173406177a4b8).(list_tcxx . . $ list_t# *l); |
| 85 | |
| 86 | /** Remove an element from the tail of the list. |
| 87 | * @param l A pointer to the list. |
| 88 | * @return A pointer to the element stored in the tail. |
| 89 | */ |
| 90 | |
| 91 | void *list_rem_tailcxx . . $ list_rem_tail(e3a173406177a4b8).(list_tcxx . . $ list_t# *l); |
| 92 | |
| 93 | /** Allocate memory for a list node. |
| 94 | * @param data A pointer to the element. |
| 95 | * @return A list node containing the element. |
| 96 | */ |
| 97 | |
| 98 | list_nd_tcxx . . $ list_nd_t# *list_nd_alloccxx . . $ list_nd_alloc(c9b460d93d208c57).(void *data); |
| 99 | |
| 100 | /** Free the memory used by a node. |
| 101 | * @param nd The node to be freed. |
| 102 | * @return A pointer to the element stored in the node. |
| 103 | */ |
| 104 | |
| 105 | void *list_nd_freecxx . . $ list_nd_free(3e4427c9aa9fd2db).(list_nd_tcxx . . $ list_nd_t# *nd); |
| 106 | |
| 107 | #ifdef __cplusplus |
| 108 | } |
| 109 | #endif |
| 110 | #endif |