2 * ausearch-string.h - Header file for ausearch-string.c
3 * Copyright (c) 2005,2008 Red Hat Inc., Durham, North Carolina.
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
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.
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.
21 * Steve Grubb <sgrubb@redhat.com>
24 #ifndef AUSTRING_HEADER
25 #define AUSTRING_HEADER
29 /* This is the node of the linked list. message & item are the only elements
30 * at this time. Any data elements that are per item goes here. */
31 typedef struct _snode{
32 char *str; // The string
33 char *key; // The key string
34 unsigned int hits; // Number of times this string was attempted to be added
35 struct _snode* next; // Next string node pointer
38 /* This is the linked list head. Only data elements that are 1 per
41 snode *head; // List head
42 snode *cur; // Pointer to current node
43 unsigned int cnt; // How many items in this list
46 void slist_create(slist *l);
47 static inline void slist_first(slist *l) { l->cur = l->head; }
48 void slist_last(slist *l);
49 snode *slist_next(slist *l);
50 static inline snode *slist_get_cur(slist *l) { return l->cur; }
51 void slist_append(slist *l, snode *node);
52 void slist_clear(slist* l);
54 /* append a string if its not already on the list */
55 int slist_add_if_uniq(slist *l, const char *str);
56 void slist_sort_by_hits(slist *l);