~ubuntu-branches/ubuntu/lucid/rsyslog/lucid

« back to all changes in this revision

Viewing changes to linkedlist.h

  • Committer: Bazaar Package Importer
  • Author(s): Michael Biebl
  • Date: 2007-10-19 17:21:49 UTC
  • Revision ID: james.westby@ubuntu.com-20071019172149-ie6ej2xve33mxiu7
Tags: upstream-1.19.10
ImportĀ upstreamĀ versionĀ 1.19.10

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Definition of the linkedlist object.
 
2
 *
 
3
 * Copyright 2007 Rainer Gerhards and Adiscon GmbH.
 
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
 * A copy of the GPL can be found in the file "COPYING" in this distribution.
 
20
 */
 
21
 
 
22
#ifndef LINKEDLIST_H_INCLUDED
 
23
#define LINKEDLIST_H_INCLUDED
 
24
 
 
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)
 
28
 */
 
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 */
 
33
};
 
34
typedef struct llElt_s llElt_t;
 
35
 
 
36
 
 
37
/* this is the list of known configuration commands with pointers to
 
38
 * their handlers.
 
39
 * The short name is cslc (Configfile SysLine Command)
 
40
 */
 
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 */
 
49
};
 
50
typedef struct linkedList_s linkedList_t;
 
51
 
 
52
typedef llElt_t* linkedListCookie_t;    /* this type avoids exposing internals and keeps us flexible */
 
53
 
 
54
/* prototypes */
 
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
 
65
 * llExecFunc()
 
66
 */
 
67
#define DEFFUNC_llExecFunc(funcName)\
 
68
        static rsRetVal funcName(void __attribute__((unused)) *pData, void __attribute__((unused)) *pParam)
 
69
 
 
70
#endif /* #ifndef LINKEDLIST_H_INCLUDED */