From e27a9d5f173f7626c576dbb2cd4c2f373edc847b Mon Sep 17 00:00:00 2001 From: Syndamia Date: Thu, 2 Sep 2021 11:10:49 +0300 Subject: (1) Updated some formatting and naming --- src/commandHandler.c | 6 +++--- src/commandHandler.h | 4 ++-- src/commandRouter.c | 8 ++++---- src/defaultCommands.c | 12 ++++++------ src/main.c | 6 +++--- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/commandHandler.c b/src/commandHandler.c index 9d158f3..54b0c7f 100644 --- a/src/commandHandler.c +++ b/src/commandHandler.c @@ -4,10 +4,10 @@ struct CommandHandler handlers[MAX_HANDLERS]; int handlerCount = 0; -void registerHandler(char *name, F_EXECUTOR executor) { +void registerHandler(char *p_name, P_EXECUTOR p_executor) { struct CommandHandler newCH; - newCH.p_name = name; - newCH.p_executor = executor; + newCH.p_name = p_name; + newCH.p_executor = p_executor; handlers[handlerCount++] = newCH; } diff --git a/src/commandHandler.h b/src/commandHandler.h index d344abb..fc2f084 100644 --- a/src/commandHandler.h +++ b/src/commandHandler.h @@ -3,11 +3,11 @@ #define MAX_HANDLERS 32 -typedef void (*F_EXECUTOR)(char *); +typedef void (*P_EXECUTOR)(char *); struct CommandHandler { char *p_name; - F_EXECUTOR p_executor; + P_EXECUTOR p_executor; }; #endif diff --git a/src/commandRouter.c b/src/commandRouter.c index 3d41ddd..baf04c2 100644 --- a/src/commandRouter.c +++ b/src/commandRouter.c @@ -7,12 +7,12 @@ extern struct CommandHandler handlers[MAX_HANDLERS]; extern int handlerCount; -bool route(char *command) { - command = strtok(command, " "); +bool route(char *p_command) { + p_command = strtok(p_command, " "); for (int i = 0; i < handlerCount; i++) { - if (strcasecmp(handlers[i].p_name, command) == 0) { - handlers[i].p_executor(command); + if (strcasecmp(handlers[i].p_name, p_command) == 0) { + handlers[i].p_executor(p_command); return true; } } diff --git a/src/defaultCommands.c b/src/defaultCommands.c index c5c927a..74415da 100644 --- a/src/defaultCommands.c +++ b/src/defaultCommands.c @@ -2,23 +2,23 @@ #include #include -void help(char *args) { +void help(char *p_args) { printf("This is the help message"); } -void about(char *args) { +void about(char *p_args) { printf("This is the about message"); } -void version(char *args) { +void version(char *p_args) { printf("This is the version message"); } -void exitApp(char *args) { - exit(0); +void exitApp(char *p_args) { + exit(EXIT_SUCCESS); } -extern void registerHandler(char *name, F_EXECUTOR executor); +extern void registerHandler(char *, P_EXECUTOR); void registerDefaultHandlers() { registerHandler("help", &help); diff --git a/src/main.c b/src/main.c index 303efea..5697352 100644 --- a/src/main.c +++ b/src/main.c @@ -23,9 +23,9 @@ int main() { printf("Welcome!\n\n"); do { // Removes the Line Feed character at the "end", if it exists - char *toChange = strchr(buffer, 0x0A); - if (toChange != NULL) - toChange[0] = 0; + char *p_toChange = strchr(buffer, 0x0A); + if (p_toChange != NULL) + p_toChange[0] = 0; if (buffer[0] > 0) if (route(buffer)) -- cgit v1.2.3