Format code

This commit is contained in:
Maschell 2022-01-26 23:20:21 +01:00
parent cceda5e231
commit 7ad9df8a8c
6 changed files with 52 additions and 60 deletions

View File

@ -14,7 +14,7 @@ typedef struct dirMagic {
OSMutex *mutex{}; OSMutex *mutex{};
FSDirectoryEntry * readResult = nullptr; FSDirectoryEntry *readResult = nullptr;
int readResultCapacity = 0; int readResultCapacity = 0;
int readResultNumberOfEntries = 0; int readResultNumberOfEntries = 0;

View File

@ -52,7 +52,7 @@ FSStatus send_result_async(FSClient *client, FSCmdBlock *block, FSAsyncData *asy
result->block = block; result->block = block;
result->status = status; result->status = status;
while (!OSSendMessage(asyncData->ioMsgQueue, (OSMessage *) &(result->ioMsg), OS_MESSAGE_FLAGS_NONE)) { while (!OSSendMessage(asyncData->ioMsgQueue, (OSMessage * ) & (result->ioMsg), OS_MESSAGE_FLAGS_NONE)) {
DEBUG_FUNCTION_LINE("Failed to send message"); DEBUG_FUNCTION_LINE("Failed to send message");
} }
} }

View File

@ -3,5 +3,5 @@
RPXLoader_ReplacementInformation gReplacementInfo __attribute__((section(".data"))); RPXLoader_ReplacementInformation gReplacementInfo __attribute__((section(".data")));
FSClient * gFSClient __attribute__((section(".data"))) = nullptr; FSClient *gFSClient __attribute__((section(".data"))) = nullptr;
FSCmdBlock * gFSCmd __attribute__((section(".data"))) = nullptr; FSCmdBlock *gFSCmd __attribute__((section(".data"))) = nullptr;

View File

@ -50,5 +50,5 @@ typedef struct RPXLoader_ReplacementInformation_t {
extern RPXLoader_ReplacementInformation gReplacementInfo; extern RPXLoader_ReplacementInformation gReplacementInfo;
extern FSClient * gFSClient; extern FSClient *gFSClient;
extern FSCmdBlock * gFSCmd; extern FSCmdBlock *gFSCmd;

View File

@ -18,7 +18,9 @@ https://github.com/benhoyt/inih
#include "ini.h" #include "ini.h"
#if !INI_USE_STACK #if !INI_USE_STACK
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#define MAX_SECTION 50 #define MAX_SECTION 50
@ -26,37 +28,34 @@ https://github.com/benhoyt/inih
/* Used by ini_parse_string() to keep track of string parsing state. */ /* Used by ini_parse_string() to keep track of string parsing state. */
typedef struct { typedef struct {
const char* ptr; const char *ptr;
size_t num_left; size_t num_left;
} ini_parse_string_ctx; } ini_parse_string_ctx;
/* Strip whitespace chars off end of given string, in place. Return s. */ /* Strip whitespace chars off end of given string, in place. Return s. */
static char* rstrip(char* s) static char *rstrip(char *s) {
{ char *p = s + strlen(s);
char* p = s + strlen(s); while (p > s && isspace((unsigned char) (*--p)))
while (p > s && isspace((unsigned char)(*--p)))
*p = '\0'; *p = '\0';
return s; return s;
} }
/* Return pointer to first non-whitespace char in given string. */ /* Return pointer to first non-whitespace char in given string. */
static char* lskip(const char* s) static char *lskip(const char *s) {
{ while (*s && isspace((unsigned char) (*s)))
while (*s && isspace((unsigned char)(*s)))
s++; s++;
return (char*)s; return (char *) s;
} }
/* Return pointer to first char (of chars) or inline comment in given string, /* Return pointer to first char (of chars) or inline comment in given string,
or pointer to null at end of string if neither found. Inline comment must or pointer to null at end of string if neither found. Inline comment must
be prefixed by a whitespace character to register as a comment. */ be prefixed by a whitespace character to register as a comment. */
static char* find_chars_or_comment(const char* s, const char* chars) static char *find_chars_or_comment(const char *s, const char *chars) {
{
#if INI_ALLOW_INLINE_COMMENTS #if INI_ALLOW_INLINE_COMMENTS
int was_space = 0; int was_space = 0;
while (*s && (!chars || !strchr(chars, *s)) && while (*s && (!chars || !strchr(chars, *s)) &&
!(was_space && strchr(INI_INLINE_COMMENT_PREFIXES, *s))) { !(was_space && strchr(INI_INLINE_COMMENT_PREFIXES, *s))) {
was_space = isspace((unsigned char)(*s)); was_space = isspace((unsigned char) (*s));
s++; s++;
} }
#else #else
@ -64,12 +63,11 @@ static char* find_chars_or_comment(const char* s, const char* chars)
s++; s++;
} }
#endif #endif
return (char*)s; return (char *) s;
} }
/* Version of strncpy that ensures dest (size bytes) is null-terminated. */ /* Version of strncpy that ensures dest (size bytes) is null-terminated. */
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 #pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation" #pragma GCC diagnostic ignored "-Wstringop-truncation"
strncpy(dest, src, size - 1); strncpy(dest, src, size - 1);
@ -79,33 +77,32 @@ static char* strncpy0(char* dest, const char* src, size_t size)
} }
/* See documentation in header file. */ /* See documentation in header file. */
int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
void* user) void *user) {
{
/* Uses a fair bit of stack (use heap instead if you need to) */ /* Uses a fair bit of stack (use heap instead if you need to) */
#if INI_USE_STACK #if INI_USE_STACK
char line[INI_MAX_LINE]; char line[INI_MAX_LINE];
int max_line = INI_MAX_LINE; int max_line = INI_MAX_LINE;
#else #else
char* line; char *line;
int max_line = INI_INITIAL_ALLOC; int max_line = INI_INITIAL_ALLOC;
#endif #endif
#if INI_ALLOW_REALLOC #if INI_ALLOW_REALLOC
char* new_line; char *new_line;
int offset; int offset;
#endif #endif
char section[MAX_SECTION] = ""; char section[MAX_SECTION] = "";
char prev_name[MAX_NAME] = ""; char prev_name[MAX_NAME] = "";
char* start; char *start;
char* end; char *end;
char* name; char *name;
char* value; char *value;
int lineno = 0; int lineno = 0;
int error = 0; int error = 0;
#if !INI_USE_STACK #if !INI_USE_STACK
line = (char*)malloc(INI_INITIAL_ALLOC); line = (char *) malloc(INI_INITIAL_ALLOC);
if (!line) { if (!line) {
return -2; return -2;
} }
@ -143,9 +140,9 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
start = line; start = line;
#if INI_ALLOW_BOM #if INI_ALLOW_BOM
if (lineno == 1 && (unsigned char)start[0] == 0xEF && if (lineno == 1 && (unsigned char) start[0] == 0xEF &&
(unsigned char)start[1] == 0xBB && (unsigned char) start[1] == 0xBB &&
(unsigned char)start[2] == 0xBF) { (unsigned char) start[2] == 0xBF) {
start += 3; start += 3;
} }
#endif #endif
@ -169,13 +166,11 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
*end = '\0'; *end = '\0';
strncpy0(section, start + 1, sizeof(section)); strncpy0(section, start + 1, sizeof(section));
*prev_name = '\0'; *prev_name = '\0';
} } else if (!error) {
else if (!error) {
/* No ']' found on section line */ /* No ']' found on section line */
error = lineno; error = lineno;
} }
} } else if (*start) {
else if (*start) {
/* Not a comment, must be a name[=:]value pair */ /* Not a comment, must be a name[=:]value pair */
end = find_chars_or_comment(start, "=:"); end = find_chars_or_comment(start, "=:");
if (*end == '=' || *end == ':') { if (*end == '=' || *end == ':') {
@ -194,8 +189,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
strncpy0(prev_name, name, sizeof(prev_name)); strncpy0(prev_name, name, sizeof(prev_name));
if (!HANDLER(user, section, name, value) && !error) if (!HANDLER(user, section, name, value) && !error)
error = lineno; error = lineno;
} } else if (!error) {
else if (!error) {
/* No '=' or ':' found on name[=:]value line */ /* No '=' or ':' found on name[=:]value line */
error = lineno; error = lineno;
} }
@ -215,15 +209,13 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
} }
/* See documentation in header file. */ /* See documentation in header file. */
int ini_parse_file(FILE* file, ini_handler handler, void* user) int ini_parse_file(FILE *file, ini_handler handler, void *user) {
{ return ini_parse_stream((ini_reader) fgets, file, handler, user);
return ini_parse_stream((ini_reader)fgets, file, handler, user);
} }
/* See documentation in header file. */ /* See documentation in header file. */
int ini_parse(const char* filename, ini_handler handler, void* user) int ini_parse(const char *filename, ini_handler handler, void *user) {
{ FILE *file;
FILE* file;
int error; int error;
file = fopen(filename, "r"); file = fopen(filename, "r");
@ -236,11 +228,11 @@ int ini_parse(const char* filename, ini_handler handler, void* user)
/* An ini_reader function to read the next line from a string buffer. This /* An ini_reader function to read the next line from a string buffer. This
is the fgets() equivalent used by ini_parse_string(). */ is the fgets() equivalent used by ini_parse_string(). */
static char* ini_reader_string(char* str, int num, void* stream) { static char *ini_reader_string(char *str, int num, void *stream) {
ini_parse_string_ctx* ctx = (ini_parse_string_ctx*)stream; ini_parse_string_ctx *ctx = (ini_parse_string_ctx *) stream;
const char* ctx_ptr = ctx->ptr; const char *ctx_ptr = ctx->ptr;
size_t ctx_num_left = ctx->num_left; size_t ctx_num_left = ctx->num_left;
char* strp = str; char *strp = str;
char c; char c;
if (ctx_num_left == 0 || num < 2) if (ctx_num_left == 0 || num < 2)
@ -262,11 +254,11 @@ static char* ini_reader_string(char* str, int num, void* stream) {
} }
/* See documentation in header file. */ /* See documentation in header file. */
int ini_parse_string(const char* string, ini_handler handler, void* user) { int ini_parse_string(const char *string, ini_handler handler, void *user) {
ini_parse_string_ctx ctx; ini_parse_string_ctx ctx;
ctx.ptr = string; ctx.ptr = string;
ctx.num_left = strlen(string); ctx.num_left = strlen(string);
return ini_parse_stream((ini_reader)ini_reader_string, &ctx, handler, return ini_parse_stream((ini_reader) ini_reader_string, &ctx, handler,
user); user);
} }

View File

@ -28,12 +28,12 @@ typedef int (*ini_handler)(void* user, const char* section,
const char* name, const char* value, const char* name, const char* value,
int lineno); int lineno);
#else #else
typedef int (*ini_handler)(void* user, const char* section, typedef int (*ini_handler)(void *user, const char *section,
const char* name, const char* value); const char *name, const char *value);
#endif #endif
/* Typedef for prototype of fgets-style reader function. */ /* Typedef for prototype of fgets-style reader function. */
typedef char* (*ini_reader)(char* str, int num, void* stream); typedef char *(*ini_reader)(char *str, int num, void *stream);
/* Parse given INI-style file. May have [section]s, name=value pairs /* Parse given INI-style file. May have [section]s, name=value pairs
(whitespace stripped), and comments starting with ';' (semicolon). Section (whitespace stripped), and comments starting with ';' (semicolon). Section
@ -48,22 +48,22 @@ typedef char* (*ini_reader)(char* str, int num, void* stream);
stop on first error), -1 on file open error, or -2 on memory allocation stop on first error), -1 on file open error, or -2 on memory allocation
error (only when INI_USE_STACK is zero). error (only when INI_USE_STACK is zero).
*/ */
int ini_parse(const char* filename, ini_handler handler, void* user); int ini_parse(const char *filename, ini_handler handler, void *user);
/* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't
close the file when it's finished -- the caller must do that. */ close the file when it's finished -- the caller must do that. */
int ini_parse_file(FILE* file, ini_handler handler, void* user); int ini_parse_file(FILE *file, ini_handler handler, void *user);
/* Same as ini_parse(), but takes an ini_reader function pointer instead of /* Same as ini_parse(), but takes an ini_reader function pointer instead of
filename. Used for implementing custom or string-based I/O (see also filename. Used for implementing custom or string-based I/O (see also
ini_parse_string). */ ini_parse_string). */
int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler,
void* user); void *user);
/* Same as ini_parse(), but takes a zero-terminated string with the INI data /* Same as ini_parse(), but takes a zero-terminated string with the INI data
instead of a file. Useful for parsing INI data from a network socket or instead of a file. Useful for parsing INI data from a network socket or
already in memory. */ already in memory. */
int ini_parse_string(const char* string, ini_handler handler, void* user); int ini_parse_string(const char *string, ini_handler handler, void *user);
/* Nonzero to allow multi-line value parsing, in the style of Python's /* Nonzero to allow multi-line value parsing, in the style of Python's
configparser. If allowed, ini_parse() will call the handler with the same configparser. If allowed, ini_parse() will call the handler with the same