summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/tinyff/common.h7
-rw-r--r--include/tinyff/image/bmp.h5
-rw-r--r--include/tinyff/image/png.h5
3 files changed, 11 insertions, 6 deletions
diff --git a/include/tinyff/common.h b/include/tinyff/common.h
index 0c04ce9..df6e841 100644
--- a/include/tinyff/common.h
+++ b/include/tinyff/common.h
@@ -6,6 +6,13 @@
#include <stdint.h>
#include <stdbool.h>
+// Context bases
+// Default
+#define FF_BASE \
+ bool valid; \
+ ff_result last_error;
+
+
// Flags
typedef bool ff_flag;
diff --git a/include/tinyff/image/bmp.h b/include/tinyff/image/bmp.h
index 80aaa4d..6cb0ff2 100644
--- a/include/tinyff/image/bmp.h
+++ b/include/tinyff/image/bmp.h
@@ -21,6 +21,8 @@ static const unsigned char BMP_SIGNATURE[2] = {
};
typedef struct {
+ FF_BASE
+
// Raw stream handle
ff_stream *raw;
@@ -42,9 +44,6 @@ typedef struct {
uint8_t* pixels;
-
- bool valid;
- ff_result last_error;
} ff_bmp_ctx;
typedef ff_result (*ff_bmp_section_handler_ptr)(uint8_t *buf, size_t len, ff_bmp_ctx* ctx);
diff --git a/include/tinyff/image/png.h b/include/tinyff/image/png.h
index 05d5846..6941b42 100644
--- a/include/tinyff/image/png.h
+++ b/include/tinyff/image/png.h
@@ -25,6 +25,8 @@ typedef enum {
} ff_png_mode;
typedef struct {
+ FF_BASE
+
// Raw stream handle
ff_stream *raw;
@@ -52,9 +54,6 @@ typedef struct {
uint8_t* palette;
uint32_t palette_size;
- bool valid;
- ff_result last_error;
-
} ff_png_ctx;
// Small BpP helper function