util.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* until.h
  2. *
  3. * Wrapper functions and data structures
  4. *
  5. * Slitheen - a decoy routing system for censorship resistance
  6. * Copyright (C) 2017 Cecylia Bocovich (cbocovic@uwaterloo.ca)
  7. *
  8. * This program is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, version 3.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. * Additional permission under GNU GPL version 3 section 7
  21. *
  22. * If you modify this Program, or any covered work, by linking or combining
  23. * it with the OpenSSL library (or a modified version of that library),
  24. * containing parts covered by the terms of [name of library's license],
  25. * the licensors of this Program grant you additional permission to convey
  26. * the resulting work. {Corresponding Source for a non-source form of such
  27. * a combination shall include the source code for the parts of the OpenSSL
  28. * library used as well as that of the covered work.}
  29. */
  30. #ifndef _UTIL_H_
  31. #define _UTIL_H_
  32. #include <stddef.h>
  33. #include <stdint.h>
  34. void *emalloc(size_t size);
  35. void *ecalloc(size_t nmemb, size_t size);
  36. //Standard queue data structure
  37. typedef struct element_st {
  38. void *data;
  39. struct element_st *next;
  40. } element;
  41. typedef struct queue_st {
  42. element *first;
  43. element *last;
  44. } queue;
  45. queue *init_queue();
  46. void enqueue(queue *list, void *data);
  47. void *dequeue(queue *list);
  48. void *peek(queue *list, int32_t n);
  49. void remove_queue(queue *list);
  50. #endif /*_UTIL_H_*/