2 * aulastlog-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 "aulastlog-llist.h"
28 void list_create(llist *l)
35 lnode *list_next(llist *l)
39 l->cur = l->cur->next;
43 void list_append(llist *l, lnode *node)
47 newnode = malloc(sizeof(lnode));
49 newnode->sec = node->sec;
50 newnode->uid = node->uid;
51 newnode->name = strdup(node->name);
53 newnode->host = strdup(node->host);
57 newnode->term = strdup(node->term);
60 newnode->item = l->cnt;
63 // if we are at top, fix this up
66 else // Otherwise add pointer to newnode
67 l->cur->next = newnode;
69 // make newnode current
74 void list_clear(llist* l)
77 register lnode* current;
81 nextnode=current->next;
93 int list_update_login(llist* l, time_t t)
104 int list_update_host(llist* l, const char *h)
113 cur->host = strdup(h);
119 int list_update_term(llist* l, const char *t)
128 cur->term = strdup(t);
134 lnode *list_find_uid(llist *l, uid_t uid)
136 register lnode* window;
138 window = l->head; /* start at the beginning */
140 if (window->uid == uid) {
144 window = window->next;