mirror of
https://github.com/wiiu-env/sdcafiine_plugin.git
synced 2024-11-24 04:19:16 +01:00
Format the code via clang-format
This commit is contained in:
parent
8cc667aa6f
commit
b97c6bf3c9
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
|
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@ -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
|
||||||
@ -26,7 +34,7 @@ jobs:
|
|||||||
id: get_repository_name
|
id: get_repository_name
|
||||||
run: |
|
run: |
|
||||||
echo REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") >> $GITHUB_ENV
|
echo REPOSITORY_NAME=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") >> $GITHUB_ENV
|
||||||
echo DATETIME=$(echo $(date '+%Y%m%d-%H%M%S')) >> $GITHUB_ENV
|
echo DATETIME=$(echo $(date '+%Y%m%d-%H%M%S')) >> $GITHUB_ENV
|
||||||
- uses: actions/download-artifact@master
|
- uses: actions/download-artifact@master
|
||||||
with:
|
with:
|
||||||
name: binary
|
name: 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/sdcafiine_plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/sdcafiine_plugin/actions/workflows/ci.yml)
|
||||||
|
|
||||||
# SDCafiine Plugin
|
# SDCafiine Plugin
|
||||||
|
|
||||||
## What is SDCafiine
|
## What is SDCafiine
|
||||||
@ -58,3 +60,7 @@ docker run -it --rm -v ${PWD}:/project sdcafiineplugin-builder make
|
|||||||
# make clean
|
# make clean
|
||||||
docker run -it --rm -v ${PWD}:/project sdcafiineplugin-builder make clean
|
docker run -it --rm -v ${PWD}:/project sdcafiineplugin-builder make clean
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Format the code via docker
|
||||||
|
|
||||||
|
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./src -i`
|
@ -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 = NULL;
|
struct dirent *dirent = NULL;
|
||||||
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) {
|
||||||
|
@ -27,8 +27,8 @@
|
|||||||
#ifndef ___DIRLIST_H_
|
#ifndef ___DIRLIST_H_
|
||||||
#define ___DIRLIST_H_
|
#define ___DIRLIST_H_
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
#include <wut_types.h>
|
#include <wut_types.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
@ -60,7 +60,8 @@ public:
|
|||||||
//!\param list index
|
//!\param list index
|
||||||
const char *GetFilepath(int32_t index) const {
|
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
|
||||||
@ -90,10 +91,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,7 +1,7 @@
|
|||||||
#include <wups.h>
|
|
||||||
#include "utils/logger.h"
|
|
||||||
#include "modpackSelector.h"
|
#include "modpackSelector.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
#include <coreinit/title.h>
|
#include <coreinit/title.h>
|
||||||
|
#include <wups.h>
|
||||||
|
|
||||||
WUPS_PLUGIN_NAME("SDCafiine");
|
WUPS_PLUGIN_NAME("SDCafiine");
|
||||||
WUPS_PLUGIN_DESCRIPTION("Wiiload Server");
|
WUPS_PLUGIN_DESCRIPTION("Wiiload Server");
|
||||||
@ -16,6 +16,6 @@ ON_APPLICATION_START() {
|
|||||||
initLogging();
|
initLogging();
|
||||||
HandleMultiModPacks(OSGetTitleID());
|
HandleMultiModPacks(OSGetTitleID());
|
||||||
}
|
}
|
||||||
ON_APPLICATION_ENDS(){
|
ON_APPLICATION_ENDS() {
|
||||||
deinitLogging();
|
deinitLogging();
|
||||||
}
|
}
|
@ -4,8 +4,8 @@
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
#include <stdint.h>
|
|
||||||
#include <nsysnet/socket.h>
|
#include <nsysnet/socket.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
#include <string>
|
#include "modpackSelector.h"
|
||||||
#include <map>
|
|
||||||
#include <cstring>
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include "modpackSelector.h"
|
#include <map>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <coreinit/thread.h>
|
#include <coreinit/thread.h>
|
||||||
#include <memory/mappedmemory.h>
|
#include <memory/mappedmemory.h>
|
||||||
|
|
||||||
#include <utils/logger.h>
|
|
||||||
#include <fs/DirList.h>
|
|
||||||
#include <coreinit/screen.h>
|
#include <coreinit/screen.h>
|
||||||
#include <vpad/input.h>
|
#include <fs/DirList.h>
|
||||||
#include <rpxloader.h>
|
#include <rpxloader.h>
|
||||||
|
#include <utils/logger.h>
|
||||||
|
#include <vpad/input.h>
|
||||||
|
|
||||||
#define TEXT_SEL(x, text1, text2) ((x) ? (text1) : (text2))
|
#define TEXT_SEL(x, text1, text2) ((x) ? (text1) : (text2))
|
||||||
|
|
||||||
|
|
||||||
void ReplaceContent(const std::string &basePath);
|
void ReplaceContent(const std::string &basePath);
|
||||||
@ -42,7 +42,7 @@ void HandleMultiModPacks(uint64_t titleID) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string packageName = curFile;
|
std::string packageName = curFile;
|
||||||
modTitlePath[packageName] = modTitleIDPath + "/" + curFile;
|
modTitlePath[packageName] = modTitleIDPath + "/" + curFile;
|
||||||
DEBUG_FUNCTION_LINE("found %s", packageName.c_str());
|
DEBUG_FUNCTION_LINE("found %s", packageName.c_str());
|
||||||
}
|
}
|
||||||
@ -51,16 +51,15 @@ void HandleMultiModPacks(uint64_t titleID) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int selected = 0;
|
int selected = 0;
|
||||||
int initScreen = 1;
|
int initScreen = 1;
|
||||||
int x_offset = -2;
|
int x_offset = -2;
|
||||||
|
|
||||||
// Init screen and screen buffers
|
// Init screen and screen buffers
|
||||||
OSScreenInit();
|
OSScreenInit();
|
||||||
uint32_t screen_buf0_size = OSScreenGetBufferSizeEx(SCREEN_TV);
|
uint32_t screen_buf0_size = OSScreenGetBufferSizeEx(SCREEN_TV);
|
||||||
uint32_t screen_buf1_size = OSScreenGetBufferSizeEx(SCREEN_DRC);
|
uint32_t screen_buf1_size = OSScreenGetBufferSizeEx(SCREEN_DRC);
|
||||||
uint8_t *screenBuffer = (uint8_t *) MEMAllocFromMappedMemoryForGX2Ex(screen_buf0_size + screen_buf1_size, 0x100
|
uint8_t *screenBuffer = (uint8_t *) MEMAllocFromMappedMemoryForGX2Ex(screen_buf0_size + screen_buf1_size, 0x100);
|
||||||
);
|
|
||||||
if (screenBuffer == nullptr) {
|
if (screenBuffer == nullptr) {
|
||||||
DEBUG_FUNCTION_LINE("Failed to alloc");
|
DEBUG_FUNCTION_LINE("Failed to alloc");
|
||||||
return;
|
return;
|
||||||
@ -82,9 +81,9 @@ void HandleMultiModPacks(uint64_t titleID) {
|
|||||||
VPADReadError error;
|
VPADReadError error;
|
||||||
|
|
||||||
int wantToExit = 0;
|
int wantToExit = 0;
|
||||||
int page = 0;
|
int page = 0;
|
||||||
int per_page = 13;
|
int per_page = 13;
|
||||||
int max_pages = (modTitlePath.size() / per_page) + 1;
|
int max_pages = (modTitlePath.size() / per_page) + 1;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
@ -122,10 +121,10 @@ void HandleMultiModPacks(uint64_t titleID) {
|
|||||||
console_print_pos(x_offset, 1, "Select your options and press A to launch.");
|
console_print_pos(x_offset, 1, "Select your options and press A to launch.");
|
||||||
console_print_pos(x_offset, 2, "Press B to launch without mods");
|
console_print_pos(x_offset, 2, "Press B to launch without mods");
|
||||||
int y_offset = 4;
|
int y_offset = 4;
|
||||||
int cur_ = 0;
|
int cur_ = 0;
|
||||||
|
|
||||||
for (auto &it : modTitlePath) {
|
for (auto &it : modTitlePath) {
|
||||||
std::string key = it.first;
|
std::string key = it.first;
|
||||||
std::string value = it.second;
|
std::string value = it.second;
|
||||||
|
|
||||||
if (wantToExit && cur_ == selected) {
|
if (wantToExit && cur_ == selected) {
|
||||||
@ -189,7 +188,6 @@ void console_print_pos(int x, int y, const char *format, ...) {
|
|||||||
|
|
||||||
OSScreenPutFontEx(SCREEN_TV, x, y, tmp);
|
OSScreenPutFontEx(SCREEN_TV, x, y, tmp);
|
||||||
OSScreenPutFontEx(SCREEN_DRC, x, y, tmp);
|
OSScreenPutFontEx(SCREEN_DRC, x, y, tmp);
|
||||||
|
|
||||||
}
|
}
|
||||||
va_end(va);
|
va_end(va);
|
||||||
|
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
#ifndef _MODPACK_SELECTOR_H_
|
#pragma once
|
||||||
#define _MODPACK_SELECTOR_H_
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void HandleMultiModPacks(uint64_t titleid/*,bool showMenu = true*/);
|
void HandleMultiModPacks(uint64_t titleid /*,bool showMenu = true*/);
|
||||||
void console_print_pos(int x, int y, const char *format, ...);
|
void console_print_pos(int x, int y, const char *format, ...);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif //_MODPACK_SELECTOR_H_
|
|
@ -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,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
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user