1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
|
/*
Vita Development Suite Libraries
*/
#ifndef _VDSUITE_USER_INI_FILE_PROCESSOR_H
#define _VDSUITE_USER_INI_FILE_PROCESSOR_H
#define SCE_INI_FILE_PROCESSOR_ERROR_MODE ((int)0x80840002)
#define SCE_INI_FILE_PROCESSOR_ERROR_EOF ((int)0x80840005)
#define SCE_INI_FILE_PROCESSOR_ERROR_READ_ONLY ((int)0x80840007)
#define SCE_INI_FILE_PROCESSOR_ERROR_FILE_NOT_FOUND ((int)0x80840009)
#define SCE_INI_FILE_PROCESSOR_ERROR_KEY_NOT_FOUND ((int)0x80840010)
#define SCE_INI_FILE_PROCESSOR_PARSE_COMPLETED 0x00840001
#ifdef __cplusplus
#include <stddef.h>
namespace sce {
namespace Ini {
class MemAllocator {
public:
typedef void* (*Allocator)(size_t size);
typedef void (*Deallocator)(void* ptr);
Allocator allocate;
Deallocator deallocate;
};
class InitParameter {
public:
InitParameter();
int unk_0x0; // size or mode? usually 0, seen: 0x1000, 0x2000
int unk_0x4; // size or mode? usually 0, seen: 0x1000, 0x2000
MemAllocator* allocator; // can be NULL
int unk_0xc;
};
class IniFileProcessor {
public:
IniFileProcessor();
virtual ~IniFileProcessor();
/**
* Initialize INI file processor to work with file
*
* @param[in] param - ::InitParameter
*
* @return 0 on success, < 0 on error.
*/
int initialize(const InitParameter* param);
/**
* Terminate INI file processor
*
* @return 0 on success, < 0 on error.
*/
int terminate();
/**
* Terminate INI file processor when file could not be opened
*
* @return 0 on success, < 0 on error.
*/
int terminateForError();
/**
* Get INI as a string. The returned buffer is not null-terminated.
*
* @param[out] ini - memory where INI data is stored
* @param[out] size - size of the INI data
*
* @return 0 on success, < 0 on error.
*/
int serialize(const char** ini, size_t* size);
/**
* Process INI as a string. Size is without null-terminator.
*
* @param[in] ini - memory where INI data is stored
* @param[in] size - size of the INI data
*
* @return 0 on success, < 0 on error.
*/
int deserialize(const char* ini, size_t size);
/**
* Open INI file
*
* @param[in] path - path to the INI file to open
* @param[in] mode - file open mode
* @param[in] unk - unknown, set to 0
*
* @return 0 on success, < 0 on error.
*/
int open(const char* path, const char* mode, int unk);
/**
* Create new INI file and open it. If file is already present, it will be overwritten
*
* @param[in] path - path to the INI file to open
* @param[in] mode - file open mode
* @param[in] unk - unknown, set to 0
*
* @return 0 on success, < 0 on error.
*
*/
int create(const char* path, const char* mode, int unk);
/**
* Close INI file
*
* @return 0 on success, < 0 on error.
*/
int close();
/**
* Cleanup temp files
*
* @return 0 on success, < 0 on error.
*/
int cleanup();
/**
* Get total number of keys in the opened INI file
*
* @return toatal number of keys, < 0 on error.
*/
int size();
/**
* Add key and set value for it
*
* @param[in] key - key string
* @param[in] value - value string
*
* @return 0 on success, < 0 on error.
*/
int add(const char* key, const char* value);
/**
* Delete key and corresponding value from INI file
*
* @param[in] key - key string
*
* @return 0 on success, < 0 on error.
*/
int del(const char* key);
/**
* Set value corresponding to set key
*
* @param[in] key - key string
* @param[in] value - value string
*
* @return 0 on success, < 0 on error.
*/
int set(const char* key, const char* value);
/**
* Find value corresponding to set key
*
* @param[in] key - key string
* @param[out] val - buffer to store value string if found
* @param[in] size - size of the output buffer
* @param[in] offset - offset into the value corresponding to key
*
* @return 0 on success, < 0 on error.
*/
int get(const char* key, char* val, size_t size, size_t offset);
/**
* Parse key and corresponding value, one key per call until eof
*
* @param[out] key - buffer to store key string, must have size at least 0x80
* @param[out] val - buffer to store value string
* @param[in] size - max string size that can fit in val, not including the null terminator
*
* @return 0 on success, < 0 on error.
*
*/
int parse(char* key, char* val, size_t size);
/**
* Reset parser to the beginning of the file
*
* @return 0 on success, < 0 on error.
*/
int reset();
private:
void *m_impl;
};
} // namespace Ini
} // namespace sce
#endif // __cplusplus
#endif // _VDSUITE_USER_INI_FILE_PROCESSOR_H
|