-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcli_defs.h
47 lines (39 loc) · 1.41 KB
/
cli_defs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#ifndef _CLI_DEFS_H_
#define _CLI_DEFS_H_
#include <stddef.h>
#ifndef MAX_BUF_SIZE
#define MAX_BUF_SIZE 128 /* Maximum size of CLI Rx buffer */
#endif
#ifndef CMD_TERMINATOR
#define CMD_TERMINATOR '\r' /* Delimiter denoting end of cmd from user */
#endif
typedef enum {
CLI_OK, /* API execution successful. */
CLI_E_NULL_PTR, /* Null pointer error. */
CLI_E_IO,
CLI_E_CMD_NOT_FOUND, /* Command name not found in command table. */
CLI_E_INVALID_ARGS, /* Invalid function parameters/arguments. */
CLI_E_BUF_FULL, /* CLI buffer full. */
CLI_IDLE /* No command to execute at the moment */
} cli_status_t;
/*!
* @brief Function type declarations.
*/
typedef cli_status_t (*cmd_func_ptr_t)(int argc, char **argv);
typedef void (*println_func_ptr_t)(char *string);
/*!
* @brief Command structure, consisting of a name and function pointer.
*/
typedef struct {
char *cmd; /* Command name. */
cmd_func_ptr_t func; /* Function pointer to associated function. */
} cmd_t;
/*!
* @brief Command-line interface handle structure.
*/
typedef struct {
println_func_ptr_t println; /* Function pointer to user defined println function. */
cmd_t *cmd_tbl; /* Pointer to series of commands which are to be accepted. */
size_t cmd_cnt; /* Number of commands in cmd_tbl. */
} cli_t;
#endif