mirror of
https://github.com/wiiu-env/homebrew_on_menu_plugin.git
synced 2024-11-22 02:29:15 +01:00
Format the code via clang-format
This commit is contained in:
parent
bcd07eb726
commit
d2c53b77af
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/homebrew_on_menu_plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/homebrew_on_menu_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 homebrew_on_menu_plugin-builder make
|
|||||||
# make clean
|
# make clean
|
||||||
docker run -it --rm -v ${PWD}:/project homebrew_on_menu_plugin-builder make clean
|
docker run -it --rm -v ${PWD}:/project homebrew_on_menu_plugin-builder make clean
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Format the code via docker
|
||||||
|
|
||||||
|
`docker run --rm -v ${PWD}:/src wiiuenv/clang-format:13.0.0-2 -r ./include ./libraries ./plugins/example_plugin/src -i`
|
@ -1,11 +1,11 @@
|
|||||||
#include "FileWrapper.h"
|
#include "FileWrapper.h"
|
||||||
#include <cstdlib>
|
|
||||||
#include "fileinfos.h"
|
#include "fileinfos.h"
|
||||||
#include <cstring>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <rpxloader.h>
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
#include <coreinit/cache.h>
|
#include <coreinit/cache.h>
|
||||||
|
#include <cstdio>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <cstring>
|
||||||
|
#include <rpxloader.h>
|
||||||
|
|
||||||
FileHandleWrapper gFileHandleWrapper[FILE_WRAPPER_SIZE] __attribute__((section(".data")));
|
FileHandleWrapper gFileHandleWrapper[FILE_WRAPPER_SIZE] __attribute__((section(".data")));
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <cstring>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <rpxloader.h>
|
|
||||||
#include "utils/logger.h"
|
|
||||||
#include "fileinfos.h"
|
#include "fileinfos.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include <cstring>
|
||||||
|
#include <rpxloader.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
FileInfos gFileInfos[FILE_INFO_SIZE] __attribute__((section(".data")));
|
FileInfos gFileInfos[FILE_INFO_SIZE] __attribute__((section(".data")));
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
#include <coreinit/mcp.h>
|
#include <coreinit/mcp.h>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
typedef struct WUT_PACKED FileInfos_ {
|
typedef struct WUT_PACKED FileInfos_ {
|
||||||
char path[256];
|
char path[256];
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <strings.h>
|
|
||||||
#include <fs/CFile.hpp>
|
#include <fs/CFile.hpp>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <strings.h>
|
||||||
|
|
||||||
CFile::CFile() {
|
CFile::CFile() {
|
||||||
iFd = -1;
|
iFd = -1;
|
||||||
@ -171,5 +171,3 @@ int32_t CFile::fwrite(const char *format, ...) {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#ifndef CFILE_HPP_
|
#ifndef CFILE_HPP_
|
||||||
#define CFILE_HPP_
|
#define CFILE_HPP_
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string>
|
|
||||||
#include <string.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <string>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <wut_types.h>
|
#include <wut_types.h>
|
||||||
|
|
||||||
|
@ -24,14 +24,14 @@
|
|||||||
* 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>
|
||||||
|
@ -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 {
|
||||||
@ -97,6 +97,7 @@ public:
|
|||||||
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,11 +1,11 @@
|
|||||||
#include <malloc.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include "fs/FSUtils.h"
|
#include "fs/FSUtils.h"
|
||||||
#include "fs/CFile.hpp"
|
#include "fs/CFile.hpp"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.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) {
|
||||||
//! always initialze input
|
//! always initialze input
|
||||||
@ -139,4 +139,3 @@ int32_t FSUtils::saveBufferToFile(const char *path, void *buffer, uint32_t size)
|
|||||||
file.close();
|
file.close();
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
src/main.cpp
37
src/main.cpp
@ -1,22 +1,22 @@
|
|||||||
#include <wups.h>
|
|
||||||
#include <cstring>
|
|
||||||
#include <coreinit/debug.h>
|
|
||||||
#include <coreinit/title.h>
|
|
||||||
#include <coreinit/cache.h>
|
|
||||||
#include <coreinit/systeminfo.h>
|
|
||||||
#include <coreinit/mcp.h>
|
|
||||||
#include <coreinit/filesystem.h>
|
|
||||||
#include <sysapp/title.h>
|
|
||||||
#include <nn/acp.h>
|
|
||||||
#include <utils/logger.h>
|
|
||||||
#include "utils/StringTools.h"
|
|
||||||
#include <fs/DirList.h>
|
|
||||||
#include "fileinfos.h"
|
|
||||||
#include <rpxloader.h>
|
|
||||||
#include "fs/FSUtils.h"
|
|
||||||
#include "filelist.h"
|
|
||||||
#include "utils/ini.h"
|
|
||||||
#include "FileWrapper.h"
|
#include "FileWrapper.h"
|
||||||
|
#include "fileinfos.h"
|
||||||
|
#include "filelist.h"
|
||||||
|
#include "fs/FSUtils.h"
|
||||||
|
#include "utils/StringTools.h"
|
||||||
|
#include "utils/ini.h"
|
||||||
|
#include <coreinit/cache.h>
|
||||||
|
#include <coreinit/debug.h>
|
||||||
|
#include <coreinit/filesystem.h>
|
||||||
|
#include <coreinit/mcp.h>
|
||||||
|
#include <coreinit/systeminfo.h>
|
||||||
|
#include <coreinit/title.h>
|
||||||
|
#include <cstring>
|
||||||
|
#include <fs/DirList.h>
|
||||||
|
#include <nn/acp.h>
|
||||||
|
#include <rpxloader.h>
|
||||||
|
#include <sysapp/title.h>
|
||||||
|
#include <utils/logger.h>
|
||||||
|
#include <wups.h>
|
||||||
|
|
||||||
typedef struct ACPMetaData {
|
typedef struct ACPMetaData {
|
||||||
char bootmovie[80696];
|
char bootmovie[80696];
|
||||||
@ -300,7 +300,6 @@ DECL_FUNCTION(int32_t, ACPCheckTitleLaunchByTitleListTypeEx, MCPTitleListType *t
|
|||||||
|
|
||||||
int result = real_ACPCheckTitleLaunchByTitleListTypeEx(title, u2);
|
int result = real_ACPCheckTitleLaunchByTitleListTypeEx(title, u2);
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DECL_FUNCTION(int, FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, const char *mode, int *handle, int error) {
|
DECL_FUNCTION(int, FSOpenFile, FSClient *client, FSCmdBlock *block, char *path, const char *mode, int *handle, int error) {
|
||||||
|
@ -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) {
|
||||||
|
@ -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 {
|
||||||
@ -62,4 +62,3 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif /* __STRING_TOOLS_H */
|
#endif /* __STRING_TOOLS_H */
|
||||||
|
|
||||||
|
@ -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,7 +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
|
||||||
@ -48,7 +62,7 @@ static char* lskip(const 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)
|
||||||
{
|
{
|
||||||
@ -67,14 +81,15 @@ 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
|
||||||
|
NUL-terminated, and doesn't pad with NULs. */
|
||||||
static char* strncpy0(char* dest, const char* src, size_t size)
|
static char* strncpy0(char* dest, const char* src, size_t size)
|
||||||
{
|
{
|
||||||
#pragma GCC diagnostic push
|
/* Could use strncpy internally, but it causes gcc warnings (see issue #91) */
|
||||||
#pragma GCC diagnostic ignored "-Wstringop-truncation"
|
size_t i;
|
||||||
strncpy(dest, src, size - 1);
|
for (i = 0; i < size - 1 && src[i]; i++)
|
||||||
#pragma GCC diagnostic pop
|
dest[i] = src[i];
|
||||||
dest[size - 1] = '\0';
|
dest[i] = '\0';
|
||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,11 +103,11 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
|||||||
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] = "";
|
||||||
@ -105,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;
|
||||||
}
|
}
|
||||||
@ -118,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;
|
||||||
@ -169,6 +184,10 @@ 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';
|
||||||
|
#if INI_CALL_HANDLER_ON_NEW_SECTION
|
||||||
|
if (!HANDLER(user, section, NULL, NULL) && !error)
|
||||||
|
error = lineno;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (!error) {
|
else if (!error) {
|
||||||
/* No ']' found on section line */
|
/* No ']' found on section line */
|
||||||
@ -197,7 +216,14 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
|
|||||||
}
|
}
|
||||||
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +234,7 @@ 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;
|
||||||
|
@ -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 */
|
||||||
|
@ -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;
|
||||||
|
@ -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
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <whb/log.h>
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <whb/log.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) {
|
||||||
|
@ -12,7 +12,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)
|
||||||
|
Loading…
Reference in New Issue
Block a user