Imported Upstream version 2.4.3
[platform/upstream/audit.git] / src / ausearch-int.h
1 /*
2 * ausearch-int.h - Header file for ausearch-int.c
3 * Copyright (c) 2005,2008 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 AUINT_HEADER
25 #define AUINT_HEADER
26
27 #include "config.h"
28
29 /* This is the node of the linked list. Number & item are the only elements
30  * at this time. Any data elements that are per item goes here. */
31 typedef struct _int_node{
32   int num;              // The number
33   unsigned int hits;    // The number of times this was attempted to be added
34   int aux1;             // Extra spot for data
35   struct _int_node* next;       // Next string node pointer
36 } int_node;
37
38 /* This is the linked list head. Only data elements that are 1 per
39  * event goes here. */
40 typedef struct {
41   int_node *head;               // List head
42   int_node *cur;                // Pointer to current node
43   unsigned int cnt;     // How many items in this list
44 } ilist;
45
46 void ilist_create(ilist *l);
47 static inline void ilist_first(ilist *l) { l->cur = l->head; }
48 int_node *ilist_next(ilist *l);
49 static inline int_node *ilist_get_cur(ilist *l) { return l->cur; }
50 void ilist_append(ilist *l, int num, unsigned int hits, int aux);
51 void ilist_clear(ilist* l);
52
53 /* append a number if its not already on the list */
54 int ilist_add_if_uniq(ilist *l, int num, int aux);
55 void ilist_sort_by_hits(ilist *l);
56
57 #endif
58