From 0900feda84681a25f6396a4671f773130e3a4064 Mon Sep 17 00:00:00 2001 From: Syping Date: Sat, 11 Feb 2023 20:06:00 +0100 Subject: [PATCH] libragephoto: add typedefs for format parser --- src/RagePhotoC.h | 3 --- src/RagePhotoTypedefs.h | 20 ++++++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/RagePhotoC.h b/src/RagePhotoC.h index 2c4153d..aa36ebf 100644 --- a/src/RagePhotoC.h +++ b/src/RagePhotoC.h @@ -35,9 +35,6 @@ extern "C" { /** RagePhoto C++ class typedef for C API. */ typedef void* ragephoto_t; -/** RagePhoto bool typedef for C API. */ -typedef int32_t ragephoto_bool_t; - /** Opens a \p ragephoto_t instance. */ LIBRAGEPHOTO_C_BINDING ragephoto_t ragephoto_open(); diff --git a/src/RagePhotoTypedefs.h b/src/RagePhotoTypedefs.h index a0aca47..0657182 100644 --- a/src/RagePhotoTypedefs.h +++ b/src/RagePhotoTypedefs.h @@ -48,6 +48,26 @@ typedef struct RagePhotoData { uint32_t unnamedSum2; /**< 2nd unnamed checksum for Red Dead Redemption 2 */ } RagePhotoData; +/** RagePhoto bool typedef. */ +typedef int32_t ragephoto_bool_t; + +/** RagePhoto load function typedef. */ +typedef ragephoto_bool_t (*ragephoto_loadfunc_t)(RagePhotoData*, const char*, size_t); + +/** RagePhoto save function typedef (char* allocated by caller). */ +typedef ragephoto_bool_t (*ragephoto_savefunc_t)(RagePhotoData*, char*, uint32_t); + +/** RagePhoto save function typedef (char* allocated by function). */ +typedef ragephoto_bool_t (*ragephoto_savepfunc_t)(RagePhotoData*, char**, uint32_t); + +/** RagePhoto format parser struct for registering custom formats. */ +typedef struct RagePhotoFormatParser { + uint32_t photoFormat; /**< Photo file format magic */ + ragephoto_loadfunc_t funcLoad; /**< Pointer to load function */ + ragephoto_savefunc_t funcSave; /**< Pointer to save function */ + ragephoto_savepfunc_t funcSavep; /**< Pointer to savep function */ +} RagePhotoFormatParser; + #ifdef __cplusplus } #endif // __cplusplus