psl1ght
A free SDK for Sony's PS3 console
save.h
1 #ifndef __LV2_SYSUTIL_SAVE_H__
2 #define __LV2_SYSUTIL_SAVE_H__
3 
4 #include <ppu-types.h>
5 #include <time.h>
6 
7 /* Maximum string/array sizes */
8 #define SYS_SAVE_MAX_DIRECTORY_NAME 32
9 #define SYS_SAVE_MAX_FILE_NAME 13
10 #define SYS_SAVE_DIRECTORY_LIST_MAX 2048
11 #define SYS_SAVE_CUSTOM_ERROR_MESSAGE_MAX 256
12 #define SYS_SAVE_MAX_LIST_PARAMETER 8
13 #define SYS_SAVE_MAX_TITLE 128
14 #define SYS_SAVE_MAX_SUBTITLE 128
15 #define SYS_SAVE_MAX_DETAIL 1024
16 #define SYS_SAVE_MAX_PROTECTED_FILE_ID 16
17 
18 /* Current version value for the save data */
19 #define SYS_SAVE_CURRENT_VERSION 0
20 
21 /* Result values for the callback */
22 #define SYS_SAVE_CALLBACK_RESULT_DONE 1
23 #define SYS_SAVE_CALLBACK_RESULT_CONTINUE 0
24 #define SYS_SAVE_CALLBACK_RESULT_NO_SPACE_LEFT -1
25 #define SYS_SAVE_CALLBACK_RESULT_ERROR -2
26 #define SYS_SAVE_CALLBACK_RESULT_CORRUPTED -3
27 #define SYS_SAVE_CALLBACK_RESULT_NOT_FOUND -4
28 #define SYS_SAVE_CALLBACK_RESULT_ERROR_CUSTOM -5
29 
30 /* Flags for the binding information */
31 #define SYS_SAVE_BIND_NO_ERROR 0x00
32 #define SYS_SAVE_BIND_ANOTHER_CONSOLE 0x01
33 #define SYS_SAVE_BIND_ANOTHER_DISC 0x02
34 #define SYS_SAVE_BIND_ANOTHER_APP 0x04
35 #define SYS_SAVE_BIND_NO_USER_INFO 0x08
36 #define SYS_SAVE_BIND_OTHER_USER 0x10
37 
38 /* Return values from the API calls */
39 #define SYS_SAVE_RETURN_DONE 0
40 #define SYS_SAVE_RETURN_CANCELED 1
41 #define SYS_SAVE_RETURN_ERROR 0x8002b400
42 
43 #define SYS_SAVE_RETURN_ERROR_CALLBACK (SYS_SAVE_RETURN_ERROR | 1)
44 #define SYS_SAVE_RETURN_ERROR_HDD_ERROR (SYS_SAVE_RETURN_ERROR | 2)
45 #define SYS_SAVE_RETURN_ERROR_INTERNAL (SYS_SAVE_RETURN_ERROR | 3)
46 #define SYS_SAVE_RETURN_ERROR_INVALID_ARG (SYS_SAVE_RETURN_ERROR | 4)
47 #define SYS_SAVE_RETURN_ERROR_NO_SPACE_LEFT (SYS_SAVE_RETURN_ERROR | 5)
48 #define SYS_SAVE_RETURN_ERROR_CORRUPTED (SYS_SAVE_RETURN_ERROR | 6)
49 #define SYS_SAVE_RETURN_ERROR_FAILED (SYS_SAVE_RETURN_ERROR | 7)
50 #define SYS_SAVE_RETURN_ERROR_ALREADY_IN_USE (SYS_SAVE_RETURN_ERROR | 8)
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
56 typedef enum {
57  SYS_SAVE_SORT_TYPE_TIMESTAMP = 0,
58  SYS_SAVE_SORT_TYPE_TITLE,
59 } sysSaveSortType;
60 
61 typedef enum {
62  SYS_SAVE_SORT_ORDER_DESCENDING = 0,
63  SYS_SAVE_SORT_ORDER_ASCENDING,
64 } sysSaveSortOrder;
65 
66 typedef enum {
67  SYS_SAVE_FOCUS_POSITION_DIRECTORY_NAME = 0,
68  SYS_SAVE_FOCUS_POSITION_LIST_HEAD,
69  SYS_SAVE_FOCUS_POSITION_LIST_TAIL,
70  SYS_SAVE_FOCUS_POSITION_LATEST,
71  SYS_SAVE_FOCUS_POSITION_OLDEST,
72  SYS_SAVE_FOCUS_POSITION_NEW_SAVE,
73 } sysSaveFocusPosition;
74 
75 typedef enum {
76  SYS_SAVE_NEW_SAVE_POSITION_TOP = 0,
77  SYS_SAVE_NEW_SAVE_POSITION_BOTTOM,
78 } sysSaveNewSavePosition;
79 
80 
81 typedef enum {
82  SYS_SAVE_FILETYPE_PROTECTED_FILE = 0,
83  SYS_SAVE_FILETYPE_STANDARD_FILE,
84  SYS_SAVE_FILETYPE_CONTENT_ICON0,
85  SYS_SAVE_FILETYPE_CONTENT_ICON1,
86  SYS_SAVE_FILETYPE_CONTENT_PIC1,
87  SYS_SAVE_FILETYPE_CONTENT_SND0,
88 } sysSaveFileType;
89 
90 typedef enum {
91  SYS_SAVE_RECREATE_MODE_OVERWRITE_CORRUPTED = 0,
92  SYS_SAVE_RECREATE_MODE_OVERWRITE_NOT_CORRUPTED,
93  SYS_SAVE_RECREATE_MODE_DELETE
94 } sysSaveRecreateMode;
95 
96 typedef enum {
97  SYS_SAVE_FILE_OPERATION_READ = 0,
98  SYS_SAVE_FILE_OPERATION_WRITE,
99  SYS_SAVE_FILE_OPERATION_DELETE,
100 } sysSaveFileOperation;
101 
102 typedef enum {
103  SYS_SAVE_ERROR_DIALOG_NONE = 0,
104  SYS_SAVE_ERROR_DIALOG_SHOW,
105  SYS_SAVE_ERROR_DIALOG_SHOW_ONCE,
106 } sysSaveErrorDialogMode;
107 
108 typedef struct {
109  sysSaveSortType sortType;
110  sysSaveSortOrder sortOrder;
111  char *pathPrefix ATTRIBUTE_PRXPTR;
112  void *reserved ATTRIBUTE_PRXPTR;
114 
115 typedef struct {
116  u32 maxDirectories;
117  u32 maxFiles;
118  u32 reserved[6];
119  u32 bufferSize;
120  void *buffer ATTRIBUTE_PRXPTR;
122 
123 
124 typedef struct {
125  s32 result;
126  u32 incrementProgress;
127  s32 missingSpaceKB;
128  char *customErrorMessage ATTRIBUTE_PRXPTR;
129  void *user_data ATTRIBUTE_PRXPTR;
131 
132 typedef struct {
133  char directoryName[SYS_SAVE_MAX_DIRECTORY_NAME];
134  char listParameter[SYS_SAVE_MAX_LIST_PARAMETER];
135  u8 reserved[8];
137 
138 typedef struct {
139  char *title ATTRIBUTE_PRXPTR;
140  u32 iconBufferSize;
141  void *iconBuffer ATTRIBUTE_PRXPTR;
142  void *reserved ATTRIBUTE_PRXPTR;
144 
145 typedef struct {
146  sysSaveNewSavePosition position;
147  char *directoryName ATTRIBUTE_PRXPTR;
148  sysSaveNewSaveGameIcon *icon ATTRIBUTE_PRXPTR;
149  void *reserved ATTRIBUTE_PRXPTR;
151 
152 typedef struct {
153  /* total directories found */
154  u32 maxDirectories;
155  /* number of directories in directoryList */
156  u32 numDirectories;
157  /* list of directories found */
158  sysSaveDirectoryList *directoryList ATTRIBUTE_PRXPTR;
159  u8 reserved[64];
160 } sysSaveListIn;
161 
162 typedef struct {
163  /* Where to put the focus of the cursor */
164  sysSaveFocusPosition focus;
165  /* The name of the directory to focus to */
166  char *focusDirectoryName ATTRIBUTE_PRXPTR;
167  u32 numDirectories;
168  sysSaveDirectoryList *directoryList ATTRIBUTE_PRXPTR;
169  sysSaveNewSaveGame *newSaveGame ATTRIBUTE_PRXPTR;
170  void *reserved ATTRIBUTE_PRXPTR;
172 
173 typedef struct {
174  time_t atime;
175  time_t mtime;
176  time_t ctime;
177  char directoryName[SYS_SAVE_MAX_DIRECTORY_NAME];
179 
180 typedef struct {
181  char title[SYS_SAVE_MAX_TITLE];
182  char subtitle[SYS_SAVE_MAX_SUBTITLE];
183  char detail[SYS_SAVE_MAX_DETAIL];
184  u32 copyProtected;
185  u32 parentalLevel;
186  char listParameter[SYS_SAVE_MAX_LIST_PARAMETER];
187  u8 reserved[256];
189 
190 typedef struct {
191  sysSaveFileType fileType;
192  u8 reserved1[4];
193  u64 fileSize;
194  time_t atime;
195  time_t mtime;
196  time_t ctime;
197  char filename[SYS_SAVE_MAX_FILE_NAME];
198  u8 reserved2[3];
200 
201 typedef struct {
202  s32 freeSpaceKB;
203  u32 isNew;
204  sysSaveDirectoryStatus directoryStatus;
205  sysSaveSystemFileParam getParam;
206  u32 bindingInformation;
207  /* Size of the save data */
208  s32 sizeKB;
209  /* Size of system file */
210  s32 systemSizeKB;
211  /* total files in the save data */
212  u32 totalFiles;
213  /* Number of files in the the file list */
214  u32 numFiles;
215  sysSaveFileStatus *fileList ATTRIBUTE_PRXPTR;
216  u8 reserved[64];
218 
219 typedef struct {
220  sysSaveSystemFileParam *setParam ATTRIBUTE_PRXPTR;
221  sysSaveRecreateMode recreateMode;
222  void *reserved ATTRIBUTE_PRXPTR;
224 
225 typedef struct {
226  u32 previousOperationResultSize;
227  u8 reserved[64];
228 } sysSaveFileIn;
229 
230 typedef struct {
231  sysSaveFileOperation fileOperation;
232  void *reserved ATTRIBUTE_PRXPTR;
233  sysSaveFileType fileType;
234  u8 protectedFileID[SYS_SAVE_MAX_PROTECTED_FILE_ID];
235  char *filename ATTRIBUTE_PRXPTR;
236  u32 offset;
237  u32 size;
238  u32 bufferSize;
239  void *buffer ATTRIBUTE_PRXPTR;
241 
242 typedef struct {
243  char *directoryName ATTRIBUTE_PRXPTR;
244  sysSaveNewSaveGameIcon *icon ATTRIBUTE_PRXPTR;
245  void *reserved ATTRIBUTE_PRXPTR;
247 
248 typedef void (* sysSaveListCallback) (sysSaveCallbackResult *result,
249  sysSaveListIn *in, sysSaveListOut *out);
250 
251 typedef void (* sysSaveStatusCallback) (sysSaveCallbackResult *result,
253 
254 typedef void (* sysSaveFileCallback) (sysSaveCallbackResult *result,
255  sysSaveFileIn *in, sysSaveFileOut *out);
256 
257 typedef void (* sysSaveFixedCallback) (sysSaveCallbackResult *result,
258  sysSaveListIn *in, sysSaveFixedOut *out);
259 
260 
261 s32 sysSaveListLoad2 (u32 version,
262  sysSaveListSettings *listSettings,
263  sysSaveBufferSettings *bufferSettings,
264  sysSaveListCallback listCb,
265  sysSaveStatusCallback statusCb,
266  sysSaveFileCallback fileCb,
267  sys_mem_container_t container,
268  void *user_data);
269 
270 s32 sysSaveListSave2 (u32 version,
271  sysSaveListSettings *listSettings,
272  sysSaveBufferSettings *bufferSettings,
273  sysSaveListCallback listCb,
274  sysSaveStatusCallback statusCb,
275  sysSaveFileCallback fileCb,
276  sys_mem_container_t container,
277  void *user_data);
278 
279 s32 sysSaveListAutoLoad (u32 version,
280  sysSaveErrorDialogMode errorDialogMode,
281  sysSaveListSettings *listSettings,
282  sysSaveBufferSettings *bufferSettings,
283  sysSaveFixedCallback fixedCb,
284  sysSaveStatusCallback statusCb,
285  sysSaveFileCallback fileCb,
286  sys_mem_container_t container,
287  void *user_data);
288 
289 s32 sysSaveListAutoSave (u32 version,
290  sysSaveErrorDialogMode errorDialogMode,
291  sysSaveListSettings *listSettings,
292  sysSaveBufferSettings *bufferSettings,
293  sysSaveFixedCallback fixedCb,
294  sysSaveStatusCallback statusCb,
295  sysSaveFileCallback fileCb,
296  sys_mem_container_t container,
297  void *user_data);
298 
299 s32 sysSaveFixedLoad2 (u32 version,
300  sysSaveListSettings *listSettings,
301  sysSaveBufferSettings *bufferSettings,
302  sysSaveFixedCallback fixedCb,
303  sysSaveStatusCallback statusCb,
304  sysSaveFileCallback fileCb,
305  sys_mem_container_t container,
306  void *user_data);
307 
308 s32 sysSaveFixedSave2 (u32 version,
309  sysSaveListSettings *listSettings,
310  sysSaveBufferSettings *bufferSettings,
311  sysSaveFixedCallback fixedCb,
312  sysSaveStatusCallback statusCb,
313  sysSaveFileCallback fileCb,
314  sys_mem_container_t container,
315  void *user_data);
316 
317 s32 sysSaveAutoLoad2 (s32 version,
318  const char *directoryName,
319  sysSaveErrorDialogMode errorDialogMode,
320  sysSaveBufferSettings *bufferSettings,
321  sysSaveStatusCallback statusCb,
322  sysSaveFileCallback fileCb,
323  sys_mem_container_t container,
324  void *user_data);
325 
326 s32 sysSaveAutoSave2 (s32 version,
327  const char *directoryName,
328  sysSaveErrorDialogMode errorDialogMode,
329  sysSaveBufferSettings *bufferSettings,
330  sysSaveStatusCallback statusCb,
331  sysSaveFileCallback fileCb,
332  sys_mem_container_t container,
333  void *user_data);
334 
335 s32 sysSaveDelete2(sys_mem_container_t container);
336 
337 #ifdef __cplusplus
338  }
339 #endif
340 
341 #endif
Definition: save.h:219
Definition: save.h:124
Definition: save.h:138
Definition: save.h:190
Definition: save.h:132
Definition: save.h:180
Definition: save.h:201
Definition: save.h:115
Definition: save.h:152
Definition: save.h:145
Definition: save.h:108
Definition: save.h:242
Definition: save.h:230
Definition: save.h:225
Definition: save.h:173
Definition: save.h:162