Format the code via clang-format

This commit is contained in:
Maschell 2022-02-04 16:35:35 +01:00
parent 91f77ed210
commit 142aa827d2
29 changed files with 512 additions and 366 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

View File

@ -6,8 +6,16 @@ on:
- main - main
jobs: jobs:
clang-format:
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 ./src
build-binary: build-binary:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
needs: clang-format
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: build binary - name: build binary

View File

@ -3,8 +3,16 @@ name: CI-PR
on: [pull_request] on: [pull_request]
jobs: jobs:
clang-format:
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 ./src
build-binary: build-binary:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
needs: clang-format
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: build binary - name: build binary

View File

@ -1,3 +1,5 @@
[![CI-Release](https://github.com/wiiu-env/RPXLoadingModule/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/RPXLoadingModule/actions/workflows/ci.yml)
## Usage ## Usage
(`[ENVIRONMENT]` is a placeholder for the actual environment name.) (`[ENVIRONMENT]` is a placeholder for the actual environment name.)
@ -18,3 +20,7 @@ docker run -it --rm -v ${PWD}:/project rpxloadingmodule-builder make
# make clean # make clean
docker run -it --rm -v ${PWD}:/project rpxloadingmodule-builder make clean docker run -it --rm -v ${PWD}:/project rpxloadingmodule-builder make clean
``` ```
## Format the code via docker
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src -i`

View File

@ -1,10 +1,10 @@
#include "FSDirReplacements.h" #include "FSDirReplacements.h"
#include <coreinit/filesystem.h>
#include <coreinit/cache.h>
#include "utils/logger.h"
#include "globals.h"
#include "FSWrapper.h" #include "FSWrapper.h"
#include "FileUtils.h" #include "FileUtils.h"
#include "globals.h"
#include "utils/logger.h"
#include <coreinit/cache.h>
#include <coreinit/filesystem.h>
#define SYNC_RESULT_HANDLER [](FSStatus res) -> FSStatus { \ #define SYNC_RESULT_HANDLER [](FSStatus res) -> FSStatus { \
return res; \ return res; \
@ -17,9 +17,9 @@
DECL_FUNCTION(FSStatus, FSOpenDir, FSClient *client, FSCmdBlock *block, char *path, FSDirectoryHandle *handle, FSErrorFlag errorMask) { DECL_FUNCTION(FSStatus, FSOpenDir, FSClient *client, FSCmdBlock *block, char *path, FSDirectoryHandle *handle, FSErrorFlag errorMask) {
DEBUG_FUNCTION_LINE_VERBOSE("%s", path); DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
FSStatus result = FSOpenDirWrapper(path, handle, errorMask, FSStatus result = FSOpenDirWrapper(
[client, block, handle, errorMask] path, handle, errorMask,
(char *_path) -> FSStatus { [client, block, handle, errorMask](char *_path) -> FSStatus {
return real_FSOpenDir(client, block, _path, handle, errorMask); return real_FSOpenDir(client, block, _path, handle, errorMask);
}, },
SYNC_RESULT_HANDLER); SYNC_RESULT_HANDLER);
@ -37,9 +37,9 @@ DECL_FUNCTION(FSStatus, FSOpenDirAsync, FSClient *client, FSCmdBlock *block, cha
// Even real_FSOpenDir is still calling our FSOpenDirAsync hook. To bypass our code we use "FORCE_REAL_FUNC_WITH_FULL_ERRORS" as an errorMask. // Even real_FSOpenDir is still calling our FSOpenDirAsync hook. To bypass our code we use "FORCE_REAL_FUNC_WITH_FULL_ERRORS" as an errorMask.
if ((errorMask & ERROR_FLAG_MASK) != FORCE_REAL_FUNC_MAGIC) { if ((errorMask & ERROR_FLAG_MASK) != FORCE_REAL_FUNC_MAGIC) {
FSStatus result = FSOpenDirWrapper(path, handle, errorMask, FSStatus result = FSOpenDirWrapper(
[client, block, handle, errorMask, asyncData] path, handle, errorMask,
(char *_path) -> FSStatus { [client, block, handle, errorMask, asyncData](char *_path) -> FSStatus {
return real_FSOpenDirAsync(client, block, _path, handle, errorMask, asyncData); return real_FSOpenDirAsync(client, block, _path, handle, errorMask, asyncData);
}, },
ASYNC_RESULT_HANDLER); ASYNC_RESULT_HANDLER);
@ -133,9 +133,9 @@ DECL_FUNCTION(FSStatus, FSRewindDirAsync, FSClient *client, FSCmdBlock *block, F
DECL_FUNCTION(FSStatus, FSMakeDir, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask) { DECL_FUNCTION(FSStatus, FSMakeDir, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask) {
DEBUG_FUNCTION_LINE_VERBOSE("%s", path); DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
FSStatus result = FSMakeDirWrapper(path, errorMask, FSStatus result = FSMakeDirWrapper(
[client, block, errorMask] path, errorMask,
(char *_path) -> FSStatus { [client, block, errorMask](char *_path) -> FSStatus {
return real_FSMakeDir(client, block, _path, errorMask); return real_FSMakeDir(client, block, _path, errorMask);
}, },
SYNC_RESULT_HANDLER); SYNC_RESULT_HANDLER);
@ -148,9 +148,9 @@ DECL_FUNCTION(FSStatus, FSMakeDir, FSClient *client, FSCmdBlock *block, char *pa
DECL_FUNCTION(FSStatus, FSMakeDirAsync, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask, FSAsyncData *asyncData) { DECL_FUNCTION(FSStatus, FSMakeDirAsync, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask, FSAsyncData *asyncData) {
DEBUG_FUNCTION_LINE_VERBOSE("%s", path); DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
FSStatus result = FSMakeDirWrapper(path, errorMask, FSStatus result = FSMakeDirWrapper(
[client, block, errorMask, asyncData] path, errorMask,
(char *_path) -> FSStatus { [client, block, errorMask, asyncData](char *_path) -> FSStatus {
return real_FSMakeDirAsync(client, block, _path, errorMask, asyncData); return real_FSMakeDirAsync(client, block, _path, errorMask, asyncData);
}, },
ASYNC_RESULT_HANDLER); ASYNC_RESULT_HANDLER);
@ -163,7 +163,7 @@ DECL_FUNCTION(FSStatus, FSMakeDirAsync, FSClient *client, FSCmdBlock *block, cha
DECL_FUNCTION(FSStatus, FSChangeDirAsync, FSClient *client, FSCmdBlock *block, const char *path, FSErrorFlag errorMask, FSAsyncData *asyncData) { DECL_FUNCTION(FSStatus, FSChangeDirAsync, FSClient *client, FSCmdBlock *block, const char *path, FSErrorFlag errorMask, FSAsyncData *asyncData) {
DEBUG_FUNCTION_LINE_VERBOSE("FSChangeDirAsync %s", path); DEBUG_FUNCTION_LINE_VERBOSE("FSChangeDirAsync %s", path);
snprintf(gReplacementInfo.contentReplacementInfo.workingDir, sizeof(gReplacementInfo.contentReplacementInfo.workingDir), "%s", path); snprintf(gReplacementInfo.contentReplacementInfo.workingDir, sizeof(gReplacementInfo.contentReplacementInfo.workingDir), "%s", path);
int len = strlen(gReplacementInfo.contentReplacementInfo.workingDir); auto len = strlen(gReplacementInfo.contentReplacementInfo.workingDir);
if (len > 0 && gReplacementInfo.contentReplacementInfo.workingDir[len - 1] != '/') { if (len > 0 && gReplacementInfo.contentReplacementInfo.workingDir[len - 1] != '/') {
gReplacementInfo.contentReplacementInfo.workingDir[len - 1] = '/'; gReplacementInfo.contentReplacementInfo.workingDir[len - 1] = '/';
gReplacementInfo.contentReplacementInfo.workingDir[len] = 0; gReplacementInfo.contentReplacementInfo.workingDir[len] = 0;

View File

@ -13,4 +13,3 @@ extern uint32_t fs_dir_function_replacements_size;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -4,9 +4,9 @@
#include <coreinit/dynload.h> #include <coreinit/dynload.h>
#include <cstring> #include <cstring>
#include "utils/logger.h"
#include "FileUtils.h"
#include "FSWrapper.h" #include "FSWrapper.h"
#include "FileUtils.h"
#include "utils/logger.h"
#define SYNC_RESULT_HANDLER [](FSStatus res) -> FSStatus { \ #define SYNC_RESULT_HANDLER [](FSStatus res) -> FSStatus { \
return res; \ return res; \
@ -18,9 +18,9 @@
DECL_FUNCTION(FSStatus, FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, const char *mode, FSFileHandle *handle, FSErrorFlag errorMask) { DECL_FUNCTION(FSStatus, FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, const char *mode, FSFileHandle *handle, FSErrorFlag errorMask) {
DEBUG_FUNCTION_LINE_VERBOSE("%s", path); DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
FSStatus result = FSOpenFileWrapper(path, mode, handle, errorMask, FSStatus result = FSOpenFileWrapper(
[client, block, mode, handle, errorMask] path, mode, handle, errorMask,
(char *_path) -> FSStatus { [client, block, mode, handle, errorMask](char *_path) -> FSStatus {
return real_FSOpenFile(client, block, _path, mode, handle, errorMask); return real_FSOpenFile(client, block, _path, mode, handle, errorMask);
}, },
SYNC_RESULT_HANDLER); SYNC_RESULT_HANDLER);
@ -34,9 +34,9 @@ DECL_FUNCTION(FSStatus, FSOpenFile, FSClient *client, FSCmdBlock *block, char *p
DECL_FUNCTION(FSStatus, FSOpenFileAsync, FSClient *client, FSCmdBlock *block, char *path, const char *mode, FSFileHandle *handle, FSErrorFlag errorMask, FSAsyncData *asyncData) { DECL_FUNCTION(FSStatus, FSOpenFileAsync, FSClient *client, FSCmdBlock *block, char *path, const char *mode, FSFileHandle *handle, FSErrorFlag errorMask, FSAsyncData *asyncData) {
DEBUG_FUNCTION_LINE_VERBOSE("%s", path); DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
FSStatus result = FSOpenFileWrapper(path, mode, handle, errorMask, FSStatus result = FSOpenFileWrapper(
[client, block, mode, handle, errorMask, asyncData] path, mode, handle, errorMask,
(char *_path) -> FSStatus { [client, block, mode, handle, errorMask, asyncData](char *_path) -> FSStatus {
return real_FSOpenFileAsync(client, block, _path, mode, handle, errorMask, asyncData); return real_FSOpenFileAsync(client, block, _path, mode, handle, errorMask, asyncData);
}, },
ASYNC_RESULT_HANDLER); ASYNC_RESULT_HANDLER);
@ -70,7 +70,8 @@ DECL_FUNCTION(FSStatus, FSCloseFileAsync, FSClient *client, FSCmdBlock *block, F
DECL_FUNCTION(FSStatus, FSGetStat, FSClient *client, FSCmdBlock *block, char *path, FSStat *stats, FSErrorFlag errorMask) { DECL_FUNCTION(FSStatus, FSGetStat, FSClient *client, FSCmdBlock *block, char *path, FSStat *stats, FSErrorFlag errorMask) {
DEBUG_FUNCTION_LINE_VERBOSE("%s", path); DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
FSStatus result = FSGetStatWrapper(path, stats, errorMask, FSStatus result = FSGetStatWrapper(
path, stats, errorMask,
[client, block, stats, errorMask](char *_path) -> FSStatus { [client, block, stats, errorMask](char *_path) -> FSStatus {
return real_FSGetStat(client, block, _path, stats, errorMask); return real_FSGetStat(client, block, _path, stats, errorMask);
}, },
@ -83,7 +84,8 @@ DECL_FUNCTION(FSStatus, FSGetStat, FSClient *client, FSCmdBlock *block, char *pa
DECL_FUNCTION(FSStatus, FSGetStatAsync, FSClient *client, FSCmdBlock *block, char *path, FSStat *stats, FSErrorFlag errorMask, FSAsyncData *asyncData) { DECL_FUNCTION(FSStatus, FSGetStatAsync, FSClient *client, FSCmdBlock *block, char *path, FSStat *stats, FSErrorFlag errorMask, FSAsyncData *asyncData) {
DEBUG_FUNCTION_LINE_VERBOSE("%s", path); DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
FSStatus result = FSGetStatWrapper(path, stats, errorMask, FSStatus result = FSGetStatWrapper(
path, stats, errorMask,
[client, block, stats, errorMask, asyncData](char *_path) -> FSStatus { [client, block, stats, errorMask, asyncData](char *_path) -> FSStatus {
return real_FSGetStatAsync(client, block, _path, stats, errorMask, asyncData); return real_FSGetStatAsync(client, block, _path, stats, errorMask, asyncData);
}, },
@ -257,7 +259,8 @@ DECL_FUNCTION(FSStatus, FSTruncateFileAsync, FSClient *client, FSCmdBlock *block
DECL_FUNCTION(FSStatus, FSRemove, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask) { DECL_FUNCTION(FSStatus, FSRemove, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask) {
DEBUG_FUNCTION_LINE_VERBOSE("%s", path); DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
FSStatus result = FSRemoveWrapper(path, errorMask, FSStatus result = FSRemoveWrapper(
path, errorMask,
[client, block, errorMask](char *_path) -> FSStatus { [client, block, errorMask](char *_path) -> FSStatus {
return real_FSRemove(client, block, _path, errorMask); return real_FSRemove(client, block, _path, errorMask);
}, },
@ -271,7 +274,8 @@ DECL_FUNCTION(FSStatus, FSRemove, FSClient *client, FSCmdBlock *block, char *pat
DECL_FUNCTION(FSStatus, FSRemoveAsync, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask, FSAsyncData *asyncData) { DECL_FUNCTION(FSStatus, FSRemoveAsync, FSClient *client, FSCmdBlock *block, char *path, FSErrorFlag errorMask, FSAsyncData *asyncData) {
DEBUG_FUNCTION_LINE_VERBOSE("%s", path); DEBUG_FUNCTION_LINE_VERBOSE("%s", path);
FSStatus result = FSRemoveWrapper(path, errorMask, FSStatus result = FSRemoveWrapper(
path, errorMask,
[client, block, errorMask, asyncData](char *_path) -> FSStatus { [client, block, errorMask, asyncData](char *_path) -> FSStatus {
return real_FSRemoveAsync(client, block, _path, errorMask, asyncData); return real_FSRemoveAsync(client, block, _path, errorMask, asyncData);
}, },
@ -285,7 +289,8 @@ DECL_FUNCTION(FSStatus, FSRemoveAsync, FSClient *client, FSCmdBlock *block, char
DECL_FUNCTION(FSStatus, FSRename, FSClient *client, FSCmdBlock *block, char *oldPath, char *newPath, FSErrorFlag errorMask) { DECL_FUNCTION(FSStatus, FSRename, FSClient *client, FSCmdBlock *block, char *oldPath, char *newPath, FSErrorFlag errorMask) {
DEBUG_FUNCTION_LINE_VERBOSE("%s %s", oldPath, newPath); DEBUG_FUNCTION_LINE_VERBOSE("%s %s", oldPath, newPath);
FSStatus result = FSRenameWrapper(oldPath, newPath, errorMask, FSStatus result = FSRenameWrapper(
oldPath, newPath, errorMask,
[client, block, errorMask](char *_oldOath, char *_newPath) -> FSStatus { [client, block, errorMask](char *_oldOath, char *_newPath) -> FSStatus {
return real_FSRename(client, block, _oldOath, _newPath, errorMask); return real_FSRename(client, block, _oldOath, _newPath, errorMask);
}, },
@ -299,7 +304,8 @@ DECL_FUNCTION(FSStatus, FSRename, FSClient *client, FSCmdBlock *block, char *old
DECL_FUNCTION(FSStatus, FSRenameAsync, FSClient *client, FSCmdBlock *block, char *oldPath, char *newPath, FSErrorFlag errorMask, FSAsyncData *asyncData) { DECL_FUNCTION(FSStatus, FSRenameAsync, FSClient *client, FSCmdBlock *block, char *oldPath, char *newPath, FSErrorFlag errorMask, FSAsyncData *asyncData) {
DEBUG_FUNCTION_LINE_VERBOSE("%s %s", oldPath, newPath); DEBUG_FUNCTION_LINE_VERBOSE("%s %s", oldPath, newPath);
FSStatus result = FSRenameWrapper(oldPath, newPath, errorMask, FSStatus result = FSRenameWrapper(
oldPath, newPath, errorMask,
[client, block, errorMask, asyncData](char *_oldOath, char *_newPath) -> FSStatus { [client, block, errorMask, asyncData](char *_oldOath, char *_newPath) -> FSStatus {
return real_FSRenameAsync(client, block, _oldOath, _newPath, errorMask, asyncData); return real_FSRenameAsync(client, block, _oldOath, _newPath, errorMask, asyncData);
}, },

View File

@ -13,4 +13,3 @@ extern uint32_t fs_file_function_replacements_size;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,15 +1,15 @@
#include "FSWrapper.h" #include "FSWrapper.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
#include <cstring>
#include <mutex>
#include <coreinit/cache.h>
#include <coreinit/debug.h>
#include "utils/logger.h"
#include "FileUtils.h" #include "FileUtils.h"
#include "globals.h" #include "globals.h"
#include "utils/logger.h"
#include <coreinit/cache.h>
#include <coreinit/debug.h>
#include <cstring>
#include <fcntl.h>
#include <mutex>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
dirMagic_t dir_handles[DIR_HANDLES_LENGTH]; dirMagic_t dir_handles[DIR_HANDLES_LENGTH];
fileMagic_t file_handles[FILE_HANDLES_LENGTH]; fileMagic_t file_handles[FILE_HANDLES_LENGTH];
@ -59,10 +59,10 @@ int getNewFileHandleIndex() {
handle_id = i; handle_id = i;
if (!file_handles[i].mutex) { if (!file_handles[i].mutex) {
file_handles[i].mutex = (OSMutex *) malloc(sizeof(OSMutex)); file_handles[i].mutex = (OSMutex *) malloc(sizeof(OSMutex));
OSInitMutex(file_handles[i].mutex);
if (!file_handles[i].mutex) { if (!file_handles[i].mutex) {
OSFatal("Failed to alloc memory for mutex"); OSFatal("Failed to alloc memory for mutex");
} }
OSInitMutex(file_handles[i].mutex);
DCFlushRange(file_handles[i].mutex, sizeof(OSMutex)); DCFlushRange(file_handles[i].mutex, sizeof(OSMutex));
DCFlushRange(&file_handles[i], sizeof(fileMagic_t)); DCFlushRange(&file_handles[i], sizeof(fileMagic_t));
} }
@ -779,14 +779,12 @@ FSStatus FSReadFileWithPosWrapper(void *buffer,
FSStatus result; FSStatus result;
if ((result = FSSetPosFileWrapper(handle, pos, errorMask, if ((result = FSSetPosFileWrapper(handle, pos, errorMask,
[](FSStatus res) -> FSStatus { return res; }) [](FSStatus res) -> FSStatus { return res; })) != FS_STATUS_OK) {
) != FS_STATUS_OK) {
return result; return result;
} }
result = FSReadFileWrapper(buffer, size, count, handle, unk1, errorMask, result = FSReadFileWrapper(buffer, size, count, handle, unk1, errorMask,
[](FSStatus res) -> FSStatus { return res; } [](FSStatus res) -> FSStatus { return res; });
);
if (result != FS_STATUS_USE_REAL_OS && result != FS_STATUS_FATAL_ERROR) { if (result != FS_STATUS_USE_REAL_OS && result != FS_STATUS_FATAL_ERROR) {
return result_handler(result); return result_handler(result);

View File

@ -1,10 +1,10 @@
#pragma once #pragma once
#include <coreinit/filesystem.h>
#include <coreinit/mutex.h>
#include <cstdint> #include <cstdint>
#include <dirent.h> #include <dirent.h>
#include <functional> #include <functional>
#include <coreinit/filesystem.h>
#include <coreinit/mutex.h>
typedef struct dirMagic { typedef struct dirMagic {
uint32_t handle{}; uint32_t handle{};

View File

@ -1,18 +1,18 @@
#include "FileUtils.h" #include "FileUtils.h"
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <mutex> #include <mutex>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "utils/StringTools.h"
#include "utils/logger.h"
#include "utils/utils.h"
#include <coreinit/cache.h>
#include <coreinit/debug.h> #include <coreinit/debug.h>
#include <map>
#include <coreinit/thread.h> #include <coreinit/thread.h>
#include <dirent.h> #include <dirent.h>
#include <coreinit/cache.h> #include <map>
#include "utils/StringTools.h"
#include "utils/utils.h"
#include "utils/logger.h"
extern "C" OSMessageQueue *OSGetDefaultAppIOQueue(); extern "C" OSMessageQueue *OSGetDefaultAppIOQueue();

View File

@ -1,14 +1,13 @@
#pragma once #pragma once
#include <string>
#include <coreinit/filesystem.h> #include <coreinit/filesystem.h>
#include <romfs_dev.h> #include <romfs_dev.h>
#include <string>
struct WUT_PACKED FSCmdBlockBody { //! FSAsyncResult object used for this command. struct WUT_PACKED FSCmdBlockBody { //! FSAsyncResult object used for this command.
WUT_UNKNOWN_BYTES(0x96C); WUT_UNKNOWN_BYTES(0x96C);
FSAsyncResult asyncResult; FSAsyncResult asyncResult;
}; };
WUT_CHECK_OFFSET(FSCmdBlockBody, 0x96C, asyncResult); WUT_CHECK_OFFSET(FSCmdBlockBody, 0x96C, asyncResult);
WUT_CHECK_SIZE(FSCmdBlockBody, 0x96C + 0x28); WUT_CHECK_SIZE(FSCmdBlockBody, 0x96C + 0x28);

View File

@ -1,21 +1,21 @@
#include <string>
#include <coreinit/cache.h>
#include <coreinit/ios.h>
#include <romfs_dev.h>
#include "utils/logger.h"
#include "RPXLoading.h" #include "RPXLoading.h"
#include "globals.h"
#include "FileUtils.h" #include "FileUtils.h"
#include <nn/acp/title.h> #include "globals.h"
#include <memory>
#include <algorithm>
#include "utils/FileReader.h" #include "utils/FileReader.h"
#include "utils/FileReaderCompressed.h" #include "utils/FileReaderCompressed.h"
#include "utils/StringTools.h" #include "utils/StringTools.h"
#include "utils/ini.h" #include "utils/ini.h"
#include "utils/logger.h"
#include <algorithm>
#include <coreinit/cache.h>
#include <coreinit/ios.h>
#include <cstring> #include <cstring>
#include <rpxloader.h>
#include <dirent.h> #include <dirent.h>
#include <memory>
#include <nn/acp/title.h>
#include <romfs_dev.h>
#include <rpxloader.h>
#include <string>
/* /*
* Patch the meta xml for the home menu * Patch the meta xml for the home menu
@ -57,7 +57,6 @@ DECL_FUNCTION(FSStatus, RPX_FSReadFile, FSClient *client, FSCmdBlock *block, uin
if ((handle & 0xF0000000) == 0x80000000) { if ((handle & 0xF0000000) == 0x80000000) {
auto reader = (FileReader *) handle; auto reader = (FileReader *) handle;
return (FSStatus) reader->read(buffer, size * count); return (FSStatus) reader->read(buffer, size * count);
} }
FSStatus result = real_RPX_FSReadFile(client, block, buffer, size, count, handle, unk1, flags); FSStatus result = real_RPX_FSReadFile(client, block, buffer, size, count, handle, unk1, flags);
return result; return result;
@ -180,7 +179,7 @@ bool RL_LoadFromSDOnNextLaunch(const char *bundle_path) {
request.path[0] = '\0'; request.path[0] = '\0';
strncat(request.path, bundle_path, sizeof(request.path) - 1); strncat(request.path, bundle_path, sizeof(request.path) - 1);
DCFlushRange(&request, sizeof(LOAD_REQUEST)); DCFlushRange(&request, sizeof(request));
int success = false; int success = false;
int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0); int mcpFd = IOS_Open("/dev/mcp", (IOSOpenMode) 0);

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <function_patcher/function_patching.h>
#include <cstdint> #include <cstdint>
#include <function_patcher/function_patching.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -21,5 +21,3 @@ extern uint32_t rpx_utils_function_replacements_size;
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,5 +1,5 @@
#include <coreinit/filesystem.h>
#include "globals.h" #include "globals.h"
#include <coreinit/filesystem.h>
RPXLoader_ReplacementInformation gReplacementInfo __attribute__((section(".data"))); RPXLoader_ReplacementInformation gReplacementInfo __attribute__((section(".data")));

View File

@ -1,6 +1,6 @@
#include <wums.h>
#include <coreinit/mutex.h>
#include <coreinit/filesystem.h> #include <coreinit/filesystem.h>
#include <coreinit/mutex.h>
#include <wums.h>
typedef struct MetaInformation_t { typedef struct MetaInformation_t {
char shortname[64]; char shortname[64];

View File

@ -1,22 +1,22 @@
#include <wums.h>
#include <cstring> #include <cstring>
#include <malloc.h> #include <malloc.h>
#include <wums.h>
#include "FSDirReplacements.h"
#include "FSFileReplacements.h"
#include "FileUtils.h"
#include "RPXLoading.h"
#include "globals.h"
#include "utils/StringTools.h"
#include "utils/logger.h"
#include <coreinit/debug.h> #include <coreinit/debug.h>
#include <coreinit/title.h> #include <coreinit/title.h>
#include <sysapp/title.h>
#include <string> #include <string>
#include "utils/logger.h" #include <sysapp/title.h>
#include "utils/StringTools.h"
#include "FSFileReplacements.h"
#include "globals.h"
#include "FileUtils.h"
#include "FSDirReplacements.h"
#include "RPXLoading.h"
#include <romfs_dev.h>
#include <coreinit/cache.h> #include <coreinit/cache.h>
#include <nn/act.h> #include <nn/act.h>
#include <romfs_dev.h>
WUMS_MODULE_EXPORT_NAME("homebrew_rpx_loader"); WUMS_MODULE_EXPORT_NAME("homebrew_rpx_loader");
WUMS_USE_WUT_DEVOPTAB(); WUMS_USE_WUT_DEVOPTAB();
@ -100,12 +100,12 @@ WUMS_APPLICATION_STARTS() {
uint32_t currentHash = StringTools::hash(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath); uint32_t currentHash = StringTools::hash(gReplacementInfo.contentReplacementInfo.bundleMountInformation.toMountPath);
nn::act::Initialize(); nn::act::Initialize();
nn::act::PersistentId slot = nn::act::GetPersistentId(); nn::act::PersistentId persistentId = nn::act::GetPersistentId();
nn::act::Finalize(); nn::act::Finalize();
std::string basePath = StringTools::strfmt("/vol/external01/wiiu/apps/save/%08X", currentHash); std::string basePath = StringTools::strfmt("/vol/external01/wiiu/apps/save/%08X", currentHash);
std::string common = StringTools::strfmt("fs:/vol/external01/wiiu/apps/save/%08X/common", currentHash); std::string common = StringTools::strfmt("fs:/vol/external01/wiiu/apps/save/%08X/common", currentHash);
std::string user = StringTools::strfmt("fs:/vol/external01/wiiu/apps/save/%08X/%08X", currentHash, 0x80000000 | slot); std::string user = StringTools::strfmt("fs:/vol/external01/wiiu/apps/save/%08X/%08X", currentHash, 0x80000000 | persistentId);
gReplacementInfo.contentReplacementInfo.savePath[0] = '\0'; gReplacementInfo.contentReplacementInfo.savePath[0] = '\0';
strncat(gReplacementInfo.contentReplacementInfo.savePath, strncat(gReplacementInfo.contentReplacementInfo.savePath,
@ -140,4 +140,3 @@ WUMS_APPLICATION_STARTS() {
DCFlushRange(&gReplacementInfo, sizeof(gReplacementInfo)); DCFlushRange(&gReplacementInfo, sizeof(gReplacementInfo));
} }
} }

View File

@ -14,7 +14,7 @@ int FileReader::read(uint8_t *buffer, uint32_t size) {
if (toRead == 0) { if (toRead == 0) {
return 0; return 0;
} }
memcpy(buffer, input_buffer + input_pos, toRead); memcpy(buffer, &input_buffer[input_pos], toRead);
input_pos += toRead; input_pos += toRead;
return toRead; return toRead;
} else if (isReadFromFile) { } else if (isReadFromFile) {

View File

@ -1,10 +1,10 @@
#pragma once #pragma once
#include <string>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <string>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
class FileReader { class FileReader {

View File

@ -1,8 +1,8 @@
#pragma once #pragma once
#include <zlib.h>
#include "FileReader.h" #include "FileReader.h"
#include "logger.h" #include "logger.h"
#include <zlib.h>
#define BUFFER_SIZE 0x20000 #define BUFFER_SIZE 0x20000
@ -12,8 +12,7 @@ public:
explicit FileReaderCompressed(std::string &file); explicit FileReaderCompressed(std::string &file);
~FileReaderCompressed() override { ~FileReaderCompressed() override = default;
}
int read(uint8_t *buffer, uint32_t size) override; int read(uint8_t *buffer, uint32_t size) override;

View File

@ -23,22 +23,22 @@
* *
* for WiiXplorer 2010 * for WiiXplorer 2010
***************************************************************************/ ***************************************************************************/
#include <vector>
#include <string>
#include <string.h>
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <string.h>
#include <wchar.h> #include <string>
#include <strings.h> #include <strings.h>
#include <wut_types.h>
#include <stdio.h>
#include <utils/StringTools.h> #include <utils/StringTools.h>
#include <vector>
#include <wchar.h>
#include <wut_types.h>
BOOL StringTools::EndsWith(const std::string &a, const std::string &b) { BOOL StringTools::EndsWith(const std::string &a, const std::string &b) {
if (b.size() > a.size()) if (b.size() > a.size()) {
return false; return false;
}
return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin()); return std::equal(a.begin() + a.size() - b.size(), a.end(), b.begin());
} }
@ -301,4 +301,3 @@ uint32_t StringTools::hash(char *str) {
} }
return h; // or, h % ARRAY_SIZE; return h; // or, h % ARRAY_SIZE;
} }

View File

@ -26,8 +26,8 @@
#ifndef __STRING_TOOLS_H #ifndef __STRING_TOOLS_H
#define __STRING_TOOLS_H #define __STRING_TOOLS_H
#include <vector>
#include <string> #include <string>
#include <vector>
#include <wut_types.h> #include <wut_types.h>
class StringTools { class StringTools {
@ -64,4 +64,3 @@ public:
}; };
#endif /* __STRING_TOOLS_H */ #endif /* __STRING_TOOLS_H */

View File

@ -1,12 +1,16 @@
/* inih -- simple .INI file parser /* inih -- simple .INI file parser
SPDX-License-Identifier: BSD-3-Clause
Copyright (C) 2009-2020, Ben Hoyt
inih is released under the New BSD license (see LICENSE.txt). Go to the project inih is released under the New BSD license (see LICENSE.txt). Go to the project
home page for more info: home page for more info:
https://github.com/benhoyt/inih https://github.com/benhoyt/inih
*/ */
// clang-format off
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
#define _CRT_SECURE_NO_WARNINGS #define _CRT_SECURE_NO_WARNINGS
#endif #endif
@ -18,9 +22,17 @@ https://github.com/benhoyt/inih
#include "ini.h" #include "ini.h"
#if !INI_USE_STACK #if !INI_USE_STACK
#if INI_CUSTOM_ALLOCATOR
#include <stddef.h>
void* ini_malloc(size_t size);
void ini_free(void* ptr);
void* ini_realloc(void* ptr, size_t size);
#else
#include <stdlib.h> #include <stdlib.h>
#define ini_malloc malloc
#define ini_free free
#define ini_realloc realloc
#endif
#endif #endif
#define MAX_SECTION 50 #define MAX_SECTION 50
@ -33,7 +45,8 @@ typedef struct {
} ini_parse_string_ctx; } ini_parse_string_ctx;
/* Strip whitespace chars off end of given string, in place. Return s. */ /* Strip whitespace chars off end of given string, in place. Return s. */
static char *rstrip(char *s) { static char* rstrip(char* s)
{
char* p = s + strlen(s); char* p = s + strlen(s);
while (p > s && isspace((unsigned char)(*--p))) while (p > s && isspace((unsigned char)(*--p)))
*p = '\0'; *p = '\0';
@ -41,16 +54,18 @@ static char *rstrip(char *s) {
} }
/* Return pointer to first non-whitespace char in given string. */ /* Return pointer to first non-whitespace char in given string. */
static char *lskip(const char *s) { static char* lskip(const char* s)
{
while (*s && isspace((unsigned char)(*s))) while (*s && isspace((unsigned char)(*s)))
s++; s++;
return (char*)s; return (char*)s;
} }
/* Return pointer to first char (of chars) or inline comment in given string, /* Return pointer to first char (of chars) or inline comment in given string,
or pointer to null at end of string if neither found. Inline comment must or pointer to NUL at end of string if neither found. Inline comment must
be prefixed by a whitespace character to register as a comment. */ be prefixed by a whitespace character to register as a comment. */
static char *find_chars_or_comment(const char *s, const char *chars) { static char* find_chars_or_comment(const char* s, const char* chars)
{
#if INI_ALLOW_INLINE_COMMENTS #if INI_ALLOW_INLINE_COMMENTS
int was_space = 0; int was_space = 0;
while (*s && (!chars || !strchr(chars, *s)) && while (*s && (!chars || !strchr(chars, *s)) &&
@ -66,30 +81,33 @@ static char *find_chars_or_comment(const char *s, const char *chars) {
return (char*)s; return (char*)s;
} }
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */ /* Similar to strncpy, but ensures dest (size bytes) is
static char *strncpy0(char *dest, const char *src, size_t size) { NUL-terminated, and doesn't pad with NULs. */
#pragma GCC diagnostic push static char* strncpy0(char* dest, const char* src, size_t size)
#pragma GCC diagnostic ignored "-Wstringop-truncation" {
strncpy(dest, src, size - 1); /* Could use strncpy internally, but it causes gcc warnings (see issue #91) */
#pragma GCC diagnostic pop size_t i;
dest[size - 1] = '\0'; for (i = 0; i < size - 1 && src[i]; i++)
dest[i] = src[i];
dest[i] = '\0';
return dest; return dest;
} }
/* See documentation in header file. */ /* See documentation in header file. */
int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
void *user) { void* user)
{
/* Uses a fair bit of stack (use heap instead if you need to) */ /* Uses a fair bit of stack (use heap instead if you need to) */
#if INI_USE_STACK #if INI_USE_STACK
char line[INI_MAX_LINE]; char line[INI_MAX_LINE];
int max_line = INI_MAX_LINE; int max_line = INI_MAX_LINE;
#else #else
char* line; char* line;
int max_line = INI_INITIAL_ALLOC; size_t max_line = INI_INITIAL_ALLOC;
#endif #endif
#if INI_ALLOW_REALLOC #if INI_ALLOW_REALLOC && !INI_USE_STACK
char* new_line; char* new_line;
int offset; size_t offset;
#endif #endif
char section[MAX_SECTION] = ""; char section[MAX_SECTION] = "";
char prev_name[MAX_NAME] = ""; char prev_name[MAX_NAME] = "";
@ -102,7 +120,7 @@ int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
int error = 0; int error = 0;
#if !INI_USE_STACK #if !INI_USE_STACK
line = (char *) malloc(INI_INITIAL_ALLOC); line = (char*)ini_malloc(INI_INITIAL_ALLOC);
if (!line) { if (!line) {
return -2; return -2;
} }
@ -115,20 +133,20 @@ int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
#endif #endif
/* Scan through stream line by line */ /* Scan through stream line by line */
while (reader(line, max_line, stream) != NULL) { while (reader(line, (int)max_line, stream) != NULL) {
#if INI_ALLOW_REALLOC #if INI_ALLOW_REALLOC && !INI_USE_STACK
offset = strlen(line); offset = strlen(line);
while (offset == max_line - 1 && line[offset - 1] != '\n') { while (offset == max_line - 1 && line[offset - 1] != '\n') {
max_line *= 2; max_line *= 2;
if (max_line > INI_MAX_LINE) if (max_line > INI_MAX_LINE)
max_line = INI_MAX_LINE; max_line = INI_MAX_LINE;
new_line = realloc(line, max_line); new_line = ini_realloc(line, max_line);
if (!new_line) { if (!new_line) {
free(line); ini_free(line);
return -2; return -2;
} }
line = new_line; line = new_line;
if (reader(line + offset, max_line - offset, stream) == NULL) if (reader(line + offset, (int)(max_line - offset), stream) == NULL)
break; break;
if (max_line >= INI_MAX_LINE) if (max_line >= INI_MAX_LINE)
break; break;
@ -166,11 +184,17 @@ int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
*end = '\0'; *end = '\0';
strncpy0(section, start + 1, sizeof(section)); strncpy0(section, start + 1, sizeof(section));
*prev_name = '\0'; *prev_name = '\0';
} else if (!error) { #if INI_CALL_HANDLER_ON_NEW_SECTION
if (!HANDLER(user, section, NULL, NULL) && !error)
error = lineno;
#endif
}
else if (!error) {
/* No ']' found on section line */ /* No ']' found on section line */
error = lineno; error = lineno;
} }
} else if (*start) { }
else if (*start) {
/* Not a comment, must be a name[=:]value pair */ /* Not a comment, must be a name[=:]value pair */
end = find_chars_or_comment(start, "=:"); end = find_chars_or_comment(start, "=:");
if (*end == '=' || *end == ':') { if (*end == '=' || *end == ':') {
@ -189,9 +213,17 @@ int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
strncpy0(prev_name, name, sizeof(prev_name)); strncpy0(prev_name, name, sizeof(prev_name));
if (!HANDLER(user, section, name, value) && !error) if (!HANDLER(user, section, name, value) && !error)
error = lineno; error = lineno;
} else if (!error) { }
else if (!error) {
/* No '=' or ':' found on name[=:]value line */ /* No '=' or ':' found on name[=:]value line */
#if INI_ALLOW_NO_VALUE
*end = '\0';
name = rstrip(start);
if (!HANDLER(user, section, name, NULL) && !error)
error = lineno; error = lineno;
#else
error = lineno;
#endif
} }
} }
@ -202,19 +234,21 @@ int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
} }
#if !INI_USE_STACK #if !INI_USE_STACK
free(line); ini_free(line);
#endif #endif
return error; return error;
} }
/* See documentation in header file. */ /* See documentation in header file. */
int ini_parse_file(FILE *file, ini_handler handler, void *user) { int ini_parse_file(FILE* file, ini_handler handler, void* user)
{
return ini_parse_stream((ini_reader)fgets, file, handler, user); return ini_parse_stream((ini_reader)fgets, file, handler, user);
} }
/* See documentation in header file. */ /* See documentation in header file. */
int ini_parse(const char *filename, ini_handler handler, void *user) { int ini_parse(const char* filename, ini_handler handler, void* user)
{
FILE* file; FILE* file;
int error; int error;

View File

@ -1,14 +1,18 @@
/* inih -- simple .INI file parser /* inih -- simple .INI file parser
SPDX-License-Identifier: BSD-3-Clause
Copyright (C) 2009-2020, Ben Hoyt
inih is released under the New BSD license (see LICENSE.txt). Go to the project inih is released under the New BSD license (see LICENSE.txt). Go to the project
home page for more info: home page for more info:
https://github.com/benhoyt/inih https://github.com/benhoyt/inih
*/ */
// clang-format off
#ifndef __INI_H__ #ifndef INI_H
#define __INI_H__ #define INI_H
/* Make this header file easier to include in C++ code */ /* Make this header file easier to include in C++ code */
#ifdef __cplusplus #ifdef __cplusplus
@ -73,7 +77,7 @@ int ini_parse_string(const char *string, ini_handler handler, void *user);
#endif #endif
/* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of
the file. See http://code.google.com/p/inih/issues/detail?id=21 */ the file. See https://github.com/benhoyt/inih/issues/21 */
#ifndef INI_ALLOW_BOM #ifndef INI_ALLOW_BOM
#define INI_ALLOW_BOM 1 #define INI_ALLOW_BOM 1
#endif #endif
@ -123,8 +127,31 @@ int ini_parse_string(const char *string, ini_handler handler, void *user);
#define INI_STOP_ON_FIRST_ERROR 0 #define INI_STOP_ON_FIRST_ERROR 0
#endif #endif
/* Nonzero to call the handler at the start of each new section (with
name and value NULL). Default is to only call the handler on
each name=value pair. */
#ifndef INI_CALL_HANDLER_ON_NEW_SECTION
#define INI_CALL_HANDLER_ON_NEW_SECTION 0
#endif
/* Nonzero to allow a name without a value (no '=' or ':' on the line) and
call the handler with value NULL in this case. Default is to treat
no-value lines as an error. */
#ifndef INI_ALLOW_NO_VALUE
#define INI_ALLOW_NO_VALUE 0
#endif
/* Nonzero to use custom ini_malloc, ini_free, and ini_realloc memory
allocation functions (INI_USE_STACK must also be 0). These functions must
have the same signatures as malloc/free/realloc and behave in a similar
way. ini_realloc is only needed if INI_ALLOW_REALLOC is set. */
#ifndef INI_CUSTOM_ALLOCATOR
#define INI_CUSTOM_ALLOCATOR 0
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#endif /* __INI_H__ */ #endif /* INI_H */

View File

@ -1,8 +1,8 @@
#ifdef DEBUG #ifdef DEBUG
#include <stdint.h> #include <stdint.h>
#include <whb/log_udp.h>
#include <whb/log_cafe.h> #include <whb/log_cafe.h>
#include <whb/log_module.h> #include <whb/log_module.h>
#include <whb/log_udp.h>
uint32_t moduleLogInit = false; uint32_t moduleLogInit = false;
uint32_t cafeLogInit = false; uint32_t cafeLogInit = false;

View File

@ -1,7 +1,7 @@
#pragma once #pragma once
#include <whb/log.h>
#include <string.h> #include <string.h>
#include <whb/log.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
@ -14,11 +14,13 @@ extern "C" {
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0) #define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
#define DEBUG_FUNCTION_LINE(FMT, ARGS...)do { \ #define DEBUG_FUNCTION_LINE(FMT, ARGS...) \
do { \
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ WHBLogPrintf("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0) } while (0)
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...)do { \ #define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) \
do { \
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \ WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
} while (0) } while (0)
@ -39,4 +41,3 @@ void deinitLogging();
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -1,6 +1,6 @@
#include "utils/logger.h"
#include <string.h> #include <string.h>
#include <whb/log.h> #include <whb/log.h>
#include "utils/logger.h"
#define PRINTF_BUFFER_LENGTH 2048 #define PRINTF_BUFFER_LENGTH 2048

View File

@ -11,7 +11,8 @@ extern "C" {
typeof(x) _x = x; \ typeof(x) _x = x; \
typeof(min) _min = min; \ typeof(min) _min = min; \
typeof(max) _max = max; \ typeof(max) _max = max; \
( ( ( _x ) < ( _min ) ) ? ( _min ) : ( ( _x ) > ( _max ) ) ? ( _max) : ( _x ) ); \ (((_x) < (_min)) ? (_min) : ((_x) > (_max)) ? (_max) \
: (_x)); \
}) })
#define DegToRad(a) ((a) *0.01745329252f) #define DegToRad(a) ((a) *0.01745329252f)