| 1 | /* |
| 2 | * |
| 3 | * Ophcrack is a Lanmanager/NTLM hash cracker based on the faster time-memory |
| 4 | * trade-off using rainbow tables. |
| 5 | * |
| 6 | * Created with the help of: Maxime Mueller, Luca Wullschleger, Claude |
| 7 | * Hochreutiner, Andreas Huber and Etienne Dysli. |
| 8 | * |
| 9 | * Copyright (c) 2008 Philippe Oechslin, Cedric Tissieres, Bertrand Mesot |
| 10 | * |
| 11 | * Ophcrack is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * Ophcrack is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with Ophcrack; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 24 | * |
| 25 | * This program is released under the GPL with the additional exemption |
| 26 | * that compiling, linking, and/or using OpenSSL is allowed. |
| 27 | * |
| 28 | * |
| 29 | * |
| 30 | * |
| 31 | */ |
| 32 | /** @file list.h |
| 33 | * Declarations for a doubly linked list. |
| 34 | */ |
| 35 | |
| 36 | #ifndef LIST_H |
| 37 | #define LIST_H |
| 38 | |
| 39 | #ifdef __cplusplus |
| 40 | extern "C" { |
| 41 | #endif |
| 42 | |
| 43 | /** A list node. */ |
| 44 | |
| 45 | typedef struct list_nd_t_ { |
| 46 | void *data; /**< The element to be stored. */ |
| 47 | struct list_nd_t_ *next; /**< A pointer to the following node. */ |
| 48 | struct list_nd_t_ *prev; /**< A pointer to the previous node. */ |
| 49 | } list_nd_t; |
| 50 | |
| 51 | /** A doubly linked list. */ |
| 52 | |
| 53 | typedef struct list_t_ { |
| 54 | int size; /**< The size of the list */ |
| 55 | list_nd_t *head; /**< A pointer to the head of the list. */ |
| 56 | list_nd_t *tail; /**< A pointer to the tail of the list. */ |
| 57 | } list_t; |
| 58 | |
| 59 | /** Allocate memory for a list. */ |
| 60 | |
| 61 | list_t *list_alloc(void); |
| 62 | |
| 63 | /** Free the memory used by the list. |
| 64 | * |
| 65 | * The memory used by the element is not freed. It is therefore your |
| 66 | * responsability to clean up that part of the memory. |
| 67 | * |
| 68 | * @param l A pointer to the list to be cleared. |
| 69 | */ |
| 70 | |
| 71 | void list_free(list_t *l); |
| 72 | |
| 73 | /** Empty the list. */ |
| 74 | |
| 75 | void list_clear(list_t *l); |
| 76 | |
| 77 | /** Add an element to the head of the list. |
| 78 | * @param l A pointer to the list. |
| 79 | * @param data A pointer to the element. |
| 80 | */ |
| 81 | |
| 82 | void list_add_head(list_t *l, void *data); |
| 83 | |
| 84 | /** Add an element to the tail of the list. |
| 85 | * @param l A pointer to the list. |
| 86 | * @param data A pointer to the element. |
| 87 | */ |
| 88 | |
| 89 | void list_add_tail(list_t *l, void *data); |
| 90 | |
| 91 | /** Remove an element from the head of the list. |
| 92 | * @param l A pointer to the list. |
| 93 | * @return A pointer to the element stored in the head. |
| 94 | */ |
| 95 | |
| 96 | void *list_rem_head(list_t *l); |
| 97 | |
| 98 | /** Remove an element from the tail of the list. |
| 99 | * @param l A pointer to the list. |
| 100 | * @return A pointer to the element stored in the tail. |
| 101 | */ |
| 102 | |
| 103 | void *list_rem_tail(list_t *l); |
| 104 | |
| 105 | /** Allocate memory for a list node. |
| 106 | * @param data A pointer to the element. |
| 107 | * @return A list node containing the element. |
| 108 | */ |
| 109 | |
| 110 | list_nd_t *list_nd_alloc(void *data); |
| 111 | |
| 112 | /** Free the memory used by a node. |
| 113 | * @param nd The node to be freed. |
| 114 | * @return A pointer to the element stored in the node. |
| 115 | */ |
| 116 | |
| 117 | void *list_nd_free(list_nd_t *nd); |
| 118 | |
| 119 | #ifdef __cplusplus |
| 120 | } |
| 121 | #endif |
| 122 | #endif |