Add clang-format for formatting, check building the example in CI

This commit is contained in:
Maschell 2022-02-03 16:24:36 +01:00
parent 9d41a89c45
commit d3cf0691ef
26 changed files with 503 additions and 348 deletions

67
.clang-format Normal file
View File

@ -0,0 +1,67 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveMacros: AcrossEmptyLinesAndComments
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never

46
.github/workflows/pr.yml vendored Normal file
View File

@ -0,0 +1,46 @@
name: CI-PR
on: [pull_request]
jobs:
clang-format-lib:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./include ./libraries
build-lib:
runs-on: ubuntu-18.04
needs: clang-format-lib
steps:
- uses: actions/checkout@v2
- name: build binary
run: |
docker build . -f Dockerfile.buildlocal -t builder
docker run --rm -v ${PWD}:/project builder make
- uses: actions/upload-artifact@master
with:
name: binary
path: "/lib/*.a"
clang-format-examples:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./plugins/example_plugin/src
build-examples:
runs-on: ubuntu-18.04
needs: clang-format-examples
steps:
- uses: actions/checkout@v2
- name: build binary
run: |
docker build . -f Dockerfile.buildexamples -t builder
cd ./plugins/example_plugin
docker run --rm -v ${PWD}:/project builder make
- uses: actions/upload-artifact@master
with:
name: binary
path: "*.wps"

View File

@ -4,8 +4,33 @@ on:
branches:
- master
jobs:
build:
clang-format-lib:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./include ./libraries
clang-format-examples:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: clang-format
run: |
docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./plugins/example_plugin/src
build-examples:
runs-on: ubuntu-18.04
needs: clang-format-examples
steps:
- uses: actions/checkout@v2
- name: build binary
run: |
docker build . -f Dockerfile.buildexamples -t builder
cd ./plugins/example_plugin
docker run --rm -v ${PWD}:/project builder make
push_image:
runs-on: ubuntu-latest
needs: clang-format-lib
steps:
- uses: actions/checkout@master
- name: Get release version

View File

@ -1,4 +1,4 @@
FROM wiiuenv/devkitppc:20210920
FROM wiiuenv/devkitppc:20211229
WORKDIR tmp_build
COPY . .

15
Dockerfile.buildexamples Normal file
View File

@ -0,0 +1,15 @@
FROM wiiuenv/devkitppc:20211229
WORKDIR tmp_build
COPY . .
RUN make clean && make && mkdir -p /artifacts/wups && cp -r lib /artifacts/wups && cp -r include /artifacts/wups && cp -r share /artifacts/wups
WORKDIR /artifacts
FROM scratch as libwups
COPY --from=0 /artifacts /artifacts
FROM wiiuenv/devkitppc:20211229
COPY --from=libwups /artifacts $DEVKITPRO
WORKDIR project

3
Dockerfile.buildlocal Normal file
View File

@ -0,0 +1,3 @@
FROM wiiuenv/devkitppc:20211229
WORKDIR project

View File

@ -56,6 +56,10 @@ This has been created by @dimok789 and can be found in the tools folder.
# Future and contribution
On the Discord you can more information about open tasks and how to contribute: https://discord.gg/bZ2rep2
## Format the code via docker
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./include ./libraries ./plugins/example_plugin/src -i`
# Credits
Some files are based on brainslug by Chadderz:
https://github.com/Chadderz121/brainslug-wii

View File

@ -26,9 +26,9 @@
#pragma once
#include "wups/common.h"
#include "wups/meta.h"
#include "wups/function_patching.h"
#include "wups/config.h"
#include "wups/hooks.h"
#include "wups/config_imports.h"
#include "wups/function_patching.h"
#include "wups/hooks.h"
#include "wups/meta.h"
#include "wups/storage.h"

View File

@ -25,24 +25,24 @@
#pragma once
#include <dirent.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>
#include <dirent.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
#define WUPS_SECTION(x) __attribute__((__section__ (".wups." x)))
#define WUPS_SECTION(x) __attribute__((__section__(".wups." x)))
#define WUPS_META(id, value) \
extern const char wups_meta_ ## id [] WUPS_SECTION("meta"); \
const char wups_meta_ ## id [] = #id "=" value
extern const char wups_meta_##id[] WUPS_SECTION("meta"); \
const char wups_meta_##id[] = #id "=" value
#ifdef __cplusplus
}

View File

@ -20,16 +20,16 @@
#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)
#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 {

View File

@ -25,7 +25,7 @@ bool WUPSConfigItemBoolean_AddToCategoryEx(WUPSConfigCategoryHandle cat, const c
WUPSConfig_Destroy(__config__); \
return 0; \
} \
} while(0)
} while (0)
#define WUPSConfigItemBoolean_AddToCategoryHandledEx(__config__, __cat__, __configID__, __displayName__, __defaultValue__, __callback__, __trueValue__, __falseValue__) \
do { \
@ -33,7 +33,7 @@ bool WUPSConfigItemBoolean_AddToCategoryEx(WUPSConfigCategoryHandle cat, const c
WUPSConfig_Destroy(__config__); \
return 0; \
} \
} while(0)
} while (0)
#ifdef __cplusplus
}

View File

@ -15,8 +15,7 @@ typedef struct ConfigItemIntegerRange {
typedef void (*IntegerRangeValueChangedCallback)(ConfigItemIntegerRange *, int32_t);
bool
WUPSConfigItemIntegerRange_AddToCategory(WUPSConfigCategoryHandle cat, const char *configID, const char *displayName,
bool WUPSConfigItemIntegerRange_AddToCategory(WUPSConfigCategoryHandle cat, const char *configID, const char *displayName,
int32_t defaultValue, int32_t minValue, int32_t maxValue,
IntegerRangeValueChangedCallback callback);
@ -26,7 +25,7 @@ WUPSConfigItemIntegerRange_AddToCategory(WUPSConfigCategoryHandle cat, const cha
WUPSConfig_Destroy(__config__); \
return 0; \
} \
} while(0)
} while (0)
#ifdef __cplusplus
}

View File

@ -26,11 +26,11 @@ bool WUPSConfigItemMultipleValues_AddToCategory(WUPSConfigCategoryHandle cat, co
#define WUPSConfigItemMultipleValues_AddToCategoryHandled(__config__, __cat__, __configID__, __displayName__, __defaultValueIndex__, __possibleValues__, __pairCount__, __callback__) \
do { \
if(!WUPSConfigItemMultipleValues_AddToCategory(__cat__, __configID__, __displayName__, __defaultValueIndex__, __possibleValues__, __pairCount__, __callback__)) { \
if (!WUPSConfigItemMultipleValues_AddToCategory(__cat__, __configID__, __displayName__, __defaultValueIndex__, __possibleValues__, __pairCount__, __callback__)) { \
WUPSConfig_Destroy(__config__); \
return 0; \
} \
} while(0)
} while (0)
#ifdef __cplusplus
}

View File

@ -1,7 +1,7 @@
#pragma once
#include "stdint.h"
#include "config.h"
#include "stdint.h"
extern "C" int32_t WUPSConfigItem_Create(WUPSConfigItemHandle *out, const char *configID, const char *displayName, WUPSConfigCallbacks_t callbacks, void *context);
@ -41,13 +41,13 @@ extern "C" int32_t WUPSConfigCategory_AddItem(WUPSConfigCategoryHandle handle, W
do { \
if (WUPSConfig_AddCategoryByName(__config__, __categoryName__, __out__) < 0) { \
WUPSConfig_Destroy(__config__); \
return 0;\
return 0; \
} \
} while(0)
} while (0)
#define WUPSConfig_CreateHandled(__config__, __configName__) \
do { \
if (WUPSConfig_Create(__config__, __configName__) < 0) { \
return 0; \
} \
} while(0)
} while (0)

View File

@ -130,43 +130,41 @@ typedef enum WUPSFPTargetProcess {
typedef struct wups_loader_entry_t {
wups_loader_entry_type_t type;
struct {
const void * physical_address; /* (optional) Physical Address. If set, the name and lib will be ignored */
const void * virtual_address; /* (optional) Physical Address. If set, the name and lib will be ignored */
const char * name; /* Name of the function that will be replaced */
const void *physical_address; /* (optional) Physical Address. If set, the name and lib will be ignored */
const void *virtual_address; /* (optional) Physical Address. If set, the name and lib will be ignored */
const char *name; /* Name of the function that will be replaced */
const wups_loader_library_type_t library; /**/
const char * my_function_name; /* Function name of your own, new function (my_XXX) */
const void * target; /* Address of our own, new function (my_XXX)*/
const void * call_addr; /* Address for calling the real function.(real_XXX) */
const char *my_function_name; /* Function name of your own, new function (my_XXX) */
const void *target; /* Address of our own, new function (my_XXX)*/
const void *call_addr; /* Address for calling the real function.(real_XXX) */
const WUPSFPTargetProcess targetProcess; /* Target process*/
} _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_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_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 \
extern const wups_loader_entry_t wups_load_##replace_func \
WUPS_SECTION("load"); \
const wups_loader_entry_t wups_load_ ## replace_func = { \
const wups_loader_entry_t wups_load_##replace_func = { \
.type = WUPS_LOADER_ENTRY_FUNCTION_MANDATORY, \
._function = { \
.physical_address = (const void*) pAddress, \
.virtual_address = (const void*) vAddress, \
.physical_address = (const void *) pAddress, \
.virtual_address = (const void *) vAddress, \
.name = #replace_function_name, \
.library = rpl_type, \
.my_function_name = #replace_func, \
.target = (const void*)&(replace_func), \
.call_addr = (const void*)&(original_func), \
.targetProcess = process\
} \
}
.target = (const void *) &(replace_func), \
.call_addr = (const void *) &(original_func), \
.targetProcess = process}}
#define DECL_FUNCTION(res, name, ...) \
res (* real_ ## name)(__VA_ARGS__) __attribute__((section(".data"))); \
res my_ ## name(__VA_ARGS__)
res (*real_##name)(__VA_ARGS__) __attribute__((section(".data"))); \
res my_##name(__VA_ARGS__)
#ifdef __cplusplus
}

View File

@ -24,11 +24,10 @@ extern "C" {
#endif
#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 = { \
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, \
.target = (const void*)&(original_func) \
}
.target = (const void *) &(original_func)}
typedef enum wups_loader_hook_type_t {
WUPS_LOADER_HOOK_INIT_WUT_MALLOC,
@ -66,61 +65,61 @@ typedef struct wups_loader_hook_t {
} wups_loader_hook_t;
#define INITIALIZE_PLUGIN() \
void init_plugin(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_PLUGIN,init_plugin); \
void init_plugin(void); \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_PLUGIN, init_plugin); \
void init_plugin()
#define DEINITIALIZE_PLUGIN() \
void deinit_plugin(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_DEINIT_PLUGIN,deinit_plugin); \
void deinit_plugin(void); \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_DEINIT_PLUGIN, deinit_plugin); \
void deinit_plugin()
#define ON_APPLICATION_START() \
void on_app_starting();\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLICATION_STARTS,on_app_starting); \
void on_app_starting(); \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLICATION_STARTS, on_app_starting); \
void on_app_starting()
#define ON_FUNCTIONS_PATCHED() \
void on_functions_patched();\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FUNCTIONS_PATCHED,on_functions_patched); \
void on_functions_patched(); \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FUNCTIONS_PATCHED, on_functions_patched); \
void on_functions_patched()
#define ON_RELEASE_FOREGROUND() \
void on_release_foreground(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_RELEASE_FOREGROUND,on_release_foreground); \
void on_release_foreground(void); \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_RELEASE_FOREGROUND, on_release_foreground); \
void on_release_foreground(void)
#define ON_ACQUIRED_FOREGROUND() \
void on_acquired_foreground(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_ACQUIRED_FOREGROUND,on_acquired_foreground); \
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); \
void on_app_requests_exit(void); \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLICATION_REQUESTS_EXIT, on_app_requests_exit); \
void on_app_requests_exit(void)
#define ON_APPLICATION_ENDS() \
void on_app_ending(void);\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_APPLICATION_ENDS,on_app_ending); \
void on_app_ending(void); \
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); \
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); \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_CONFIG_CLOSED, on_wups_config_closed); \
void on_wups_config_closed(void)
#define WUPS_USE_STORAGE(x) \
WUPS_META(storage_id, x); \
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);\
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
@ -131,77 +130,77 @@ typedef struct wups_loader_hook_t {
#define WUPS_USE_WUT_MALLOC() \
__EXTERN_C_MACRO void __init_wut_malloc(); \
void on_init_wut_malloc(){ \
void on_init_wut_malloc() { \
__init_wut_malloc(); \
}\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_MALLOC,on_init_wut_malloc); \
} \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_MALLOC, on_init_wut_malloc); \
__EXTERN_C_MACRO void __fini_wut_malloc(); \
void on_fini_wut_malloc(){ \
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(); \
void on_init_wut_devoptab(){ \
void on_init_wut_devoptab() { \
__init_wut_devoptab(); \
}\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB,on_init_wut_devoptab); \
} \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_DEVOPTAB, on_init_wut_devoptab); \
__EXTERN_C_MACRO void __fini_wut_devoptab(); \
void on_fini_wut_devoptab(){ \
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(); \
void on_init_wut_newlib(){ \
void on_init_wut_newlib() { \
__init_wut_newlib(); \
}\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_NEWLIB,on_init_wut_newlib); \
} \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_NEWLIB, on_init_wut_newlib); \
__EXTERN_C_MACRO void __fini_wut_newlib(); \
void on_fini_wut_newlib(){ \
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(){ \
void on_init_wut_stdcpp() { \
__init_wut_stdcpp(); \
}\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_STDCPP,on_init_wut_stdcpp); \
} \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_STDCPP, on_init_wut_stdcpp); \
__EXTERN_C_MACRO void __fini_wut_stdcpp(); \
void on_fini_wut_stdcpp(){ \
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___INIT_WRAPPER() \
__EXTERN_C_MACRO void __init(); \
void __init_wrapper(){ \
void __init_wrapper() { \
__init(); \
}\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WRAPPER,__init_wrapper);
} \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WRAPPER, __init_wrapper);
#define WUPS___FINI_WRAPPER() \
__EXTERN_C_MACRO void __fini(); \
void __fini_wrapper(){ \
void __fini_wrapper() { \
__fini(); \
}\
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WRAPPER,__fini_wrapper);
} \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_FINI_WRAPPER, __fini_wrapper);
#define WUPS_USE_WUT_SOCKETS() \
__EXTERN_C_MACRO void __attribute__((weak)) __init_wut_socket(); \
void on_init_wut_sockets(){ \
void on_init_wut_sockets() { \
if (&__init_wut_socket) __init_wut_socket(); \
} \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_SOCKETS,on_init_wut_sockets); \
WUPS_HOOK_EX(WUPS_LOADER_HOOK_INIT_WUT_SOCKETS, on_init_wut_sockets); \
__EXTERN_C_MACRO void __attribute__((weak)) __fini_wut_socket(); \
void on_fini_wut_sockets(){ \
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
}

View File

@ -32,7 +32,8 @@
extern "C" {
#endif
#define WUPS_PLUGIN_NAME(x) WUPS_META(name, x); \
#define WUPS_PLUGIN_NAME(x) \
WUPS_META(name, x); \
WUPS_META(wups, "0.7.0"); \
WUPS_USE_WUT_MALLOC(); \
WUPS_USE_WUT_SOCKETS(); \

View File

@ -1,7 +1,7 @@
#include <wups.h>
#include "wups/config/WUPSConfigItemBoolean.h"
#include <cstdio>
#include <cstdlib>
#include "wups/config/WUPSConfigItemBoolean.h"
#include <wups.h>
void WUPSConfigItemBoolean_onDelete(void *context);
@ -82,8 +82,7 @@ WUPSConfigItemBoolean_AddToCategoryEx(WUPSConfigCategoryHandle cat, const char *
.isMovementAllowed = &WUPSConfigItemBoolean_isMovementAllowed,
.callCallback = &WUPSConfigItemBoolean_callCallback,
.onButtonPressed = &WUPSConfigItemBoolean_onButtonPressed,
.onDelete = &WUPSConfigItemBoolean_onDelete
};
.onDelete = &WUPSConfigItemBoolean_onDelete};
if (WUPSConfigItem_Create(&item->handle, configID, displayName, callbacks, item) < 0) {
free(item);

View File

@ -1,7 +1,7 @@
#include <wups.h>
#include "wups/config/WUPSConfigItemIntegerRange.h"
#include <cstdio>
#include <cstdlib>
#include "wups/config/WUPSConfigItemIntegerRange.h"
#include <wups.h>
int32_t WUPSConfigItemIntegerRange_getCurrentValueDisplay(void *context, char *out_buf, int32_t out_size) {
auto *item = (ConfigItemIntegerRange *) context;
@ -64,7 +64,6 @@ void WUPSConfigItemIntegerRange_onDelete(void *context) {
}
void WUPSConfigItemIntegerRange_onSelected(void *context, bool isSelected) {
}
extern "C" bool WUPSConfigItemIntegerRange_AddToCategory(WUPSConfigCategoryHandle cat, const char *configID, const char *displayName, int32_t defaultValue, int32_t minValue, int32_t maxValue,
@ -91,8 +90,7 @@ extern "C" bool WUPSConfigItemIntegerRange_AddToCategory(WUPSConfigCategoryHandl
.isMovementAllowed = &WUPSConfigItemIntegerRange_isMovementAllowed,
.callCallback = &WUPSConfigItemIntegerRange_callCallback,
.onButtonPressed = &WUPSConfigItemIntegerRange_onButtonPressed,
.onDelete = &WUPSConfigItemIntegerRange_onDelete
};
.onDelete = &WUPSConfigItemIntegerRange_onDelete};
if (WUPSConfigItem_Create(&(item->handle), configID, displayName, callbacks, item) < 0) {
free(item);

View File

@ -1,8 +1,8 @@
#include <wups.h>
#include "wups/config/WUPSConfigItemMultipleValues.h"
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "wups/config/WUPSConfigItemMultipleValues.h"
#include <wups.h>
void WUPSConfigItemMultipleValues_onDelete(void *context);
@ -119,8 +119,7 @@ WUPSConfigItemMultipleValues_AddToCategory(WUPSConfigCategoryHandle cat, const c
.isMovementAllowed = &WUPSConfigItemMultipleValues_isMovementAllowed,
.callCallback = &WUPSConfigItemMultipleValues_callCallback,
.onButtonPressed = &WUPSConfigItemMultipleValues_onButtonPressed,
.onDelete = &WUPSConfigItemMultipleValues_onDelete
};
.onDelete = &WUPSConfigItemMultipleValues_onDelete};
if (WUPSConfigItem_Create(&item->handle, configID, displayName, callbacks, item) < 0) {
free(item);

View File

@ -1,6 +1,6 @@
#include <wups.h>
#include <cstring>
#include <cstdlib>
#include <cstring>
#include <wups.h>
#include "utils/base64.h"

View File

@ -77,8 +77,7 @@ size_t b64_decoded_size(const char *in) {
static const int b64invs[] = {
62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 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, -1, -1, -1, -1, -1,
-1, 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
};
-1, 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};
static int b64_isvalidchar(char c) {
if (c >= '0' && c <= '9')

View File

@ -1,7 +1,7 @@
#pragma once
#include <stdlib.h>
#include <stdint.h>
#include <stdlib.h>
// based on https://nachtimwald.com/2017/11/18/base64-encode-and-decode-in-c/

View File

@ -1,14 +1,14 @@
#include <wups.h>
#include <whb/libmanager.h>
#include <coreinit/filesystem.h>
#include <coreinit/thread.h>
#include <coreinit/time.h>
#include <malloc.h>
#include <string.h>
#include <utils/logger.h>
#include <coreinit/time.h>
#include <coreinit/thread.h>
#include <coreinit/filesystem.h>
#include <whb/libmanager.h>
#include <whb/log_cafe.h>
#include <whb/log_module.h>
#include <whb/log_udp.h>
#include <wups.h>
#include <wups/config/WUPSConfigItemBoolean.h>
/**
@ -35,7 +35,7 @@ bool logFSOpen = true;
/**
Get's called ONCE when the loader exits, but BEFORE the ON_APPLICATION_START gets called or functions are overridden.
**/
INITIALIZE_PLUGIN(){
INITIALIZE_PLUGIN() {
if (!WHBLogModuleInit()) {
WHBLogCafeInit();
WHBLogUdpInit();
@ -46,7 +46,7 @@ INITIALIZE_PLUGIN(){
WUPS_OpenStorage();
// Try to get value from storage
if(WUPS_GetBool(nullptr, "logFSOpen", &logFSOpen) != WUPS_STORAGE_ERROR_SUCCESS){
if (WUPS_GetBool(nullptr, "logFSOpen", &logFSOpen) != WUPS_STORAGE_ERROR_SUCCESS) {
// Add the value to the storage if it's missing.
WUPS_StoreBool(nullptr, "logFSOpen", logFSOpen);
}
@ -59,7 +59,7 @@ INITIALIZE_PLUGIN(){
Gets called when the plugin loader is re-entered => when the plugin is unloaded.
The overridden functions are restored before this is getting called.
**/
DEINITIALIZE_PLUGIN(){
DEINITIALIZE_PLUGIN() {
DEBUG_FUNCTION_LINE("DEINITIALIZE_PLUGIN of example_plugin!");
}
@ -68,7 +68,7 @@ DEINITIALIZE_PLUGIN(){
This is called BEFORE the functions are overridden.
Make sure to initialize all functions you're using in the overridden functions!
**/
ON_APPLICATION_START(){
ON_APPLICATION_START() {
if (!WHBLogModuleInit()) {
WHBLogCafeInit();
WHBLogUdpInit();
@ -80,7 +80,7 @@ ON_APPLICATION_START(){
/**
Gets called when an application request to exit.
**/
ON_APPLICATION_REQUESTS_EXIT(){
ON_APPLICATION_REQUESTS_EXIT() {
DEBUG_FUNCTION_LINE("ON_APPLICATION_REQUESTS_EXIT of example_plugin!");
}
@ -142,7 +142,7 @@ WUPS_CONFIG_CLOSED() {
DECL_FUNCTION(int, FSOpenFile, FSClient *pClient, FSCmdBlock *pCmd, const char *path, const char *mode, int *handle, int error) {
int result = real_FSOpenFile(pClient, pCmd, path, mode, handle, error);
if (logFSOpen) {
DEBUG_FUNCTION_LINE("FSOpenFile called for folder %s! Result %d",path,result);
DEBUG_FUNCTION_LINE("FSOpenFile called for folder %s! Result %d", path, result);
}
return result;
}

View File

@ -10,16 +10,19 @@ extern "C" {
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
#define OSFATAL_FUNCTION_LINE(FMT, ARGS...)do { \
OSFatal_printf("[%s]%s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
#define OSFATAL_FUNCTION_LINE(FMT, ARGS...) \
do { \
OSFatal_printf("[%s]%s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0);
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0);
#ifdef __cplusplus