-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli_defs.h
More file actions
53 lines (46 loc) · 1.32 KB
/
cli_defs.h
File metadata and controls
53 lines (46 loc) · 1.32 KB
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
48
49
50
51
52
53
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
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)(const char *string);
/*!
* @brief Command structure, consisting of a name and function pointer.
*/
typedef struct
{
const char *cmd; /* Command name. */
cmd_func_ptr_t func; /* Function pointer to associated function. */
const char *help; /* help/usage summary */
} 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;
#ifdef __cplusplus
}
#endif