1 /* pkg_dest_list.c - the opkg package management system
5 Copyright (C) 2001 University of Southern California
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.
21 #include "void_list.h"
22 #include "pkg_dest_list.h"
23 #include "libbb/libbb.h"
25 int pkg_dest_list_elt_init(pkg_dest_list_elt_t *elt, pkg_dest_t *data)
27 return void_list_elt_init((void_list_elt_t *) elt, data);
30 void pkg_dest_list_elt_deinit(pkg_dest_list_elt_t *elt)
32 void_list_elt_deinit((void_list_elt_t *) elt);
35 int pkg_dest_list_init(pkg_dest_list_t *list)
37 return void_list_init((void_list_t *) list);
40 void pkg_dest_list_deinit(pkg_dest_list_t *list)
42 pkg_dest_list_elt_t *iter, *n;
45 list_for_each_entry_safe(iter, n, &list->head, node) {
46 pkg_dest = (pkg_dest_t *)iter->data;
47 pkg_dest_deinit(pkg_dest);
49 /* malloced in pkg_dest_list_append */
53 void_list_deinit((void_list_t *) list);
56 pkg_dest_t *pkg_dest_list_append(pkg_dest_list_t *list, const char *name,
57 const char *root_dir,const char *lists_dir)
62 /* freed in pkg_dest_list_deinit */
63 pkg_dest = xcalloc(1, sizeof(pkg_dest_t));
65 pkg_dest_init(pkg_dest, name, root_dir,lists_dir);
66 err = void_list_append((void_list_t *) list, pkg_dest);
74 int pkg_dest_list_push(pkg_dest_list_t *list, pkg_dest_t *data)
76 return void_list_push((void_list_t *) list, data);
79 pkg_dest_list_elt_t *pkg_dest_list_pop(pkg_dest_list_t *list)
81 return (pkg_dest_list_elt_t *) void_list_pop((void_list_t *) list);