diff options
Diffstat (limited to '')
-rw-r--r-- | include/user/ini_file_processor.h | 198 | ||||
-rw-r--r-- | nids/360/SceIniFileProcessor.yml | 30 |
2 files changed, 228 insertions, 0 deletions
diff --git a/include/user/ini_file_processor.h b/include/user/ini_file_processor.h new file mode 100644 index 0000000..77ee0b1 --- /dev/null +++ b/include/user/ini_file_processor.h @@ -0,0 +1,198 @@ +#ifndef _DOLCESDK_PSP2_INI_FILE_PROCESSOR_H_ +#define _DOLCESDK_PSP2_INI_FILE_PROCESSOR_H_ + +#define SCE_INI_FILE_PROCESSOR_ERROR_MODE 0x80840002 +#define SCE_INI_FILE_PROCESSOR_ERROR_EOF 0x80840005 +#define SCE_INI_FILE_PROCESSOR_ERROR_READ_ONLY 0x80840007 +#define SCE_INI_FILE_PROCESSOR_ERROR_FILE_NOT_FOUND 0x80840009 +#define SCE_INI_FILE_PROCESSOR_ERROR_KEY_NOT_FOUND 0x80840010 + +#define SCE_INI_FILE_PROCESSOR_PARSE_COMPLETED 0x00840001 + +#ifdef __cplusplus + +#include <cstddef> + +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 char array + * + * @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 char array + * + * @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 openFile(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 createFile(const char* path, const char* mode, int unk); + + /** + * Close file + * + * @return 0 on success, < 0 on error. + */ + int closeFile(); + + /** + * Clean 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 outValueBuf + * + * @return 0 on success, < 0 on error. + */ + int get(const char* key, char* val, size_t size); + + /** + * Parse key and corresponding value, one key per call until eof + * + * @param[out] key - buffer to store key string + * @param[out] val - buffer to store value string + * @param[in] size - size of output buffers + * + * @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 *context; +}; + +} // namespace Ini +} // namespace sce + +#endif // __cplusplus + +#endif // _DOLCESDK_PSP2_INI_FILE_PROCESSOR_H_ diff --git a/nids/360/SceIniFileProcessor.yml b/nids/360/SceIniFileProcessor.yml new file mode 100644 index 0000000..4620450 --- /dev/null +++ b/nids/360/SceIniFileProcessor.yml @@ -0,0 +1,30 @@ +modules: + SceIniFileProcessor: + nid: 0x999CFBD5 + libraries: + SceIniFileProcessor: + nid: 0x5EE28724 + functions: + _ZN3sce3Ini13InitParameterC1Ev: 0x14146AF5 + _ZN3sce3Ini13InitParameterC2Ev: 0x9F8FC03F + _ZN3sce3Ini16IniFileProcessor10createFileEPKcS3_i: 0xFD8DE2F8 + _ZN3sce3Ini16IniFileProcessor10initializeEPKNS0_13InitParameterE: 0x0975D396 + _ZN3sce3Ini16IniFileProcessor11deserializeEPKcj: 0xB785FE67 + _ZN3sce3Ini16IniFileProcessor17terminateForErrorEv: 0x48A6BDCB + _ZN3sce3Ini16IniFileProcessor3addEPKcS3_: 0x703E1BAE + _ZN3sce3Ini16IniFileProcessor3delEPKc: 0xC2B3A41C + _ZN3sce3Ini16IniFileProcessor3getEPKcPcj: 0x7F22CED1 + _ZN3sce3Ini16IniFileProcessor3setEPKcS3_: 0xDBC5F9A8 + _ZN3sce3Ini16IniFileProcessor4sizeEv: 0xD7648B61 + _ZN3sce3Ini16IniFileProcessor5parseEPcS2_j: 0xD5C7B3EE + _ZN3sce3Ini16IniFileProcessor5resetEv: 0xB48C756B + _ZN3sce3Ini16IniFileProcessor7cleanupEv: 0xA51840C7 + _ZN3sce3Ini16IniFileProcessor8openFileEPKcS3_i: 0x51B791E8 + _ZN3sce3Ini16IniFileProcessor9closeFileEv: 0xEDFAD6B4 + _ZN3sce3Ini16IniFileProcessor9serializeEPPKcPj: 0x109B4E83 + _ZN3sce3Ini16IniFileProcessor9terminateEv: 0x2BEF7391 + _ZN3sce3Ini16IniFileProcessorC1Ev: 0xA0F71A2C + _ZN3sce3Ini16IniFileProcessorC2Ev: 0x746B194F + _ZN3sce3Ini16IniFileProcessorD0Ev: 0x9F57E743 + _ZN3sce3Ini16IniFileProcessorD1Ev: 0xACEB88BD + _ZN3sce3Ini16IniFileProcessorD2Ev: 0x7169CE28 |