libragephoto: introduce C library port

CMakeLists.txt: fixes for MSVC and C library support
RagePhoto: non C++11 support
RagePhotoC: clarify C instance support in comment
RagePhotoTypedefs: add typedefs for C library
This commit is contained in:
Syping 2023-06-06 19:39:22 +02:00
parent af3580dff4
commit 3046cbd077
5 changed files with 1261 additions and 16 deletions

1213
src/RagePhoto.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -970,7 +970,11 @@ bool RagePhoto::saveFile(const std::string &filename, uint32_t photoFormat)
m_data->error = Error::Uninitialised; // 0
return false;
}
#if (RAGEPHOTO_CXX_STD >= 11) && (__cplusplus >= 201103L)
ofs << sdata;
#else
ofs.write(sdata.data(), sdata.size());
#endif
ok = ofs.good();
ofs.close();
return ok;

View file

@ -36,7 +36,7 @@ extern "C" {
* \file RagePhotoC.h
*/
/** RagePhoto C++ class typedef for C API. */
/** RagePhoto C instance/C++ class typedef. */
typedef void* ragephoto_t;
/** Opens a \p ragephoto_t instance. */

View file

@ -70,6 +70,12 @@ typedef struct RagePhotoFormatParser {
ragephoto_saveszfunc_t funcSaveSz; /**< Pointer to saveSize function */
} RagePhotoFormatParser;
/** RagePhoto instance struct for storing data and format parser pointer. */
typedef struct RagePhotoInstance {
RagePhotoData *data; /**< Pointer for data */
RagePhotoFormatParser *parser; /**< Pointer for format parser */
} RagePhotoInstance;
/* RagePhoto default sizes */
#define RAGEPHOTO_DEFAULT_GTA5_PHOTOBUFFER 524288UL /**< GTA V default Photo Buffer Size */
#define RAGEPHOTO_DEFAULT_RDR2_PHOTOBUFFER 1048576UL /**< RDR 2 default Photo Buffer Size */
@ -126,6 +132,10 @@ typedef struct RagePhotoFormatParser {
#define RAGEPHOTO_FORMAT_GTA5 0x01000000UL /**< GTA V Photo Format */
#define RAGEPHOTO_FORMAT_RDR2 0x04000000UL /**< RDR 2 Photo Format */
/* RagePhoto sign initials */
#define RAGEPHOTO_SIGNINITIAL_GTA5 0xE47AB81CUL /**< GTA V Sign Initial */
#define RAGEPHOTO_SIGNINITIAL_RDR2 0x00FEEB1EUL /**< RDR 2 Sign Initial */
#ifdef __cplusplus
}
#endif // __cplusplus