HALFRED  0.4.0
hal_cli.h
Go to the documentation of this file.
1 
10 #ifndef HAL_CLI_H
11 #define HAL_CLI_H
12 
13 #include <stdint.h>
14 #include <stddef.h>
15 #include <stdbool.h>
16 
115 
116 #ifndef CLI_COMMAND_BUF_SIZE
117 
119 #define CLI_COMMAND_BUF_SIZE 127
120 
121 #endif
122 
124 typedef struct CLIConsoleDesc* CLIConsole;
125 
127 typedef enum {
137 
143  struct {
145  uint8_t busy : 1;
147  uint8_t multichar : 1;
148  uint8_t doublechar : 1;
149  } state;
151  void (*command_processor) (CLIConsole clic);
155  size_t cnt;
157  size_t offset;
159  int cols;
161  int rows;
162 };
163 
172 #define CLI_DECLARE(name, iodevice, command_processor, attribute) \
173  static struct CLIConsoleDesc name##_desc = {iodevice, {0,0,0}, command_processor, {0x00}, 0, 0 }; \
174  attribute CLIConsole name = &name##_desc
175 
176 
184 CLIConsole CLI_Create(IODevice iodevice);
185 
192 void CLI_Destroy(CLIConsole cli);
193 
199 void CLI_DisplayMainScreen(CLIConsole cli);
200 
209 CLIConsoleAction CLI_ProcessConsole(CLIConsole cli);
210 
217 void CLI_SetCommandProcessor(CLIConsole cli, void (*cmd_proc) (CLIConsole cli));
218 
224 void CLI_ForceCommandMode(CLIConsole cli);
225 
231 void CLI_CursorSave(CLIConsole cli);
232 
238 void CLI_CursorRestore(CLIConsole cli);
239 
245 void CLI_CursorRest(CLIConsole cli);
246 
258 bool CLI_GetCommand(CLIConsole cli, char* dst, size_t dst_size);
259 
266 bool CLI_IsNextArg(CLIConsole cli);
267 
274 bool CLI_GetNextArg(CLIConsole cli, char* arg);
275 
284 bool CLI_GetNextArgAndConvertToLowerCase(CLIConsole cli, char* arg, size_t argMaxSize);
285 
294 bool CLI_GetNextArgINT32(CLIConsole cli, int32_t *arg);
295 
304 bool CLI_GetNextArgUINT32(CLIConsole cli, uint32_t *arg);
305 
314 bool CLI_GetNextArgINT64(CLIConsole cli, int64_t *arg);
315 
324 bool CLI_GetNextArgUINT64(CLIConsole cli, uint64_t *arg);
325 
332 void CLI_GetBack(CLIConsole cli, int argc);
333 
334 
342 #define CLI_HaltConsoleInput(cli) do { cli->state.busy = 1; } while (0)
343 
350 #define CLI_EnableConsoleInput(cli) do { cli->state.busy = 0; } while (0)
351 
360 #define CLI_GetIODevice(cli) (cli->iodevice)
361 
369 #define CLI_SetIODevice(cli,device) (cli->iodevice=device)
370 
374 #endif /* HAL_CLI_H */
uint8_t multichar
bit indicating command line mode (1) or key press mode (0: default)
Definition: hal_cli.h:147
void CLI_GetBack(CLIConsole cli, int argc)
void CLI_Destroy(CLIConsole cli)
void CLI_SetCommandProcessor(CLIConsole cli, void(*cmd_proc)(CLIConsole cli))
bool CLI_IsNextArg(CLIConsole cli)
No action was taken.
Definition: hal_cli.h:129
void(* command_processor)(CLIConsole clic)
external command processor handle
Definition: hal_cli.h:151
struct CLIConsoleDesc::@0 state
console state and work mode
uint8_t busy
bit indicating that the console is busy and unable to receive new charaters
Definition: hal_cli.h:145
bool CLI_GetNextArgINT64(CLIConsole cli, int64_t *arg)
Console is busy.
Definition: hal_cli.h:135
int rows
console size: number of rows
Definition: hal_cli.h:161
bool CLI_GetNextArgINT32(CLIConsole cli, int32_t *arg)
bool CLI_GetNextArgUINT64(CLIConsole cli, uint64_t *arg)
Definition: hali_iodevice.h:44
Command Line Interface Console descriptor.
Definition: hal_cli.h:139
size_t cnt
command buffer counter
Definition: hal_cli.h:155
bool CLI_GetCommand(CLIConsole cli, char *dst, size_t dst_size)
IODevice iodevice
IODevice object associated with console.
Definition: hal_cli.h:141
struct CLIConsoleDesc * CLIConsole
Definition: hal_cli.h:124
void CLI_CursorSave(CLIConsole cli)
size_t offset
command analyzer progress offset
Definition: hal_cli.h:157
User supplied function was called.
Definition: hal_cli.h:133
CLIConsole CLI_Create(IODevice iodevice)
bool CLI_GetNextArg(CLIConsole cli, char *arg)
int cols
console size: number of columns
Definition: hal_cli.h:159
A default action was taken (could not resolve which option call)
Definition: hal_cli.h:131
void CLI_DisplayMainScreen(CLIConsole cli)
void CLI_ForceCommandMode(CLIConsole cli)
bool CLI_GetNextArgAndConvertToLowerCase(CLIConsole cli, char *arg, size_t argMaxSize)
void CLI_CursorRestore(CLIConsole cli)
char buf[CLI_COMMAND_BUF_SIZE]
command buffer
Definition: hal_cli.h:153
#define CLI_COMMAND_BUF_SIZE
Default size of the command line buffer.
Definition: hal_cli.h:119
void CLI_CursorRest(CLIConsole cli)
CLIConsoleAction CLI_ProcessConsole(CLIConsole cli)
CLIConsoleAction
Type denoting action taken by the CLI_ProcessConsole function.
Definition: hal_cli.h:127
bool CLI_GetNextArgUINT32(CLIConsole cli, uint32_t *arg)