libragephoto Version: 0.5.0
Loading...
Searching...
No Matches
RagePhotoTypedefs.h
1/*****************************************************************************
2* libragephoto RAGE Photo Parser
3* Copyright (C) 2021-2023 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
74typedef struct RagePhotoInstance {
78
79/* RagePhoto default sizes */
80#define RAGEPHOTO_DEFAULT_GTA5_PHOTOBUFFER 524288UL
81#define RAGEPHOTO_DEFAULT_RDR2_PHOTOBUFFER 1048576UL
82#define RAGEPHOTO_DEFAULT_DESCBUFFER 256UL
83#define RAGEPHOTO_DEFAULT_JSONBUFFER 3072UL
84#define RAGEPHOTO_DEFAULT_TITLBUFFER 256UL
85#define RAGEPHOTO_GTA5_HEADERSIZE 264UL
86#define RAGEPHOTO_RDR2_HEADERSIZE 272UL
88/* RagePhoto error codes */
89#define RAGEPHOTO_ERROR_DESCBUFFERTIGHT 39L
90#define RAGEPHOTO_ERROR_DESCMALLOCERROR 31L
91#define RAGEPHOTO_ERROR_DESCREADERROR 32L
92#define RAGEPHOTO_ERROR_HEADERBUFFERTIGHT 35L
93#define RAGEPHOTO_ERROR_HEADERMALLOCERROR 4L
94#define RAGEPHOTO_ERROR_INCOMPATIBLEFORMAT 2L
95#define RAGEPHOTO_ERROR_INCOMPLETECHECKSUM 7L
96#define RAGEPHOTO_ERROR_INCOMPLETEDESCBUFFER 30L
97#define RAGEPHOTO_ERROR_INCOMPLETEDESCMARKER 28L
98#define RAGEPHOTO_ERROR_INCOMPLETEDESCOFFSET 11L
99#define RAGEPHOTO_ERROR_INCOMPLETEEOF 8L
100#define RAGEPHOTO_ERROR_INCOMPLETEHEADER 3L
101#define RAGEPHOTO_ERROR_INCOMPLETEJENDMARKER 33L
102#define RAGEPHOTO_ERROR_INCOMPLETEJPEGMARKER 12L
103#define RAGEPHOTO_ERROR_INCOMPLETEJSONBUFFER 20L
104#define RAGEPHOTO_ERROR_INCOMPLETEJSONMARKER 18L
105#define RAGEPHOTO_ERROR_INCOMPLETEJSONOFFSET 9L
106#define RAGEPHOTO_ERROR_INCOMPLETEPHOTOBUFFER 14L
107#define RAGEPHOTO_ERROR_INCOMPLETEPHOTOSIZE 15L
108#define RAGEPHOTO_ERROR_INCOMPLETETITLEBUFFER 25L
109#define RAGEPHOTO_ERROR_INCOMPLETETITLEMARKER 23L
110#define RAGEPHOTO_ERROR_INCOMPLETETITLEOFFSET 10L
111#define RAGEPHOTO_ERROR_INCORRECTDESCMARKER 29L
112#define RAGEPHOTO_ERROR_INCORRECTJENDMARKER 34L
113#define RAGEPHOTO_ERROR_INCORRECTJPEGMARKER 13L
114#define RAGEPHOTO_ERROR_INCORRECTJSONMARKER 19L
115#define RAGEPHOTO_ERROR_INCORRECTTITLEMARKER 24L
116#define RAGEPHOTO_ERROR_JSONBUFFERTIGHT 37L
117#define RAGEPHOTO_ERROR_JSONMALLOCERROR 21L
118#define RAGEPHOTO_ERROR_JSONREADERROR 22L
119#define RAGEPHOTO_ERROR_NOERROR 255L
120#define RAGEPHOTO_ERROR_NOFORMATIDENTIFIER 1L
121#define RAGEPHOTO_ERROR_PHOTOBUFFERTIGHT 36L
122#define RAGEPHOTO_ERROR_PHOTOMALLOCERROR 16L
123#define RAGEPHOTO_ERROR_PHOTOREADERROR 17L
124#define RAGEPHOTO_ERROR_TITLEBUFFERTIGHT 38L
125#define RAGEPHOTO_ERROR_TITLEMALLOCERROR 26L
126#define RAGEPHOTO_ERROR_TITLEREADERROR 27L
127#define RAGEPHOTO_ERROR_UNICODEINITERROR 5L
128#define RAGEPHOTO_ERROR_UNICODEHEADERERROR 6L
129#define RAGEPHOTO_ERROR_UNINITIALISED 0L
131/* RagePhoto formats */
132#define RAGEPHOTO_FORMAT_GTA5 0x01000000UL
133#define RAGEPHOTO_FORMAT_RDR2 0x04000000UL
135/* RagePhoto sign initials */
136#define RAGEPHOTO_SIGNINITIAL_GTA5 0xE47AB81CUL
137#define RAGEPHOTO_SIGNINITIAL_RDR2 0x00FEEB1EUL
139#ifdef __cplusplus
140}
141#endif // __cplusplus
142
143#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:74
RagePhotoFormatParser * parser
Definition RagePhotoTypedefs.h:76
RagePhotoData * data
Definition RagePhotoTypedefs.h:75