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"
24 int pkg_dest_list_elt_init(pkg_dest_list_elt_t *elt, pkg_dest_t *data)
26 return void_list_elt_init((void_list_elt_t *) elt, data);
29 void pkg_dest_list_elt_deinit(pkg_dest_list_elt_t *elt)
31 void_list_elt_deinit((void_list_elt_t *) elt);
34 int pkg_dest_list_init(pkg_dest_list_t *list)
36 return void_list_init((void_list_t *) list);
39 void pkg_dest_list_deinit(pkg_dest_list_t *list)
41 pkg_dest_list_elt_t *iter, *n;
44 list_for_each_entry_safe(iter, n, &list->head, node) {
45 pkg_dest = (pkg_dest_t *)iter->data;
46 pkg_dest_deinit(pkg_dest);
48 /* malloced in pkg_dest_list_append */
52 void_list_deinit((void_list_t *) list);
55 pkg_dest_t *pkg_dest_list_append(pkg_dest_list_t *list, const char *name,
56 const char *root_dir,const char *lists_dir)
61 /* freed in plg_dest_list_deinit */
62 pkg_dest = calloc(1, sizeof(pkg_dest_t));
63 if (pkg_dest == NULL) {
64 fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
68 pkg_dest_init(pkg_dest, name, root_dir,lists_dir);
69 err = void_list_append((void_list_t *) list, pkg_dest);
77 int pkg_dest_list_push(pkg_dest_list_t *list, pkg_dest_t *data)
79 return void_list_push((void_list_t *) list, data);
82 pkg_dest_list_elt_t *pkg_dest_list_pop(pkg_dest_list_t *list)
84 return (pkg_dest_list_elt_t *) void_list_pop((void_list_t *) list);