klist.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* evx/include/lib/klist.h
  2. *
  3. * This file is part of evx.
  4. *
  5. * evx is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * evx is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with evx. If not, see <https://www.gnu.org/licenses/>
  17. */
  18. #ifndef __KLIST_H
  19. #define __KLIST_H
  20. #include <sys/types.h>
  21. struct klist_node {
  22. long value;
  23. void *data;
  24. struct klist_node *next, *prev;
  25. };
  26. struct klist_node *klist_find_value(struct klist_node *head, int value);
  27. void klist_init(struct klist_node *head);
  28. void klist_add(struct klist_node *head, struct klist_node *new);
  29. void klist_del(struct klist_node *head, struct klist_node *will_del);
  30. #define klist_empty(list) ((list)->next == (list))
  31. #define KLIST_NODE_INIT(__x) { \
  32. .value = 0, \
  33. .data = NULL, \
  34. .next = __x, \
  35. .prev = __x, \
  36. }
  37. #endif