mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2026-08-28 04:36:39 -05:00
WUPS 0.6, add support for config and storage
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
* by Alex Chadwick
|
||||
*
|
||||
* Copyright (C) 2014, Alex Chadwick
|
||||
* Modified by Maschell, 2018
|
||||
* Modified by Maschell, 2018-2021
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -23,12 +23,12 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WUPS_H_
|
||||
#define WUPS_H_
|
||||
#pragma once
|
||||
|
||||
#include "wups/common.h"
|
||||
#include "wups/meta.h"
|
||||
#include "wups/function_patching.h"
|
||||
#include "wups/config.h"
|
||||
#include "wups/hooks.h"
|
||||
|
||||
#endif /* WUPS_WUPS_H_ */
|
||||
#include "wups/config_imports.h"
|
||||
#include "wups/storage.h"
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WUPS_COMMON_DEF_H_
|
||||
#define WUPS_COMMON_DEF_H_
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@@ -48,5 +47,3 @@ extern "C" {
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WUPS_COMMON_DEF_H_ */
|
||||
|
||||
55
include/wups/config.h
Normal file
55
include/wups/config.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2021 Maschell
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define WUPS_CONFIG_BUTTON_NONE 0
|
||||
#define WUPS_CONFIG_BUTTON_LEFT (1<<0)
|
||||
#define WUPS_CONFIG_BUTTON_RIGHT (1<<1)
|
||||
#define WUPS_CONFIG_BUTTON_UP (1<<2)
|
||||
#define WUPS_CONFIG_BUTTON_DOWN (1<<3)
|
||||
#define WUPS_CONFIG_BUTTON_A (1<<4)
|
||||
#define WUPS_CONFIG_BUTTON_B (1<<5)
|
||||
#define WUPS_CONFIG_BUTTON_ZL (1<<6)
|
||||
#define WUPS_CONFIG_BUTTON_ZR (1<<7)
|
||||
#define WUPS_CONFIG_BUTTON_L (1<<8)
|
||||
#define WUPS_CONFIG_BUTTON_R (1<<9)
|
||||
typedef int32_t WUPSConfigButtons;
|
||||
|
||||
typedef struct {
|
||||
int32_t (*getCurrentValueDisplay)(void *context, char *out_buf, int32_t out_size);
|
||||
|
||||
int32_t (*getCurrentValueSelectedDisplay)(void *context, char *out_buf, int32_t out_size);
|
||||
|
||||
void (*onSelected)(void *context, bool isSelected);
|
||||
|
||||
void (*restoreDefault)(void *context);
|
||||
|
||||
bool (*isMovementAllowed)(void *context);
|
||||
|
||||
bool (*callCallback)(void *context);
|
||||
|
||||
void (*onButtonPressed)(void *context, WUPSConfigButtons button);
|
||||
|
||||
void (*onDelete)(void *context);
|
||||
} WUPSConfigCallbacks_t;
|
||||
|
||||
typedef uint32_t WUPSConfigItemHandle;
|
||||
typedef uint32_t WUPSConfigHandle;
|
||||
typedef uint32_t WUPSConfigCategoryHandle;
|
||||
40
include/wups/config/WUPSConfigItemBoolean.h
Normal file
40
include/wups/config/WUPSConfigItemBoolean.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <wups.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ConfigItemBoolean {
|
||||
WUPSConfigItemHandle handle;
|
||||
bool defaultValue;
|
||||
bool value;
|
||||
char trueValue[32];
|
||||
char falseValue[32];
|
||||
void *callback;
|
||||
} ConfigItemBoolean;
|
||||
|
||||
typedef void (*BooleanValueChangedCallback)(ConfigItemBoolean *, bool);
|
||||
|
||||
bool WUPSConfigItemBoolean_AddToCategory(WUPSConfigCategoryHandle cat, const char *configID, const char *displayName, bool defaultValue, BooleanValueChangedCallback callback);
|
||||
bool WUPSConfigItemBoolean_AddToCategoryEx(WUPSConfigCategoryHandle cat, const char *configID, const char *displayName, bool defaultValue, BooleanValueChangedCallback callback, const char *trueValue,
|
||||
const char *falseValue);
|
||||
|
||||
#define WUPSConfigItemBoolean_AddToCategoryHandled(__config__, __cat__, __configID__, __displayName__, __defaultValue__, __callback__) \
|
||||
do { \
|
||||
if (!WUPSConfigItemBoolean_AddToCategory(__cat__, __configID__, __displayName__, __defaultValue__, __callback__)) { \
|
||||
WUPSConfig_Destroy(__config__); \
|
||||
return 0; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define WUPSConfigItemBoolean_AddToCategoryHandledEx(__config__, __cat__, __configID__, __displayName__, __defaultValue__, __callback__, __trueValue__, __falseValue__) \
|
||||
do { \
|
||||
if (!WUPSConfigItemBoolean_AddToCategoryEx(__cat__, __configID__, __displayName__, __defaultValue__, __callback__, __trueValue__, __falseValue__)) { \
|
||||
WUPSConfig_Destroy(__config__); \
|
||||
return 0; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
33
include/wups/config/WUPSConfigItemIntegerRange.h
Normal file
33
include/wups/config/WUPSConfigItemIntegerRange.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <wups.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ConfigItemIntegerRange {
|
||||
WUPSConfigItemHandle handle;
|
||||
int defaultValue;
|
||||
int value;
|
||||
int minValue;
|
||||
int maxValue;
|
||||
void *callback;
|
||||
} ConfigItemIntegerRange;
|
||||
|
||||
typedef void (*IntegerRangeValueChangedCallback)(ConfigItemIntegerRange *, int32_t);
|
||||
|
||||
bool
|
||||
WUPSConfigItemIntegerRange_AddToCategory(WUPSConfigCategoryHandle cat, const char *configID, const char *displayName,
|
||||
int32_t defaultValue, int32_t minValue, int32_t maxValue,
|
||||
IntegerRangeValueChangedCallback callback);
|
||||
|
||||
#define WUPSConfigItemIntegerRange_AddToCategoryHandled(__config__, __cat__, __configID__, __displayName__, __defaultValue__, __minValue__, __maxValue__, __callback__) \
|
||||
do { \
|
||||
if (!WUPSConfigItemIntegerRange_AddToCategory(__cat__, __configID__, __displayName__, __defaultValue__, __minValue__, __maxValue__, __callback__)) { \
|
||||
WUPSConfig_Destroy(__config__); \
|
||||
return 0; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
37
include/wups/config/WUPSConfigItemMultipleValues.h
Normal file
37
include/wups/config/WUPSConfigItemMultipleValues.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <wups.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef struct ConfigItemMultipleValuesPair {
|
||||
uint32_t value;
|
||||
char *valueName;
|
||||
} ConfigItemMultipleValuesPair;
|
||||
|
||||
typedef struct ConfigItemMultipleValues {
|
||||
char *configID;
|
||||
WUPSConfigItemHandle handle;
|
||||
int32_t defaultValueIndex;
|
||||
int32_t valueIndex;
|
||||
void *callback;
|
||||
ConfigItemMultipleValuesPair *values;
|
||||
int valueCount;
|
||||
} ConfigItemMultipleValues;
|
||||
|
||||
typedef void (*MultipleValuesChangedCallback)(ConfigItemMultipleValues *, uint32_t);
|
||||
|
||||
bool WUPSConfigItemMultipleValues_AddToCategory(WUPSConfigCategoryHandle cat, const char *configID, const char *displayName, int defaultValueIndex, ConfigItemMultipleValuesPair *possibleValues,
|
||||
int pairCount, MultipleValuesChangedCallback callback);
|
||||
|
||||
#define WUPSConfigItemMultipleValues_AddToCategoryHandled(__config__, __cat__, __configID__, __displayName__, __defaultValueIndex__, __possibleValues__, __pairCount__, __callback__) \
|
||||
do { \
|
||||
if(!WUPSConfigItemMultipleValues_AddToCategory(__cat__, __configID__, __displayName__, __defaultValueIndex__, __possibleValues__, __pairCount__, __callback__)) { \
|
||||
WUPSConfig_Destroy(__config__); \
|
||||
return 0; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
53
include/wups/config_imports.h
Normal file
53
include/wups/config_imports.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#pragma once
|
||||
|
||||
#include "stdint.h"
|
||||
#include "config.h"
|
||||
|
||||
extern "C" int32_t WUPSConfigItem_Create(WUPSConfigItemHandle *out, const char *configID, const char *displayName, WUPSConfigCallbacks_t callbacks, void *context);
|
||||
|
||||
extern "C" int32_t WUPSConfig_Destroy(WUPSConfigHandle handle);
|
||||
|
||||
extern "C" int32_t WUPSConfigItem_SetDisplayName(WUPSConfigItemHandle handle, const char *displayName);
|
||||
|
||||
extern "C" int32_t WUPSConfigItem_GetDisplayName(WUPSConfigItemHandle handle, char *out_buf, int32_t out_len);
|
||||
|
||||
extern "C" int32_t WUPSConfigItem_SetConfigID(WUPSConfigItemHandle handle, const char *configID);
|
||||
|
||||
extern "C" int32_t WUPSConfigItem_GetConfigID(WUPSConfigItemHandle handle, char *out_buf, int32_t out);
|
||||
|
||||
extern "C" int32_t WUPSConfig_Create(WUPSConfigHandle *out, const char *name);
|
||||
|
||||
extern "C" int32_t WUPSConfigCategory_Destroy(WUPSConfigCategoryHandle handle);
|
||||
|
||||
extern "C" int32_t WUPSConfig_GetName(WUPSConfigHandle handle, char *out_buf, int32_t out_len);
|
||||
|
||||
extern "C" int32_t WUPSConfig_AddCategoryByName(WUPSConfigHandle handle, const char *categoryName, WUPSConfigCategoryHandle *out);
|
||||
|
||||
extern "C" int32_t WUPSConfig_AddCategory(WUPSConfigHandle handle, WUPSConfigCategoryHandle category);
|
||||
|
||||
/*
|
||||
extern "C" int32_t WUPSConfig_GetCategoryCount(WUPSConfigHandle handle, int32_t *category_count);
|
||||
|
||||
extern "C" int32_t WUPSConfig_GetCategories(WUPSConfigHandle handle, WUPSConfigCategoryHandle *categories_out, int32_t categories_out_size);
|
||||
*/
|
||||
|
||||
extern "C" int32_t WUPSConfigCategory_Create(WUPSConfigCategoryHandle *out, const char *name);
|
||||
|
||||
extern "C" int32_t WUPSConfigCategory_GetName(WUPSConfigCategoryHandle handle, char *out_buf, int32_t out_len);
|
||||
|
||||
extern "C" int32_t WUPSConfigCategory_AddItem(WUPSConfigCategoryHandle handle, WUPSConfigItemHandle item_Handle);
|
||||
|
||||
#define WUPSConfig_AddCategoryByNameHandled(__config__, __categoryName__, __out__) \
|
||||
do { \
|
||||
if (WUPSConfig_AddCategoryByName(__config__, __categoryName__, __out__) < 0) { \
|
||||
WUPSConfig_Destroy(__config__); \
|
||||
return 0;\
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
#define WUPSConfig_CreateHandled(__config__, __configName__) \
|
||||
do { \
|
||||
if (WUPSConfig_Create(__config__, __configName__) < 0) { \
|
||||
return 0; \
|
||||
} \
|
||||
} while(0)
|
||||
@@ -23,8 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WUPS_FUNCTION_PATCHING_DEF_H_
|
||||
#define WUPS_FUNCTION_PATCHING_DEF_H_
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
@@ -100,8 +99,7 @@ typedef enum wups_loader_library_type_t {
|
||||
WUPS_LOADER_LIBRARY_VPADBASE,
|
||||
WUPS_LOADER_LIBRARY_ZLIB125,
|
||||
WUPS_LOADER_LIBRARY_OTHER,
|
||||
}
|
||||
wups_loader_library_type_t;
|
||||
} wups_loader_library_type_t;
|
||||
|
||||
typedef enum wups_loader_entry_type_t {
|
||||
WUPS_LOADER_ENTRY_FUNCTION,
|
||||
@@ -143,11 +141,11 @@ typedef struct wups_loader_entry_t {
|
||||
} _function;
|
||||
} wups_loader_entry_t;
|
||||
|
||||
#define WUPS_MUST_REPLACE_PHYSICAL(x, physical_address, virtual_address) WUPS_MUST_REPLACE_PHYSICAL_FOR_PROCESS(x, physical_address, virtual_address, WUPS_FP_TARGET_PROCESS_GAME_AND_MENU);
|
||||
#define WUPS_MUST_REPLACE_PHYSICAL_FOR_PROCESS(x, physical_address, virtual_address, targetProcess) WUPS_MUST_REPLACE_EX(physical_address, virtual_address, real_ ## x, WUPS_LOADER_LIBRARY_OTHER, my_ ## x, x, targetProcess);
|
||||
#define WUPS_MUST_REPLACE_PHYSICAL(x, physical_address, virtual_address) WUPS_MUST_REPLACE_PHYSICAL_FOR_PROCESS(x, physical_address, virtual_address, WUPS_FP_TARGET_PROCESS_GAME_AND_MENU)
|
||||
#define WUPS_MUST_REPLACE_PHYSICAL_FOR_PROCESS(x, physical_address, virtual_address, targetProcess) WUPS_MUST_REPLACE_EX(physical_address, virtual_address, real_ ## x, WUPS_LOADER_LIBRARY_OTHER, my_ ## x, x, targetProcess)
|
||||
|
||||
#define WUPS_MUST_REPLACE(x, lib, function_name) WUPS_MUST_REPLACE_FOR_PROCESS(x, lib, function_name, WUPS_FP_TARGET_PROCESS_GAME_AND_MENU);
|
||||
#define WUPS_MUST_REPLACE_FOR_PROCESS(x, lib, function_name, targetProcess) WUPS_MUST_REPLACE_EX(NULL, NULL, real_ ## x, lib, my_ ## x, function_name, targetProcess);
|
||||
#define WUPS_MUST_REPLACE(x, lib, function_name) WUPS_MUST_REPLACE_FOR_PROCESS(x, lib, function_name, WUPS_FP_TARGET_PROCESS_GAME_AND_MENU)
|
||||
#define WUPS_MUST_REPLACE_FOR_PROCESS(x, lib, function_name, targetProcess) WUPS_MUST_REPLACE_EX(NULL, NULL, real_ ## x, lib, my_ ## x, function_name, targetProcess)
|
||||
|
||||
#define WUPS_MUST_REPLACE_EX(pAddress, vAddress, original_func, rpl_type, replace_func, replace_function_name, process) \
|
||||
extern const wups_loader_entry_t wups_load_ ## replace_func \
|
||||
@@ -172,6 +170,4 @@ typedef struct wups_loader_entry_t {
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WUPS_FUNCTION_PATCHING_DEF_H_ */
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
/****************************************************************************
|
||||
* Copyright (C) 2018 Maschell
|
||||
* Copyright (C) 2018-2021 Maschell
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -15,8 +15,7 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef WUPS_HOOKS_DEF_H_
|
||||
#define WUPS_HOOKS_DEF_H_
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
|
||||
@@ -24,7 +23,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WUPS_HOOK_EX(type_def,original_func) \
|
||||
#define WUPS_HOOK_EX(type_def, original_func) \
|
||||
extern const wups_loader_hook_t wups_hooks_ ## original_func WUPS_SECTION("hooks"); \
|
||||
const wups_loader_hook_t wups_hooks_ ## original_func = { \
|
||||
.type = type_def, \
|
||||
@@ -43,6 +42,11 @@ typedef enum wups_loader_hook_type_t {
|
||||
WUPS_LOADER_HOOK_INIT_WUT_SOCKETS,
|
||||
WUPS_LOADER_HOOK_FINI_WUT_SOCKETS,
|
||||
|
||||
WUPS_LOADER_HOOK_GET_CONFIG,
|
||||
WUPS_LOADER_HOOK_CONFIG_CLOSED,
|
||||
|
||||
WUPS_LOADER_HOOK_INIT_STORAGE, /* Only for internal usage */
|
||||
|
||||
WUPS_LOADER_HOOK_INIT_PLUGIN, /* Called when exiting the plugin loader */
|
||||
WUPS_LOADER_HOOK_DEINIT_PLUGIN, /* Called when re-entering the plugin loader */
|
||||
WUPS_LOADER_HOOK_APPLICATION_STARTS, /* Called when an application gets started */
|
||||
@@ -51,7 +55,6 @@ typedef enum wups_loader_hook_type_t {
|
||||
WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND, /* Called when an foreground is acquired */
|
||||
WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT, /* Called when an application wants to exit */
|
||||
WUPS_LOADER_HOOK_APPLICATION_ENDS, /* Called when an application ends */
|
||||
WUPS_LOADER_HOOK_VSYNC, /* Called when an application calls GX2WaitForVsync (most times each frame) */
|
||||
} wups_loader_hook_type_t;
|
||||
|
||||
typedef struct wups_loader_hook_t {
|
||||
@@ -88,7 +91,7 @@ typedef struct wups_loader_hook_t {
|
||||
void on_acquired_foreground(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND,on_acquired_foreground); \
|
||||
void on_acquired_foreground(void)
|
||||
|
||||
|
||||
#define ON_APPLICATION_REQUESTS_EXIT() \
|
||||
void on_app_requests_exit(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT,on_app_requests_exit); \
|
||||
@@ -99,14 +102,25 @@ typedef struct wups_loader_hook_t {
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLICATION_ENDS,on_app_ending); \
|
||||
void on_app_ending(void)
|
||||
|
||||
#define ON_VYSNC() \
|
||||
void on_vsync(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_VSYNC,on_vsync); \
|
||||
void on_vsync(void)
|
||||
#define WUPS_GET_CONFIG() \
|
||||
WUPSConfigHandle on_get_wups_config(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_GET_CONFIG,on_get_wups_config); \
|
||||
WUPSConfigHandle on_get_wups_config(void)
|
||||
|
||||
#define WUPS_CONFIG_CLOSED() \
|
||||
void on_wups_config_closed(void);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_CONFIG_CLOSED,on_wups_config_closed); \
|
||||
void on_wups_config_closed(void)
|
||||
|
||||
#define WUPS_USE_STORAGE() \
|
||||
void init_storage(wups_loader_init_storage_args_t);\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_STORAGE,init_storage); \
|
||||
void init_storage(wups_loader_init_storage_args_t args){ \
|
||||
WUPS_InitStorage(args);\
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define __EXTERN_C_MACRO extern "C"
|
||||
#define __EXTERN_C_MACRO extern "C"
|
||||
#else
|
||||
#define __EXTERN_C_MACRO
|
||||
#endif
|
||||
@@ -121,7 +135,7 @@ typedef struct wups_loader_hook_t {
|
||||
void on_fini_wut_malloc(){ \
|
||||
__fini_wut_malloc(); \
|
||||
} \
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_MALLOC,on_fini_wut_malloc); \
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_MALLOC,on_fini_wut_malloc)
|
||||
|
||||
#define WUPS_USE_WUT_DEVOPTAB() \
|
||||
__EXTERN_C_MACRO void __init_wut_devoptab(); \
|
||||
@@ -133,7 +147,7 @@ typedef struct wups_loader_hook_t {
|
||||
void on_fini_wut_devoptab(){ \
|
||||
__fini_wut_devoptab(); \
|
||||
}\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB,on_fini_wut_devoptab);
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_DEVOPTAB,on_fini_wut_devoptab)
|
||||
|
||||
#define WUPS_USE_WUT_NEWLIB() \
|
||||
__EXTERN_C_MACRO void __init_wut_newlib(); \
|
||||
@@ -145,8 +159,8 @@ typedef struct wups_loader_hook_t {
|
||||
void on_fini_wut_newlib(){ \
|
||||
__fini_wut_newlib(); \
|
||||
}\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_NEWLIB,on_fini_wut_newlib);
|
||||
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_NEWLIB,on_fini_wut_newlib)
|
||||
|
||||
#define WUPS_USE_WUT_STDCPP() \
|
||||
__EXTERN_C_MACRO void __init_wut_stdcpp(); \
|
||||
void on_init_wut_stdcpp(){ \
|
||||
@@ -157,7 +171,7 @@ typedef struct wups_loader_hook_t {
|
||||
void on_fini_wut_stdcpp(){ \
|
||||
__fini_wut_stdcpp(); \
|
||||
}\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_STDCPP,on_fini_wut_stdcpp);
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_STDCPP,on_fini_wut_stdcpp)
|
||||
|
||||
#define WUPS_USE_WUT_SOCKETS() \
|
||||
__EXTERN_C_MACRO void __attribute__((weak)) __init_wut_socket(); \
|
||||
@@ -169,10 +183,8 @@ typedef struct wups_loader_hook_t {
|
||||
void on_fini_wut_sockets(){ \
|
||||
if (&__fini_wut_socket) __fini_wut_socket(); \
|
||||
}\
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_SOCKETS,on_fini_wut_sockets);
|
||||
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WUT_SOCKETS,on_fini_wut_sockets)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WUPS_WUPS_H_ */
|
||||
|
||||
@@ -23,8 +23,7 @@
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef WUPS_META_DEF_H_
|
||||
#define WUPS_META_DEF_H_
|
||||
#pragma once
|
||||
|
||||
#include "common.h"
|
||||
#include "hooks.h"
|
||||
@@ -33,16 +32,21 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define WUPS_PLUGIN_NAME(x) WUPS_META(name, x); WUPS_META(wups, "0.5"); WUPS_USE_WUT_MALLOC() WUPS_USE_WUT_SOCKETS() WUPS_USE_WUT_NEWLIB() WUPS_USE_WUT_STDCPP() WUPS_META(buildtimestamp, __DATE__ " " __TIME__);
|
||||
#define WUPS_PLUGIN_AUTHOR(x) WUPS_META(author, x)
|
||||
#define WUPS_PLUGIN_VERSION(x) WUPS_META(version, x)
|
||||
#define WUPS_PLUGIN_LICENSE(x) WUPS_META(license, x)
|
||||
#define WUPS_PLUGIN_DESCRIPTION(x) WUPS_META(description, x)
|
||||
#define WUPS_PLUGIN_ID(x) WUPS_META(id, x)
|
||||
#define WUPS_PLUGIN_CONFIG_REVISION(x) WUPS_META(config_revision, #x)
|
||||
#define WUPS_PLUGIN_NAME(x) WUPS_META(name, x); \
|
||||
WUPS_META(wups, "0.6"); \
|
||||
WUPS_USE_WUT_MALLOC(); \
|
||||
WUPS_USE_WUT_SOCKETS(); \
|
||||
WUPS_USE_WUT_NEWLIB(); \
|
||||
WUPS_USE_WUT_STDCPP(); \
|
||||
WUPS_META(buildtimestamp, __DATE__ " " __TIME__);
|
||||
|
||||
#define WUPS_PLUGIN_AUTHOR(x) WUPS_META(author, x)
|
||||
#define WUPS_PLUGIN_VERSION(x) WUPS_META(version, x)
|
||||
#define WUPS_PLUGIN_LICENSE(x) WUPS_META(license, x)
|
||||
#define WUPS_PLUGIN_DESCRIPTION(x) WUPS_META(description, x)
|
||||
#define WUPS_PLUGIN_ID(x) WUPS_META(id, x)
|
||||
#define WUPS_PLUGIN_CONFIG_REVISION(x) WUPS_META(config_revision, #x)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* WUPS_COMMON_DEF_H_ */
|
||||
|
||||
79
include/wups/storage.h
Normal file
79
include/wups/storage.h
Normal file
@@ -0,0 +1,79 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum wups_storage_type_t_ {
|
||||
WUPS_STORAGE_TYPE_INVALID,
|
||||
WUPS_STORAGE_TYPE_STRING,
|
||||
WUPS_STORAGE_TYPE_INT,
|
||||
WUPS_STORAGE_TYPE_ITEM,
|
||||
} wups_storage_type_t;
|
||||
|
||||
enum {
|
||||
WUPS_STORAGE_ERROR_SUCCESS = 0,
|
||||
WUPS_STORAGE_ERROR_NOT_OPENED = -1,
|
||||
WUPS_STORAGE_ERROR_ALREADY_OPENED = -2,
|
||||
WUPS_STORAGE_ERROR_INVALID_ARGS = -3,
|
||||
WUPS_STORAGE_ERROR_NOT_FOUND = -4,
|
||||
WUPS_STORAGE_ERROR_NOT_INITIALIZED = -5,
|
||||
WUPS_STORAGE_ERROR_INVALID_BACKEND_PARAMS = -6,
|
||||
WUPS_STORAGE_ERROR_INVALID_JSON = -7,
|
||||
WUPS_STORAGE_ERROR_IO = -8,
|
||||
WUPS_STORAGE_ERROR_B64_DECODE_FAILED = -9,
|
||||
WUPS_STORAGE_ERROR_BUFFER_TOO_SMALL = -10,
|
||||
};
|
||||
|
||||
typedef struct wups_storage_item_t_ {
|
||||
char *key;
|
||||
void *data;
|
||||
uint32_t data_size;
|
||||
uint32_t pending_delete;
|
||||
wups_storage_type_t type;
|
||||
} wups_storage_item_t;
|
||||
|
||||
typedef int32_t (*OpenStorageFunction)(const char *plugin_id, wups_storage_item_t *items);
|
||||
typedef int32_t (*CloseStorageFunction)(const char *plugin_id, wups_storage_item_t *items);
|
||||
|
||||
typedef struct wups_loader_init_storage_args_t_ {
|
||||
OpenStorageFunction open_storage_ptr;
|
||||
CloseStorageFunction close_storage_ptr;
|
||||
const char *plugin_id;
|
||||
} wups_loader_init_storage_args_t;
|
||||
|
||||
/* called by backend */
|
||||
void WUPS_InitStorage(wups_loader_init_storage_args_t args);
|
||||
|
||||
/* opens storage for reading and writing */
|
||||
int32_t WUPS_OpenStorage(void);
|
||||
|
||||
/* closes storage and saves changes */
|
||||
int32_t WUPS_CloseStorage(void);
|
||||
|
||||
/* deletes key from storage */
|
||||
int32_t WUPS_DeleteItem(wups_storage_item_t *parent, const char *key);
|
||||
|
||||
/* returns the size of key on success, or an error code */
|
||||
// TODO do we need this? what about binary data?
|
||||
// int32_t WUPS_GetSize(const char* key);
|
||||
|
||||
int32_t WUPS_CreateSubItem(wups_storage_item_t *parent, const char *key, wups_storage_item_t **outItem);
|
||||
int32_t WUPS_GetSubItem(wups_storage_item_t *parent, const char *key, wups_storage_item_t **outItem);
|
||||
|
||||
int32_t WUPS_StoreString(wups_storage_item_t *parent, const char *key, const char *string);
|
||||
int32_t WUPS_StoreBool(wups_storage_item_t *parent, const char *key, bool value);
|
||||
int32_t WUPS_StoreInt(wups_storage_item_t *parent, const char *key, int32_t value);
|
||||
int32_t WUPS_StoreBinary(wups_storage_item_t *parent, const char *key, const void *data, uint32_t size);
|
||||
|
||||
int32_t WUPS_GetString(wups_storage_item_t *parent, const char *key, char *outString, uint32_t maxSize);
|
||||
int32_t WUPS_GetBool(wups_storage_item_t *parent, const char *key, bool *outBool);
|
||||
int32_t WUPS_GetInt(wups_storage_item_t *parent, const char *key, int32_t *outInt);
|
||||
int32_t WUPS_GetBinary(wups_storage_item_t *parent, const char *key, void *outData, uint32_t maxSize);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user