25 #ifndef COMMAND_HANDLER_H
26 #define COMMAND_HANDLER_H
45 #ifndef PREVIOUS_BUF_SIZE
46 #define PREVIOUS_BUF_SIZE 50
49 #ifndef MAX_COMMAND_BUF
50 #define MAX_COMMAND_BUF 256
53 #ifdef THREADED_SUPPORT
55 #error "Threaded support can't exist without malloc."
58 #ifndef CUSTOM_THREADS
111 #ifndef NO_WS_LOGGING
119 #ifdef DISABLE_MALLOC
120 #ifndef COMMAND_LIMIT
121 #define COMMAND_LIMIT 25
131 WS_COMMAND_LIMIT_REACHED,
132 WS_OUT_STREAM_NOT_SET,
137 int (*mainCommand)(
int argc,
char** argv);
138 int (*helpCommand)(
int argc,
char** argv);
173 WS_FG_BRIGHT_BLACK = 90,
174 WS_FG_BRIGHT_RED = 91,
175 WS_FG_BRIGHT_GREEN = 92,
176 WS_FG_BRIGHT_YELLOW = 93,
177 WS_FG_BRIGHT_BLUE = 94,
178 WS_FG_BRIGHT_MAGENTA = 95,
179 WS_FG_BRIGHT_CYAN = 96,
180 WS_FG_BRIGHT_WHITE = 97,
194 WS_BG_BRIGHT_BLACK = 100,
195 WS_BG_BRIGHT_RED = 101,
196 WS_BG_BRIGHT_GREEN = 102,
197 WS_BG_BRIGHT_YELLOW = 103,
198 WS_BG_BRIGHT_BLUE = 104,
199 WS_BG_BRIGHT_MAGENTA = 105,
200 WS_BG_BRIGHT_CYAN = 106,
201 WS_BG_BRIGHT_WHITE = 107,
230 WS_CURSOR_LEFT = 0x4b,
231 WS_CURSOR_RIGHT = 0x4d,
233 WS_CURSOR_DOWN = 0x50,
259 #ifndef NO_WS_LOGGING
Atomic bool structure provided by WallShell.
Definition: wall_shell.h:96
bool b
Bool currently stored by the atomic_bool.
Definition: wall_shell.h:97
ws_mutex_t * mut
Pointer to the mutex the bool uses.
Definition: wall_shell.h:98
Color structure used internally by WallShell.
Definition: wall_shell.h:204
ws_fg_color_t foreground
Foreground color of the structure.
Definition: wall_shell.h:205
ws_bg_color_t background
Background color of the structure.
Definition: wall_shell.h:206
Command Data Structure.
Definition: wall_shell.h:136
const char ** aliases
Any aliases you want your command to have.
Definition: wall_shell.h:140
const char * commandName
Name of the command.
Definition: wall_shell.h:139
size_t aliases_count
Amount of aliases in your alias array.
Definition: wall_shell.h:141
General help structure.
Definition: wall_shell.h:144
const char ** commands
Commands that are a subset of this command/topic.
Definition: wall_shell.h:147
const char * description
Description of the command.
Definition: wall_shell.h:146
const char ** aliases
Any aliases that this command has.
Definition: wall_shell.h:149
const char * commandName
Name of the command.
Definition: wall_shell.h:145
const int commands_count
Amount of commands in the commands part of this structure.
Definition: wall_shell.h:148
const int aliases_count
Amount of commands in the aliases part of this structure.
Definition: wall_shell.h:150
Specific help structure.
Definition: wall_shell.h:153
const char * description
Description of the command.
Definition: wall_shell.h:155
const char * commandName
Name of the command.
Definition: wall_shell.h:154
const int optional_count
Amount of flags/subcommands in the optional part of this structure.
Definition: wall_shell.h:159
const int required_count
Amount of flags/subcommands in the required part of this structure.
Definition: wall_shell.h:157
const char ** optional
Flags/subcommands that are optional when running this command.
Definition: wall_shell.h:158
const char ** required
Flags/subcommands that are a required when running this command.
Definition: wall_shell.h:156
ws_error_t ws_setConsoleColors(ws_color_t colors)
Set the background and foreground colors to the provided ones.
Definition: wall_shell.c:468
ws_error_t ws_registerCommand(const ws_command_t c)
Register the command to the command handler.
Definition: wall_shell.c:1160
void ws_destroyMutex(ws_mutex_t *mut)
Destroys the provided mutex.
Definition: wallshell_config.c:78
ws_fg_color_t
All built in foreground colors.
Definition: wall_shell.h:162
void ws_printSpecificHelp(ws_help_entry_specific_t *entry)
Prints the specific help entry.
Definition: wall_shell.c:2133
ws_thread_id_t ws_getThreadID()
Gets the threadID of the calling thread.
Definition: wall_shell.c:604
bool ws_getAtomicBool(ws_atomic_bool_t *ab)
Gets the value stored by the atomic bool.
Definition: wall_shell.c:632
ws_mutex_t * ws_createMutex()
Create a mutex.
Definition: wallshell_config.c:73
void ws_setStream(ws_stream type, FILE *stream)
Sets the stream to the provided one.
Definition: wall_shell.c:142
bool ws_promptUser(const char *format,...)
Prompts the user yes/no using the given prompt.
Definition: wall_shell.c:2177
void ws_setConsoleLocale()
Sets the console locale.
Definition: wall_shell.c:2083
uint64_t ws_thread_id_t
Wrapper around your system's thread hadnle.
Definition: wall_shell.h:83
ws_bg_color_t
All built in background colors.
Definition: wall_shell.h:183
void ws_deregisterCommand(const ws_command_t c)
Deregister the provided command.
Definition: wall_shell.c:1201
void ws_moveCursor_n(ws_cursor_t direction, size_t n)
Move the cursor n times in the provided direction.
Definition: wallshell_config.c:63
ws_error_t ws_setBackgroundColor(ws_bg_color_t color)
Sets the background color to the provided color.
Definition: wall_shell.c:495
void ws_setAtomicBool(ws_atomic_bool_t *ab, bool b)
Sets the value of the provided atomic bool.
Definition: wall_shell.c:646
void ws_setForegroundDefault(ws_fg_color_t c)
Set the default foreground color.
Definition: wall_shell.c:424
void ws_printThreadID()
Prints the threadID of the calling thread.
Definition: wall_shell.c:764
void ws_unlockMutex(ws_mutex_t *mut)
Unlocks the provided mutex.
Definition: wallshell_config.c:72
void ws_initializeDefaultStreams()
Initialize all streams to their defaults.
Definition: wall_shell.c:157
void ws_destroyAtomicBool(ws_atomic_bool_t *ab)
Destroys the provided atomic bool.
Definition: wall_shell.c:670
void ws_removeThreadName(const char *name)
Removes the name of the provided thread.
Definition: wall_shell.c:735
ws_error_t ws_executeCommand(char *commandBuf)
Execute a command with the provided buffer.
Definition: wall_shell.c:1663
void ws_setConsolePrefix(const char *newPrefix)
Set the prefix to the provided one.
Definition: wall_shell.c:1754
void ws_logger(ws_logtype_t type, const char *format,...)
Logger function for WallShell.
Definition: wall_shell.c:1030
ws_error_t ws_setForegroundColor(ws_fg_color_t color)
Sets the foreground color to the provided color.
Definition: wall_shell.c:482
ws_atomic_bool_t * ws_createAtomicBool(bool b)
Creates an atomic bool.
Definition: wall_shell.c:658
void ws_moveCursor(ws_cursor_t direction)
Moves the cursor once in the provided direction.
Definition: wallshell_config.c:59
void ws_sleep(size_t ms)
Sleep function wrapper.
Definition: wallshell_config.c:91
void ws_setDefaultColors(ws_color_t c)
Set the default colors to the provided ones.
Definition: wall_shell.c:446
void ws_setAsciiDeleteAsBackspace(bool b)
Some consoles send backspace as ASCII delete (0x7f) instead of '\b'.
Definition: wall_shell.c:317
void ws_cleanAll()
Cleans everything.
Definition: wall_shell.c:1763
bool ws_compareCommands(const ws_command_t c1, const ws_command_t c2)
Operator overloading isn't available in C.
Definition: wall_shell.c:2067
ws_error_t
All potential error returns by WallShell functions.
Definition: wall_shell.h:128
void ws_setBackgroundDefault(ws_bg_color_t c)
Set the default background color.
Definition: wall_shell.c:435
void ws_doPrintThreadID(bool b)
Set print threadID, which prints the threadID of function calling ws_logger.
Definition: wall_shell.c:787
void ws_lockMutex(ws_mutex_t *mut)
Locks the provided mutex.
Definition: wallshell_config.c:71
void ws_setLoggerColors(ws_logtype_t type, ws_fg_color_t fg, ws_bg_color_t bg)
Set the logger colors for the specified log type.
Definition: wall_shell.c:1043
void ws_setThreadName(char *name)
Sets the name of the calling thread.
Definition: wall_shell.c:703
ws_color_t ws_getDefaultColors()
Get the current default colors.
Definition: wall_shell.c:461
ws_color_t ws_getCurrentColors()
Get the current console colors.
Definition: wall_shell.c:455
pthread_mutex_t ws_mutex_t
Wrapper around your system's mutex type.
Definition: wall_shell.h:78
void ws_vlogger(ws_logtype_t type, const char *format, va_list args)
Logger function for WallShell.
Definition: wall_shell.c:992
void ws_printGeneralHelp(ws_help_entry_general_t *entry)
help
Definition: wall_shell.c:2090
ws_stream
Simple enum relating to stream types that WallShell uses.
Definition: wall_shell.h:220
void ws_stopTerminal()
Stops the currently running terminal.
Definition: wall_shell.c:1446
ws_error_t ws_terminalMain()
Main function for the terminal.
Definition: wall_shell.c:1785
ws_logtype_t
Logging types.
Definition: wall_shell.h:260
ws_cursor_t
Cursor directions.
Definition: wall_shell.h:229
Configuration file to put compile time options for WallShell.