pkg_src_list.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* pkg_src_list.c - the opkg package management system
  2. Carl D. Worth
  3. Copyright (C) 2001 University of Southern California
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License as
  6. published by the Free Software Foundation; either version 2, or (at
  7. your option) any later version.
  8. This program is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. */
  13. #include "pkg_src_list.h"
  14. #include "void_list.h"
  15. #include "libbb/libbb.h"
  16. void pkg_src_list_init(pkg_src_list_t * list)
  17. {
  18. void_list_init((void_list_t *) list);
  19. }
  20. void pkg_src_list_deinit(pkg_src_list_t * list)
  21. {
  22. pkg_src_list_elt_t *iter, *n;
  23. pkg_src_t *pkg_src;
  24. list_for_each_entry_safe(iter, n, &list->head, node) {
  25. pkg_src = (pkg_src_t *) iter->data;
  26. pkg_src_deinit(pkg_src);
  27. /* malloced in pkg_src_list_append */
  28. free(pkg_src);
  29. iter->data = NULL;
  30. }
  31. void_list_deinit((void_list_t *) list);
  32. }
  33. pkg_src_t *pkg_src_list_append(pkg_src_list_t * list,
  34. const char *name, const char *base_url,
  35. const char *extra_data, int gzip)
  36. {
  37. /* freed in pkg_src_list_deinit */
  38. pkg_src_t *pkg_src = xcalloc(1, sizeof(pkg_src_t));
  39. pkg_src_init(pkg_src, name, base_url, extra_data, gzip);
  40. void_list_append((void_list_t *) list, pkg_src);
  41. return pkg_src;
  42. }
  43. void pkg_src_list_push(pkg_src_list_t * list, pkg_src_t * data)
  44. {
  45. void_list_push((void_list_t *) list, data);
  46. }
  47. pkg_src_list_elt_t *pkg_src_list_pop(pkg_src_list_t * list)
  48. {
  49. return (pkg_src_list_elt_t *) void_list_pop((void_list_t *) list);
  50. }