mirror of
https://github.com/wiiu-env/WiiUPluginSystem.git
synced 2024-11-15 23:35:15 +01:00
New config API
This commit is contained in:
parent
d84fd56329
commit
ba3cd165dd
2
Makefile
2
Makefile
@ -39,7 +39,7 @@ ASFLAGS := -g $(MACHDEP)
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS :=
|
||||
LIBDIRS := $(WUT_ROOT)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
|
@ -27,8 +27,17 @@
|
||||
|
||||
#include "wups/common.h"
|
||||
#include "wups/config.h"
|
||||
#include "wups/config_imports.h"
|
||||
#include "wups/config_api.h"
|
||||
#include "wups/function_patching.h"
|
||||
#include "wups/hooks.h"
|
||||
#include "wups/meta.h"
|
||||
#include "wups/storage.h"
|
||||
#ifdef DEBUG
|
||||
#include <coreinit/debug.h>
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG
|
||||
#define WUPS_DEBUG_REPORT(fmt, ...) OSReport(fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define WUPS_DEBUG_REPORT(fmt, ...)
|
||||
#endif
|
||||
|
@ -38,6 +38,26 @@
|
||||
#define WUPS_CONFIG_BUTTON_MINUS (1 << 15)
|
||||
typedef int32_t WUPSConfigButtons;
|
||||
|
||||
typedef enum WUPSConfigAPIStatus {
|
||||
WUPSCONFIG_API_RESULT_SUCCESS = 0,
|
||||
WUPSCONFIG_API_RESULT_INVALID_ARGUMENT = -0x01,
|
||||
WUPSCONFIG_API_RESULT_OUT_OF_MEMORY = -0x03,
|
||||
WUPSCONFIG_API_RESULT_NOT_FOUND = -0x06,
|
||||
WUPSCONFIG_API_RESULT_INVALID_PLUGIN_IDENTIFIER = -0x70,
|
||||
WUPSCONFIG_API_RESULT_MISSING_CALLBACK = -0x71,
|
||||
WUPSCONFIG_API_RESULT_MODULE_NOT_FOUND = -0x80,
|
||||
WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT = -0x81,
|
||||
WUPSCONFIG_API_RESULT_UNSUPPORTED_VERSION = -0x82,
|
||||
WUPSCONFIG_API_RESULT_UNSUPPORTED_COMMAND = -0x83,
|
||||
WUPSCONFIG_API_RESULT_LIB_UNINITIALIZED = -0x84,
|
||||
WUPSCONFIG_API_RESULT_UNKNOWN_ERROR = -0x100,
|
||||
} WUPSConfigAPIStatus;
|
||||
|
||||
typedef enum WUPSConfigAPICallbackStatus {
|
||||
WUPSCONFIG_API_CALLBACK_RESULT_SUCCESS = 0,
|
||||
WUPSCONFIG_API_CALLBACK_RESULT_ERROR = -1,
|
||||
} WUPSConfigAPICallbackStatus;
|
||||
|
||||
typedef struct {
|
||||
int32_t (*getCurrentValueDisplay)(void *context, char *out_buf, int32_t out_size);
|
||||
|
||||
@ -54,8 +74,101 @@ typedef struct {
|
||||
void (*onButtonPressed)(void *context, WUPSConfigButtons button);
|
||||
|
||||
void (*onDelete)(void *context);
|
||||
} WUPSConfigCallbacks_t;
|
||||
} WUPSConfigAPIItemCallbacksV1;
|
||||
|
||||
typedef uint32_t WUPSConfigItemHandle;
|
||||
typedef uint32_t WUPSConfigHandle;
|
||||
typedef uint32_t WUPSConfigCategoryHandle;
|
||||
#define WUPS_API_ITEM_OPTION_VERSION_V1 1
|
||||
typedef struct WUPSConfigAPIItemOptionsV1 {
|
||||
const char *displayName;
|
||||
void *context;
|
||||
WUPSConfigAPIItemCallbacksV1 callbacks;
|
||||
} WUPSConfigAPIItemOptionsV1;
|
||||
|
||||
typedef struct WUPSConfigAPICreateItemOptions {
|
||||
uint32_t version;
|
||||
union {
|
||||
WUPSConfigAPIItemOptionsV1 v1;
|
||||
} data;
|
||||
} WUPSConfigAPICreateItemOptions;
|
||||
|
||||
typedef uint32_t WUPSConfigAPIVersion;
|
||||
|
||||
typedef struct WUPSConfigItemHandle {
|
||||
void *handle;
|
||||
#ifdef __cplusplus
|
||||
WUPSConfigItemHandle() {
|
||||
handle = nullptr;
|
||||
}
|
||||
explicit WUPSConfigItemHandle(void *handle) : handle(handle) {}
|
||||
bool operator==(const WUPSConfigItemHandle other) const {
|
||||
return handle == other.handle;
|
||||
}
|
||||
bool operator==(const void *other) const {
|
||||
return handle == other;
|
||||
}
|
||||
#endif
|
||||
} WUPSConfigItemHandle;
|
||||
|
||||
typedef struct WUPSConfigHandle {
|
||||
void *handle;
|
||||
#ifdef __cplusplus
|
||||
WUPSConfigHandle() {
|
||||
handle = nullptr;
|
||||
}
|
||||
explicit WUPSConfigHandle(void *handle) : handle(handle) {}
|
||||
bool operator==(const WUPSConfigHandle other) const {
|
||||
return handle == other.handle;
|
||||
}
|
||||
bool operator==(const void *other) const {
|
||||
return handle == other;
|
||||
}
|
||||
#endif
|
||||
} WUPSConfigHandle;
|
||||
|
||||
typedef struct WUPSConfigCategoryHandle {
|
||||
void *handle;
|
||||
#ifdef __cplusplus
|
||||
WUPSConfigCategoryHandle() {
|
||||
handle = nullptr;
|
||||
}
|
||||
explicit WUPSConfigCategoryHandle(void *handle) : handle(handle) {}
|
||||
bool operator==(const WUPSConfigCategoryHandle other) const {
|
||||
return handle == other.handle;
|
||||
}
|
||||
bool operator==(const void *other) const {
|
||||
return handle == other;
|
||||
}
|
||||
#endif
|
||||
} WUPSConfigCategoryHandle;
|
||||
|
||||
#define WUPS_API_CATEGORY_OPTION_VERSION_V1 1
|
||||
|
||||
typedef struct WUPSConfigAPICreateCategoryOptionsV1 {
|
||||
const char *name;
|
||||
} WUPSConfigAPICreateCategoryOptionsV1;
|
||||
|
||||
typedef struct WUPSConfigAPICreateCategoryOptions {
|
||||
uint32_t version;
|
||||
union {
|
||||
WUPSConfigAPICreateCategoryOptionsV1 v1;
|
||||
} data;
|
||||
} WUPSConfigAPICreateCategoryOptions;
|
||||
|
||||
#define WUPS_API_CONFIG_API_OPTION_VERSION_V1 1
|
||||
|
||||
typedef struct WUPSConfigAPIOptionsV1 {
|
||||
const char *name;
|
||||
} WUPSConfigAPIOptionsV1;
|
||||
|
||||
typedef struct WUPSConfigAPIOptions {
|
||||
uint32_t version;
|
||||
union {
|
||||
WUPSConfigAPIOptionsV1 v1;
|
||||
} data;
|
||||
} WUPSConfigAPIOptions;
|
||||
|
||||
#define WUPS_CONFIG_API_VERSION_ERROR 0xFFFFFFFF
|
||||
|
||||
typedef struct wups_loader_init_config_args_t {
|
||||
uint32_t arg_version;
|
||||
uint32_t plugin_identifier;
|
||||
} wups_loader_init_config_args_t;
|
||||
|
@ -20,22 +20,6 @@ bool WUPSConfigItemBoolean_AddToCategory(WUPSConfigCategoryHandle cat, const cha
|
||||
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__, __configIs__, __displayName__, __defaultValue__, __callback__) \
|
||||
do { \
|
||||
if (!WUPSConfigItemBoolean_AddToCategory(__cat__, __configIs__, __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
|
@ -20,14 +20,6 @@ bool WUPSConfigItemIntegerRange_AddToCategory(WUPSConfigCategoryHandle cat, cons
|
||||
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
|
@ -1,4 +1,6 @@
|
||||
#include <wups.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <wups/config.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -24,14 +26,6 @@ typedef void (*MultipleValuesChangedCallback)(ConfigItemMultipleValues *, uint32
|
||||
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
|
@ -10,14 +10,6 @@ typedef struct ConfigItemStub {
|
||||
|
||||
bool WUPSConfigItemStub_AddToCategory(WUPSConfigCategoryHandle cat, const char *configID, const char *displayName);
|
||||
|
||||
#define WUPSConfigItemStub_AddToCategoryHandled(__config__, __cat__, __configID__, __displayName__) \
|
||||
do { \
|
||||
if (!WUPSConfigItemStub_AddToCategory(__cat__, __configID__, __displayName__)) { \
|
||||
WUPSConfig_Destroy(__config__); \
|
||||
return 0; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
52
include/wups/config_api.h
Normal file
52
include/wups/config_api.h
Normal file
@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef WUPSConfigAPICallbackStatus (*WUPSConfigAPI_MenuOpenedCallback)(WUPSConfigCategoryHandle root);
|
||||
typedef void (*WUPSConfigAPI_MenuClosedCallback)();
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_InitEx(uint32_t pluginIdentifier, WUPSConfigAPIOptions, WUPSConfigAPI_MenuOpenedCallback, WUPSConfigAPI_MenuClosedCallback);
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Init(WUPSConfigAPIOptionsV1 optionsV1, WUPSConfigAPI_MenuOpenedCallback openedCallback, WUPSConfigAPI_MenuClosedCallback closedCallback);
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_GetVersion(WUPSConfigAPIVersion *outVariable);
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Category_CreateEx(WUPSConfigAPICreateCategoryOptions options, WUPSConfigCategoryHandle *out);
|
||||
|
||||
static inline WUPSConfigAPIStatus WUPSConfigAPI_Category_Create(WUPSConfigAPICreateCategoryOptionsV1 options, WUPSConfigCategoryHandle *out) {
|
||||
WUPSConfigAPICreateCategoryOptions optionsWrapper = {
|
||||
.version = WUPS_API_CATEGORY_OPTION_VERSION_V1,
|
||||
.data = {.v1 = options},
|
||||
};
|
||||
return WUPSConfigAPI_Category_CreateEx(optionsWrapper, out);
|
||||
}
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Category_Destroy(WUPSConfigCategoryHandle handle);
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Category_AddCategory(WUPSConfigCategoryHandle parentHandle, WUPSConfigCategoryHandle categoryHandle);
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Category_AddItem(WUPSConfigCategoryHandle parentHandle, WUPSConfigItemHandle itemHandle);
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Item_CreateEx(WUPSConfigAPICreateItemOptions options, WUPSConfigItemHandle *out);
|
||||
|
||||
static inline WUPSConfigAPIStatus WUPSConfigAPI_Item_Create(WUPSConfigAPIItemOptionsV1 options, WUPSConfigItemHandle *out) {
|
||||
WUPSConfigAPICreateItemOptions itemOptions = {
|
||||
.version = WUPS_API_ITEM_OPTION_VERSION_V1,
|
||||
.data = {.v1 = options},
|
||||
};
|
||||
return WUPSConfigAPI_Item_CreateEx(itemOptions, out);
|
||||
}
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Item_Destroy(WUPSConfigItemHandle handle);
|
||||
|
||||
const char *WUPSConfigAPI_GetStatusStr(WUPSConfigAPIStatus status);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -1,63 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "config.h"
|
||||
#include "stdint.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int32_t WUPSConfigItem_Create(WUPSConfigItemHandle *out, const char *configID, const char *displayName, WUPSConfigCallbacks_t callbacks, void *context);
|
||||
|
||||
int32_t WUPSConfigItem_Destroy(WUPSConfigItemHandle handle);
|
||||
|
||||
int32_t WUPSConfig_Destroy(WUPSConfigHandle handle);
|
||||
|
||||
int32_t WUPSConfigItem_SetDisplayName(WUPSConfigItemHandle handle, const char *displayName);
|
||||
|
||||
int32_t WUPSConfigItem_GetDisplayName(WUPSConfigItemHandle handle, char *out_buf, int32_t out_len);
|
||||
|
||||
int32_t WUPSConfigItem_SetConfigID(WUPSConfigItemHandle handle, const char *configID);
|
||||
|
||||
int32_t WUPSConfigItem_GetConfigID(WUPSConfigItemHandle handle, char *out_buf, int32_t out);
|
||||
|
||||
int32_t WUPSConfig_Create(WUPSConfigHandle *out, const char *name);
|
||||
|
||||
int32_t WUPSConfigCategory_Destroy(WUPSConfigCategoryHandle handle);
|
||||
|
||||
int32_t WUPSConfig_GetName(WUPSConfigHandle handle, char *out_buf, int32_t out_len);
|
||||
|
||||
int32_t WUPSConfig_AddCategoryByName(WUPSConfigHandle handle, const char *categoryName, WUPSConfigCategoryHandle *out);
|
||||
|
||||
int32_t WUPSConfig_AddCategory(WUPSConfigHandle handle, WUPSConfigCategoryHandle category);
|
||||
|
||||
/*
|
||||
int32_t WUPSConfig_GetCategoryCount(WUPSConfigHandle handle, int32_t *category_count);
|
||||
|
||||
int32_t WUPSConfig_GetCategories(WUPSConfigHandle handle, WUPSConfigCategoryHandle *categories_out, int32_t categories_out_size);
|
||||
*/
|
||||
|
||||
int32_t WUPSConfigCategory_Create(WUPSConfigCategoryHandle *out, const char *name);
|
||||
|
||||
int32_t WUPSConfigCategory_GetName(WUPSConfigCategoryHandle handle, char *out_buf, int32_t out_len);
|
||||
|
||||
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)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -44,20 +44,21 @@ typedef enum wups_loader_hook_type_t {
|
||||
WUPS_LOADER_HOOK_INIT_WRAPPER, /* Calls __init */
|
||||
WUPS_LOADER_HOOK_FINI_WRAPPER, /* Calls __fini */
|
||||
|
||||
WUPS_LOADER_HOOK_GET_CONFIG,
|
||||
WUPS_LOADER_HOOK_CONFIG_CLOSED,
|
||||
WUPS_LOADER_HOOK_GET_CONFIG_DEPRECATED, /* Deprecated implementation */
|
||||
WUPS_LOADER_HOOK_CONFIG_CLOSED_DEPRECATED, /* Deprecated implementation */
|
||||
|
||||
WUPS_LOADER_HOOK_INIT_STORAGE_DEPRECATED, /* Deprecated implementation */
|
||||
|
||||
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 */
|
||||
WUPS_LOADER_HOOK_RELEASE_FOREGROUND, /* Called when an foreground is going to be released */
|
||||
WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND, /* Called when an foreground is acquired */
|
||||
WUPS_LOADER_HOOK_RELEASE_FOREGROUND, /* Called when a foreground is going to be released */
|
||||
WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND, /* Called when a 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_INIT_STORAGE, /* Only for internal usage */
|
||||
WUPS_LOADER_HOOK_INIT_CONFIG, /* Only for internal usage */
|
||||
} wups_loader_hook_type_t;
|
||||
|
||||
typedef struct wups_loader_hook_t {
|
||||
@ -100,15 +101,11 @@ typedef struct wups_loader_hook_t {
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLICATION_ENDS, on_app_ending); \
|
||||
void on_app_ending(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_GET_CONFIG(x) \
|
||||
static_assert(false, "Please use \"WUPSConfigAPI_Init\" inside \"INITIALIZE_PLUGIN\" to provide a callback instead");
|
||||
|
||||
#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_CONFIG_CLOSED() \
|
||||
static_assert(false, "Please use \"WUPSConfigAPI_Init\" inside \"INITIALIZE_PLUGIN\" to provide a callback instead");
|
||||
|
||||
#define WUPS_USE_STORAGE(x) \
|
||||
WUPS_META(storage_id, x); \
|
||||
@ -118,12 +115,21 @@ typedef struct wups_loader_hook_t {
|
||||
WUPS_InitStorage(args); \
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define __EXTERN_C_MACRO extern "C"
|
||||
#else
|
||||
#define __EXTERN_C_MACRO
|
||||
#endif
|
||||
|
||||
#define WUPS_INIT_CONFIG_FUNCTIONS() \
|
||||
__EXTERN_C_MACRO WUPSConfigAPIStatus WUPSConfigAPI_InitLibrary_Internal(wups_loader_init_config_args_t args); \
|
||||
void wups_init_config_functions(wups_loader_init_config_args_t); \
|
||||
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_CONFIG, wups_init_config_functions); \
|
||||
void wups_init_config_functions(wups_loader_init_config_args_t args) { \
|
||||
WUPSConfigAPI_InitLibrary_Internal(args); \
|
||||
}
|
||||
|
||||
#define WUPS_USE_WUT_MALLOC() \
|
||||
__EXTERN_C_MACRO void __init_wut_malloc(); \
|
||||
void on_init_wut_malloc() { \
|
||||
|
@ -48,6 +48,7 @@ extern "C" {
|
||||
WUPS_USE_WUT_STDCPP(); \
|
||||
WUPS___INIT_WRAPPER(); \
|
||||
WUPS___FINI_WRAPPER(); \
|
||||
WUPS_INIT_CONFIG_FUNCTIONS(); \
|
||||
WUPS_META(buildtimestamp, __DATE__ " " __TIME__); \
|
||||
extern const char wups_meta_plugin_name[] WUPS_SECTION("meta"); \
|
||||
const char wups_meta_plugin_name[] = __plugin_name; \
|
||||
|
@ -71,7 +71,7 @@ void WUPSConfigItemBoolean_onDelete(void *context) {
|
||||
extern "C" bool
|
||||
WUPSConfigItemBoolean_AddToCategoryEx(WUPSConfigCategoryHandle cat, const char *configId, const char *displayName, bool defaultValue, BooleanValueChangedCallback callback, const char *trueValue,
|
||||
const char *falseValue) {
|
||||
if (cat == 0) {
|
||||
if (cat == nullptr) {
|
||||
return false;
|
||||
}
|
||||
auto *item = (ConfigItemBoolean *) malloc(sizeof(ConfigItemBoolean));
|
||||
@ -91,7 +91,7 @@ WUPSConfigItemBoolean_AddToCategoryEx(WUPSConfigCategoryHandle cat, const char *
|
||||
snprintf(item->trueValue, sizeof(item->trueValue), "%s", trueValue);
|
||||
snprintf(item->falseValue, sizeof(item->falseValue), "%s", falseValue);
|
||||
|
||||
WUPSConfigCallbacks_t callbacks = {
|
||||
WUPSConfigAPIItemCallbacksV1 callbacks = {
|
||||
.getCurrentValueDisplay = &WUPSConfigItemBoolean_getCurrentValueDisplay,
|
||||
.getCurrentValueSelectedDisplay = &WUPSConfigItemBoolean_getCurrentValueSelectedDisplay,
|
||||
.onSelected = &WUPSConfigItemBoolean_onSelected,
|
||||
@ -101,13 +101,19 @@ WUPSConfigItemBoolean_AddToCategoryEx(WUPSConfigCategoryHandle cat, const char *
|
||||
.onButtonPressed = &WUPSConfigItemBoolean_onButtonPressed,
|
||||
.onDelete = &WUPSConfigItemBoolean_onDelete};
|
||||
|
||||
if (WUPSConfigItem_Create(&item->handle, configId, displayName, callbacks, item) < 0) {
|
||||
WUPSConfigAPIItemOptionsV1 options = {
|
||||
.displayName = displayName,
|
||||
.context = item,
|
||||
.callbacks = callbacks,
|
||||
};
|
||||
|
||||
if (WUPSConfigAPI_Item_Create(options, &item->handle) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||
WUPSConfigItemBoolean_Cleanup(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (WUPSConfigCategory_AddItem(cat, item->handle) < 0) {
|
||||
WUPSConfigItem_Destroy(item->handle);
|
||||
if (WUPSConfigAPI_Category_AddItem(cat, item->handle) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||
WUPSConfigAPI_Item_Destroy(item->handle);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -96,7 +96,7 @@ extern "C" bool WUPSConfigItemIntegerRange_AddToCategory(WUPSConfigCategoryHandl
|
||||
item->maxValue = maxValue;
|
||||
item->callback = (void *) callback;
|
||||
|
||||
WUPSConfigCallbacks_t callbacks = {
|
||||
WUPSConfigAPIItemCallbacksV1 callbacks = {
|
||||
.getCurrentValueDisplay = &WUPSConfigItemIntegerRange_getCurrentValueDisplay,
|
||||
.getCurrentValueSelectedDisplay = &WUPSConfigItemIntegerRange_getCurrentValueSelectedDisplay,
|
||||
.onSelected = &WUPSConfigItemIntegerRange_onSelected,
|
||||
@ -106,13 +106,19 @@ extern "C" bool WUPSConfigItemIntegerRange_AddToCategory(WUPSConfigCategoryHandl
|
||||
.onButtonPressed = &WUPSConfigItemIntegerRange_onButtonPressed,
|
||||
.onDelete = &WUPSConfigItemIntegerRange_onDelete};
|
||||
|
||||
if (WUPSConfigItem_Create(&(item->handle), configId, displayName, callbacks, item) < 0) {
|
||||
WUPSConfigAPIItemOptionsV1 options = {
|
||||
.displayName = displayName,
|
||||
.context = item,
|
||||
.callbacks = callbacks,
|
||||
};
|
||||
|
||||
if (WUPSConfigAPI_Item_Create(options, &(item->handle)) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||
WUPSConfigItemIntegerRange_Cleanup(item);
|
||||
return false;
|
||||
};
|
||||
|
||||
if (WUPSConfigCategory_AddItem(cat, item->handle) < 0) {
|
||||
WUPSConfigItem_Destroy(item->handle);
|
||||
if (WUPSConfigAPI_Category_AddItem(cat, item->handle) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||
WUPSConfigAPI_Item_Destroy(item->handle);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -126,7 +126,7 @@ WUPSConfigItemMultipleValues_AddToCategory(WUPSConfigCategoryHandle cat, const c
|
||||
item->configId = nullptr;
|
||||
}
|
||||
|
||||
WUPSConfigCallbacks_t callbacks = {
|
||||
WUPSConfigAPIItemCallbacksV1 callbacks = {
|
||||
.getCurrentValueDisplay = &WUPSConfigItemMultipleValues_getCurrentValueDisplay,
|
||||
.getCurrentValueSelectedDisplay = &WUPSConfigItemMultipleValues_getCurrentValueSelectedDisplay,
|
||||
.onSelected = &WUPSConfigItemMultipleValues_onSelected,
|
||||
@ -136,13 +136,19 @@ WUPSConfigItemMultipleValues_AddToCategory(WUPSConfigCategoryHandle cat, const c
|
||||
.onButtonPressed = &WUPSConfigItemMultipleValues_onButtonPressed,
|
||||
.onDelete = &WUPSConfigItemMultipleValues_onDelete};
|
||||
|
||||
if (WUPSConfigItem_Create(&item->handle, configId, displayName, callbacks, item) < 0) {
|
||||
WUPSConfigAPIItemOptionsV1 options = {
|
||||
.displayName = displayName,
|
||||
.context = item,
|
||||
.callbacks = callbacks,
|
||||
};
|
||||
|
||||
if (WUPSConfigAPI_Item_Create(options, &item->handle) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||
WUPSConfigItemMultipleValues_Cleanup(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (WUPSConfigCategory_AddItem(cat, item->handle) < 0) {
|
||||
WUPSConfigItem_Destroy(item->handle);
|
||||
if (WUPSConfigAPI_Category_AddItem(cat, item->handle) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||
WUPSConfigAPI_Item_Destroy(item->handle);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -51,7 +51,7 @@ WUPSConfigItemStub_AddToCategoryEx(WUPSConfigCategoryHandle cat, const char *con
|
||||
return false;
|
||||
}
|
||||
|
||||
WUPSConfigCallbacks_t callbacks = {
|
||||
WUPSConfigAPIItemCallbacksV1 callbacks = {
|
||||
.getCurrentValueDisplay = &WUPSConfigItemStub_getCurrentValueDisplay,
|
||||
.getCurrentValueSelectedDisplay = &WUPSConfigItemStub_getCurrentValueSelectedDisplay,
|
||||
.onSelected = &WUPSConfigItemStub_onSelected,
|
||||
@ -61,13 +61,19 @@ WUPSConfigItemStub_AddToCategoryEx(WUPSConfigCategoryHandle cat, const char *con
|
||||
.onButtonPressed = &WUPSConfigItemStub_onButtonPressed,
|
||||
.onDelete = &WUPSConfigItemStub_onDelete};
|
||||
|
||||
if (WUPSConfigItem_Create(&item->handle, configID, displayName, callbacks, item) < 0) {
|
||||
WUPSConfigAPIItemOptionsV1 options = {
|
||||
.displayName = displayName,
|
||||
.context = item,
|
||||
.callbacks = callbacks,
|
||||
};
|
||||
|
||||
if (WUPSConfigAPI_Item_Create(options, &item->handle) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||
WUPSConfigItemStub_Cleanup(item);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (WUPSConfigCategory_AddItem(cat, item->handle) < 0) {
|
||||
WUPSConfigItem_Destroy(item->handle);
|
||||
if (WUPSConfigAPI_Category_AddItem(cat, item->handle) != WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||
WUPSConfigAPI_Item_Destroy(item->handle);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -1,20 +0,0 @@
|
||||
:NAME homebrew_wupsbackend
|
||||
|
||||
:TEXT
|
||||
WUPSConfigItem_Create
|
||||
WUPSConfigItem_Destroy
|
||||
WUPSConfigItem_SetDisplayName
|
||||
WUPSConfigItem_GetDisplayName
|
||||
WUPSConfigItem_SetConfigID
|
||||
WUPSConfigItem_GetConfigID
|
||||
|
||||
WUPSConfig_Create
|
||||
WUPSConfig_Destroy
|
||||
WUPSConfig_GetName
|
||||
WUPSConfig_AddCategoryByName
|
||||
WUPSConfig_AddCategory
|
||||
|
||||
WUPSConfigCategory_Create
|
||||
WUPSConfigCategory_Destroy
|
||||
WUPSConfigCategory_GetName
|
||||
WUPSConfigCategory_AddItem
|
245
libraries/libwups/config_api.cpp
Normal file
245
libraries/libwups/config_api.cpp
Normal file
@ -0,0 +1,245 @@
|
||||
#include "wups/config_api.h"
|
||||
#include "wups.h"
|
||||
#include <coreinit/dynload.h>
|
||||
#include <wups/config.h>
|
||||
|
||||
static OSDynLoad_Module sModuleHandle = nullptr;
|
||||
|
||||
static WUPSConfigAPIStatus (*sAPIGetVersion)(WUPSConfigAPIVersion *out) = nullptr;
|
||||
static WUPSConfigAPIStatus (*sAPIInitEx)(uint32_t pluginIdentifier, WUPSConfigAPIOptions options, WUPSConfigAPI_MenuOpenedCallback openedCallback, WUPSConfigAPI_MenuClosedCallback closedCallback) = nullptr;
|
||||
static WUPSConfigAPIStatus (*sAPICategoryCreateEx)(WUPSConfigAPICreateCategoryOptions options, WUPSConfigCategoryHandle *out) = nullptr;
|
||||
static WUPSConfigAPIStatus (*sAPICategoryDestroy)(WUPSConfigCategoryHandle handle) = nullptr;
|
||||
static WUPSConfigAPIStatus (*sAPICategoryAddCategory)(WUPSConfigCategoryHandle parentHandle, WUPSConfigCategoryHandle categoryHandle) = nullptr;
|
||||
static WUPSConfigAPIStatus (*sAPICategoryAddItem)(WUPSConfigCategoryHandle parentHandle, WUPSConfigItemHandle itemHandle) = nullptr;
|
||||
static WUPSConfigAPIStatus (*sAPIItemCreateEx)(WUPSConfigAPICreateItemOptions options, WUPSConfigItemHandle *out) = nullptr;
|
||||
static WUPSConfigAPIStatus (*sAPIItemDestroy)(WUPSConfigItemHandle handle) = nullptr;
|
||||
|
||||
static WUPSConfigAPIVersion sConfigAPIVersion = WUPS_CONFIG_API_VERSION_ERROR;
|
||||
|
||||
static bool sConfigLibInitDone = false;
|
||||
static uint32_t sConfigPluginIdentifier = 0xFFFFFFFF;
|
||||
|
||||
const char *WUPSConfigAPI_GetStatusStr(WUPSConfigAPIStatus status) {
|
||||
switch (status) {
|
||||
case WUPSCONFIG_API_RESULT_SUCCESS:
|
||||
return "WUPSCONFIG_API_RESULT_SUCCESS";
|
||||
case WUPSCONFIG_API_RESULT_INVALID_ARGUMENT:
|
||||
return "WUPSCONFIG_API_RESULT_INVALID_ARGUMENT";
|
||||
case WUPSCONFIG_API_RESULT_OUT_OF_MEMORY:
|
||||
return "WUPSCONFIG_API_RESULT_OUT_OF_MEMORY";
|
||||
case WUPSCONFIG_API_RESULT_NOT_FOUND:
|
||||
return "WUPSCONFIG_API_RESULT_NOT_FOUND";
|
||||
case WUPSCONFIG_API_RESULT_MODULE_NOT_FOUND:
|
||||
return "WUPSCONFIG_API_RESULT_MODULE_NOT_FOUND";
|
||||
case WUPSCONFIG_API_RESULT_INVALID_PLUGIN_IDENTIFIER:
|
||||
return "WUPSCONFIG_API_RESULT_INVALID_PLUGIN_IDENTIFIER";
|
||||
case WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT:
|
||||
return "WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT";
|
||||
case WUPSCONFIG_API_RESULT_UNSUPPORTED_VERSION:
|
||||
return "WUPSCONFIG_API_RESULT_UNSUPPORTED_VERSION";
|
||||
case WUPSCONFIG_API_RESULT_UNSUPPORTED_COMMAND:
|
||||
return "WUPSCONFIG_API_RESULT_UNSUPPORTED_COMMAND";
|
||||
case WUPSCONFIG_API_RESULT_LIB_UNINITIALIZED:
|
||||
return "WUPSCONFIG_API_RESULT_LIB_UNINITIALIZED";
|
||||
case WUPSCONFIG_API_RESULT_UNKNOWN_ERROR:
|
||||
return "WUPSCONFIG_API_RESULT_UNKNOWN_ERROR";
|
||||
case WUPSCONFIG_API_RESULT_MISSING_CALLBACK:
|
||||
return "WUPSCONFIG_API_RESULT_MISSING_CALLBACK";
|
||||
}
|
||||
return "WUPSCONFIG_API_RESULT_UNKNOWN_ERROR";
|
||||
}
|
||||
|
||||
extern "C" WUPSConfigAPIStatus WUPSConfigAPI_InitLibrary_Internal(wups_loader_init_config_args_t args) {
|
||||
if (sConfigLibInitDone) {
|
||||
return WUPSCONFIG_API_RESULT_SUCCESS;
|
||||
}
|
||||
if (args.arg_version != 1) {
|
||||
return WUPSCONFIG_API_RESULT_UNSUPPORTED_VERSION;
|
||||
}
|
||||
|
||||
if (OSDynLoad_Acquire("homebrew_wupsbackend", &sModuleHandle) != OS_DYNLOAD_OK) {
|
||||
WUPS_DEBUG_REPORT("libuwps: OSDynLoad_Acquire \"homebrew_wupsbackend\" failed.\n");
|
||||
return WUPSCONFIG_API_RESULT_MODULE_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "WUPSConfigAPI_GetVersion", (void **) &sAPIGetVersion) != OS_DYNLOAD_OK) {
|
||||
WUPS_DEBUG_REPORT("libuwps: FindExport WUPSConfigAPI_GetVersion failed.\n");
|
||||
return WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT;
|
||||
}
|
||||
auto res = WUPSConfigAPI_GetVersion(&sConfigAPIVersion);
|
||||
if (res != WUPSCONFIG_API_RESULT_SUCCESS) {
|
||||
return WUPSCONFIG_API_RESULT_UNSUPPORTED_VERSION;
|
||||
}
|
||||
|
||||
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "WUPSConfigAPI_InitEx", (void **) &sAPIInitEx) != OS_DYNLOAD_OK) {
|
||||
WUPS_DEBUG_REPORT("libwups: FindExport WUPSConfigAPI_InitEx failed.\n");
|
||||
return WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT;
|
||||
}
|
||||
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "WUPSConfigAPI_Category_CreateEx", (void **) &sAPICategoryCreateEx) != OS_DYNLOAD_OK) {
|
||||
WUPS_DEBUG_REPORT("libwups: FindExport WUPSConfigAPI_Category_CreateEx failed.\n");
|
||||
return WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT;
|
||||
}
|
||||
|
||||
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "WUPSConfigAPI_Category_Destroy", (void **) &sAPICategoryDestroy) != OS_DYNLOAD_OK) {
|
||||
WUPS_DEBUG_REPORT("libwups: FindExport WUPSConfigAPI_Category_Destroy failed.\n");
|
||||
return WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT;
|
||||
}
|
||||
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "WUPSConfigAPI_Category_AddCategory", (void **) &sAPICategoryAddCategory) != OS_DYNLOAD_OK) {
|
||||
WUPS_DEBUG_REPORT("libwups: FindExport WUPSConfigAPI_Category_AddCategory failed.\n");
|
||||
return WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT;
|
||||
}
|
||||
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "WUPSConfigAPI_Category_AddItem", (void **) &sAPICategoryAddItem) != OS_DYNLOAD_OK) {
|
||||
WUPS_DEBUG_REPORT("libwups: FindExport WUPSConfigAPI_Category_AddItem failed.\n");
|
||||
return WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT;
|
||||
}
|
||||
|
||||
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "WUPSConfigAPI_Item_CreateEx", (void **) &sAPIItemCreateEx) != OS_DYNLOAD_OK) {
|
||||
WUPS_DEBUG_REPORT("libwups: FindExport WUPSConfigAPI_Item_Create failed.\n");
|
||||
return WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT;
|
||||
}
|
||||
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "WUPSConfigAPI_Item_Destroy", (void **) &sAPIItemDestroy) != OS_DYNLOAD_OK) {
|
||||
WUPS_DEBUG_REPORT("libwups: FindExport WUPSConfigAPI_Item_Destroy failed.\n");
|
||||
return WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT;
|
||||
}
|
||||
|
||||
sConfigLibInitDone = true;
|
||||
sConfigPluginIdentifier = args.plugin_identifier;
|
||||
|
||||
return WUPSCONFIG_API_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
extern "C" WUPSConfigAPIStatus WUPSConfigAPI_DeInitLibrary_Internal() {
|
||||
return WUPSCONFIG_API_RESULT_SUCCESS;
|
||||
}
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_GetVersion(WUPSConfigAPIVersion *outVariable) {
|
||||
if (sAPIGetVersion == nullptr) {
|
||||
if (OSDynLoad_Acquire("homebrew_notifications", &sModuleHandle) != OS_DYNLOAD_OK) {
|
||||
WUPS_DEBUG_REPORT("libwups: OSDynLoad_Acquire failed.\n");
|
||||
return WUPSCONFIG_API_RESULT_MODULE_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (OSDynLoad_FindExport(sModuleHandle, OS_DYNLOAD_EXPORT_FUNC, "WUPSConfigAPI_GetVersion", (void **) &sAPIGetVersion) != OS_DYNLOAD_OK) {
|
||||
WUPS_DEBUG_REPORT("libwups: FindExport WUPSConfigAPI_GetVersion failed.\n");
|
||||
return WUPSCONFIG_API_RESULT_MODULE_MISSING_EXPORT;
|
||||
}
|
||||
}
|
||||
|
||||
return sAPIGetVersion(outVariable);
|
||||
}
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_InitEx(uint32_t pluginIdentifier, WUPSConfigAPIOptions options, WUPSConfigAPI_MenuOpenedCallback openedCallback, WUPSConfigAPI_MenuClosedCallback closedCallback) {
|
||||
if (sConfigAPIVersion == WUPS_CONFIG_API_VERSION_ERROR) {
|
||||
return WUPSCONFIG_API_RESULT_LIB_UNINITIALIZED;
|
||||
}
|
||||
if (sAPIInitEx == nullptr || sConfigAPIVersion < 1) {
|
||||
return WUPSCONFIG_API_RESULT_UNSUPPORTED_COMMAND;
|
||||
}
|
||||
|
||||
if (openedCallback == nullptr || closedCallback == nullptr || options.version != 1) {
|
||||
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return sAPIInitEx(pluginIdentifier, options, openedCallback, closedCallback);
|
||||
}
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Init(WUPSConfigAPIOptionsV1 optionsV1, WUPSConfigAPI_MenuOpenedCallback openedCallback, WUPSConfigAPI_MenuClosedCallback closedCallback) {
|
||||
if (sConfigPluginIdentifier == 0xFFFFFFFF) {
|
||||
return WUPSCONFIG_API_RESULT_INVALID_PLUGIN_IDENTIFIER;
|
||||
}
|
||||
WUPSConfigAPIOptions options = {
|
||||
.version = WUPS_API_CONFIG_API_OPTION_VERSION_V1,
|
||||
.data = {.v1 = optionsV1},
|
||||
};
|
||||
return WUPSConfigAPI_InitEx(sConfigPluginIdentifier, options, openedCallback, closedCallback);
|
||||
}
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Category_CreateEx(WUPSConfigAPICreateCategoryOptions options, WUPSConfigCategoryHandle *out) {
|
||||
if (sConfigAPIVersion == WUPS_CONFIG_API_VERSION_ERROR) {
|
||||
return WUPSCONFIG_API_RESULT_LIB_UNINITIALIZED;
|
||||
}
|
||||
if (sAPICategoryCreateEx == nullptr || sConfigAPIVersion < 1) {
|
||||
return WUPSCONFIG_API_RESULT_UNSUPPORTED_COMMAND;
|
||||
}
|
||||
|
||||
if (out == nullptr) {
|
||||
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return sAPICategoryCreateEx(options, out);
|
||||
}
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Category_Destroy(WUPSConfigCategoryHandle handle) {
|
||||
if (sConfigAPIVersion == WUPS_CONFIG_API_VERSION_ERROR) {
|
||||
return WUPSCONFIG_API_RESULT_LIB_UNINITIALIZED;
|
||||
}
|
||||
if (sAPICategoryDestroy == nullptr || sConfigAPIVersion < 1) {
|
||||
return WUPSCONFIG_API_RESULT_UNSUPPORTED_COMMAND;
|
||||
}
|
||||
|
||||
if (handle == nullptr) {
|
||||
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return sAPICategoryDestroy(handle);
|
||||
}
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Category_AddCategory(WUPSConfigCategoryHandle parentHandle, WUPSConfigCategoryHandle categoryHandle) {
|
||||
if (sConfigAPIVersion == WUPS_CONFIG_API_VERSION_ERROR) {
|
||||
return WUPSCONFIG_API_RESULT_LIB_UNINITIALIZED;
|
||||
}
|
||||
if (sAPICategoryAddCategory == nullptr || sConfigAPIVersion < 1) {
|
||||
return WUPSCONFIG_API_RESULT_UNSUPPORTED_COMMAND;
|
||||
}
|
||||
|
||||
if (parentHandle == nullptr || categoryHandle == nullptr) {
|
||||
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return sAPICategoryAddCategory(parentHandle, categoryHandle);
|
||||
}
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Category_AddItem(WUPSConfigCategoryHandle parentHandle, WUPSConfigItemHandle itemHandle) {
|
||||
if (sConfigAPIVersion == WUPS_CONFIG_API_VERSION_ERROR) {
|
||||
return WUPSCONFIG_API_RESULT_LIB_UNINITIALIZED;
|
||||
}
|
||||
if (sAPICategoryAddItem == nullptr || sConfigAPIVersion < 1) {
|
||||
return WUPSCONFIG_API_RESULT_UNSUPPORTED_COMMAND;
|
||||
}
|
||||
|
||||
if (parentHandle == 0 || itemHandle == 0) {
|
||||
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return sAPICategoryAddItem(parentHandle, itemHandle);
|
||||
}
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Item_CreateEx(WUPSConfigAPICreateItemOptions options, WUPSConfigItemHandle *out) {
|
||||
if (sConfigAPIVersion == WUPS_CONFIG_API_VERSION_ERROR) {
|
||||
return WUPSCONFIG_API_RESULT_LIB_UNINITIALIZED;
|
||||
}
|
||||
if (sAPIItemCreateEx == nullptr || sConfigAPIVersion < 1) {
|
||||
return WUPSCONFIG_API_RESULT_UNSUPPORTED_COMMAND;
|
||||
}
|
||||
|
||||
if (out == nullptr) {
|
||||
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return sAPIItemCreateEx(options, out);
|
||||
}
|
||||
|
||||
WUPSConfigAPIStatus WUPSConfigAPI_Item_Destroy(WUPSConfigItemHandle handle) {
|
||||
if (sConfigAPIVersion == WUPS_CONFIG_API_VERSION_ERROR) {
|
||||
return WUPSCONFIG_API_RESULT_LIB_UNINITIALIZED;
|
||||
}
|
||||
if (sAPIItemDestroy == nullptr || sConfigAPIVersion < 1) {
|
||||
return WUPSCONFIG_API_RESULT_UNSUPPORTED_COMMAND;
|
||||
}
|
||||
|
||||
if (handle == nullptr) {
|
||||
return WUPSCONFIG_API_RESULT_INVALID_ARGUMENT;
|
||||
}
|
||||
|
||||
return sAPIItemDestroy(handle);
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <wups.h>
|
||||
#include <wups/storage.h>
|
||||
|
||||
struct wups_internal_functions_t {
|
||||
OpenStorageFunction openfunction_ptr = nullptr;
|
||||
@ -18,7 +17,7 @@ struct wups_internal_functions_t {
|
||||
static wups_internal_functions_t __internal_functions __attribute__((section(".data"))) = {};
|
||||
|
||||
WUPSStorageError WUPS_InitStorage(wups_loader_init_storage_args_t args) {
|
||||
if (args.version != WUPS_STORAGE_CUR_API_VERSION) {
|
||||
if (args.version > WUPS_STORAGE_CUR_API_VERSION) {
|
||||
__internal_functions = {};
|
||||
return WUPS_STORAGE_ERROR_INVALID_VERSION;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user