summaryrefslogtreecommitdiff
path: root/include/tinyff
diff options
context:
space:
mode:
Diffstat (limited to 'include/tinyff')
-rw-r--r--include/tinyff/common.h9
-rw-r--r--include/tinyff/dbg.h29
-rw-r--r--include/tinyff/image/png.h14
-rw-r--r--include/tinyff/result.h7
4 files changed, 53 insertions, 6 deletions
diff --git a/include/tinyff/common.h b/include/tinyff/common.h
index d53adae..1fc4efb 100644
--- a/include/tinyff/common.h
+++ b/include/tinyff/common.h
@@ -5,10 +5,11 @@
#include <stdint.h>
-// Human readable number types
-// NOTE: The only reason I created these was so
-// that debugging will be easier
-typedef uint8_t ff_byte;
+// Flags
+typedef bool ff_flag;
+
+#define FF_ENABLE true
+#define FF_DISABLE false
// Functions
diff --git a/include/tinyff/dbg.h b/include/tinyff/dbg.h
new file mode 100644
index 0000000..7392f5a
--- /dev/null
+++ b/include/tinyff/dbg.h
@@ -0,0 +1,29 @@
+#ifndef DBG_H
+#define DBG_H
+
+// Debug writes extra messages to a stream of the user's choice
+// To enable debug, the user needs to include this header
+// Then they can use the ff_set_debug_stream function to set the stream
+// And then use ff_dprintf to print debug messages
+// By default, debug is disabled
+
+
+#define FF_DEBUG_ENABLED 1
+
+#include <stdio.h>
+#include <stdarg.h>
+#include "result.h"
+#include "common.h"
+
+static FILE *intff_debug_stream = NULL;
+
+// This flag is the same name as FF_DEBUG_ENABLED but is local to this file
+// Thats why it has the int prefix
+static ff_flag intff_debug_enabled = 0;
+
+ff_result ff_set_debug_stream(FILE *stream);
+
+
+ff_result ff_dprintf(const char *format, ...);
+
+#endif \ No newline at end of file
diff --git a/include/tinyff/image/png.h b/include/tinyff/image/png.h
index b2f400f..80e8fe6 100644
--- a/include/tinyff/image/png.h
+++ b/include/tinyff/image/png.h
@@ -38,7 +38,7 @@ typedef struct {
// Chunk handling
-typedef (*ff_png_chunk_handler_ptr)(uint8_t *data, size_t len, ff_png_ctx* ctx);
+typedef (*ff_png_chunk_handler_ptr)(uint8_t *buf, size_t len, ff_png_ctx* ctx);
typedef struct {
const char *type;
@@ -54,7 +54,17 @@ const ff_png_chunk_handler ff_png_chunk_handlers[] = {
{NULL, NULL} // Terminator
};
-void ff_png_header_handler(uint8_t *data, size_t len, ff_png_ctx* ctx);
+// Handler declarations
+// Massive W.I.P
+
+// Required by definition
+void ff_png_header_handler(uint8_t *buf, size_t len, ff_png_ctx* ctx); // IHDR
+void ff_png_data_handler(uint8_t *buf, size_t len, ff_png_ctx* ctx); // IDAT
+void ff_png_end_handler(uint8_t *buf, size_t len, ff_png_ctx* ctx); // IEND
+
+// PLTE is a funny one
+// Its only required for indexed color types
+
ff_result ff_png_isvalid(FILE *file);
ff_result ff_open_png(const char *filepath, ff_png_ctx **out_ctx);
diff --git a/include/tinyff/result.h b/include/tinyff/result.h
index 9b17d4a..daea32e 100644
--- a/include/tinyff/result.h
+++ b/include/tinyff/result.h
@@ -2,8 +2,15 @@
#define RESULT_H
typedef enum {
+ // -- SUCCESS --
FF_RESULT_OK = 0,
+ // -- WARNINGS --
+ FF_RESULT_WARN_DEBUG_DISABLED,
+ FF_RESULT_WARN_NO_IMPL,
+
+ // -- ERRORS --
+
// File
FF_RESULT_ERROR_INVALID_FILE_SIGNITURE,
FF_RESULT_ERROR_INVALID_FILE,