1
/* Definition of the linkedlist object.
3
* Copyright 2007 Rainer Gerhards and Adiscon GmbH.
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.
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.
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.
19
* A copy of the GPL can be found in the file "COPYING" in this distribution.
22
#ifndef LINKEDLIST_H_INCLUDED
23
#define LINKEDLIST_H_INCLUDED
25
/* this is a single entry for a parse routine. It describes exactly
26
* one entry point/handler.
27
* The short name is cslch (Configfile SysLine CommandHandler)
29
struct llElt_s { /* config file sysline parse entry */
30
struct llElt_s *pNext;
31
void *pKey; /* key for this element */
32
void *pData; /* user-supplied data pointer */
34
typedef struct llElt_s llElt_t;
37
/* this is the list of known configuration commands with pointers to
39
* The short name is cslc (Configfile SysLine Command)
41
struct linkedList_s { /* config file sysline parse entry */
42
int iNumElts; /* number of elements in list */
43
rsRetVal (*pEltDestruct)(void*pData); /* destructor for user pointer in llElt_t's */
44
rsRetVal (*pKeyDestruct)(void*pKey); /* destructor for key pointer in llElt_t's */
45
int (*cmpOp)(void*, void*); /* pointer to key compare operation function, retval like strcmp */
46
void *pKey; /* the list key (searchable, if set) */
47
llElt_t *pRoot; /* list root */
48
llElt_t *pLast; /* list tail */
50
typedef struct linkedList_s linkedList_t;
52
typedef llElt_t* linkedListCookie_t; /* this type avoids exposing internals and keeps us flexible */
55
rsRetVal llInit(linkedList_t *pThis, rsRetVal (*pEltDestructor)(), rsRetVal (*pKeyDestructor)(void*), int (*pCmpOp)());
56
rsRetVal llDestroy(linkedList_t *pThis);
57
rsRetVal llDestroyRootElt(linkedList_t *pThis);
58
rsRetVal llGetNextElt(linkedList_t *pThis, linkedListCookie_t *ppElt, void **ppUsr);
59
rsRetVal llAppend(linkedList_t *pThis, void *pKey, void *pData);
60
rsRetVal llFind(linkedList_t *pThis, void *pKey, void **ppData);
61
rsRetVal llGetKey(llElt_t *pThis, void *ppData);
62
rsRetVal llGetNumElts(linkedList_t *pThis, int *piCnt);
63
rsRetVal llExecFunc(linkedList_t *pThis, rsRetVal (*pFunc)(void*, void*), void* pParam);
64
/* use the macro below to define a function that will be executed by
67
#define DEFFUNC_llExecFunc(funcName)\
68
static rsRetVal funcName(void __attribute__((unused)) *pData, void __attribute__((unused)) *pParam)
70
#endif /* #ifndef LINKEDLIST_H_INCLUDED */