mirror of
https://github.com/wiiu-env/ftpiiu_plugin.git
synced 2024-12-23 03:11:49 +01:00
Format the code via clang-format
This commit is contained in:
parent
5e6e8bdb53
commit
63f21d5a18
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/ftpiiu_plugin/actions/workflows/ci.yml/badge.svg)](https://github.com/wiiu-env/ftpiiu_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.)
|
||||||
|
|
||||||
@ -18,3 +20,7 @@ docker run -it --rm -v ${PWD}:/project ftpiiuplugin-builder make
|
|||||||
# make clean
|
# make clean
|
||||||
docker run -it --rm -v ${PWD}:/project ftpiiuplugin-builder make clean
|
docker run -it --rm -v ${PWD}:/project ftpiiuplugin-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,7 +1,7 @@
|
|||||||
#include "BackgroundThread.hpp"
|
#include "BackgroundThread.hpp"
|
||||||
#include <cstring>
|
|
||||||
#include "ftp.h"
|
#include "ftp.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
BackgroundThread *BackgroundThread::instance = nullptr;
|
BackgroundThread *BackgroundThread::instance = nullptr;
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "utils/BackgroundThreadWrapper.hpp"
|
#include "utils/BackgroundThreadWrapper.hpp"
|
||||||
#include <coreinit/cache.h>
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
#include <coreinit/cache.h>
|
||||||
|
|
||||||
#define PORT 21
|
#define PORT 21
|
||||||
|
|
||||||
|
36
src/ftp.c
36
src/ftp.c
@ -23,23 +23,22 @@ misrepresented as being the original software.
|
|||||||
3.This notice may not be removed or altered from any source distribution.
|
3.This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
#include "main.h"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include <coreinit/thread.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/dir.h>
|
#include <sys/dir.h>
|
||||||
#include <coreinit/thread.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
|
||||||
#include "main.h"
|
|
||||||
#include "utils/logger.h"
|
|
||||||
|
|
||||||
//! TODO: fix those function
|
//! TODO: fix those function
|
||||||
#define gettime() OSGetTick()
|
#define gettime() OSGetTick()
|
||||||
|
|
||||||
#include "ftp.h"
|
#include "ftp.h"
|
||||||
#include "virtualpath.h"
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
#include "virtualpath.h"
|
||||||
#include "vrt.h"
|
#include "vrt.h"
|
||||||
|
|
||||||
#define UNUSED __attribute__((unused))
|
#define UNUSED __attribute__((unused))
|
||||||
@ -56,7 +55,7 @@ static uint8_t num_clients = 0;
|
|||||||
static uint16_t passive_port = 1024;
|
static uint16_t passive_port = 1024;
|
||||||
static char *password = NULL;
|
static char *password = NULL;
|
||||||
|
|
||||||
#define console_printf(FMT, ARGS...) DEBUG_FUNCTION_LINE_WRITE(FMT, ## ARGS);
|
#define console_printf(FMT, ARGS...) DEBUG_FUNCTION_LINE_WRITE(FMT, ##ARGS);
|
||||||
|
|
||||||
typedef int32_t (*data_connection_callback)(int32_t data_socket, void *arg);
|
typedef int32_t (*data_connection_callback)(int32_t data_socket, void *arg);
|
||||||
|
|
||||||
@ -614,14 +613,14 @@ static int32_t ftp_SITE_UNKNOWN(client_t *client, char *rest UNUSED) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t ftp_SITE_LOAD(client_t *client, char *path UNUSED) {
|
static int32_t ftp_SITE_LOAD(client_t *client, char *path UNUSED) {
|
||||||
// FILE *f = vrt_fopen(client->cwd, path, "rb");
|
// FILE *f = vrt_fopen(client->cwd, path, "rb");
|
||||||
// if (!f) return write_reply(client, 550, strerror(errno));
|
// if (!f) return write_reply(client, 550, strerror(errno));
|
||||||
// char *real_path = to_real_path(client->cwd, path);
|
// char *real_path = to_real_path(client->cwd, path);
|
||||||
// if (!real_path) goto end;
|
// if (!real_path) goto end;
|
||||||
// load_from_file(f, real_path);
|
// load_from_file(f, real_path);
|
||||||
// free(real_path);
|
// free(real_path);
|
||||||
// end:
|
// end:
|
||||||
// fclose(f);
|
// fclose(f);
|
||||||
return write_reply(client, 500, "Unable to load.");
|
return write_reply(client, 500, "Unable to load.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,15 +670,13 @@ static const char *authenticated_commands[] = {
|
|||||||
"SIZE", "PASV", "PORT", "TYPE", "SYST", "MODE",
|
"SIZE", "PASV", "PORT", "TYPE", "SYST", "MODE",
|
||||||
"RETR", "STOR", "APPE", "REST", "DELE", "MKD",
|
"RETR", "STOR", "APPE", "REST", "DELE", "MKD",
|
||||||
"RMD", "RNFR", "RNTO", "NLST", "QUIT", "REIN",
|
"RMD", "RNFR", "RNTO", "NLST", "QUIT", "REIN",
|
||||||
"SITE", "NOOP", "ALLO", NULL
|
"SITE", "NOOP", "ALLO", NULL};
|
||||||
};
|
|
||||||
static const ftp_command_handler authenticated_handlers[] = {
|
static const ftp_command_handler authenticated_handlers[] = {
|
||||||
ftp_USER, ftp_PASS, ftp_LIST, ftp_PWD, ftp_CWD, ftp_CDUP,
|
ftp_USER, ftp_PASS, ftp_LIST, ftp_PWD, ftp_CWD, ftp_CDUP,
|
||||||
ftp_SIZE, ftp_PASV, ftp_PORT, ftp_TYPE, ftp_SYST, ftp_MODE,
|
ftp_SIZE, ftp_PASV, ftp_PORT, ftp_TYPE, ftp_SYST, ftp_MODE,
|
||||||
ftp_RETR, ftp_STOR, ftp_APPE, ftp_REST, ftp_DELE, ftp_MKD,
|
ftp_RETR, ftp_STOR, ftp_APPE, ftp_REST, ftp_DELE, ftp_MKD,
|
||||||
ftp_DELE, ftp_RNFR, ftp_RNTO, ftp_NLST, ftp_QUIT, ftp_REIN,
|
ftp_DELE, ftp_RNFR, ftp_RNTO, ftp_NLST, ftp_QUIT, ftp_REIN,
|
||||||
ftp_SITE, ftp_NOOP, ftp_SUPERFLUOUS, ftp_UNKNOWN
|
ftp_SITE, ftp_NOOP, ftp_SUPERFLUOUS, ftp_UNKNOWN};
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
returns negative to signal an error that requires closing the connection
|
returns negative to signal an error that requires closing the connection
|
||||||
@ -890,7 +887,6 @@ static void process_control_events(client_t *client) {
|
|||||||
goto recv_loop_end;
|
goto recv_loop_end;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next != client->buf) { // some lines were processed
|
if (next != client->buf) { // some lines were processed
|
||||||
@ -902,7 +898,7 @@ static void process_control_events(client_t *client) {
|
|||||||
}
|
}
|
||||||
console_printf("Received line longer than %u bytes, closing client.\n", FTP_BUFFER_SIZE - 1);
|
console_printf("Received line longer than %u bytes, closing client.\n", FTP_BUFFER_SIZE - 1);
|
||||||
|
|
||||||
recv_loop_end:
|
recv_loop_end:
|
||||||
cleanup_client(client);
|
cleanup_client(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ misrepresented as being the original software.
|
|||||||
#define _FTP_H_
|
#define _FTP_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"{
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
13
src/main.cpp
13
src/main.cpp
@ -1,15 +1,15 @@
|
|||||||
#include <wups.h>
|
#include "BackgroundThread.hpp"
|
||||||
|
#include "utils/logger.h"
|
||||||
|
#include "virtualpath.h"
|
||||||
|
#include <coreinit/cache.h>
|
||||||
|
#include <coreinit/dynload.h>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <iosuhax.h>
|
#include <iosuhax.h>
|
||||||
#include <iosuhax_devoptab.h>
|
#include <iosuhax_devoptab.h>
|
||||||
#include <iosuhax_disc_interface.h>
|
#include <iosuhax_disc_interface.h>
|
||||||
#include <coreinit/dynload.h>
|
|
||||||
#include <nn/ac.h>
|
#include <nn/ac.h>
|
||||||
#include <coreinit/cache.h>
|
|
||||||
#include "utils/logger.h"
|
|
||||||
#include <whb/log_udp.h>
|
#include <whb/log_udp.h>
|
||||||
#include "virtualpath.h"
|
#include <wups.h>
|
||||||
#include "BackgroundThread.hpp"
|
|
||||||
|
|
||||||
WUPS_PLUGIN_NAME("FTPiiU");
|
WUPS_PLUGIN_NAME("FTPiiU");
|
||||||
WUPS_PLUGIN_DESCRIPTION("FTP Server");
|
WUPS_PLUGIN_DESCRIPTION("FTP Server");
|
||||||
@ -112,4 +112,3 @@ ON_APPLICATION_REQUESTS_EXIT() {
|
|||||||
|
|
||||||
deinitLogging();
|
deinitLogging();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#define MAXPATHLEN 256
|
#define MAXPATHLEN 256
|
||||||
|
|
||||||
|
12
src/net.c
12
src/net.c
@ -21,21 +21,21 @@ misrepresented as being the original software.
|
|||||||
3.This notice may not be removed or altered from any source distribution.
|
3.This notice may not be removed or altered from any source distribution.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
#include "main.h"
|
||||||
|
#include <malloc.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/fcntl.h>
|
#include <sys/fcntl.h>
|
||||||
#include "main.h"
|
#include <unistd.h>
|
||||||
|
|
||||||
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
#define MIN(x, y) ((x) < (y) ? (x) : (y))
|
||||||
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
#define MAX_NET_BUFFER_SIZE (128*1024)
|
#define MAX_NET_BUFFER_SIZE (128 * 1024)
|
||||||
#define MIN_NET_BUFFER_SIZE 4096
|
#define MIN_NET_BUFFER_SIZE 4096
|
||||||
#define FREAD_BUFFER_SIZE (128*1024)
|
#define FREAD_BUFFER_SIZE (128 * 1024)
|
||||||
|
|
||||||
extern uint32_t hostIpAddress;
|
extern uint32_t hostIpAddress;
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ int32_t send_from_file(int32_t s, FILE *f) {
|
|||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
end:
|
end:
|
||||||
free(buf);
|
free(buf);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
12
src/net.h
12
src/net.h
@ -25,18 +25,18 @@ misrepresented as being the original software.
|
|||||||
#define _NET_H_
|
#define _NET_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
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/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <netinet/in.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void initialise_network();
|
void initialise_network();
|
||||||
|
@ -19,4 +19,3 @@ void BackgroundThreadWrapper::executeThread() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CThread.h"
|
#include "CThread.h"
|
||||||
#include <wut_types.h>
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <wut_types.h>
|
||||||
|
|
||||||
class BackgroundThreadWrapper : public CThread {
|
class BackgroundThreadWrapper : public CThread {
|
||||||
public:
|
public:
|
||||||
@ -20,6 +20,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::recursive_mutex mutex;
|
std::recursive_mutex mutex;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void executeThread() override;
|
void executeThread() override;
|
||||||
|
|
||||||
|
@ -17,11 +17,11 @@
|
|||||||
#ifndef CTHREAD_H_
|
#ifndef CTHREAD_H_
|
||||||
#define CTHREAD_H_
|
#define CTHREAD_H_
|
||||||
|
|
||||||
#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:
|
||||||
@ -125,6 +125,7 @@ public:
|
|||||||
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
|
||||||
|
@ -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,12 +14,14 @@ 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...) \
|
||||||
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
|
||||||
@ -39,4 +41,3 @@ void deinitLogging();
|
|||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <string.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <whb/log.h>
|
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
#include <stddef.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) {
|
||||||
|
@ -8,26 +8,27 @@ extern "C" {
|
|||||||
|
|
||||||
#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);
|
||||||
|
@ -26,10 +26,10 @@
|
|||||||
*
|
*
|
||||||
* for WiiXplorer 2010
|
* for WiiXplorer 2010
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
#include <malloc.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "virtualpath.h"
|
#include "virtualpath.h"
|
||||||
#include "utils/logger.h"
|
#include "utils/logger.h"
|
||||||
|
#include <malloc.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
uint8_t MAX_VIRTUAL_PARTITIONS = 0;
|
uint8_t MAX_VIRTUAL_PARTITIONS = 0;
|
||||||
VIRTUAL_PARTITION *VIRTUAL_PARTITIONS = NULL;
|
VIRTUAL_PARTITION *VIRTUAL_PARTITIONS = NULL;
|
||||||
|
@ -31,11 +31,11 @@
|
|||||||
#define _VIRTUALPATH_H_
|
#define _VIRTUALPATH_H_
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C"{
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char *name;
|
char *name;
|
||||||
|
21
src/vrt.c
21
src/vrt.c
@ -23,12 +23,12 @@ misrepresented as being the original software.
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "main.h"
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/dirent.h>
|
#include <sys/dirent.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include "main.h"
|
|
||||||
|
|
||||||
#include "virtualpath.h"
|
#include "virtualpath.h"
|
||||||
#include "vrt.h"
|
#include "vrt.h"
|
||||||
@ -62,14 +62,17 @@ static char *virtual_abspath(char *virtual_cwd, char *virtual_path) {
|
|||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if (*token == '.') state = 2;
|
if (*token == '.') state = 2;
|
||||||
else if (*token != '/') state = 0;
|
else if (*token != '/')
|
||||||
|
state = 0;
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
if (*token == '/' || !*token) {
|
if (*token == '/' || !*token) {
|
||||||
state = 1;
|
state = 1;
|
||||||
*(curr_dir + 1) = '\0';
|
*(curr_dir + 1) = '\0';
|
||||||
} else if (*token == '.') state = 3;
|
} else if (*token == '.')
|
||||||
else state = 0;
|
state = 3;
|
||||||
|
else
|
||||||
|
state = 0;
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
if (*token == '/' || !*token) {
|
if (*token == '/' || !*token) {
|
||||||
@ -77,9 +80,11 @@ static char *virtual_abspath(char *virtual_cwd, char *virtual_path) {
|
|||||||
*curr_dir = '\0';
|
*curr_dir = '\0';
|
||||||
char *prev_dir = strrchr(normalised_path, '/');
|
char *prev_dir = strrchr(normalised_path, '/');
|
||||||
if (prev_dir) curr_dir = prev_dir;
|
if (prev_dir) curr_dir = prev_dir;
|
||||||
else *curr_dir = '/';
|
else
|
||||||
|
*curr_dir = '/';
|
||||||
*(curr_dir + 1) = '\0';
|
*(curr_dir + 1) = '\0';
|
||||||
} else state = 0;
|
} else
|
||||||
|
state = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!*token) break;
|
if (!*token) break;
|
||||||
@ -92,7 +97,7 @@ static char *virtual_abspath(char *virtual_cwd, char *virtual_path) {
|
|||||||
normalised_path[--end] = '\x00';
|
normalised_path[--end] = '\x00';
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
if (path != virtual_path) free(path);
|
if (path != virtual_path) free(path);
|
||||||
return normalised_path;
|
return normalised_path;
|
||||||
}
|
}
|
||||||
@ -149,7 +154,7 @@ char *to_real_path(char *virtual_cwd, char *virtual_path) {
|
|||||||
strcpy(path, prefix);
|
strcpy(path, prefix);
|
||||||
strcat(path, rest);
|
strcat(path, rest);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
free(virtual_path);
|
free(virtual_path);
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user