2 * ausearch-avc.c - Minimal linked list library for avcs
3 * Copyright (c) 2006,2008,2014 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>
27 #include "ausearch-avc.h"
30 void alist_create(alist *l)
37 anode *alist_next(alist *l)
41 l->cur = l->cur->next;
45 static void alist_last(alist *l)
52 // Start with cur in hopes that we don't start at beginning
58 // Loop until no next value
64 void alist_append(alist *l, anode *node)
68 newnode = malloc(sizeof(anode));
71 newnode->scontext = node->scontext;
73 newnode->scontext = NULL;
76 newnode->tcontext = node->tcontext;
78 newnode->tcontext = NULL;
80 newnode->avc_result = node->avc_result;
83 newnode->avc_perm = node->avc_perm;
85 newnode->avc_perm = NULL;
88 newnode->avc_class = node->avc_class;
90 newnode->avc_class = NULL;
94 // Make sure cursor is at the end
97 // if we are at top, fix this up
100 else // Otherwise add pointer to newnode
101 l->cur->next = newnode;
103 // make newnode current
108 int alist_find_subj(alist *l)
110 register anode* window = l->head;
113 if (window->scontext) {
118 window = window->next;
123 anode *alist_next_subj(alist *l)
127 while (l->cur->next) {
129 if (l->cur->scontext)
135 int alist_find_obj(alist *l)
137 register anode* window = l->head;
140 if (window->tcontext) {
145 window = window->next;
150 anode *alist_next_obj(alist *l)
154 while (l->cur->next) {
156 if (l->cur->tcontext)
162 int alist_find_avc(alist *l)
164 register anode* window = l->head;
167 if (window->avc_result != AVC_UNSET) {
172 window = window->next;
177 anode *alist_next_avc(alist *l)
181 while (l->cur->next) {
183 if (l->cur->avc_result != AVC_UNSET)
189 void alist_clear(alist* l)
192 register anode* current;
196 nextnode=current->next;
197 anode_clear(current);
206 void anode_init(anode *an)
210 an->avc_result = AVC_UNSET;
212 an->avc_class = NULL;
215 void anode_clear(anode *an)