mirror of
https://github.com/wiiu-env/wiiload_plugin.git
synced 2024-11-22 02:29:15 +01:00
Format the code via clang-format
This commit is contained in:
parent
dcbf322005
commit
3cf879dee7
67
.clang-format
Normal file
67
.clang-format
Normal 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
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@ -6,8 +6,16 @@ on:
|
|||||||
- master
|
- master
|
||||||
|
|
||||||
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
|
||||||
|
8
.github/workflows/pr.yml
vendored
8
.github/workflows/pr.yml
vendored
@ -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
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
[![CI-Release](https://github.com/wiiu-env/wiiload_plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/wiiload_plugin/actions/workflows/ci.yml)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
(`[ENVIRONMENT]` is a placeholder for the actual environment name.)
|
(`[ENVIRONMENT]` is a placeholder for the actual environment name.)
|
||||||
|
|
||||||
@ -19,3 +21,7 @@ docker run -it --rm -v ${PWD}:/project wiiloadplugin-builder make
|
|||||||
# make clean
|
# make clean
|
||||||
docker run -it --rm -v ${PWD}:/project wiiloadplugin-builder make clean
|
docker run -it --rm -v ${PWD}:/project wiiloadplugin-builder make clean
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Format the code via docker
|
||||||
|
|
||||||
|
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src -i`
|
@ -1,13 +1,13 @@
|
|||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <strings.h>
|
|
||||||
#include <fs/CFile.hpp>
|
#include <fs/CFile.hpp>
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
CFile::CFile() {
|
CFile::CFile() {
|
||||||
iFd = -1;
|
iFd = -1;
|
||||||
mem_file = nullptr;
|
mem_file = nullptr;
|
||||||
filesize = 0;
|
filesize = 0;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
CFile::CFile(const std::string &filepath, eOpenTypes mode) {
|
CFile::CFile(const std::string &filepath, eOpenTypes mode) {
|
||||||
@ -34,7 +34,7 @@ int32_t CFile::open(const std::string &filepath, eOpenTypes mode) {
|
|||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
default:
|
default:
|
||||||
case ReadOnly: // file must exist
|
case ReadOnly: // file must exist
|
||||||
openMode = O_RDONLY;
|
openMode = O_RDONLY;
|
||||||
break;
|
break;
|
||||||
case WriteOnly: // file will be created / zerod
|
case WriteOnly: // file will be created / zerod
|
||||||
@ -76,10 +76,10 @@ void CFile::close() {
|
|||||||
if (iFd >= 0)
|
if (iFd >= 0)
|
||||||
::close(iFd);
|
::close(iFd);
|
||||||
|
|
||||||
iFd = -1;
|
iFd = -1;
|
||||||
mem_file = NULL;
|
mem_file = NULL;
|
||||||
filesize = 0;
|
filesize = 0;
|
||||||
pos = 0;
|
pos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t CFile::read(uint8_t *ptr, size_t size) {
|
int32_t CFile::read(uint8_t *ptr, size_t size) {
|
||||||
@ -126,7 +126,7 @@ int32_t CFile::write(const uint8_t *ptr, size_t size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t CFile::seek(long int offset, int32_t origin) {
|
int32_t CFile::seek(long int offset, int32_t origin) {
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
int64_t newPos = pos;
|
int64_t newPos = pos;
|
||||||
|
|
||||||
if (origin == SEEK_SET) {
|
if (origin == SEEK_SET) {
|
||||||
@ -157,7 +157,7 @@ int32_t CFile::seek(long int offset, int32_t origin) {
|
|||||||
|
|
||||||
int32_t CFile::fwrite(const char *format, ...) {
|
int32_t CFile::fwrite(const char *format, ...) {
|
||||||
char tmp[512];
|
char tmp[512];
|
||||||
tmp[0] = 0;
|
tmp[0] = 0;
|
||||||
int32_t result = -1;
|
int32_t result = -1;
|
||||||
|
|
||||||
va_list va;
|
va_list va;
|
||||||
@ -170,5 +170,3 @@ int32_t CFile::fwrite(const char *format, ...) {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <string>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <string>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wut_types.h>
|
#include <wut_types.h>
|
||||||
|
|
||||||
|
@ -24,22 +24,22 @@
|
|||||||
* DirList Class
|
* DirList Class
|
||||||
* for WiiXplorer 2010
|
* for WiiXplorer 2010
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
#include <algorithm>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <algorithm>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/dirent.h>
|
#include <sys/dirent.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include <fs/DirList.h>
|
#include <fs/DirList.h>
|
||||||
#include <utils/StringTools.h>
|
#include <utils/StringTools.h>
|
||||||
|
|
||||||
DirList::DirList() {
|
DirList::DirList() {
|
||||||
Flags = 0;
|
Flags = 0;
|
||||||
Filter = 0;
|
Filter = 0;
|
||||||
Depth = 0;
|
Depth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DirList::DirList(const std::string &path, const char *filter, uint32_t flags, uint32_t maxDepth) {
|
DirList::DirList(const std::string &path, const char *filter, uint32_t flags, uint32_t maxDepth) {
|
||||||
@ -54,9 +54,9 @@ DirList::~DirList() {
|
|||||||
BOOL DirList::LoadPath(const std::string &folder, const char *filter, uint32_t flags, uint32_t maxDepth) {
|
BOOL DirList::LoadPath(const std::string &folder, const char *filter, uint32_t flags, uint32_t maxDepth) {
|
||||||
if (folder.empty()) return false;
|
if (folder.empty()) return false;
|
||||||
|
|
||||||
Flags = flags;
|
Flags = flags;
|
||||||
Filter = filter;
|
Filter = filter;
|
||||||
Depth = maxDepth;
|
Depth = maxDepth;
|
||||||
|
|
||||||
std::string folderpath(folder);
|
std::string folderpath(folder);
|
||||||
uint32_t length = folderpath.size();
|
uint32_t length = folderpath.size();
|
||||||
@ -81,14 +81,14 @@ BOOL DirList::InternalLoadPath(std::string &folderpath) {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
struct dirent *dirent = nullptr;
|
struct dirent *dirent = nullptr;
|
||||||
DIR *dir = NULL;
|
DIR *dir = NULL;
|
||||||
|
|
||||||
dir = opendir(folderpath.c_str());
|
dir = opendir(folderpath.c_str());
|
||||||
if (dir == NULL)
|
if (dir == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
while ((dirent = readdir(dir)) != 0) {
|
while ((dirent = readdir(dir)) != 0) {
|
||||||
BOOL isDir = dirent->d_type & DT_DIR;
|
BOOL isDir = dirent->d_type & DT_DIR;
|
||||||
const char *filename = dirent->d_name;
|
const char *filename = dirent->d_name;
|
||||||
|
|
||||||
if (isDir) {
|
if (isDir) {
|
||||||
@ -191,7 +191,7 @@ void DirList::SortList(BOOL (*SortFunc)(const DirEntry &a, const DirEntry &b)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint64_t DirList::GetFilesize(int32_t index) const {
|
uint64_t DirList::GetFilesize(int32_t index) const {
|
||||||
struct stat st{};
|
struct stat st {};
|
||||||
const char *path = GetFilepath(index);
|
const char *path = GetFilepath(index);
|
||||||
|
|
||||||
if (!path || stat(path, &st) != 0)
|
if (!path || stat(path, &st) != 0)
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <wut_types.h>
|
#include <wut_types.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -59,7 +59,8 @@ public:
|
|||||||
//!\param list index
|
//!\param list index
|
||||||
[[nodiscard]] const char *GetFilepath(int32_t index) const {
|
[[nodiscard]] const char *GetFilepath(int32_t index) const {
|
||||||
if (!valid(index)) return "";
|
if (!valid(index)) return "";
|
||||||
else return FileInfo[index].FilePath;
|
else
|
||||||
|
return FileInfo[index].FilePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Get the a filesize of the list
|
//! Get the a filesize of the list
|
||||||
@ -89,10 +90,11 @@ public:
|
|||||||
|
|
||||||
//! Enum for search/filter flags
|
//! Enum for search/filter flags
|
||||||
enum {
|
enum {
|
||||||
Files = 0x01,
|
Files = 0x01,
|
||||||
Dirs = 0x02,
|
Dirs = 0x02,
|
||||||
CheckSubfolders = 0x08,
|
CheckSubfolders = 0x08,
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Internal parser
|
// Internal parser
|
||||||
BOOL InternalLoadPath(std::string &path);
|
BOOL InternalLoadPath(std::string &path);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#include <malloc.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <fs/FSUtils.h>
|
|
||||||
#include <fs/CFile.hpp>
|
#include <fs/CFile.hpp>
|
||||||
|
#include <fs/FSUtils.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
#include <utils/logger.h>
|
#include <utils/logger.h>
|
||||||
|
|
||||||
int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) {
|
int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_t *size) {
|
||||||
@ -27,8 +27,8 @@ int32_t FSUtils::LoadFileToMem(const char *filepath, uint8_t **inbuffer, uint32_
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32_t blocksize = 0x4000;
|
uint32_t blocksize = 0x4000;
|
||||||
uint32_t done = 0;
|
uint32_t done = 0;
|
||||||
int32_t readBytes = 0;
|
int32_t readBytes = 0;
|
||||||
|
|
||||||
while (done < filesize) {
|
while (done < filesize) {
|
||||||
if (done + blocksize > filesize) {
|
if (done + blocksize > filesize) {
|
||||||
@ -62,7 +62,7 @@ int32_t FSUtils::CheckFile(const char *filepath) {
|
|||||||
if (!filepath)
|
if (!filepath)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
struct stat filestat{};
|
struct stat filestat {};
|
||||||
|
|
||||||
char dirnoslash[strlen(filepath) + 2];
|
char dirnoslash[strlen(filepath) + 2];
|
||||||
snprintf(dirnoslash, sizeof(dirnoslash), "%s", filepath);
|
snprintf(dirnoslash, sizeof(dirnoslash), "%s", filepath);
|
||||||
@ -106,7 +106,7 @@ int32_t FSUtils::CreateSubfolder(const char *fullpath) {
|
|||||||
if (!ptr) {
|
if (!ptr) {
|
||||||
//!Device root directory (must be with '/')
|
//!Device root directory (must be with '/')
|
||||||
strcat(parentpath, "/");
|
strcat(parentpath, "/");
|
||||||
struct stat filestat{};
|
struct stat filestat {};
|
||||||
if (stat(parentpath, &filestat) == 0)
|
if (stat(parentpath, &filestat) == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@ -139,4 +139,3 @@ BOOL FSUtils::saveBufferToFile(const char *path, void *buffer, uint32_t size) {
|
|||||||
file.close();
|
file.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <wups.h>
|
|
||||||
#include "utils/logger.h"
|
|
||||||
#include "utils/TcpReceiver.h"
|
#include "utils/TcpReceiver.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include <wups.h>
|
||||||
|
|
||||||
WUPS_PLUGIN_NAME("Wiiload");
|
WUPS_PLUGIN_NAME("Wiiload");
|
||||||
WUPS_PLUGIN_DESCRIPTION("Wiiload Server");
|
WUPS_PLUGIN_DESCRIPTION("Wiiload Server");
|
||||||
|
@ -16,11 +16,11 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <malloc.h>
|
#include "utils/logger.h"
|
||||||
#include <unistd.h>
|
|
||||||
#include <coreinit/systeminfo.h>
|
#include <coreinit/systeminfo.h>
|
||||||
#include <coreinit/thread.h>
|
#include <coreinit/thread.h>
|
||||||
#include "utils/logger.h"
|
#include <malloc.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
class CThread {
|
class CThread {
|
||||||
public:
|
public:
|
||||||
@ -28,7 +28,7 @@ public:
|
|||||||
|
|
||||||
//! constructor
|
//! constructor
|
||||||
explicit CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = nullptr, void *callbackArg = nullptr)
|
explicit CThread(int32_t iAttr, int32_t iPriority = 16, int32_t iStackSize = 0x8000, CThread::Callback callback = nullptr, void *callbackArg = nullptr)
|
||||||
: pThread(nullptr), pThreadStack(nullptr), pCallback(callback), pCallbackArg(callbackArg) {
|
: pThread(nullptr), pThreadStack(nullptr), pCallback(callback), pCallbackArg(callbackArg) {
|
||||||
//! save attribute assignment
|
//! save attribute assignment
|
||||||
iAttributes = iAttr;
|
iAttributes = iAttr;
|
||||||
//! allocate the thread
|
//! allocate the thread
|
||||||
@ -115,19 +115,20 @@ public:
|
|||||||
free(pThread);
|
free(pThread);
|
||||||
}
|
}
|
||||||
|
|
||||||
pThread = nullptr;
|
pThread = nullptr;
|
||||||
pThreadStack = nullptr;
|
pThreadStack = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Thread attributes
|
//! Thread attributes
|
||||||
enum eCThreadAttributes {
|
enum eCThreadAttributes {
|
||||||
eAttributeNone = 0x07,
|
eAttributeNone = 0x07,
|
||||||
eAttributeAffCore0 = 0x01,
|
eAttributeAffCore0 = 0x01,
|
||||||
eAttributeAffCore1 = 0x02,
|
eAttributeAffCore1 = 0x02,
|
||||||
eAttributeAffCore2 = 0x04,
|
eAttributeAffCore2 = 0x04,
|
||||||
eAttributeDetach = 0x08,
|
eAttributeDetach = 0x08,
|
||||||
eAttributePinnedAff = 0x10
|
eAttributePinnedAff = 0x10
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static int threadCallback(int argc, const char **argv) {
|
static int threadCallback(int argc, const char **argv) {
|
||||||
//! After call to start() continue with the internal function
|
//! After call to start() continue with the internal function
|
||||||
|
@ -23,17 +23,16 @@
|
|||||||
*
|
*
|
||||||
* 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) {
|
||||||
@ -84,7 +83,7 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
|
|||||||
static char tmp[512];
|
static char tmp[512];
|
||||||
static wchar_t strWChar[512];
|
static wchar_t strWChar[512];
|
||||||
strWChar[0] = 0;
|
strWChar[0] = 0;
|
||||||
tmp[0] = 0;
|
tmp[0] = 0;
|
||||||
|
|
||||||
if (!format)
|
if (!format)
|
||||||
return (const wchar_t *) strWChar;
|
return (const wchar_t *) strWChar;
|
||||||
@ -97,7 +96,7 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
|
|||||||
if ((vsprintf(tmp, format, va) >= 0)) {
|
if ((vsprintf(tmp, format, va) >= 0)) {
|
||||||
int bt;
|
int bt;
|
||||||
int32_t strlength = strlen(tmp);
|
int32_t strlength = strlen(tmp);
|
||||||
bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512);
|
bt = mbstowcs(strWChar, tmp, (strlength < 512) ? strlength : 512);
|
||||||
|
|
||||||
if (bt > 0) {
|
if (bt > 0) {
|
||||||
strWChar[bt] = 0;
|
strWChar[bt] = 0;
|
||||||
@ -111,13 +110,13 @@ const wchar_t *StringTools::wfmt(const char *format, ...) {
|
|||||||
|
|
||||||
int32_t StringTools::strprintf(std::string &str, const char *format, ...) {
|
int32_t StringTools::strprintf(std::string &str, const char *format, ...) {
|
||||||
static char tmp[512];
|
static char tmp[512];
|
||||||
tmp[0] = 0;
|
tmp[0] = 0;
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
|
|
||||||
va_list va;
|
va_list va;
|
||||||
va_start(va, format);
|
va_start(va, format);
|
||||||
if ((vsprintf(tmp, format, va) >= 0)) {
|
if ((vsprintf(tmp, format, va) >= 0)) {
|
||||||
str = tmp;
|
str = tmp;
|
||||||
result = str.size();
|
result = str.size();
|
||||||
}
|
}
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
@ -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 {
|
||||||
@ -55,7 +55,7 @@ public:
|
|||||||
static const char *FullpathToFilename(const char *path) {
|
static const char *FullpathToFilename(const char *path) {
|
||||||
if (!path) return path;
|
if (!path) return path;
|
||||||
|
|
||||||
const char *ptr = path;
|
const char *ptr = path;
|
||||||
const char *Filename = ptr;
|
const char *Filename = ptr;
|
||||||
|
|
||||||
while (*ptr != '\0') {
|
while (*ptr != '\0') {
|
||||||
@ -85,4 +85,3 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __STRING_TOOLS_H */
|
#endif /* __STRING_TOOLS_H */
|
||||||
|
|
||||||
|
@ -1,35 +1,35 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <zlib.h>
|
#include <string>
|
||||||
#include <sysapp/launch.h>
|
#include <sysapp/launch.h>
|
||||||
|
#include <vector>
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#include <coreinit/dynload.h>
|
|
||||||
#include <coreinit/title.h>
|
|
||||||
#include <coreinit/messagequeue.h>
|
|
||||||
#include <coreinit/ios.h>
|
|
||||||
#include <coreinit/debug.h>
|
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
|
#include <coreinit/debug.h>
|
||||||
|
#include <coreinit/dynload.h>
|
||||||
|
#include <coreinit/ios.h>
|
||||||
|
#include <coreinit/messagequeue.h>
|
||||||
|
#include <coreinit/title.h>
|
||||||
#include <sysapp/title.h>
|
#include <sysapp/title.h>
|
||||||
|
|
||||||
#include "TcpReceiver.h"
|
#include "TcpReceiver.h"
|
||||||
#include "fs/FSUtils.h"
|
#include "fs/FSUtils.h"
|
||||||
#include "utils/net.h"
|
#include "utils/net.h"
|
||||||
#include "utils/utils.h"
|
#include "utils/utils.h"
|
||||||
#include <wups_backend/PluginUtils.h>
|
|
||||||
#include <rpxloader.h>
|
#include <rpxloader.h>
|
||||||
|
#include <wups_backend/PluginUtils.h>
|
||||||
|
|
||||||
#define RPX_TEMP_PATH "fs:/vol/external01/wiiu/apps/"
|
#define RPX_TEMP_PATH "fs:/vol/external01/wiiu/apps/"
|
||||||
#define RPX_TEMP_FILE "fs:/vol/external01/wiiu/apps/temp.rpx"
|
#define RPX_TEMP_FILE "fs:/vol/external01/wiiu/apps/temp.rpx"
|
||||||
#define WUHB_TEMP_FILE "fs:/vol/external01/wiiu/apps/temp.wuhb"
|
#define WUHB_TEMP_FILE "fs:/vol/external01/wiiu/apps/temp.wuhb"
|
||||||
#define WUHB_TEMP_FILE_2 "fs:/vol/external01/wiiu/apps/temp2.wuhb"
|
#define WUHB_TEMP_FILE_2 "fs:/vol/external01/wiiu/apps/temp2.wuhb"
|
||||||
#define RPX_TEMP_FILE_EX "wiiu/apps/temp.rpx"
|
#define RPX_TEMP_FILE_EX "wiiu/apps/temp.rpx"
|
||||||
#define WUHB_TEMP_FILE_EX "wiiu/apps/temp.wuhb"
|
#define WUHB_TEMP_FILE_EX "wiiu/apps/temp.wuhb"
|
||||||
#define WUHB_TEMP_FILE_2_EX "wiiu/apps/temp2.wuhb"
|
#define WUHB_TEMP_FILE_2_EX "wiiu/apps/temp2.wuhb"
|
||||||
|
|
||||||
TcpReceiver::TcpReceiver(int32_t port)
|
TcpReceiver::TcpReceiver(int32_t port)
|
||||||
: CThread(CThread::eAttributeAffCore1, 16, 0x20000), exitRequested(false), serverPort(port), serverSocket(-1) {
|
: CThread(CThread::eAttributeAffCore1, 16, 0x20000), exitRequested(false), serverPort(port), serverSocket(-1) {
|
||||||
|
|
||||||
resumeThread();
|
resumeThread();
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ TcpReceiver::~TcpReceiver() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define wiiu_geterrno() (socketlasterr())
|
#define wiiu_geterrno() (socketlasterr())
|
||||||
|
|
||||||
void TcpReceiver::executeThread() {
|
void TcpReceiver::executeThread() {
|
||||||
serverSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
serverSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);
|
||||||
@ -53,10 +53,10 @@ void TcpReceiver::executeThread() {
|
|||||||
uint32_t enable = 1;
|
uint32_t enable = 1;
|
||||||
setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable));
|
setsockopt(serverSocket, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable));
|
||||||
|
|
||||||
struct sockaddr_in bindAddress{};
|
struct sockaddr_in bindAddress {};
|
||||||
memset(&bindAddress, 0, sizeof(bindAddress));
|
memset(&bindAddress, 0, sizeof(bindAddress));
|
||||||
bindAddress.sin_family = AF_INET;
|
bindAddress.sin_family = AF_INET;
|
||||||
bindAddress.sin_port = serverPort;
|
bindAddress.sin_port = serverPort;
|
||||||
bindAddress.sin_addr.s_addr = INADDR_ANY;
|
bindAddress.sin_addr.s_addr = INADDR_ANY;
|
||||||
|
|
||||||
socklen_t len;
|
socklen_t len;
|
||||||
@ -71,11 +71,11 @@ void TcpReceiver::executeThread() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sockaddr_in clientAddr{};
|
struct sockaddr_in clientAddr {};
|
||||||
memset(&clientAddr, 0, sizeof(clientAddr));
|
memset(&clientAddr, 0, sizeof(clientAddr));
|
||||||
|
|
||||||
while (!exitRequested) {
|
while (!exitRequested) {
|
||||||
len = 16;
|
len = 16;
|
||||||
int32_t clientSocket = accept(serverSocket, (struct sockaddr *) &clientAddr, &len);
|
int32_t clientSocket = accept(serverSocket, (struct sockaddr *) &clientAddr, &len);
|
||||||
if (clientSocket >= 0) {
|
if (clientSocket >= 0) {
|
||||||
uint32_t ipAddress = clientAddr.sin_addr.s_addr;
|
uint32_t ipAddress = clientAddr.sin_addr.s_addr;
|
||||||
@ -100,7 +100,7 @@ void TcpReceiver::executeThread() {
|
|||||||
int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
||||||
DEBUG_FUNCTION_LINE("Loading file from ip %08X", ipAddress);
|
DEBUG_FUNCTION_LINE("Loading file from ip %08X", ipAddress);
|
||||||
|
|
||||||
uint32_t fileSize = 0;
|
uint32_t fileSize = 0;
|
||||||
uint32_t fileSizeUnc = 0;
|
uint32_t fileSizeUnc = 0;
|
||||||
unsigned char haxx[8];
|
unsigned char haxx[8];
|
||||||
memset(haxx, 0, sizeof(haxx));
|
memset(haxx, 0, sizeof(haxx));
|
||||||
@ -142,8 +142,8 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
|||||||
return FILE_READ_ERROR;
|
return FILE_READ_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool res = false;
|
bool res = false;
|
||||||
bool loadedRPX = false;
|
bool loadedRPX = false;
|
||||||
const char *file_path = nullptr;
|
const char *file_path = nullptr;
|
||||||
|
|
||||||
// Do we need to unzip this thing?
|
// Do we need to unzip this thing?
|
||||||
@ -168,7 +168,7 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
|||||||
memset(&s, 0, sizeof(s));
|
memset(&s, 0, sizeof(s));
|
||||||
|
|
||||||
s.zalloc = Z_NULL;
|
s.zalloc = Z_NULL;
|
||||||
s.zfree = Z_NULL;
|
s.zfree = Z_NULL;
|
||||||
s.opaque = Z_NULL;
|
s.opaque = Z_NULL;
|
||||||
|
|
||||||
ret = inflateInit(&s);
|
ret = inflateInit(&s);
|
||||||
@ -180,10 +180,10 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.avail_in = fileSize;
|
s.avail_in = fileSize;
|
||||||
s.next_in = (Bytef *) (&loadAddress[0]);
|
s.next_in = (Bytef *) (&loadAddress[0]);
|
||||||
|
|
||||||
s.avail_out = fileSizeUnc;
|
s.avail_out = fileSizeUnc;
|
||||||
s.next_out = (Bytef *) &inflatedData[0];
|
s.next_out = (Bytef *) &inflatedData[0];
|
||||||
|
|
||||||
ret = inflate(&s, Z_FINISH);
|
ret = inflate(&s, Z_FINISH);
|
||||||
if (ret != Z_OK && ret != Z_STREAM_END) {
|
if (ret != Z_OK && ret != Z_STREAM_END) {
|
||||||
@ -204,7 +204,7 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
|||||||
return NOT_ENOUGH_MEMORY;
|
return NOT_ENOUGH_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
uLongf f = fileSizeUnc;
|
uLongf f = fileSizeUnc;
|
||||||
int32_t result = uncompress((Bytef *) &inflatedData[0], &f, (Bytef *) loadAddress, fileSize);
|
int32_t result = uncompress((Bytef *) &inflatedData[0], &f, (Bytef *) loadAddress, fileSize);
|
||||||
if (result != Z_OK) {
|
if (result != Z_OK) {
|
||||||
DEBUG_FUNCTION_LINE("uncompress failed %i", result);
|
DEBUG_FUNCTION_LINE("uncompress failed %i", result);
|
||||||
@ -213,17 +213,17 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fileSizeUnc = f;
|
fileSizeUnc = f;
|
||||||
fileSize = fileSizeUnc;
|
fileSize = fileSizeUnc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(inflatedData, "WUHB", 4) == 0) {
|
if (memcmp(inflatedData, "WUHB", 4) == 0) {
|
||||||
DEBUG_FUNCTION_LINE("Try to load a .wuhb");
|
DEBUG_FUNCTION_LINE("Try to load a .wuhb");
|
||||||
FSUtils::CreateSubfolder(RPX_TEMP_PATH);
|
FSUtils::CreateSubfolder(RPX_TEMP_PATH);
|
||||||
res = FSUtils::saveBufferToFile(WUHB_TEMP_FILE, inflatedData, fileSize);
|
res = FSUtils::saveBufferToFile(WUHB_TEMP_FILE, inflatedData, fileSize);
|
||||||
file_path = WUHB_TEMP_FILE_EX;
|
file_path = WUHB_TEMP_FILE_EX;
|
||||||
if (!res) {
|
if (!res) {
|
||||||
// temp.wuhb might be mounted, let's try temp2.wuhb
|
// temp.wuhb might be mounted, let's try temp2.wuhb
|
||||||
res = FSUtils::saveBufferToFile(WUHB_TEMP_FILE_2, inflatedData, fileSize);
|
res = FSUtils::saveBufferToFile(WUHB_TEMP_FILE_2, inflatedData, fileSize);
|
||||||
file_path = WUHB_TEMP_FILE_2_EX;
|
file_path = WUHB_TEMP_FILE_2_EX;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +231,7 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
|||||||
} else if (inflatedData[0x7] == 0xCA && inflatedData[0x8] == 0xFE && inflatedData[0x9] != 0x50 && inflatedData[0xA] != 0x4C) {
|
} else if (inflatedData[0x7] == 0xCA && inflatedData[0x8] == 0xFE && inflatedData[0x9] != 0x50 && inflatedData[0xA] != 0x4C) {
|
||||||
DEBUG_FUNCTION_LINE("Try to load a .rpx");
|
DEBUG_FUNCTION_LINE("Try to load a .rpx");
|
||||||
FSUtils::CreateSubfolder(RPX_TEMP_PATH);
|
FSUtils::CreateSubfolder(RPX_TEMP_PATH);
|
||||||
res = FSUtils::saveBufferToFile(RPX_TEMP_FILE, inflatedData, fileSize);
|
res = FSUtils::saveBufferToFile(RPX_TEMP_FILE, inflatedData, fileSize);
|
||||||
file_path = RPX_TEMP_FILE_EX;
|
file_path = RPX_TEMP_FILE_EX;
|
||||||
loadedRPX = true;
|
loadedRPX = true;
|
||||||
} else if (inflatedData[0x7] == 0xCA && inflatedData[0x8] == 0xFE && inflatedData[0x9] == 0x50 && inflatedData[0xA] == 0x4C) {
|
} else if (inflatedData[0x7] == 0xCA && inflatedData[0x8] == 0xFE && inflatedData[0x9] == 0x50 && inflatedData[0xA] == 0x4C) {
|
||||||
@ -241,10 +241,9 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
|||||||
std::vector<PluginContainer> finalList;
|
std::vector<PluginContainer> finalList;
|
||||||
|
|
||||||
finalList.push_back(newContainer.value());
|
finalList.push_back(newContainer.value());
|
||||||
for (auto &plugin: oldPlugins) {
|
for (auto &plugin : oldPlugins) {
|
||||||
if (plugin.metaInformation.getName() == newContainer->metaInformation.getName() &&
|
if (plugin.metaInformation.getName() == newContainer->metaInformation.getName() &&
|
||||||
plugin.metaInformation.getAuthor() == newContainer->metaInformation.getAuthor()
|
plugin.metaInformation.getAuthor() == newContainer->metaInformation.getAuthor()) {
|
||||||
) {
|
|
||||||
DEBUG_FUNCTION_LINE("Skipping duplicate");
|
DEBUG_FUNCTION_LINE("Skipping duplicate");
|
||||||
PluginUtils::destroyPluginContainer(plugin);
|
PluginUtils::destroyPluginContainer(plugin);
|
||||||
continue;
|
continue;
|
||||||
@ -253,7 +252,7 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto &plugin: finalList) {
|
for (auto &plugin : finalList) {
|
||||||
DEBUG_FUNCTION_LINE("name: %s", plugin.getMetaInformation().getName().c_str());
|
DEBUG_FUNCTION_LINE("name: %s", plugin.getMetaInformation().getName().c_str());
|
||||||
DEBUG_FUNCTION_LINE("author: %s", plugin.getMetaInformation().getAuthor().c_str());
|
DEBUG_FUNCTION_LINE("author: %s", plugin.getMetaInformation().getAuthor().c_str());
|
||||||
DEBUG_FUNCTION_LINE("handle: %08X", plugin.getPluginData().getHandle());
|
DEBUG_FUNCTION_LINE("handle: %08X", plugin.getPluginData().getHandle());
|
||||||
@ -279,13 +278,13 @@ int32_t TcpReceiver::loadToMemory(int32_t clientSocket, uint32_t ipAddress) {
|
|||||||
if (memcmp(loadAddress, "WUHB", 4) == 0) {
|
if (memcmp(loadAddress, "WUHB", 4) == 0) {
|
||||||
DEBUG_FUNCTION_LINE("Try to load a .wuhb");
|
DEBUG_FUNCTION_LINE("Try to load a .wuhb");
|
||||||
FSUtils::CreateSubfolder(RPX_TEMP_PATH);
|
FSUtils::CreateSubfolder(RPX_TEMP_PATH);
|
||||||
res = FSUtils::saveBufferToFile(WUHB_TEMP_FILE, loadAddress, fileSize);
|
res = FSUtils::saveBufferToFile(WUHB_TEMP_FILE, loadAddress, fileSize);
|
||||||
file_path = WUHB_TEMP_FILE_EX;
|
file_path = WUHB_TEMP_FILE_EX;
|
||||||
loadedRPX = true;
|
loadedRPX = true;
|
||||||
} else if (loadAddress[0x7] == 0xCA && loadAddress[0x8] == 0xFE) {
|
} else if (loadAddress[0x7] == 0xCA && loadAddress[0x8] == 0xFE) {
|
||||||
DEBUG_FUNCTION_LINE("Try to load a rpx");
|
DEBUG_FUNCTION_LINE("Try to load a rpx");
|
||||||
FSUtils::CreateSubfolder(RPX_TEMP_PATH);
|
FSUtils::CreateSubfolder(RPX_TEMP_PATH);
|
||||||
res = FSUtils::saveBufferToFile(RPX_TEMP_FILE, loadAddress, fileSize);
|
res = FSUtils::saveBufferToFile(RPX_TEMP_FILE, loadAddress, fileSize);
|
||||||
file_path = RPX_TEMP_FILE_EX;
|
file_path = RPX_TEMP_FILE_EX;
|
||||||
loadedRPX = true;
|
loadedRPX = true;
|
||||||
} else if (loadAddress[0x7] == 0xCA && loadAddress[0x8] == 0xFE && loadAddress[0x9] == 0x50) {
|
} else if (loadAddress[0x7] == 0xCA && loadAddress[0x8] == 0xFE && loadAddress[0x9] == 0x50) {
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "CThread.h"
|
#include "CThread.h"
|
||||||
|
|
||||||
class TcpReceiver : public CThread {
|
class TcpReceiver : public CThread {
|
||||||
public:
|
public:
|
||||||
enum eLoadResults {
|
enum eLoadResults {
|
||||||
SUCCESS = 0,
|
SUCCESS = 0,
|
||||||
INVALID_INPUT = -1,
|
INVALID_INPUT = -1,
|
||||||
FILE_OPEN_FAILURE = -2,
|
FILE_OPEN_FAILURE = -2,
|
||||||
FILE_READ_ERROR = -3,
|
FILE_READ_ERROR = -3,
|
||||||
NOT_ENOUGH_MEMORY = -4,
|
NOT_ENOUGH_MEMORY = -4,
|
||||||
NOT_A_VALID_PLUGIN = -5,
|
NOT_A_VALID_PLUGIN = -5,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
#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;
|
||||||
uint32_t udpLogInit = false;
|
uint32_t udpLogInit = false;
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
|
|
||||||
void initLogging() {
|
void initLogging() {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
if (!(moduleLogInit = WHBLogModuleInit())) {
|
if (!(moduleLogInit = WHBLogModuleInit())) {
|
||||||
cafeLogInit = WHBLogCafeInit();
|
cafeLogInit = WHBLogCafeInit();
|
||||||
udpLogInit = WHBLogUdpInit();
|
udpLogInit = WHBLogUdpInit();
|
||||||
}
|
}
|
||||||
#endif // DEBUG
|
#endif // DEBUG
|
||||||
}
|
}
|
||||||
|
@ -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" {
|
||||||
@ -9,26 +9,28 @@ extern "C" {
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
|
|
||||||
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
#define __FILENAME_X__ (strrchr(__FILE__, '\\') ? strrchr(__FILE__, '\\') + 1 : __FILE__)
|
||||||
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILENAME_X__)
|
||||||
|
|
||||||
#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...) \
|
||||||
WHBLogPrintf("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
do { \
|
||||||
|
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...) \
|
||||||
WHBLogWritef("[%23s]%30s@L%04d: " FMT "",__FILENAME__,__FUNCTION__, __LINE__, ## ARGS); \
|
do { \
|
||||||
|
WHBLogWritef("[%23s]%30s@L%04d: " FMT "", __FILENAME__, __FUNCTION__, __LINE__, ##ARGS); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
#define DEBUG_FUNCTION_LINE_VERBOSE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
|
#define DEBUG_FUNCTION_LINE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
#define DEBUG_FUNCTION_LINE_WRITE(FMT, ARGS...) while (0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -39,4 +41,3 @@ void deinitLogging();
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ int32_t checkbyte(int32_t sock) {
|
|||||||
unsigned char buffer[1];
|
unsigned char buffer[1];
|
||||||
int32_t ret;
|
int32_t ret;
|
||||||
|
|
||||||
ret = recv(sock, buffer, 1, MSG_DONTWAIT);
|
ret = recv(sock, buffer, 1, MSG_DONTWAIT);
|
||||||
socket_lock = 0;
|
socket_lock = 0;
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@ -68,7 +68,7 @@ int32_t sendwait(int32_t sock, const void *buffer, int32_t len) {
|
|||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
// For some reason the send blocks/crashes if the buffer is too big..
|
// For some reason the send blocks/crashes if the buffer is too big..
|
||||||
int cur_length = len <= 0x30 ? len : 0x30;
|
int cur_length = len <= 0x30 ? len : 0x30;
|
||||||
ret = send(sock, buffer, cur_length, 0);
|
ret = send(sock, buffer, cur_length, 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
socket_lock = 0;
|
socket_lock = 0;
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -6,16 +6,16 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <arpa/inet.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <sys/socket.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/socket.h>
|
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
int32_t recvwait(int32_t sock, void *buffer, int32_t len);
|
int32_t recvwait(int32_t sock, void *buffer, int32_t len);
|
||||||
|
|
||||||
|
@ -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"
|
|
||||||
|
|
||||||
// https://gist.github.com/ccbrown/9722406
|
// https://gist.github.com/ccbrown/9722406
|
||||||
void dumpHex(const void *data, size_t size) {
|
void dumpHex(const void *data, size_t size) {
|
||||||
|
@ -6,28 +6,29 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LIMIT(x, min, max) \
|
#define LIMIT(x, min, max) \
|
||||||
({ \
|
({ \
|
||||||
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)
|
||||||
#define RadToDeg(a) ( (a) * 57.29577951f )
|
#define RadToDeg(a) ((a) *57.29577951f)
|
||||||
|
|
||||||
#define ALIGN4(x) (((x) + 3) & ~3)
|
#define ALIGN4(x) (((x) + 3) & ~3)
|
||||||
#define ALIGN32(x) (((x) + 31) & ~31)
|
#define ALIGN32(x) (((x) + 31) & ~31)
|
||||||
|
|
||||||
// those work only in powers of 2
|
// those work only in powers of 2
|
||||||
#define ROUNDDOWN(val, align) ((val) & ~(align-1))
|
#define ROUNDDOWN(val, align) ((val) & ~(align - 1))
|
||||||
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align-1)), align)
|
#define ROUNDUP(val, align) ROUNDDOWN(((val) + (align - 1)), align)
|
||||||
|
|
||||||
|
|
||||||
#define le16(i) ((((uint16_t) ((i) & 0xFF)) << 8) | ((uint16_t) (((i) & 0xFF00) >> 8)))
|
#define le16(i) ((((uint16_t) ((i) &0xFF)) << 8) | ((uint16_t) (((i) &0xFF00) >> 8)))
|
||||||
#define le32(i) ((((uint32_t)le16((i) & 0xFFFF)) << 16) | ((uint32_t)le16(((i) & 0xFFFF0000) >> 16)))
|
#define le32(i) ((((uint32_t) le16((i) &0xFFFF)) << 16) | ((uint32_t) le16(((i) &0xFFFF0000) >> 16)))
|
||||||
#define le64(i) ((((uint64_t)le32((i) & 0xFFFFFFFFLL)) << 32) | ((uint64_t)le32(((i) & 0xFFFFFFFF00000000LL) >> 32)))
|
#define le64(i) ((((uint64_t) le32((i) &0xFFFFFFFFLL)) << 32) | ((uint64_t) le32(((i) &0xFFFFFFFF00000000LL) >> 32)))
|
||||||
|
|
||||||
//Needs to have log_init() called beforehand.
|
//Needs to have log_init() called beforehand.
|
||||||
void dumpHex(const void *data, size_t size);
|
void dumpHex(const void *data, size_t size);
|
||||||
|
Loading…
Reference in New Issue
Block a user