2
0

dataqueue.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2022 Sam Lantinga <[email protected]>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #ifndef max_dataqueue_h_
  19. #define max_dataqueue_h_
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #if __STDC_VERSION__ >= 199901L
  23. #include <stdint.h>
  24. #else
  25. typedef unsigned char uint8_t;
  26. #endif
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif
  30. /* this is not (currently) a public API. But maybe it should be! */
  31. struct data_queue;
  32. typedef struct data_queue data_queue;
  33. data_queue *bmx_queue_new(const size_t packetlen, const size_t initialslack);
  34. void bmx_queue_free(data_queue *queue);
  35. void bmx_queue_clear(data_queue *queue, const size_t slack);
  36. int bmx_queue_write(data_queue *queue, const void *data, const size_t len);
  37. size_t bmx_queue_read(data_queue *queue, void *buf, const size_t len);
  38. size_t bmx_queue_peek(data_queue *queue, void *buf, const size_t len);
  39. size_t bmx_queue_count(data_queue *queue);
  40. #ifdef __cplusplus
  41. }
  42. #endif
  43. #endif /* max_dataqueue_h_ */