Imported Upstream version 2.4.3
[platform/upstream/audit.git] / src / ausearch-nvpair.h
1 /*
2 * ausearch-nvpair.h - Header file for ausearch-nvpair.c
3 * Copyright (c) 2006-08 Red Hat Inc., Durham, North Carolina.
4 * All Rights Reserved.
5 *
6 * This software may be freely redistributed and/or modified under the
7 * terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2, or (at your option) any
9 * later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 *
20 * Authors:
21 *   Steve Grubb <sgrubb@redhat.com>
22 */
23
24 #ifndef AUNVPAIR_HEADER
25 #define AUNVPAIR_HEADER
26
27 #include "config.h"
28 #include <sys/types.h>
29
30 /* This is the node of the linked list. message & item are the only elements
31  * at this time. Any data elements that are per item goes here. */
32 typedef struct _nvnode{
33   char *name;           // The name string
34   long val;             // The value field
35   struct _nvnode* next; // Next nvpair node pointer
36 } nvnode;
37
38 /* This is the linked list head. Only data elements that are 1 per
39  * event goes here. */
40 typedef struct {
41   nvnode *head;         // List head
42   nvnode *cur;          // Pointer to current node
43   unsigned int cnt;     // How many items in this list
44 } nvlist;
45
46 void nvlist_create(nvlist *l);
47 static inline void nvlist_first(nvlist *l) { l->cur = l->head; }
48 nvnode *nvlist_next(nvlist *l);
49 static inline nvnode *nvlist_get_cur(nvlist *l) { return l->cur; }
50 void nvlist_append(nvlist *l, nvnode *node);
51 void nvlist_clear(nvlist* l);
52
53 /* Given a numeric index, find that record. */
54 int nvlist_find_val(nvlist *l, long val);
55
56 #endif
57