summaryrefslogtreecommitdiff
path: root/include/kitchensink/internal/utils
diff options
context:
space:
mode:
Diffstat (limited to 'include/kitchensink/internal/utils')
-rw-r--r--include/kitchensink/internal/utils/kitbuffer.h28
-rw-r--r--include/kitchensink/internal/utils/kithelpers.h11
-rw-r--r--include/kitchensink/internal/utils/kitlog.h11
-rw-r--r--include/kitchensink/internal/utils/kitringbuffer.h23
4 files changed, 73 insertions, 0 deletions
diff --git a/include/kitchensink/internal/utils/kitbuffer.h b/include/kitchensink/internal/utils/kitbuffer.h
new file mode 100644
index 0000000..4d0f8cc
--- /dev/null
+++ b/include/kitchensink/internal/utils/kitbuffer.h
@@ -0,0 +1,28 @@
+#ifndef KITBUFFER_H
+#define KITBUFFER_H
+
+#include "kitchensink/kitconfig.h"
+
+typedef struct Kit_Buffer Kit_Buffer;
+
+typedef void (*Kit_BufferFreeCallback)(void*);
+
+struct Kit_Buffer {
+ unsigned int read_p;
+ unsigned int write_p;
+ unsigned int size;
+ Kit_BufferFreeCallback free_cb;
+ void **data;
+};
+
+KIT_LOCAL Kit_Buffer* Kit_CreateBuffer(unsigned int size, Kit_BufferFreeCallback free_cb);
+KIT_LOCAL void Kit_DestroyBuffer(Kit_Buffer *buffer);
+
+KIT_LOCAL void Kit_ClearBuffer(Kit_Buffer *buffer);
+KIT_LOCAL void* Kit_ReadBuffer(Kit_Buffer *buffer);
+KIT_LOCAL void* Kit_PeekBuffer(const Kit_Buffer *buffer);
+KIT_LOCAL void Kit_AdvanceBuffer(Kit_Buffer *buffer);
+KIT_LOCAL int Kit_WriteBuffer(Kit_Buffer *buffer, void *ptr);
+KIT_LOCAL int Kit_IsBufferFull(const Kit_Buffer *buffer);
+
+#endif // KITBUFFER_H
diff --git a/include/kitchensink/internal/utils/kithelpers.h b/include/kitchensink/internal/utils/kithelpers.h
new file mode 100644
index 0000000..5b94a7a
--- /dev/null
+++ b/include/kitchensink/internal/utils/kithelpers.h
@@ -0,0 +1,11 @@
+#ifndef KITHELPERS_H
+#define KITHELPERS_H
+
+#include <stdbool.h>
+#include <libavformat/avformat.h>
+#include "kitchensink/kitconfig.h"
+
+KIT_LOCAL double _GetSystemTime();
+KIT_LOCAL bool attachment_is_font(AVStream *stream);
+
+#endif // KITHELPERS_H
diff --git a/include/kitchensink/internal/utils/kitlog.h b/include/kitchensink/internal/utils/kitlog.h
new file mode 100644
index 0000000..1a56e53
--- /dev/null
+++ b/include/kitchensink/internal/utils/kitlog.h
@@ -0,0 +1,11 @@
+#ifndef KITLOG_H
+#define KITLOG_H
+
+#ifdef NDEBUG
+ #define LOG(...)
+#else
+ #include <stdio.h>
+ #define LOG(...) fprintf(stderr, __VA_ARGS__)
+#endif
+
+#endif // KITLOG_H
diff --git a/include/kitchensink/internal/utils/kitringbuffer.h b/include/kitchensink/internal/utils/kitringbuffer.h
new file mode 100644
index 0000000..2f67520
--- /dev/null
+++ b/include/kitchensink/internal/utils/kitringbuffer.h
@@ -0,0 +1,23 @@
+#ifndef KITRINGBUFFER_H
+#define KITRINGBUFFER_H
+
+#include "kitchensink/kitconfig.h"
+
+typedef struct Kit_RingBuffer {
+ int size;
+ int len;
+ int wpos, rpos;
+ char* data;
+} Kit_RingBuffer;
+
+KIT_LOCAL Kit_RingBuffer* Kit_CreateRingBuffer(unsigned int size);
+KIT_LOCAL void Kit_DestroyRingBuffer(Kit_RingBuffer* rb);
+KIT_LOCAL int Kit_WriteRingBuffer(Kit_RingBuffer *rb, const char* data, int len);
+KIT_LOCAL int Kit_ReadRingBuffer(Kit_RingBuffer *rb, char* data, int len);
+KIT_LOCAL int Kit_PeekRingBuffer(const Kit_RingBuffer *rb, char* data, int len);
+KIT_LOCAL int Kit_AdvanceRingBuffer(Kit_RingBuffer *rb, int len);
+KIT_LOCAL int Kit_GetRingBufferLength(const Kit_RingBuffer *rb);
+KIT_LOCAL int Kit_GetRingBufferSize(const Kit_RingBuffer *rb);
+KIT_LOCAL int Kit_GetRingBufferFree(const Kit_RingBuffer *rb);
+
+#endif // KITRINGBUFFER_H