libragephoto Version: 0.6.0
Loading...
Searching...
No Matches
RagePhotoTypedefs.h
1/*****************************************************************************
2* libragephoto RAGE Photo Parser
3* Copyright (C) 2021-2024 Syping
4*
5* Redistribution and use in source and binary forms, with or without modification,
6* are permitted provided that the following conditions are met:
7*
8* 1. Redistributions of source code must retain the above copyright notice,
9* this list of conditions and the following disclaimer.
10*
11* 2. Redistributions in binary form must reproduce the above copyright notice,
12* this list of conditions and the following disclaimer in the documentation
13* and/or other materials provided with the distribution.
14*
15* This software is provided as-is, no warranties are given to you, we are not
16* responsible for anything with use of the software, you are self responsible.
17*****************************************************************************/
18
19#ifndef RAGEPHOTOTYPEDEFS_H
20#define RAGEPHOTOTYPEDEFS_H
21
22#include <stdbool.h>
23#include <stddef.h>
24#include <stdint.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif // __cplusplus
29
31typedef struct RagePhotoData {
32 char* jpeg;
34 char* json;
35 char* header;
36 char* title;
37 int32_t error;
38 uint32_t descBuffer;
39 uint32_t descOffset;
40 uint32_t endOfFile;
41 uint32_t headerSum;
42 uint32_t headerSum2;
43 uint32_t jpegBuffer;
44 uint32_t jpegSize;
45 uint32_t jsonBuffer;
46 uint32_t jsonOffset;
47 uint32_t photoFormat;
48 uint32_t titlBuffer;
49 uint32_t titlOffset;
51
53typedef bool (*ragephoto_loadfunc_t)(RagePhotoData*, const char*, size_t);
54
56typedef bool (*ragephoto_savefunc_t)(RagePhotoData*, char*, uint32_t);
57
59typedef bool (*ragephoto_savepfunc_t)(RagePhotoData*, char**, uint32_t);
60
62typedef size_t (*ragephoto_saveszfunc_t)(RagePhotoData*, uint32_t);
63
65typedef struct RagePhotoFormatParser {
66 uint32_t photoFormat;
67 ragephoto_loadfunc_t funcLoad;
68 ragephoto_savefunc_t funcSave;
69 ragephoto_savepfunc_t funcSavep;
70 ragephoto_saveszfunc_t funcSaveSz;
72
80
82typedef enum RagePhotoLibraryFlag {
83 RAGEPHOTO_FLAG_LEGACY_NULL_RETURN = 1 << 0
84} RagePhotoLibraryFlag;
85
86/* RagePhoto default sizes */
87#define RAGEPHOTO_DEFAULT_GTA5_PHOTOBUFFER UINT32_C(524288)
88#define RAGEPHOTO_DEFAULT_RDR2_PHOTOBUFFER UINT32_C(1048576)
89#define RAGEPHOTO_DEFAULT_DESCBUFFER UINT32_C(256)
90#define RAGEPHOTO_DEFAULT_JSONBUFFER UINT32_C(3072)
91#define RAGEPHOTO_DEFAULT_TITLBUFFER UINT32_C(256)
92#define RAGEPHOTO_GTA5_HEADERSIZE UINT32_C(264)
93#define RAGEPHOTO_RDR2_HEADERSIZE UINT32_C(272)
95/* RagePhoto error codes */
96#define RAGEPHOTO_ERROR_DESCBUFFERTIGHT INT32_C(39)
97#define RAGEPHOTO_ERROR_DESCMALLOCERROR INT32_C(31)
98#define RAGEPHOTO_ERROR_DESCREADERROR INT32_C(32)
99#define RAGEPHOTO_ERROR_HEADERBUFFERTIGHT INT32_C(35)
100#define RAGEPHOTO_ERROR_HEADERMALLOCERROR INT32_C(4)
101#define RAGEPHOTO_ERROR_INCOMPATIBLEFORMAT INT32_C(2)
102#define RAGEPHOTO_ERROR_INCOMPLETECHECKSUM INT32_C(7)
103#define RAGEPHOTO_ERROR_INCOMPLETEDESCBUFFER INT32_C(30)
104#define RAGEPHOTO_ERROR_INCOMPLETEDESCMARKER INT32_C(28)
105#define RAGEPHOTO_ERROR_INCOMPLETEDESCOFFSET INT32_C(11)
106#define RAGEPHOTO_ERROR_INCOMPLETEEOF INT32_C(8)
107#define RAGEPHOTO_ERROR_INCOMPLETEHEADER INT32_C(3)
108#define RAGEPHOTO_ERROR_INCOMPLETEJENDMARKER INT32_C(33)
109#define RAGEPHOTO_ERROR_INCOMPLETEJPEGMARKER INT32_C(12)
110#define RAGEPHOTO_ERROR_INCOMPLETEJSONBUFFER INT32_C(20)
111#define RAGEPHOTO_ERROR_INCOMPLETEJSONMARKER INT32_C(18)
112#define RAGEPHOTO_ERROR_INCOMPLETEJSONOFFSET INT32_C(9)
113#define RAGEPHOTO_ERROR_INCOMPLETEPHOTOBUFFER INT32_C(14)
114#define RAGEPHOTO_ERROR_INCOMPLETEPHOTOSIZE INT32_C(15)
115#define RAGEPHOTO_ERROR_INCOMPLETETITLEBUFFER INT32_C(25)
116#define RAGEPHOTO_ERROR_INCOMPLETETITLEMARKER INT32_C(23)
117#define RAGEPHOTO_ERROR_INCOMPLETETITLEOFFSET INT32_C(10)
118#define RAGEPHOTO_ERROR_INCORRECTDESCMARKER INT32_C(29)
119#define RAGEPHOTO_ERROR_INCORRECTJENDMARKER INT32_C(34)
120#define RAGEPHOTO_ERROR_INCORRECTJPEGMARKER INT32_C(13)
121#define RAGEPHOTO_ERROR_INCORRECTJSONMARKER INT32_C(19)
122#define RAGEPHOTO_ERROR_INCORRECTTITLEMARKER INT32_C(24)
123#define RAGEPHOTO_ERROR_JSONBUFFERTIGHT INT32_C(37)
124#define RAGEPHOTO_ERROR_JSONMALLOCERROR INT32_C(21)
125#define RAGEPHOTO_ERROR_JSONREADERROR INT32_C(22)
126#define RAGEPHOTO_ERROR_NOERROR INT32_C(255)
127#define RAGEPHOTO_ERROR_NOFORMATIDENTIFIER INT32_C(1)
128#define RAGEPHOTO_ERROR_PHOTOBUFFERTIGHT INT32_C(36)
129#define RAGEPHOTO_ERROR_PHOTOMALLOCERROR INT32_C(16)
130#define RAGEPHOTO_ERROR_PHOTOREADERROR INT32_C(17)
131#define RAGEPHOTO_ERROR_TITLEBUFFERTIGHT INT32_C(38)
132#define RAGEPHOTO_ERROR_TITLEMALLOCERROR INT32_C(26)
133#define RAGEPHOTO_ERROR_TITLEREADERROR INT32_C(27)
134#define RAGEPHOTO_ERROR_UNICODEINITERROR INT32_C(5)
135#define RAGEPHOTO_ERROR_UNICODEHEADERERROR INT32_C(6)
136#define RAGEPHOTO_ERROR_UNINITIALISED INT32_C(0)
138/* RagePhoto formats */
139#define RAGEPHOTO_FORMAT_GTA5 UINT32_C(0x01000000)
140#define RAGEPHOTO_FORMAT_RDR2 UINT32_C(0x04000000)
142/* RagePhoto sign initials */
143#define RAGEPHOTO_SIGNINITIAL_GTA5 UINT32_C(0xE47AB81C)
144#define RAGEPHOTO_SIGNINITIAL_RDR2 UINT32_C(0x00FEEB1E)
146#ifdef __cplusplus
147}
148#endif // __cplusplus
149
150#endif // RAGEPHOTOTYPEDEFS_H
Definition RagePhotoTypedefs.h:31
char * title
Definition RagePhotoTypedefs.h:36
uint32_t photoFormat
Definition RagePhotoTypedefs.h:47
uint32_t jpegSize
Definition RagePhotoTypedefs.h:44
uint32_t endOfFile
Definition RagePhotoTypedefs.h:40
uint32_t jsonOffset
Definition RagePhotoTypedefs.h:46
uint32_t titlOffset
Definition RagePhotoTypedefs.h:49
char * json
Definition RagePhotoTypedefs.h:34
uint32_t descOffset
Definition RagePhotoTypedefs.h:39
uint32_t headerSum2
Definition RagePhotoTypedefs.h:42
char * jpeg
Definition RagePhotoTypedefs.h:32
uint32_t descBuffer
Definition RagePhotoTypedefs.h:38
uint32_t titlBuffer
Definition RagePhotoTypedefs.h:48
uint32_t headerSum
Definition RagePhotoTypedefs.h:41
char * header
Definition RagePhotoTypedefs.h:35
char * description
Definition RagePhotoTypedefs.h:33
uint32_t jsonBuffer
Definition RagePhotoTypedefs.h:45
uint32_t jpegBuffer
Definition RagePhotoTypedefs.h:43
int32_t error
Definition RagePhotoTypedefs.h:37
Definition RagePhotoTypedefs.h:65
ragephoto_saveszfunc_t funcSaveSz
Definition RagePhotoTypedefs.h:70
uint32_t photoFormat
Definition RagePhotoTypedefs.h:66
ragephoto_loadfunc_t funcLoad
Definition RagePhotoTypedefs.h:67
ragephoto_savepfunc_t funcSavep
Definition RagePhotoTypedefs.h:69
ragephoto_savefunc_t funcSave
Definition RagePhotoTypedefs.h:68
Definition RagePhotoTypedefs.h:76
RagePhotoFormatParser * parser
Definition RagePhotoTypedefs.h:78
RagePhotoData * data
Definition RagePhotoTypedefs.h:77