libragephoto: remove offset jumping

- CMakeLists.txt: add RAGEPHOTO_DEBUG option
- RagePhoto.c: fix ragephoto_loadfile and add support for 64-Bit files
- RagePhoto.*: improve correctness
- ragephoto-*viewer: depend on ragephoto 0.6 or newer
This commit is contained in:
Syping 2024-04-05 04:17:41 +02:00
parent 1e160ee170
commit c8c2f65b3a
10 changed files with 291 additions and 278 deletions

View File

@ -70,6 +70,9 @@ endif()
# RagePhoto Benchmark
option(RAGEPHOTO_BENCHMARK "Build with libragephoto benchmark" OFF)
# RagePhoto Debug
option(RAGEPHOTO_DEBUG "Build with libragephoto debug output" OFF)
# RagePhoto API
option(RAGEPHOTO_C_API "Build libragephoto with C API support" ON)
if (RAGEPHOTO_C_LIBRARY)
@ -123,6 +126,7 @@ target_compile_definitions(ragephoto PRIVATE
LIBRAGEPHOTO_LIBRARY
${LIBRAGEPHOTO_DEFINES}
$<$<BOOL:${RAGEPHOTO_BENCHMARK}>:RAGEPHOTO_BENCHMARK>
$<$<BOOL:${RAGEPHOTO_DEBUG}>:RAGEPHOTO_DEBUG>
)
if (MSVC AND MSVC_VERSION GREATER_EQUAL 1914)
target_compile_options(ragephoto PRIVATE $<$<COMPILE_LANGUAGE:CXX>:/Zc:__cplusplus>)

View File

@ -1,10 +1,10 @@
## libragephoto
Open Source RAGE Photo Parser for GTA V and RDR 2
- Read/Write RAGE Photos error free and correct
- Support for metadata stored in RAGE Photos
- Export RAGE Photos to jpeg with ragephoto-extract
- High Efficient and Simple C/C++ API
- Read/Write RAGE Photos error free and correct
- Support for metadata stored in RAGE Photos
- Export RAGE Photos to jpeg with ragephoto-extract
- High Efficient and Simple C/C++ API
#### Build libragephoto
@ -20,6 +20,7 @@ sudo cmake --install libragephoto-build
`-DRAGEPHOTO_BENCHMARK=ON`
`-DRAGEPHOTO_C_API=OFF`
`-DRAGEPHOTO_C_LIBRARY=ON`
`-DRAGEPHOTO_DEBUG=ON`
`-DRAGEPHOTO_DOC=ON`
`-DRAGEPHOTO_EXAMPLE_GTKVIEWER=ON`
`-DRAGEPHOTO_EXAMPLE_QTVIEWER=ON`

View File

@ -35,7 +35,7 @@ if (TARGET ragephoto)
set(RAGEPHOTO_LIBRARIES ragephoto)
set(RAGEPHOTO_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
else()
pkg_check_modules(RAGEPHOTO REQUIRED ragephoto)
pkg_check_modules(RAGEPHOTO REQUIRED ragephoto>=0.6)
endif()
add_executable(ragephoto-gtkviewer WIN32 ${GTKVIEWER_SOURCES})

View File

@ -41,7 +41,7 @@ if (TARGET ragephoto)
set(RAGEPHOTO_LIBRARY_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
else()
find_package(PkgConfig REQUIRED)
pkg_check_modules(RAGEPHOTO REQUIRED ragephoto)
pkg_check_modules(RAGEPHOTO REQUIRED ragephoto>=0.6)
endif()
add_executable(ragephoto-qtviewer WIN32 ${QTVIEWER_SOURCES})

View File

@ -84,7 +84,7 @@ inline bool writeDataChar(const char *input, char **output)
if (*output) {
const size_t dst_s = strlen(*output) + 1;
if (dst_s > src_s) {
char *t_output = (char*)(realloc(*output, src_s));
char *t_output = (char*)realloc(*output, src_s);
if (!t_output) {
return false;
}
@ -92,7 +92,7 @@ inline bool writeDataChar(const char *input, char **output)
memcpy(*output, input, src_s);
}
else if (dst_s < src_s) {
char *t_output = (char*)(malloc(src_s));
char *t_output = (char*)malloc(src_s);
if (!t_output) {
return false;
}
@ -105,7 +105,7 @@ inline bool writeDataChar(const char *input, char **output)
}
}
else {
char *t_output = (char*)(malloc(src_s));
char *t_output = (char*)malloc(src_s);
if (!t_output) {
return false;
}
@ -136,12 +136,12 @@ inline uint32_t joaatFromInitial(const char *data, size_t size, uint32_t init_va
uint32_t val = init_val;
for (size_t i = 0; i != size; i++) {
val += data[i];
val += (val << 10);
val ^= (val >> 6);
val += val << 10;
val ^= val >> 6;
}
val += (val << 3);
val ^= (val >> 11);
val += (val << 15);
val += val << 3;
val ^= val >> 11;
val += val << 15;
return val;
}
/* END OF STATIC LIBRARY FUNCTIONS */
@ -149,16 +149,16 @@ inline uint32_t joaatFromInitial(const char *data, size_t size, uint32_t init_va
/* BEGIN OF RAGEPHOTO CLASS */
ragephoto_t ragephoto_open()
{
RagePhotoInstance *instance = (RagePhotoInstance*)(malloc(sizeof(RagePhotoInstance)));
RagePhotoInstance *instance = (RagePhotoInstance*)malloc(sizeof(RagePhotoInstance));
if (!instance)
return NULL;
instance->data = (RagePhotoData*)(malloc(sizeof(RagePhotoData)));
instance->data = (RagePhotoData*)malloc(sizeof(RagePhotoData));
if (!instance->data) {
free(instance);
return NULL;
}
memset(instance->data, 0, sizeof(RagePhotoData));
instance->parser = (RagePhotoFormatParser*)(malloc(sizeof(RagePhotoFormatParser)));
instance->parser = (RagePhotoFormatParser*)malloc(sizeof(RagePhotoFormatParser));
if (!instance->parser) {
free(instance->data);
free(instance);
@ -192,12 +192,12 @@ void ragephoto_addparser(ragephoto_t instance_t, RagePhotoFormatParser *rp_parse
return;
size_t length;
for (length = 0; memcmp(&n_parser, &instance->parser[length], sizeof(RagePhotoFormatParser)); length++);
RagePhotoFormatParser *t_parser = (RagePhotoFormatParser*)(realloc(instance->parser, (length + 2 * sizeof(RagePhotoFormatParser))));
RagePhotoFormatParser *t_parser = (RagePhotoFormatParser*)realloc(instance->parser, (length + 2 * sizeof(RagePhotoFormatParser)));
if (!t_parser)
return;
instance->parser = t_parser;
memcpy(&instance->parser[length], rp_parser, sizeof(RagePhotoFormatParser));
memset(&instance->parser[length+1], 0, sizeof(RagePhotoFormatParser));
memset(&instance->parser[length + 1], 0, sizeof(RagePhotoFormatParser));
}
}
@ -268,7 +268,7 @@ bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser
rp_data->error = RAGEPHOTO_ERROR_UNICODEINITERROR; // 4
return false;
}
rp_data->header = (char*)(malloc(256));
rp_data->header = (char*)malloc(256);
if (!rp_data->header) {
rp_data->error = RAGEPHOTO_ERROR_HEADERMALLOCERROR; // 4
iconv_close(iconv_in);
@ -285,7 +285,7 @@ bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser
return false;
}
#elif defined(UNICODE_WINCVT)
rp_data->header = (char*)(malloc(256));
rp_data->header = (char*)malloc(256);
if (!rp_data->header) {
rp_data->error = RAGEPHOTO_ERROR_HEADERMALLOCERROR; // 4
return false;
@ -413,7 +413,7 @@ bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser
rp_data->jpegSize = charToUInt32LE(uInt32Buffer);
#endif
rp_data->jpeg = (char*)(malloc(rp_data->jpegSize));
rp_data->jpeg = (char*)malloc(rp_data->jpegSize);
if (!rp_data->jpeg) {
rp_data->error = RAGEPHOTO_ERROR_PHOTOMALLOCERROR; // 16
return false;
@ -426,7 +426,7 @@ bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser
return false;
}
pos = rp_data->jsonOffset + headerSize;
pos += rp_data->jpegBuffer - rp_data->jpegSize;
size = readBuffer(data, markerBuffer, &pos, 4, length);
if (size != 4) {
rp_data->error = RAGEPHOTO_ERROR_INCOMPLETEJSONMARKER; // 18
@ -448,7 +448,7 @@ bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser
rp_data->jsonBuffer = charToUInt32LE(uInt32Buffer);
#endif
rp_data->json = (char*)(malloc(rp_data->jsonBuffer));
rp_data->json = (char*)malloc(rp_data->jsonBuffer);
if (!rp_data->json) {
rp_data->error = RAGEPHOTO_ERROR_JSONMALLOCERROR; // 21
return false;
@ -461,7 +461,6 @@ bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser
return false;
}
pos = rp_data->titlOffset + headerSize;
size = readBuffer(data, markerBuffer, &pos, 4, length);
if (size != 4) {
rp_data->error = RAGEPHOTO_ERROR_INCOMPLETETITLEMARKER; // 23
@ -483,7 +482,7 @@ bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser
rp_data->titlBuffer = charToUInt32LE(uInt32Buffer);
#endif
rp_data->title = (char*)(malloc(rp_data->titlBuffer));
rp_data->title = (char*)malloc(rp_data->titlBuffer);
if (!rp_data->title) {
rp_data->error = RAGEPHOTO_ERROR_TITLEMALLOCERROR; // 26
return false;
@ -496,7 +495,6 @@ bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser
return false;
}
pos = rp_data->descOffset + headerSize;
size = readBuffer(data, markerBuffer, &pos, 4, length);
if (size != 4) {
rp_data->error = RAGEPHOTO_ERROR_INCOMPLETEDESCMARKER; // 28
@ -518,7 +516,7 @@ bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser
rp_data->descBuffer = charToUInt32LE(uInt32Buffer);
#endif
rp_data->description = (char*)(malloc(rp_data->descBuffer));
rp_data->description = (char*)malloc(rp_data->descBuffer);
if (!rp_data->description) {
rp_data->error = RAGEPHOTO_ERROR_DESCMALLOCERROR; // 31
return false;
@ -531,7 +529,6 @@ bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser
return false;
}
pos = rp_data->endOfFile + headerSize - 4;
size = readBuffer(data, markerBuffer, &pos, 4, length);
if (size != 4) {
rp_data->error = RAGEPHOTO_ERROR_INCOMPLETEJENDMARKER; // 33
@ -555,29 +552,26 @@ bool ragephotodata_load(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser
#endif
#ifdef RAGEPHOTO_DEBUG
const uint32_t jsonOffset = rp_data->jpegBuffer + UINT32_C(28);
const uint32_t titlOffset = jsonOffset + rp_data->jsonBuffer + UINT32_C(8);
const uint32_t descOffset = titlOffset + rp_data->titlBuffer + UINT32_C(8);
const uint32_t endOfFile = descOffset + rp_data->descBuffer + UINT32_C(12);
printf("header: %s\n", rp_data->header);
printf("headerSum: %" PRIu32 "\n", rp_data->headerSum);
printf("headerSum2: %" PRIu32 "\n", rp_data->headerSum2);
printf("photoBuffer: %" PRIu32 "\n", rp_data->jpegBuffer);
printf("descBuffer: %" PRIu32 "\n", rp_data->descBuffer);
printf("descOffset: %" PRIu32 "\n", rp_data->descOffset);
printf("descOffset: %" PRIu32 " (%" PRIu32 ")\n", rp_data->descOffset, descOffset);
printf("description: %s\n", rp_data->description);
printf("jsonBuffer: %" PRIu32 "\n", rp_data->jsonBuffer);
printf("jsonOffset: %" PRIu32 "\n", rp_data->jsonOffset);
printf("jsonOffset: %" PRIu32 " (%" PRIu32 ")\n", rp_data->jsonOffset, jsonOffset);
printf("json: %s\n", rp_data->json);
printf("sign: %" PRIu64 "\n", ragephotodata_getphotosign(rp_data));
printf("titlBuffer: %" PRIu32 "\n", rp_data->titlBuffer);
printf("titlOffset: %" PRIu32 "\n", rp_data->titlOffset);
printf("titlOffset: %" PRIu32 " (%" PRIu32 ")\n", rp_data->titlOffset, titlOffset);
printf("title: %s\n", rp_data->title);
printf("eofOffset: %" PRIu32 "\n", rp_data->endOfFile);
printf("ragephotodata_setbufferoffsets()\n");
ragephotodata_setbufferoffsets(rp_data);
printf("descOffset: %" PRIu32 "\n", rp_data->descOffset);
printf("jsonOffset: %" PRIu32 "\n", rp_data->jsonOffset);
printf("titlOffset: %" PRIu32 "\n", rp_data->titlOffset);
printf("eofOffset: %" PRIu32 "\n", rp_data->endOfFile);
printf("calc size: %zu\n", ragephotodata_getsavesize(rp_data, rp_parser));
printf("real size: %zu\n", length);
printf("eofOffset: %" PRIu32 " (%" PRIu32 ")\n", rp_data->endOfFile, endOfFile);
printf("size: %zu / %zu\n", length, ragephotodata_getsavesize(rp_data, NULL));
#endif
rp_data->error = RAGEPHOTO_ERROR_NOERROR; // 255
@ -610,7 +604,7 @@ bool ragephoto_load(ragephoto_t instance_t, const char *data, size_t size)
bool ragephoto_loadfile(ragephoto_t instance_t, const char *filename)
{
RagePhotoInstance *instance = (RagePhotoInstance*)instance_t;
#ifdef _WIN32
#if defined(_WIN32)
FILE *file = NULL;
fopen_s(&file, filename, "rb");
#else
@ -618,18 +612,36 @@ bool ragephoto_loadfile(ragephoto_t instance_t, const char *filename)
#endif
if (!file)
return false;
#if defined(_WIN64)
int fseek_ret = _fseeki64(file, 0, SEEK_END);
#elif (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
int fseek_ret = fseeko(file, 0, SEEK_END);
#else
int fseek_ret = fseek(file, 0, SEEK_END);
if (!fseek_ret) {
#endif
if (fseek_ret == -1) {
fclose(file);
return false;
}
#if defined(_WIN64)
const long long fileSize = _ftelli64(file);
#elif (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
const _off_t fileSize = ftello(file);
#else
const long fileSize = ftell(file);
if (fileSize == -1L) {
#endif
if (fileSize == -1) {
fclose(file);
return false;
}
#if defined(_WIN64)
fseek_ret = _fseeki64(file, 0, SEEK_SET);
#elif (defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS == 64) || (defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L)
fseek_ret = fseeko(file, 0, SEEK_SET);
#else
fseek_ret = fseek(file, 0, SEEK_SET);
if (!fseek_ret) {
#endif
if (fseek_ret == -1) {
fclose(file);
return false;
}
@ -638,7 +650,7 @@ bool ragephoto_loadfile(ragephoto_t instance_t, const char *filename)
fclose(file);
return false;
}
const size_t readSize = fread(data, 1, fileSize, file);
const size_t readSize = fread(data, sizeof(char), fileSize, file);
fclose(file);
if (fileSize != readSize) {
free(data);
@ -673,9 +685,9 @@ uint64_t ragephotodata_getphotosignf(RagePhotoData *rp_data, uint32_t photoForma
{
if (rp_data->jpeg) {
if (photoFormat == RAGEPHOTO_FORMAT_GTA5)
return (0x100000000000000ULL | joaatFromInitial(rp_data->jpeg, rp_data->jpegSize, RAGEPHOTO_SIGNINITIAL_GTA5));
return (UINT64_C(0x100000000000000) | joaatFromInitial(rp_data->jpeg, rp_data->jpegSize, RAGEPHOTO_SIGNINITIAL_GTA5));
else if (photoFormat == RAGEPHOTO_FORMAT_RDR2)
return (0x100000000000000ULL | joaatFromInitial(rp_data->jpeg, rp_data->jpegSize, RAGEPHOTO_SIGNINITIAL_RDR2));
return (UINT64_C(0x100000000000000) | joaatFromInitial(rp_data->jpeg, rp_data->jpegSize, RAGEPHOTO_SIGNINITIAL_RDR2));
}
return 0;
}
@ -790,7 +802,7 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
const size_t photoHeader_size = 256;
#endif
const size_t length = ragephotodata_getsavesizef(rp_data, rp_parser, photoFormat);
const size_t length = ragephotodata_getsavesizef(rp_data, NULL, photoFormat);
size_t pos = 0;
char uInt32Buffer[4];
@ -823,33 +835,37 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
#endif
writeBuffer(uInt32Buffer, data, &pos, length, 4);
}
const size_t headerSize = pos;
const uint32_t jsonOffset = rp_data->jpegBuffer + UINT32_C(28);
const uint32_t titlOffset = jsonOffset + rp_data->jsonBuffer + UINT32_C(8);
const uint32_t descOffset = titlOffset + rp_data->titlBuffer + UINT32_C(8);
const uint32_t endOfFile = descOffset + rp_data->descBuffer + UINT32_C(12);
#if __BYTE_ORDER == __LITTLE_ENDIAN
memcpy(uInt32Buffer, &rp_data->endOfFile, 4);
memcpy(uInt32Buffer, &endOfFile, 4);
#else
uInt32ToCharLE(rp_data->endOfFile, uInt32Buffer);
uInt32ToCharLE(endOfFile, uInt32Buffer);
#endif
writeBuffer(uInt32Buffer, data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
memcpy(uInt32Buffer, &rp_data->jsonOffset, 4);
memcpy(uInt32Buffer, &jsonOffset, 4);
#else
uInt32ToCharLE(rp_data->jsonOffset, uInt32Buffer);
uInt32ToCharLE(jsonOffset, uInt32Buffer);
#endif
writeBuffer(uInt32Buffer, data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
memcpy(uInt32Buffer, &rp_data->titlOffset, 4);
memcpy(uInt32Buffer, &titlOffset, 4);
#else
uInt32ToCharLE(rp_data->titlOffset, uInt32Buffer);
uInt32ToCharLE(titlOffset, uInt32Buffer);
#endif
writeBuffer(uInt32Buffer, data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
memcpy(uInt32Buffer, &rp_data->descOffset, 4);
memcpy(uInt32Buffer, &descOffset, 4);
#else
uInt32ToCharLE(rp_data->descOffset, uInt32Buffer);
uInt32ToCharLE(descOffset, uInt32Buffer);
#endif
writeBuffer(uInt32Buffer, data, &pos, length, 4);
@ -881,7 +897,6 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
zeroBuffer(data, &pos, length, rp_data->jpegBuffer - rp_data->jpegSize);
}
pos = rp_data->jsonOffset + headerSize;
writeBuffer("JSON", data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
@ -904,7 +919,6 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
zeroBuffer(data, &pos, length, rp_data->jsonBuffer);
}
pos = rp_data->titlOffset + headerSize;
writeBuffer("TITL", data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
@ -927,7 +941,6 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
zeroBuffer(data, &pos, length, rp_data->titlBuffer);
}
pos = rp_data->descOffset + headerSize;
writeBuffer("DESC", data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
@ -950,7 +963,6 @@ bool ragephotodata_savef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parse
zeroBuffer(data, &pos, length, rp_data->descBuffer);
}
pos = rp_data->endOfFile + headerSize - 4;
writeBuffer("JEND", data, &pos, length, 4);
rp_data->error = RAGEPHOTO_ERROR_NOERROR; // 255
@ -1028,9 +1040,9 @@ bool ragephoto_savefile(ragephoto_t instance_t, const char *filename)
size_t ragephotodata_getsavesizef(RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser, uint32_t photoFormat)
{
if (photoFormat == RAGEPHOTO_FORMAT_GTA5)
return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + RAGEPHOTO_GTA5_HEADERSIZE + 56UL);
return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + RAGEPHOTO_GTA5_HEADERSIZE + UINT32_C(56));
else if (photoFormat == RAGEPHOTO_FORMAT_RDR2)
return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + RAGEPHOTO_RDR2_HEADERSIZE + 56UL);
return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + RAGEPHOTO_RDR2_HEADERSIZE + UINT32_C(56));
else if (rp_parser) {
RagePhotoFormatParser n_parser;
memset(&n_parser, 0, sizeof(RagePhotoFormatParser));
@ -1116,7 +1128,7 @@ bool ragephoto_setphotodatac(ragephoto_t instance_t, RagePhotoData *rp_data)
if (rp_data->header) {
const size_t headerSize = strlen(rp_data->header) + 1;
instance->data->header = (char*)(malloc(headerSize));
instance->data->header = (char*)malloc(headerSize);
if (!instance->data->header)
return false;
memcpy(instance->data->header, rp_data->header, headerSize);
@ -1125,7 +1137,7 @@ bool ragephoto_setphotodatac(ragephoto_t instance_t, RagePhotoData *rp_data)
}
if (rp_data->jpeg) {
instance->data->jpeg = (char*)(malloc(rp_data->jpegSize));
instance->data->jpeg = (char*)malloc(rp_data->jpegSize);
if (!instance->data->jpeg)
return false;
memcpy(instance->data->jpeg, rp_data->jpeg, rp_data->jpegSize);
@ -1135,7 +1147,7 @@ bool ragephoto_setphotodatac(ragephoto_t instance_t, RagePhotoData *rp_data)
if (rp_data->json) {
const size_t jsonSize = strlen(rp_data->json) + 1;
instance->data->json = (char*)(malloc(jsonSize));
instance->data->json = (char*)malloc(jsonSize);
if (!instance->data->json)
return false;
memcpy(instance->data->json, rp_data->json, jsonSize);
@ -1144,7 +1156,7 @@ bool ragephoto_setphotodatac(ragephoto_t instance_t, RagePhotoData *rp_data)
if (rp_data->title) {
const size_t titleSize = strlen(rp_data->title) + 1;
instance->data->title = (char*)(malloc(titleSize));
instance->data->title = (char*)malloc(titleSize);
if (!instance->data->title)
return false;
memcpy(instance->data->title, rp_data->title, titleSize);
@ -1153,7 +1165,7 @@ bool ragephoto_setphotodatac(ragephoto_t instance_t, RagePhotoData *rp_data)
if (rp_data->description) {
const size_t descriptionSize = strlen(rp_data->description) + 1;
instance->data->description = (char*)(malloc(descriptionSize));
instance->data->description = (char*)malloc(descriptionSize);
if (!instance->data->description)
return false;
memcpy(instance->data->description, rp_data->description, descriptionSize);
@ -1189,7 +1201,7 @@ bool ragephoto_setphotojpeg(ragephoto_t instance_t, const char *data, uint32_t s
RagePhotoInstance *instance = (RagePhotoInstance*)instance_t;
if (instance->data->jpeg) {
if (instance->data->jpegSize > size) {
char *t_photoData = (char*)(realloc(instance->data->jpeg, size));
char *t_photoData = (char*)realloc(instance->data->jpeg, size);
if (!t_photoData) {
instance->data->error = RAGEPHOTO_ERROR_PHOTOMALLOCERROR; // 16
return false;
@ -1200,7 +1212,7 @@ bool ragephoto_setphotojpeg(ragephoto_t instance_t, const char *data, uint32_t s
}
else if (instance->data->jpegSize < size) {
free(instance->data->jpeg);
instance->data->jpeg = (char*)(malloc(size));
instance->data->jpeg = (char*)malloc(size);
if (!instance->data->jpeg) {
instance->data->error = RAGEPHOTO_ERROR_PHOTOMALLOCERROR; // 16
return false;
@ -1213,7 +1225,7 @@ bool ragephoto_setphotojpeg(ragephoto_t instance_t, const char *data, uint32_t s
}
}
else {
instance->data->jpeg = (char*)(malloc(size));
instance->data->jpeg = (char*)malloc(size);
if (!instance->data->jpeg) {
instance->data->error = RAGEPHOTO_ERROR_PHOTOMALLOCERROR; // 16
return false;

View File

@ -43,7 +43,7 @@
#endif
/* CLASSIC RAGEPHOTO TYPEDEF */
typedef ragephoto::cxx_abi::photo RagePhoto;
typedef ragephoto::photo RagePhoto;
/* BEGIN OF STATIC LIBRARY FUNCTIONS */
inline size_t readBuffer(const char *input, void *output, size_t *pos, size_t outputLen, size_t inputLen)
@ -143,12 +143,12 @@ inline uint32_t joaatFromInitial(const char *data, size_t size, uint32_t init_va
uint32_t val = init_val;
for (size_t i = 0; i != size; i++) {
val += data[i];
val += (val << 10);
val ^= (val >> 6);
val += val << 10;
val ^= val >> 6;
}
val += (val << 3);
val ^= (val >> 11);
val += (val << 15);
val += val << 3;
val ^= val >> 11;
val += val << 15;
return val;
}
/* END OF STATIC LIBRARY FUNCTIONS */
@ -191,7 +191,7 @@ void RagePhoto::addParser(RagePhotoFormatParser *rp_parser)
throw std::runtime_error("RagePhotoFormatParser array can't be expanded");
m_parser = t_parser;
memcpy(&m_parser[length], rp_parser, sizeof(RagePhotoFormatParser));
memset(&m_parser[length+1], 0, sizeof(RagePhotoFormatParser));
memset(&m_parser[length + 1], 0, sizeof(RagePhotoFormatParser));
}
}
@ -333,7 +333,6 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
rp_data->headerSum2 = charToUInt32LE(uInt32Buffer);
#endif
}
const size_t headerSize = pos;
size = readBuffer(data, uInt32Buffer, &pos, 4, length);
if (size != 4) {
@ -424,7 +423,7 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
return false;
}
pos = rp_data->jsonOffset + headerSize;
pos += rp_data->jpegBuffer - rp_data->jpegSize;
size = readBuffer(data, markerBuffer, &pos, 4, length);
if (size != 4) {
rp_data->error = Error::IncompleteJsonMarker; // 18
@ -459,7 +458,6 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
return false;
}
pos = rp_data->titlOffset + headerSize;
size = readBuffer(data, markerBuffer, &pos, 4, length);
if (size != 4) {
rp_data->error = Error::IncompleteTitleMarker; // 23
@ -494,7 +492,6 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
return false;
}
pos = rp_data->descOffset + headerSize;
size = readBuffer(data, markerBuffer, &pos, 4, length);
if (size != 4) {
rp_data->error = Error::IncompleteDescMarker; // 28
@ -529,7 +526,6 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
return false;
}
pos = rp_data->endOfFile + headerSize - 4;
size = readBuffer(data, markerBuffer, &pos, 4, length);
if (size != 4) {
rp_data->error = Error::IncompleteJendMarker; // 33
@ -547,29 +543,26 @@ bool RagePhoto::load(const char *data, size_t length, RagePhotoData *rp_data, Ra
#endif
#ifdef RAGEPHOTO_DEBUG
const uint32_t jsonOffset = rp_data->jpegBuffer + UINT32_C(28);
const uint32_t titlOffset = jsonOffset + rp_data->jsonBuffer + UINT32_C(8);
const uint32_t descOffset = titlOffset + rp_data->titlBuffer + UINT32_C(8);
const uint32_t endOfFile = descOffset + rp_data->descBuffer + UINT32_C(12);
std::cout << "header: " << rp_data->header << std::endl;
std::cout << "headerSum: " << rp_data->headerSum << std::endl;
std::cout << "headerSum2: " << rp_data->headerSum2 << std::endl;
std::cout << "photoBuffer: " << rp_data->jpegBuffer << std::endl;
std::cout << "descBuffer: " << rp_data->descBuffer << std::endl;
std::cout << "descOffset: " << rp_data->descOffset << std::endl;
std::cout << "descOffset: " << rp_data->descOffset << " (" << descOffset << ")" << std::endl;
std::cout << "description: " << rp_data->description << std::endl;
std::cout << "jsonBuffer: " << rp_data->jsonBuffer << std::endl;
std::cout << "jsonOffset: " << rp_data->jsonOffset << std::endl;
std::cout << "jsonOffset: " << rp_data->jsonOffset << " (" << jsonOffset << ")" << std::endl;
std::cout << "json: " << rp_data->json << std::endl;
std::cout << "sign: " << jpegSign(rp_data) << std::endl;
std::cout << "titlBuffer: " << rp_data->titlBuffer << std::endl;
std::cout << "titlOffset: " << rp_data->titlOffset << std::endl;
std::cout << "titlOffset: " << rp_data->titlOffset << " (" << titlOffset << ")" << std::endl;
std::cout << "title: " << rp_data->title << std::endl;
std::cout << "eofOffset: " << rp_data->endOfFile << std::endl;
std::cout << "setBufferOffsets()" << std::endl;
setBufferOffsets(rp_data);
std::cout << "descOffset: " << rp_data->descOffset << std::endl;
std::cout << "jsonOffset: " << rp_data->jsonOffset << std::endl;
std::cout << "titlOffset: " << rp_data->titlOffset << std::endl;
std::cout << "eofOffset: " << rp_data->endOfFile << std::endl;
std::cout << "calc size: " << saveSize(rp_data, rp_parser) << std::endl;
std::cout << "real size: " << length << std::endl;
std::cout << "eofOffset: " << rp_data->endOfFile << " (" << endOfFile << ")" << std::endl;
std::cout << "size: " << length << " (" << saveSize(rp_data, nullptr) << ")" << std::endl;
#endif
rp_data->error = Error::NoError; // 255
@ -653,9 +646,9 @@ uint64_t RagePhoto::jpegSign(uint32_t photoFormat, RagePhotoData *rp_data)
{
if (rp_data->jpeg) {
if (photoFormat == PhotoFormat::GTA5)
return (0x100000000000000ULL | joaatFromInitial(rp_data->jpeg, rp_data->jpegSize, SignInitials::SIGTA5));
return (UINT64_C(0x100000000000000) | joaatFromInitial(rp_data->jpeg, rp_data->jpegSize, SignInitials::SIGTA5));
else if (photoFormat == PhotoFormat::RDR2)
return (0x100000000000000ULL | joaatFromInitial(rp_data->jpeg, rp_data->jpegSize, SignInitials::SIRDR2));
return (UINT64_C(0x100000000000000) | joaatFromInitial(rp_data->jpeg, rp_data->jpegSize, SignInitials::SIRDR2));
}
return 0;
}
@ -764,7 +757,7 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
const size_t photoHeader_size = 256;
#endif
const size_t length = saveSize(photoFormat, rp_data, rp_parser);
const size_t length = saveSize(photoFormat, rp_data, nullptr);
size_t pos = 0;
char uInt32Buffer[4];
@ -796,33 +789,37 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
#endif
writeBuffer(uInt32Buffer, data, &pos, length, 4);
}
const size_t headerSize = pos;
const uint32_t jsonOffset = rp_data->jpegBuffer + UINT32_C(28);
const uint32_t titlOffset = jsonOffset + rp_data->jsonBuffer + UINT32_C(8);
const uint32_t descOffset = titlOffset + rp_data->titlBuffer + UINT32_C(8);
const uint32_t endOfFile = descOffset + rp_data->descBuffer + UINT32_C(12);
#if __BYTE_ORDER == __LITTLE_ENDIAN
memcpy(uInt32Buffer, &rp_data->endOfFile, 4);
memcpy(uInt32Buffer, &endOfFile, 4);
#else
uInt32ToCharLE(rp_data->endOfFile, uInt32Buffer);
uInt32ToCharLE(endOfFile, uInt32Buffer);
#endif
writeBuffer(uInt32Buffer, data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
memcpy(uInt32Buffer, &rp_data->jsonOffset, 4);
memcpy(uInt32Buffer, &jsonOffset, 4);
#else
uInt32ToCharLE(rp_data->jsonOffset, uInt32Buffer);
uInt32ToCharLE(jsonOffset, uInt32Buffer);
#endif
writeBuffer(uInt32Buffer, data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
memcpy(uInt32Buffer, &rp_data->titlOffset, 4);
memcpy(uInt32Buffer, &titlOffset, 4);
#else
uInt32ToCharLE(rp_data->titlOffset, uInt32Buffer);
uInt32ToCharLE(titlOffset, uInt32Buffer);
#endif
writeBuffer(uInt32Buffer, data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
memcpy(uInt32Buffer, &rp_data->descOffset, 4);
memcpy(uInt32Buffer, &descOffset, 4);
#else
uInt32ToCharLE(rp_data->descOffset, uInt32Buffer);
uInt32ToCharLE(descOffset, uInt32Buffer);
#endif
writeBuffer(uInt32Buffer, data, &pos, length, 4);
@ -854,7 +851,6 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
zeroBuffer(data, &pos, length, rp_data->jpegBuffer - rp_data->jpegSize);
}
pos = rp_data->jsonOffset + headerSize;
writeBuffer("JSON", data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
@ -877,7 +873,6 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
zeroBuffer(data, &pos, length, rp_data->jsonBuffer);
}
pos = rp_data->titlOffset + headerSize;
writeBuffer("TITL", data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
@ -900,7 +895,6 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
zeroBuffer(data, &pos, length, rp_data->titlBuffer);
}
pos = rp_data->descOffset + headerSize;
writeBuffer("DESC", data, &pos, length, 4);
#if __BYTE_ORDER == __LITTLE_ENDIAN
@ -923,7 +917,6 @@ bool RagePhoto::save(char *data, uint32_t photoFormat, RagePhotoData *rp_data, R
zeroBuffer(data, &pos, length, rp_data->descBuffer);
}
pos = rp_data->endOfFile + headerSize - 4;
writeBuffer("JEND", data, &pos, length, 4);
rp_data->error = Error::NoError; // 255
@ -1014,9 +1007,9 @@ bool RagePhoto::saveFile(const char *filename)
size_t RagePhoto::saveSize(uint32_t photoFormat, RagePhotoData *rp_data, RagePhotoFormatParser *rp_parser)
{
if (photoFormat == PhotoFormat::GTA5)
return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + GTA5_HEADERSIZE + 56UL);
return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + GTA5_HEADERSIZE + UINT32_C(56));
else if (photoFormat == PhotoFormat::RDR2)
return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + RDR2_HEADERSIZE + 56UL);
return (rp_data->jpegBuffer + rp_data->jsonBuffer + rp_data->titlBuffer + rp_data->descBuffer + RDR2_HEADERSIZE + UINT32_C(56));
else if (rp_parser) {
RagePhotoFormatParser n_parser[1]{};
for (size_t i = 0; memcmp(&n_parser[0], &rp_parser[i], sizeof(RagePhotoFormatParser)); i++) {

View File

@ -23,18 +23,23 @@
#include "RagePhotoLibrary.h"
#ifdef LIBRAGEPHOTO_CXX_ONLY
#include "ragephoto_cxx.hpp"
typedef ragephoto::cxx_abi::photo RagePhoto;
typedef ragephoto::photo RagePhoto;
#elif defined LIBRAGEPHOTO_CXX_C
#ifdef LIBRAGEPHOTO_STATIC
#include "ragephoto_cxx.hpp"
typedef ragephoto::cxx_abi::photo RagePhoto;
typedef ragephoto::photo RagePhoto;
#else
#ifdef LIBRAGEPHOTO_PREFER_NATIVE
#include "ragephoto_cxx.hpp"
typedef ragephoto::photo RagePhoto;
#else
#include "ragephoto_c.hpp"
typedef ragephoto::c_abi::photo RagePhoto;
typedef ragephoto::c_wrapper::photo RagePhoto;
#endif // LIBRAGEPHOTO_PREFER_NATIVE
#endif // LIBRAGEPHOTO_STATIC
#elif defined LIBRAGEPHOTO_C_ONLY
#include "ragephoto_c.hpp"
typedef ragephoto::c_abi::photo RagePhoto;
typedef ragephoto::c_wrapper::photo RagePhoto;
#else
#error "Could not determine best RagePhoto implementation, libragephoto installation might be corrupt!"
#endif // LIBRAGEPHOTO_CXX_ONLY

View File

@ -77,64 +77,64 @@ typedef struct RagePhotoInstance {
} 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 */
#define RAGEPHOTO_DEFAULT_DESCBUFFER 256UL /**< Default Description Buffer Size */
#define RAGEPHOTO_DEFAULT_JSONBUFFER 3072UL /**< Default JSON Buffer Size */
#define RAGEPHOTO_DEFAULT_TITLBUFFER 256UL /**< Default Title Buffer Size */
#define RAGEPHOTO_GTA5_HEADERSIZE 264UL /**< GTA V Header Size */
#define RAGEPHOTO_RDR2_HEADERSIZE 272UL /**< RDR 2 Header Size */
#define RAGEPHOTO_DEFAULT_GTA5_PHOTOBUFFER UINT32_C(524288) /**< GTA V default Photo Buffer Size */
#define RAGEPHOTO_DEFAULT_RDR2_PHOTOBUFFER UINT32_C(1048576) /**< RDR 2 default Photo Buffer Size */
#define RAGEPHOTO_DEFAULT_DESCBUFFER UINT32_C(256) /**< Default Description Buffer Size */
#define RAGEPHOTO_DEFAULT_JSONBUFFER UINT32_C(3072) /**< Default JSON Buffer Size */
#define RAGEPHOTO_DEFAULT_TITLBUFFER UINT32_C(256) /**< Default Title Buffer Size */
#define RAGEPHOTO_GTA5_HEADERSIZE UINT32_C(264) /**< GTA V Header Size */
#define RAGEPHOTO_RDR2_HEADERSIZE UINT32_C(272) /**< RDR 2 Header Size */
/* RagePhoto error codes */
#define RAGEPHOTO_ERROR_DESCBUFFERTIGHT 39L /**< Description Buffer is too tight */
#define RAGEPHOTO_ERROR_DESCMALLOCERROR 31L /**< Description Buffer can't be allocated */
#define RAGEPHOTO_ERROR_DESCREADERROR 32L /**< Description can't be read successfully */
#define RAGEPHOTO_ERROR_HEADERBUFFERTIGHT 35L /**< Header Buffer is too tight */
#define RAGEPHOTO_ERROR_HEADERMALLOCERROR 4L /**< Header Buffer can't be allocated */
#define RAGEPHOTO_ERROR_INCOMPATIBLEFORMAT 2L /**< Format is incompatible */
#define RAGEPHOTO_ERROR_INCOMPLETECHECKSUM 7L /**< Header checksum is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEDESCBUFFER 30L /**< Description Buffer Size is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEDESCMARKER 28L /**< Description Marker is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEDESCOFFSET 11L /**< Description Offset is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEEOF 8L /**< End Of File Offset is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEHEADER 3L /**< Header is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEJENDMARKER 33L /**< JEND Marker is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEJPEGMARKER 12L /**< JPEG Marker is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEJSONBUFFER 20L /**< JSON Buffer Size is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEJSONMARKER 18L /**< JSON Marker incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEJSONOFFSET 9L /**< JSON Offset incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEPHOTOBUFFER 14L /**< Photo Buffer Size is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEPHOTOSIZE 15L /**< Photo Size is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETETITLEBUFFER 25L /**< Title Buffer Size is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETETITLEMARKER 23L /**< Title Marker is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETETITLEOFFSET 10L /**< Title Offset is incomplete */
#define RAGEPHOTO_ERROR_INCORRECTDESCMARKER 29L /**< Description Marker is incorrect */
#define RAGEPHOTO_ERROR_INCORRECTJENDMARKER 34L /**< JEND Marker is incorrect */
#define RAGEPHOTO_ERROR_INCORRECTJPEGMARKER 13L /**< JPEG Marker is incorrect */
#define RAGEPHOTO_ERROR_INCORRECTJSONMARKER 19L /**< JSON Marker is incorrect */
#define RAGEPHOTO_ERROR_INCORRECTTITLEMARKER 24L /**< Title Marker is incorrect */
#define RAGEPHOTO_ERROR_JSONBUFFERTIGHT 37L /**< JSON Buffer is too tight */
#define RAGEPHOTO_ERROR_JSONMALLOCERROR 21L /**< JSON Buffer can't be allocated */
#define RAGEPHOTO_ERROR_JSONREADERROR 22L /**< JSON can't be read successfully */
#define RAGEPHOTO_ERROR_NOERROR 255L /**< Finished without errors */
#define RAGEPHOTO_ERROR_NOFORMATIDENTIFIER 1L /**< No format detected, empty file */
#define RAGEPHOTO_ERROR_PHOTOBUFFERTIGHT 36L /**< Photo Buffer is too tight */
#define RAGEPHOTO_ERROR_PHOTOMALLOCERROR 16L /**< Photo Buffer can't be allocated */
#define RAGEPHOTO_ERROR_PHOTOREADERROR 17L /**< Photo can't be read */
#define RAGEPHOTO_ERROR_TITLEBUFFERTIGHT 38L /**< Title Buffer is too tight */
#define RAGEPHOTO_ERROR_TITLEMALLOCERROR 26L /**< Title Buffer can't be allocated */
#define RAGEPHOTO_ERROR_TITLEREADERROR 27L /**< Title can't be read */
#define RAGEPHOTO_ERROR_UNICODEINITERROR 5L /**< Failed to initialise Unicode decoder */
#define RAGEPHOTO_ERROR_UNICODEHEADERERROR 6L /**< Header can't be encoded/decoded successfully */
#define RAGEPHOTO_ERROR_UNINITIALISED 0L /**< Uninitialised, file access failed */
#define RAGEPHOTO_ERROR_DESCBUFFERTIGHT INT32_C(39) /**< Description Buffer is too tight */
#define RAGEPHOTO_ERROR_DESCMALLOCERROR INT32_C(31) /**< Description Buffer can't be allocated */
#define RAGEPHOTO_ERROR_DESCREADERROR INT32_C(32) /**< Description can't be read successfully */
#define RAGEPHOTO_ERROR_HEADERBUFFERTIGHT INT32_C(35) /**< Header Buffer is too tight */
#define RAGEPHOTO_ERROR_HEADERMALLOCERROR INT32_C(4) /**< Header Buffer can't be allocated */
#define RAGEPHOTO_ERROR_INCOMPATIBLEFORMAT INT32_C(2) /**< Format is incompatible */
#define RAGEPHOTO_ERROR_INCOMPLETECHECKSUM INT32_C(7) /**< Header checksum is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEDESCBUFFER INT32_C(30) /**< Description Buffer Size is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEDESCMARKER INT32_C(28) /**< Description Marker is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEDESCOFFSET INT32_C(11) /**< Description Offset is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEEOF INT32_C(8) /**< End Of File Offset is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEHEADER INT32_C(3) /**< Header is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEJENDMARKER INT32_C(33) /**< JEND Marker is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEJPEGMARKER INT32_C(12) /**< JPEG Marker is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEJSONBUFFER INT32_C(20) /**< JSON Buffer Size is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEJSONMARKER INT32_C(18) /**< JSON Marker incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEJSONOFFSET INT32_C(9) /**< JSON Offset incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEPHOTOBUFFER INT32_C(14) /**< Photo Buffer Size is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETEPHOTOSIZE INT32_C(15) /**< Photo Size is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETETITLEBUFFER INT32_C(25) /**< Title Buffer Size is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETETITLEMARKER INT32_C(23) /**< Title Marker is incomplete */
#define RAGEPHOTO_ERROR_INCOMPLETETITLEOFFSET INT32_C(10) /**< Title Offset is incomplete */
#define RAGEPHOTO_ERROR_INCORRECTDESCMARKER INT32_C(29) /**< Description Marker is incorrect */
#define RAGEPHOTO_ERROR_INCORRECTJENDMARKER INT32_C(34) /**< JEND Marker is incorrect */
#define RAGEPHOTO_ERROR_INCORRECTJPEGMARKER INT32_C(13) /**< JPEG Marker is incorrect */
#define RAGEPHOTO_ERROR_INCORRECTJSONMARKER INT32_C(19) /**< JSON Marker is incorrect */
#define RAGEPHOTO_ERROR_INCORRECTTITLEMARKER INT32_C(24) /**< Title Marker is incorrect */
#define RAGEPHOTO_ERROR_JSONBUFFERTIGHT INT32_C(37) /**< JSON Buffer is too tight */
#define RAGEPHOTO_ERROR_JSONMALLOCERROR INT32_C(21) /**< JSON Buffer can't be allocated */
#define RAGEPHOTO_ERROR_JSONREADERROR INT32_C(22) /**< JSON can't be read successfully */
#define RAGEPHOTO_ERROR_NOERROR INT32_C(255) /**< Finished without errors */
#define RAGEPHOTO_ERROR_NOFORMATIDENTIFIER INT32_C(1) /**< No format detected, empty file */
#define RAGEPHOTO_ERROR_PHOTOBUFFERTIGHT INT32_C(36) /**< Photo Buffer is too tight */
#define RAGEPHOTO_ERROR_PHOTOMALLOCERROR INT32_C(16) /**< Photo Buffer can't be allocated */
#define RAGEPHOTO_ERROR_PHOTOREADERROR INT32_C(17) /**< Photo can't be read */
#define RAGEPHOTO_ERROR_TITLEBUFFERTIGHT INT32_C(38) /**< Title Buffer is too tight */
#define RAGEPHOTO_ERROR_TITLEMALLOCERROR INT32_C(26) /**< Title Buffer can't be allocated */
#define RAGEPHOTO_ERROR_TITLEREADERROR INT32_C(27) /**< Title can't be read */
#define RAGEPHOTO_ERROR_UNICODEINITERROR INT32_C(5) /**< Failed to initialise Unicode decoder */
#define RAGEPHOTO_ERROR_UNICODEHEADERERROR INT32_C(6) /**< Header can't be encoded/decoded successfully */
#define RAGEPHOTO_ERROR_UNINITIALISED INT32_C(0) /**< Uninitialised, file access failed */
/* RagePhoto formats */
#define RAGEPHOTO_FORMAT_GTA5 0x01000000UL /**< GTA V Photo Format */
#define RAGEPHOTO_FORMAT_RDR2 0x04000000UL /**< RDR 2 Photo Format */
#define RAGEPHOTO_FORMAT_GTA5 UINT32_C(0x01000000) /**< GTA V Photo Format */
#define RAGEPHOTO_FORMAT_RDR2 UINT32_C(0x04000000) /**< 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 */
#define RAGEPHOTO_SIGNINITIAL_GTA5 UINT32_C(0xE47AB81C) /**< GTA V Sign Initial */
#define RAGEPHOTO_SIGNINITIAL_RDR2 UINT32_C(0x00FEEB1E) /**< RDR 2 Sign Initial */
#ifdef __cplusplus
}

View File

@ -25,7 +25,7 @@
#include <iostream>
namespace ragephoto {
namespace c_abi {
namespace c_wrapper {
/**
* \brief GTA V and RDR 2 Photo Parser (C API wrapper).
@ -35,67 +35,67 @@ class photo
public:
/** Default sizes */
enum DefaultSize : uint32_t {
DEFAULT_GTA5_PHOTOBUFFER = 524288UL, /**< GTA V default Photo Buffer Size */
DEFAULT_RDR2_PHOTOBUFFER = 1048576UL, /**< RDR 2 default Photo Buffer Size */
DEFAULT_DESCBUFFER = 256UL, /**< Default Description Buffer Size */
DEFAULT_JSONBUFFER = 3072UL, /**< Default JSON Buffer Size */
DEFAULT_TITLBUFFER = 256UL, /**< Default Title Buffer Size */
GTA5_HEADERSIZE = 264UL, /**< GTA V Header Size */
RDR2_HEADERSIZE = 272UL, /**< RDR 2 Header Size */
DEFAULT_GTA5_PHOTOBUFFER = RAGEPHOTO_DEFAULT_GTA5_PHOTOBUFFER, /**< GTA V default Photo Buffer Size */
DEFAULT_RDR2_PHOTOBUFFER = RAGEPHOTO_DEFAULT_RDR2_PHOTOBUFFER, /**< RDR 2 default Photo Buffer Size */
DEFAULT_DESCBUFFER = RAGEPHOTO_DEFAULT_DESCBUFFER, /**< Default Description Buffer Size */
DEFAULT_JSONBUFFER = RAGEPHOTO_DEFAULT_JSONBUFFER, /**< Default JSON Buffer Size */
DEFAULT_TITLBUFFER = RAGEPHOTO_DEFAULT_TITLBUFFER, /**< Default Title Buffer Size */
GTA5_HEADERSIZE = RAGEPHOTO_GTA5_HEADERSIZE, /**< GTA V Header Size */
RDR2_HEADERSIZE = RAGEPHOTO_RDR2_HEADERSIZE, /**< RDR 2 Header Size */
};
/** Parsing and set errors */
enum Error : int32_t {
DescBufferTight = 39L, /**< Description Buffer is too tight */
DescMallocError = 31L, /**< Description Buffer can't be allocated */
DescReadError = 32L, /**< Description can't be read successfully */
HeaderBufferTight = 35L, /**< Header Buffer is too tight */
HeaderMallocError = 4L, /**< Header Buffer can't be allocated */
IncompatibleFormat = 2L, /**< Format is incompatible */
IncompleteChecksum = 7L, /**< Header checksum is incomplete */
IncompleteDescBuffer = 30L, /**< Description Buffer Size is incomplete */
IncompleteDescMarker = 28L, /**< Description Marker is incomplete */
IncompleteDescOffset = 11L, /**< Description Offset is incomplete */
IncompleteEOF = 8L, /**< End Of File Offset is incomplete */
IncompleteHeader = 3L, /**< Header is incomplete */
IncompleteJendMarker = 33L, /**< JEND Marker is incomplete */
IncompleteJpegMarker = 12L, /**< JPEG Marker is incomplete */
IncompleteJsonBuffer = 20L, /**< JSON Buffer Size is incomplete */
IncompleteJsonMarker = 18L, /**< JSON Marker incomplete */
IncompleteJsonOffset = 9L, /**< JSON Offset incomplete */
IncompletePhotoBuffer = 14L, /**< Photo Buffer Size is incomplete */
IncompletePhotoSize = 15L, /**< Photo Size is incomplete */
IncompleteTitleBuffer = 25L, /**< Title Buffer Size is incomplete */
IncompleteTitleMarker = 23L, /**< Title Marker is incomplete */
IncompleteTitleOffset = 10L, /**< Title Offset is incomplete */
IncorrectDescMarker = 29L, /**< Description Marker is incorrect */
IncorrectJendMarker = 34L, /**< JEND Marker is incorrect */
IncorrectJpegMarker = 13L, /**< JPEG Marker is incorrect */
IncorrectJsonMarker = 19L, /**< JSON Marker is incorrect */
IncorrectTitleMarker = 24L, /**< Title Marker is incorrect */
JsonBufferTight = 37L, /**< JSON Buffer is too tight */
JsonMallocError = 21L, /**< JSON Buffer can't be allocated */
JsonReadError = 22L, /**< JSON can't be read successfully */
NoError = 255L, /**< Finished without errors */
NoFormatIdentifier = 1L, /**< No format detected, empty file */
PhotoBufferTight = 36L, /**< Photo Buffer is too tight */
PhotoMallocError = 16L, /**< Photo Buffer can't be allocated */
PhotoReadError = 17L, /**< Photo can't be read */
TitleBufferTight = 38L, /**< Title Buffer is too tight */
TitleMallocError = 26L, /**< Title Buffer can't be allocated */
TitleReadError = 27L, /**< Title can't be read */
UnicodeInitError = 5L, /**< Failed to initialise Unicode decoder */
UnicodeHeaderError = 6L, /**< Header can't be encoded/decoded successfully */
Uninitialised = 0L, /**< Uninitialised, file access failed */
DescBufferTight = RAGEPHOTO_ERROR_DESCBUFFERTIGHT, /**< Description Buffer is too tight */
DescMallocError = RAGEPHOTO_ERROR_DESCMALLOCERROR, /**< Description Buffer can't be allocated */
DescReadError = RAGEPHOTO_ERROR_DESCREADERROR, /**< Description can't be read successfully */
HeaderBufferTight = RAGEPHOTO_ERROR_HEADERBUFFERTIGHT, /**< Header Buffer is too tight */
HeaderMallocError = RAGEPHOTO_ERROR_HEADERMALLOCERROR, /**< Header Buffer can't be allocated */
IncompatibleFormat = RAGEPHOTO_ERROR_INCOMPATIBLEFORMAT, /**< Format is incompatible */
IncompleteChecksum = RAGEPHOTO_ERROR_INCOMPLETECHECKSUM, /**< Header checksum is incomplete */
IncompleteDescBuffer = RAGEPHOTO_ERROR_INCOMPLETEDESCBUFFER, /**< Description Buffer Size is incomplete */
IncompleteDescMarker = RAGEPHOTO_ERROR_INCOMPLETEDESCMARKER, /**< Description Marker is incomplete */
IncompleteDescOffset = RAGEPHOTO_ERROR_INCOMPLETEDESCOFFSET, /**< Description Offset is incomplete */
IncompleteEOF = RAGEPHOTO_ERROR_INCOMPLETEEOF, /**< End Of File Offset is incomplete */
IncompleteHeader = RAGEPHOTO_ERROR_INCOMPLETEHEADER, /**< Header is incomplete */
IncompleteJendMarker = RAGEPHOTO_ERROR_INCOMPLETEJENDMARKER, /**< JEND Marker is incomplete */
IncompleteJpegMarker = RAGEPHOTO_ERROR_INCOMPLETEJPEGMARKER, /**< JPEG Marker is incomplete */
IncompleteJsonBuffer = RAGEPHOTO_ERROR_INCOMPLETEJSONBUFFER, /**< JSON Buffer Size is incomplete */
IncompleteJsonMarker = RAGEPHOTO_ERROR_INCOMPLETEJSONMARKER, /**< JSON Marker incomplete */
IncompleteJsonOffset = RAGEPHOTO_ERROR_INCOMPLETEJSONOFFSET, /**< JSON Offset incomplete */
IncompletePhotoBuffer = RAGEPHOTO_ERROR_INCOMPLETEPHOTOBUFFER, /**< Photo Buffer Size is incomplete */
IncompletePhotoSize = RAGEPHOTO_ERROR_INCOMPLETEPHOTOSIZE, /**< Photo Size is incomplete */
IncompleteTitleBuffer = RAGEPHOTO_ERROR_INCOMPLETETITLEBUFFER, /**< Title Buffer Size is incomplete */
IncompleteTitleMarker = RAGEPHOTO_ERROR_INCOMPLETETITLEMARKER, /**< Title Marker is incomplete */
IncompleteTitleOffset = RAGEPHOTO_ERROR_INCOMPLETETITLEOFFSET, /**< Title Offset is incomplete */
IncorrectDescMarker = RAGEPHOTO_ERROR_INCORRECTDESCMARKER, /**< Description Marker is incorrect */
IncorrectJendMarker = RAGEPHOTO_ERROR_INCORRECTJENDMARKER, /**< JEND Marker is incorrect */
IncorrectJpegMarker = RAGEPHOTO_ERROR_INCORRECTJPEGMARKER, /**< JPEG Marker is incorrect */
IncorrectJsonMarker = RAGEPHOTO_ERROR_INCORRECTJSONMARKER, /**< JSON Marker is incorrect */
IncorrectTitleMarker = RAGEPHOTO_ERROR_INCORRECTTITLEMARKER, /**< Title Marker is incorrect */
JsonBufferTight = RAGEPHOTO_ERROR_JSONBUFFERTIGHT, /**< JSON Buffer is too tight */
JsonMallocError = RAGEPHOTO_ERROR_JSONMALLOCERROR, /**< JSON Buffer can't be allocated */
JsonReadError = RAGEPHOTO_ERROR_JSONREADERROR, /**< JSON can't be read successfully */
NoError = RAGEPHOTO_ERROR_NOERROR, /**< Finished without errors */
NoFormatIdentifier = RAGEPHOTO_ERROR_NOFORMATIDENTIFIER, /**< No format detected, empty file */
PhotoBufferTight = RAGEPHOTO_ERROR_PHOTOBUFFERTIGHT, /**< Photo Buffer is too tight */
PhotoMallocError = RAGEPHOTO_ERROR_PHOTOMALLOCERROR, /**< Photo Buffer can't be allocated */
PhotoReadError = RAGEPHOTO_ERROR_PHOTOREADERROR, /**< Photo can't be read */
TitleBufferTight = RAGEPHOTO_ERROR_TITLEBUFFERTIGHT, /**< Title Buffer is too tight */
TitleMallocError = RAGEPHOTO_ERROR_TITLEMALLOCERROR, /**< Title Buffer can't be allocated */
TitleReadError = RAGEPHOTO_ERROR_TITLEREADERROR, /**< Title can't be read */
UnicodeInitError = RAGEPHOTO_ERROR_UNICODEINITERROR, /**< Failed to initialise Unicode decoder */
UnicodeHeaderError = RAGEPHOTO_ERROR_UNICODEHEADERERROR, /**< Header can't be encoded/decoded successfully */
Uninitialised = RAGEPHOTO_ERROR_UNINITIALISED, /**< Uninitialised, file access failed */
};
/** Photo Formats */
enum PhotoFormat : uint32_t {
GTA5 = 0x01000000UL, /**< GTA V Photo Format */
RDR2 = 0x04000000UL, /**< RDR 2 Photo Format */
GTA5 = RAGEPHOTO_FORMAT_GTA5, /**< GTA V Photo Format */
RDR2 = RAGEPHOTO_FORMAT_RDR2, /**< RDR 2 Photo Format */
};
/** Sign Initials */
enum SignInitials : uint32_t {
SIGTA5 = 0xE47AB81CUL, /**< GTA V Sign Initial */
SIRDR2 = 0x00FEEB1EUL, /**< RDR 2 Sign Initial */
SIGTA5 = RAGEPHOTO_SIGNINITIAL_GTA5, /**< GTA V Sign Initial */
SIRDR2 = RAGEPHOTO_SIGNINITIAL_RDR2, /**< RDR 2 Sign Initial */
};
photo() {
instance = ragephoto_open();
@ -346,7 +346,7 @@ private:
ragephoto_t instance;
};
} // c_abi
} // c_wrapper
} // ragephoto
#endif // __cplusplus

View File

@ -28,7 +28,6 @@
#include <cstdio>
namespace ragephoto {
namespace cxx_abi {
/**
* \brief GTA V and RDR 2 Photo Parser.
@ -38,67 +37,67 @@ class LIBRAGEPHOTO_CXX_PUBLIC photo
public:
/** Default sizes */
enum DefaultSize : uint32_t {
DEFAULT_GTA5_PHOTOBUFFER = 524288UL, /**< GTA V default Photo Buffer Size */
DEFAULT_RDR2_PHOTOBUFFER = 1048576UL, /**< RDR 2 default Photo Buffer Size */
DEFAULT_DESCBUFFER = 256UL, /**< Default Description Buffer Size */
DEFAULT_JSONBUFFER = 3072UL, /**< Default JSON Buffer Size */
DEFAULT_TITLBUFFER = 256UL, /**< Default Title Buffer Size */
GTA5_HEADERSIZE = 264UL, /**< GTA V Header Size */
RDR2_HEADERSIZE = 272UL, /**< RDR 2 Header Size */
DEFAULT_GTA5_PHOTOBUFFER = RAGEPHOTO_DEFAULT_GTA5_PHOTOBUFFER, /**< GTA V default Photo Buffer Size */
DEFAULT_RDR2_PHOTOBUFFER = RAGEPHOTO_DEFAULT_RDR2_PHOTOBUFFER, /**< RDR 2 default Photo Buffer Size */
DEFAULT_DESCBUFFER = RAGEPHOTO_DEFAULT_DESCBUFFER, /**< Default Description Buffer Size */
DEFAULT_JSONBUFFER = RAGEPHOTO_DEFAULT_JSONBUFFER, /**< Default JSON Buffer Size */
DEFAULT_TITLBUFFER = RAGEPHOTO_DEFAULT_TITLBUFFER, /**< Default Title Buffer Size */
GTA5_HEADERSIZE = RAGEPHOTO_GTA5_HEADERSIZE, /**< GTA V Header Size */
RDR2_HEADERSIZE = RAGEPHOTO_RDR2_HEADERSIZE, /**< RDR 2 Header Size */
};
/** Parsing and set errors */
enum Error : int32_t {
DescBufferTight = 39L, /**< Description Buffer is too tight */
DescMallocError = 31L, /**< Description Buffer can't be allocated */
DescReadError = 32L, /**< Description can't be read successfully */
HeaderBufferTight = 35L, /**< Header Buffer is too tight */
HeaderMallocError = 4L, /**< Header Buffer can't be allocated */
IncompatibleFormat = 2L, /**< Format is incompatible */
IncompleteChecksum = 7L, /**< Header checksum is incomplete */
IncompleteDescBuffer = 30L, /**< Description Buffer Size is incomplete */
IncompleteDescMarker = 28L, /**< Description Marker is incomplete */
IncompleteDescOffset = 11L, /**< Description Offset is incomplete */
IncompleteEOF = 8L, /**< End Of File Offset is incomplete */
IncompleteHeader = 3L, /**< Header is incomplete */
IncompleteJendMarker = 33L, /**< JEND Marker is incomplete */
IncompleteJpegMarker = 12L, /**< JPEG Marker is incomplete */
IncompleteJsonBuffer = 20L, /**< JSON Buffer Size is incomplete */
IncompleteJsonMarker = 18L, /**< JSON Marker incomplete */
IncompleteJsonOffset = 9L, /**< JSON Offset incomplete */
IncompletePhotoBuffer = 14L, /**< Photo Buffer Size is incomplete */
IncompletePhotoSize = 15L, /**< Photo Size is incomplete */
IncompleteTitleBuffer = 25L, /**< Title Buffer Size is incomplete */
IncompleteTitleMarker = 23L, /**< Title Marker is incomplete */
IncompleteTitleOffset = 10L, /**< Title Offset is incomplete */
IncorrectDescMarker = 29L, /**< Description Marker is incorrect */
IncorrectJendMarker = 34L, /**< JEND Marker is incorrect */
IncorrectJpegMarker = 13L, /**< JPEG Marker is incorrect */
IncorrectJsonMarker = 19L, /**< JSON Marker is incorrect */
IncorrectTitleMarker = 24L, /**< Title Marker is incorrect */
JsonBufferTight = 37L, /**< JSON Buffer is too tight */
JsonMallocError = 21L, /**< JSON Buffer can't be allocated */
JsonReadError = 22L, /**< JSON can't be read successfully */
NoError = 255L, /**< Finished without errors */
NoFormatIdentifier = 1L, /**< No format detected, empty file */
PhotoBufferTight = 36L, /**< Photo Buffer is too tight */
PhotoMallocError = 16L, /**< Photo Buffer can't be allocated */
PhotoReadError = 17L, /**< Photo can't be read */
TitleBufferTight = 38L, /**< Title Buffer is too tight */
TitleMallocError = 26L, /**< Title Buffer can't be allocated */
TitleReadError = 27L, /**< Title can't be read */
UnicodeInitError = 5L, /**< Failed to initialise Unicode decoder */
UnicodeHeaderError = 6L, /**< Header can't be encoded/decoded successfully */
Uninitialised = 0L, /**< Uninitialised, file access failed */
DescBufferTight = RAGEPHOTO_ERROR_DESCBUFFERTIGHT, /**< Description Buffer is too tight */
DescMallocError = RAGEPHOTO_ERROR_DESCMALLOCERROR, /**< Description Buffer can't be allocated */
DescReadError = RAGEPHOTO_ERROR_DESCREADERROR, /**< Description can't be read successfully */
HeaderBufferTight = RAGEPHOTO_ERROR_HEADERBUFFERTIGHT, /**< Header Buffer is too tight */
HeaderMallocError = RAGEPHOTO_ERROR_HEADERMALLOCERROR, /**< Header Buffer can't be allocated */
IncompatibleFormat = RAGEPHOTO_ERROR_INCOMPATIBLEFORMAT, /**< Format is incompatible */
IncompleteChecksum = RAGEPHOTO_ERROR_INCOMPLETECHECKSUM, /**< Header checksum is incomplete */
IncompleteDescBuffer = RAGEPHOTO_ERROR_INCOMPLETEDESCBUFFER, /**< Description Buffer Size is incomplete */
IncompleteDescMarker = RAGEPHOTO_ERROR_INCOMPLETEDESCMARKER, /**< Description Marker is incomplete */
IncompleteDescOffset = RAGEPHOTO_ERROR_INCOMPLETEDESCOFFSET, /**< Description Offset is incomplete */
IncompleteEOF = RAGEPHOTO_ERROR_INCOMPLETEEOF, /**< End Of File Offset is incomplete */
IncompleteHeader = RAGEPHOTO_ERROR_INCOMPLETEHEADER, /**< Header is incomplete */
IncompleteJendMarker = RAGEPHOTO_ERROR_INCOMPLETEJENDMARKER, /**< JEND Marker is incomplete */
IncompleteJpegMarker = RAGEPHOTO_ERROR_INCOMPLETEJPEGMARKER, /**< JPEG Marker is incomplete */
IncompleteJsonBuffer = RAGEPHOTO_ERROR_INCOMPLETEJSONBUFFER, /**< JSON Buffer Size is incomplete */
IncompleteJsonMarker = RAGEPHOTO_ERROR_INCOMPLETEJSONMARKER, /**< JSON Marker incomplete */
IncompleteJsonOffset = RAGEPHOTO_ERROR_INCOMPLETEJSONOFFSET, /**< JSON Offset incomplete */
IncompletePhotoBuffer = RAGEPHOTO_ERROR_INCOMPLETEPHOTOBUFFER, /**< Photo Buffer Size is incomplete */
IncompletePhotoSize = RAGEPHOTO_ERROR_INCOMPLETEPHOTOSIZE, /**< Photo Size is incomplete */
IncompleteTitleBuffer = RAGEPHOTO_ERROR_INCOMPLETETITLEBUFFER, /**< Title Buffer Size is incomplete */
IncompleteTitleMarker = RAGEPHOTO_ERROR_INCOMPLETETITLEMARKER, /**< Title Marker is incomplete */
IncompleteTitleOffset = RAGEPHOTO_ERROR_INCOMPLETETITLEOFFSET, /**< Title Offset is incomplete */
IncorrectDescMarker = RAGEPHOTO_ERROR_INCORRECTDESCMARKER, /**< Description Marker is incorrect */
IncorrectJendMarker = RAGEPHOTO_ERROR_INCORRECTJENDMARKER, /**< JEND Marker is incorrect */
IncorrectJpegMarker = RAGEPHOTO_ERROR_INCORRECTJPEGMARKER, /**< JPEG Marker is incorrect */
IncorrectJsonMarker = RAGEPHOTO_ERROR_INCORRECTJSONMARKER, /**< JSON Marker is incorrect */
IncorrectTitleMarker = RAGEPHOTO_ERROR_INCORRECTTITLEMARKER, /**< Title Marker is incorrect */
JsonBufferTight = RAGEPHOTO_ERROR_JSONBUFFERTIGHT, /**< JSON Buffer is too tight */
JsonMallocError = RAGEPHOTO_ERROR_JSONMALLOCERROR, /**< JSON Buffer can't be allocated */
JsonReadError = RAGEPHOTO_ERROR_JSONREADERROR, /**< JSON can't be read successfully */
NoError = RAGEPHOTO_ERROR_NOERROR, /**< Finished without errors */
NoFormatIdentifier = RAGEPHOTO_ERROR_NOFORMATIDENTIFIER, /**< No format detected, empty file */
PhotoBufferTight = RAGEPHOTO_ERROR_PHOTOBUFFERTIGHT, /**< Photo Buffer is too tight */
PhotoMallocError = RAGEPHOTO_ERROR_PHOTOMALLOCERROR, /**< Photo Buffer can't be allocated */
PhotoReadError = RAGEPHOTO_ERROR_PHOTOREADERROR, /**< Photo can't be read */
TitleBufferTight = RAGEPHOTO_ERROR_TITLEBUFFERTIGHT, /**< Title Buffer is too tight */
TitleMallocError = RAGEPHOTO_ERROR_TITLEMALLOCERROR, /**< Title Buffer can't be allocated */
TitleReadError = RAGEPHOTO_ERROR_TITLEREADERROR, /**< Title can't be read */
UnicodeInitError = RAGEPHOTO_ERROR_UNICODEINITERROR, /**< Failed to initialise Unicode decoder */
UnicodeHeaderError = RAGEPHOTO_ERROR_UNICODEHEADERERROR, /**< Header can't be encoded/decoded successfully */
Uninitialised = RAGEPHOTO_ERROR_UNINITIALISED, /**< Uninitialised, file access failed */
};
/** Photo Formats */
enum PhotoFormat : uint32_t {
GTA5 = 0x01000000UL, /**< GTA V Photo Format */
RDR2 = 0x04000000UL, /**< RDR 2 Photo Format */
GTA5 = RAGEPHOTO_FORMAT_GTA5, /**< GTA V Photo Format */
RDR2 = RAGEPHOTO_FORMAT_RDR2, /**< RDR 2 Photo Format */
};
/** Sign Initials */
enum SignInitials : uint32_t {
SIGTA5 = 0xE47AB81CUL, /**< GTA V Sign Initial */
SIRDR2 = 0x00FEEB1EUL, /**< RDR 2 Sign Initial */
SIGTA5 = RAGEPHOTO_SIGNINITIAL_GTA5, /**< GTA V Sign Initial */
SIRDR2 = RAGEPHOTO_SIGNINITIAL_RDR2, /**< RDR 2 Sign Initial */
};
photo();
~photo();
@ -190,7 +189,6 @@ private:
RagePhotoFormatParser *m_parser;
};
} // cxx_abi
} // ragephoto
#endif // __cplusplus