diff --git a/src/FSWrapper.h b/src/FSWrapper.h index e4f12d0..dc26c38 100644 --- a/src/FSWrapper.h +++ b/src/FSWrapper.h @@ -14,7 +14,7 @@ typedef struct dirMagic { OSMutex *mutex{}; - FSDirectoryEntry * readResult = nullptr; + FSDirectoryEntry *readResult = nullptr; int readResultCapacity = 0; int readResultNumberOfEntries = 0; diff --git a/src/FileUtils.cpp b/src/FileUtils.cpp index 9490ead..8975b16 100644 --- a/src/FileUtils.cpp +++ b/src/FileUtils.cpp @@ -52,7 +52,7 @@ FSStatus send_result_async(FSClient *client, FSCmdBlock *block, FSAsyncData *asy result->block = block; 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"); } } diff --git a/src/globals.cpp b/src/globals.cpp index db3dcbc..85ed382 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -3,5 +3,5 @@ RPXLoader_ReplacementInformation gReplacementInfo __attribute__((section(".data"))); -FSClient * gFSClient __attribute__((section(".data"))) = nullptr; -FSCmdBlock * gFSCmd __attribute__((section(".data"))) = nullptr; \ No newline at end of file +FSClient *gFSClient __attribute__((section(".data"))) = nullptr; +FSCmdBlock *gFSCmd __attribute__((section(".data"))) = nullptr; \ No newline at end of file diff --git a/src/globals.h b/src/globals.h index 33a05fa..190610a 100644 --- a/src/globals.h +++ b/src/globals.h @@ -50,5 +50,5 @@ typedef struct RPXLoader_ReplacementInformation_t { extern RPXLoader_ReplacementInformation gReplacementInfo; -extern FSClient * gFSClient; -extern FSCmdBlock * gFSCmd; \ No newline at end of file +extern FSClient *gFSClient; +extern FSCmdBlock *gFSCmd; \ No newline at end of file diff --git a/src/utils/ini.c b/src/utils/ini.c index ccf4640..b65aad3 100644 --- a/src/utils/ini.c +++ b/src/utils/ini.c @@ -18,7 +18,9 @@ https://github.com/benhoyt/inih #include "ini.h" #if !INI_USE_STACK + #include + #endif #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. */ typedef struct { - const char* ptr; + const char *ptr; size_t num_left; } ini_parse_string_ctx; /* Strip whitespace chars off end of given string, in place. Return s. */ -static char* rstrip(char* s) -{ - char* p = s + strlen(s); - while (p > s && isspace((unsigned char)(*--p))) +static char *rstrip(char *s) { + char *p = s + strlen(s); + while (p > s && isspace((unsigned char) (*--p))) *p = '\0'; return s; } /* Return pointer to first non-whitespace char in given string. */ -static char* lskip(const char* s) -{ - while (*s && isspace((unsigned char)(*s))) +static char *lskip(const char *s) { + while (*s && isspace((unsigned char) (*s))) s++; - return (char*)s; + return (char *) s; } /* 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 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 int was_space = 0; while (*s && (!chars || !strchr(chars, *s)) && !(was_space && strchr(INI_INLINE_COMMENT_PREFIXES, *s))) { - was_space = isspace((unsigned char)(*s)); + was_space = isspace((unsigned char) (*s)); s++; } #else @@ -64,12 +63,11 @@ static char* find_chars_or_comment(const char* s, const char* chars) s++; } #endif - return (char*)s; + return (char *) s; } /* 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 ignored "-Wstringop-truncation" 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. */ -int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, - void* user) -{ +int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler, + void *user) { /* Uses a fair bit of stack (use heap instead if you need to) */ #if INI_USE_STACK char line[INI_MAX_LINE]; int max_line = INI_MAX_LINE; #else - char* line; + char *line; int max_line = INI_INITIAL_ALLOC; #endif #if INI_ALLOW_REALLOC - char* new_line; + char *new_line; int offset; #endif char section[MAX_SECTION] = ""; char prev_name[MAX_NAME] = ""; - char* start; - char* end; - char* name; - char* value; + char *start; + char *end; + char *name; + char *value; int lineno = 0; int error = 0; #if !INI_USE_STACK - line = (char*)malloc(INI_INITIAL_ALLOC); + line = (char *) malloc(INI_INITIAL_ALLOC); if (!line) { return -2; } @@ -143,9 +140,9 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, start = line; #if INI_ALLOW_BOM - if (lineno == 1 && (unsigned char)start[0] == 0xEF && - (unsigned char)start[1] == 0xBB && - (unsigned char)start[2] == 0xBF) { + if (lineno == 1 && (unsigned char) start[0] == 0xEF && + (unsigned char) start[1] == 0xBB && + (unsigned char) start[2] == 0xBF) { start += 3; } #endif @@ -169,13 +166,11 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, *end = '\0'; strncpy0(section, start + 1, sizeof(section)); *prev_name = '\0'; - } - else if (!error) { + } else if (!error) { /* No ']' found on section line */ error = lineno; } - } - else if (*start) { + } else if (*start) { /* Not a comment, must be a name[=:]value pair */ end = find_chars_or_comment(start, "=:"); 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)); if (!HANDLER(user, section, name, value) && !error) error = lineno; - } - else if (!error) { + } else if (!error) { /* No '=' or ':' found on name[=:]value line */ error = lineno; } @@ -215,15 +209,13 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, } /* See documentation in header file. */ -int ini_parse_file(FILE* file, ini_handler handler, void* user) -{ - return ini_parse_stream((ini_reader)fgets, file, handler, user); +int ini_parse_file(FILE *file, ini_handler handler, void *user) { + return ini_parse_stream((ini_reader) fgets, file, handler, user); } /* See documentation in header file. */ -int ini_parse(const char* filename, ini_handler handler, void* user) -{ - FILE* file; +int ini_parse(const char *filename, ini_handler handler, void *user) { + FILE *file; int error; 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 is the fgets() equivalent used by ini_parse_string(). */ -static char* ini_reader_string(char* str, int num, void* stream) { - ini_parse_string_ctx* ctx = (ini_parse_string_ctx*)stream; - const char* ctx_ptr = ctx->ptr; +static char *ini_reader_string(char *str, int num, void *stream) { + ini_parse_string_ctx *ctx = (ini_parse_string_ctx *) stream; + const char *ctx_ptr = ctx->ptr; size_t ctx_num_left = ctx->num_left; - char* strp = str; + char *strp = str; char c; 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. */ -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; ctx.ptr = 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); } diff --git a/src/utils/ini.h b/src/utils/ini.h index 79a5fae..89c351f 100644 --- a/src/utils/ini.h +++ b/src/utils/ini.h @@ -28,12 +28,12 @@ typedef int (*ini_handler)(void* user, const char* section, const char* name, const char* value, int lineno); #else -typedef int (*ini_handler)(void* user, const char* section, - const char* name, const char* value); +typedef int (*ini_handler)(void *user, const char *section, + const char *name, const char *value); #endif /* 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 (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 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 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 filename. Used for implementing custom or string-based I/O (see also ini_parse_string). */ -int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, - void* user); +int ini_parse_stream(ini_reader reader, void *stream, ini_handler handler, + void *user); /* 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 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 configparser. If allowed, ini_parse() will call the handler with the same