diff options
author | FreeArtMan <dos21h@gmail.com> | 2016-08-17 21:55:21 +0100 |
---|---|---|
committer | FreeArtMan <dos21h@gmail.com> | 2016-08-17 21:55:21 +0100 |
commit | d4d2c1e98aa3f4abb9ea2e6d294e2cad7e408b65 (patch) | |
tree | be8a9ada0b5cc3faa70376e683549792d6805440 /cmd.h | |
parent | e6ddd00fedabeb470c7f3b132cb2289109688e73 (diff) | |
download | libcmd-d4d2c1e98aa3f4abb9ea2e6d294e2cad7e408b65.tar.gz libcmd-d4d2c1e98aa3f4abb9ea2e6d294e2cad7e408b65.zip |
Autocomplete and history for cmd manager
Diffstat (limited to 'cmd.h')
-rw-r--r-- | cmd.h | 13 |
1 files changed, 11 insertions, 2 deletions
@@ -74,6 +74,7 @@ typedef struct cmd_table_t int (*clb)(cmd_arg_t*); //callback to command int (*hlp)(cmd_arg_t*); //help command int (*pre)(cmd_arg_t*); //preconditions for execution + int (*autocpl)(cmd_arg_t*); //autocomplete according to context } cmd_table_t; /* @@ -101,6 +102,9 @@ typedef struct cmd_mng_t //not yet ready //int flag_logging; + + // flag turn on/off autocomplete + int flag_autocomplete; cmd_table_t *table; } cmd_mng_t; @@ -128,7 +132,7 @@ PARAM: cmng - cli manager index - index value in history RETURN: - [FREE] return value if there is under index + return non-NULL value if there something */ char* cmd_mng_history( cmd_mng_t *cmng, int index ); @@ -139,7 +143,7 @@ PARAM: RETURN: [FREE] return string list of autocomplete commands */ -char* cmd_mng_autocomplete( cmd_mng_t *cmng, char *cmd ); +char* cmd_mng_autocomplete( cmd_mng_t *cmng, char *cmd, size_t cmd_sz ); /* PARAM: cmng @@ -148,6 +152,11 @@ RETURN: return result of execution */ int cmd_mng_exec( cmd_mng_t *cmng, const char *cmd, size_t sz_cmd ); +/* +Free resources that where givent to cmd manager, like history +*/ +int cmd_mng_free( cmd_mng_t *cmng); + #define STR_AC_EQ(A,B) (strncmp_ac((A),(B),strlen(A))==(strlen(A)+1)) #define STR_AC_PEQ(A,B) (strncmp_ac((A),(B),strlen(A))<(strlen(A))) |