2 * aulast-llist.c - Minimal linked list library
3 * Copyright (c) 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>
26 #include "aulast-llist.h"
28 void list_create(llist *l)
34 lnode *list_next(llist *l)
38 l->cur = l->cur->next;
42 static void list_append(llist *l, lnode *node)
46 // if we are at top, fix this up
50 // Make sure we are at the end
52 l->cur = l->cur->next;
57 // make newnode current
61 void list_clear(llist* l)
64 register lnode* current;
68 nextnode=current->next;
69 free((void *)current->name);
70 free((void *)current->term);
71 free((void *)current->host);
79 int list_create_session(llist *l, uid_t auid, int pid, int session,
82 lnode *n = malloc(sizeof(lnode));
95 n->loginuid_proof = serial;
96 n->user_login_proof = 0;
97 n->user_end_proof = 0;
102 int list_update_start(llist* l, time_t start, const char *host,
103 const char *term, int res, unsigned long serial)
111 cur->status = SESSION_START;
113 cur->term = strdup(term);
115 cur->host = strdup(host);
117 cur->user_login_proof = serial;
121 int list_update_logout(llist* l, time_t t, unsigned long serial)
129 cur->status = LOG_OUT;
130 cur->user_end_proof = serial;
134 lnode *list_delete_cur(llist *l)
136 register lnode *cur, *prev;
138 prev = cur = l->head; /* start at the beginning */
141 if (cur == prev && cur == l->head) {
144 free((void *)cur->name);
145 free((void *)cur->term);
146 free((void *)cur->host);
150 prev->next = cur->next;
151 free((void *)cur->name);
152 free((void *)cur->term);
153 free((void *)cur->host);
166 lnode *list_find_auid(llist *l, uid_t auid, int pid, unsigned int session)
170 cur = l->head; /* start at the beginning */
172 if (cur->pid == pid && cur->auid == auid &&
173 cur->session == session) {
182 lnode *list_find_session(llist *l, unsigned int session)
186 cur = l->head; /* start at the beginning */
188 if (cur->session == session) {