2
0

pkg_dest_list.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* pkg_dest_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 <stdio.h>
  14. #include "pkg_dest.h"
  15. #include "void_list.h"
  16. #include "pkg_dest_list.h"
  17. #include "libbb/libbb.h"
  18. void pkg_dest_list_elt_init(pkg_dest_list_elt_t * elt, pkg_dest_t * data)
  19. {
  20. void_list_elt_init((void_list_elt_t *) elt, data);
  21. }
  22. void pkg_dest_list_elt_deinit(pkg_dest_list_elt_t * elt)
  23. {
  24. void_list_elt_deinit((void_list_elt_t *) elt);
  25. }
  26. void pkg_dest_list_init(pkg_dest_list_t * list)
  27. {
  28. void_list_init((void_list_t *) list);
  29. }
  30. void pkg_dest_list_deinit(pkg_dest_list_t * list)
  31. {
  32. pkg_dest_list_elt_t *iter, *n;
  33. pkg_dest_t *pkg_dest;
  34. list_for_each_entry_safe(iter, n, &list->head, node) {
  35. pkg_dest = (pkg_dest_t *) iter->data;
  36. pkg_dest_deinit(pkg_dest);
  37. /* malloced in pkg_dest_list_append */
  38. free(pkg_dest);
  39. iter->data = NULL;
  40. }
  41. void_list_deinit((void_list_t *) list);
  42. }
  43. pkg_dest_t *pkg_dest_list_append(pkg_dest_list_t * list, const char *name,
  44. const char *root_dir, const char *lists_dir)
  45. {
  46. pkg_dest_t *pkg_dest;
  47. /* freed in pkg_dest_list_deinit */
  48. pkg_dest = xcalloc(1, sizeof(pkg_dest_t));
  49. pkg_dest_init(pkg_dest, name, root_dir, lists_dir);
  50. void_list_append((void_list_t *) list, pkg_dest);
  51. return pkg_dest;
  52. }
  53. void pkg_dest_list_push(pkg_dest_list_t * list, pkg_dest_t * data)
  54. {
  55. void_list_push((void_list_t *) list, data);
  56. }
  57. pkg_dest_list_elt_t *pkg_dest_list_pop(pkg_dest_list_t * list)
  58. {
  59. return (pkg_dest_list_elt_t *) void_list_pop((void_list_t *) list);
  60. }