Main Page | Modules | Class List | Directories | File List | Class Members | File Members | Related Pages

sf_sdlist.h

Go to the documentation of this file.
00001 /* $Id$ */
00002 /*
00003 ** Copyright (C) 2002 Martin Roesch <roesch@sourcefire.com>
00004 **
00005 ** This is hi
00006 **
00007 ** This program is free software; you can redistribute it and/or modify
00008 ** it under the terms of the GNU General Public License as published by
00009 ** the Free Software Foundation; either version 2 of the License, or
00010 ** (at your option) any later version.
00011 **
00012 ** This program is distributed in the hope that it will be useful,
00013 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 ** GNU General Public License for more details.
00016 **
00017 ** You should have received a copy of the GNU General Public License
00018 ** along with this program; if not, write to the Free Software
00019 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00020 */
00021 
00022 
00023 #ifndef _SF_SDLIST
00024 #define _SF_SDLIST
00025 
00026 /* based off Linked List structure p. 57  _Mastering algorithms in C_
00027  *
00028  * Differs from sf_list by using static listitem blocks.
00029  *
00030  * Use mempool as the interface to this code instead of trying to use it directly
00031  * 
00032  */
00033 
00034 typedef struct _SDListItem {
00035     void *data;
00036     struct _SDListItem *next;
00037     struct _SDListItem *prev;
00038 } SDListItem;
00039 
00040 
00041 typedef struct sfSDList {
00042     int size;
00043     SDListItem *head;
00044     SDListItem *tail;
00045     void (*destroy)(void *data); /* delete function called for each
00046                                     member of the linked list */
00047 } sfSDList;
00048 
00049 
00050 /* initialize a DList */
00051 int sf_sdlist_init(sfSDList *list, void (*destroy)(void *data));
00052 
00053 /* delete an DList */
00054 int sf_sdlist_delete(sfSDList *list);
00055 
00056 /* insert item, putting data in container */
00057 int sf_sdlist_insert_next(sfSDList *list, SDListItem *item, void *data,
00058                           SDListItem *container);
00059 
00060 /* remove the item after the item */
00061 int sf_sdlist_remove_next(sfSDList *list, SDListItem *item);
00062 
00063 /* remove this item from the list */
00064 int sf_sdlist_remove(sfSDList *list, SDListItem *item);
00065 
00066 /* append at the end of the list */
00067 int sf_sdlist_append(sfSDList *list, void *data, SDListItem *container);
00068 
00069 void print_sdlist(sfSDList *list);
00070 
00071 #endif /* _SF_DLIST */

Generated on Sun May 14 14:51:18 2006 by  doxygen 1.4.2