2 * ausearch-nvpair.c - Minimal linked list library for name-value pairs
3 * Copyright (c) 2006-08 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>
26 #include "ausearch-nvpair.h"
29 void nvlist_create(nvlist *l)
36 nvnode *nvlist_next(nvlist *l)
40 l->cur = l->cur->next;
44 void nvlist_append(nvlist *l, nvnode *node)
46 nvnode* newnode = malloc(sizeof(nvnode));
48 newnode->name = node->name;
49 newnode->val = node->val;
52 // if we are at top, fix this up
55 else { // Add pointer to newnode and make sure we are at the end
57 l->cur = l->cur->next;
58 l->cur->next = newnode;
61 // make newnode current
66 int nvlist_find_val(nvlist *l, long val)
68 register nvnode* window = l->head;
71 if (window->val == val) {
76 window = window->next;
81 void nvlist_clear(nvlist* l)
84 register nvnode* current;
88 nextnode=current->next;