1 /* active_list.h - the opkg package management system
3 Tick Chen <tick@openmoko.com>
5 Copyright (C) 2008 Openmoko Inc.
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License as
9 published by the Free Software Foundation; either version 2, or (at
10 your option) any later version.
12 This program is distributed in the hope that it will be useful, but
13 WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 General Public License for more details.
19 #include "active_list.h"
23 void active_list_init(struct active_list *ptr) {
24 INIT_LIST_HEAD(&ptr->node);
25 INIT_LIST_HEAD(&ptr->depend);
31 struct active_list * active_list_next(struct active_list *head, struct active_list *ptr) {
32 struct active_list *next=NULL;
34 fprintf(stderr, "active_list_prev head = %p, ptr = %p invalid value!!\n", head, ptr);
39 next = list_entry(ptr->node.next, struct active_list, node);
43 if (ptr->depended && &ptr->depended->depend == ptr->node.next ) {
46 while (next->depend.next != &next->depend) {
47 next = list_entry(next->depend.next, struct active_list, node);
53 void active_list_clear(struct active_list *head) {
56 void active_list_add_depend(struct active_list *node, struct active_list *depend) {
57 list_del_init(&depend->node);
58 list_add_tail(&depend->node, &node->depend);
59 depend->depended = node;
62 void active_list_add(struct active_list *head, struct active_list *node) {
63 list_del_init(&node->node);
64 list_add_tail(&node->node, &head->node);
65 node->depended = head;