diff options
Diffstat (limited to 'ihe.c')
-rw-r--r-- | ihe.c | 77 |
1 files changed, 49 insertions, 28 deletions
@@ -1,9 +1,12 @@ #include "ihe.h" #include "core.h" +/* Global variables */ +cmd_mng_t cmd_mng; static int cmd_loop = 1; extern cmd_table_t tab[]; + #define CMK_KEYMAP1(KEY) (in_buf[0]==(KEY)&&(ret_read==1)) #define CMD_IN_BUF_SIZE 32 @@ -388,34 +391,34 @@ CMD COMMANDS */ cmd_table_t tab[] = { - {"version", c_version }, - {"arg", c_arg }, + {"version", c_version , NULL, NULL, NULL}, + {"arg", c_arg , NULL, NULL, NULL}, //{"quit", c_quit}, - {"help", c_help}, - {"?", c_help}, - {"open", c_open}, - {"close", c_close}, - {"info", c_info}, - {"seek", c_seek}, - {"pos", c_pos}, - {"size", c_size}, - {"blk", c_blk}, - {"read", c_read}, - {"dump", c_dump}, - {"dumpx", c_dumpx}, - {"dumps", c_dumps}, - {"write", c_write}, - {"writes", c_writes}, - {"resize", c_resize}, - {"flags", c_flags}, - {"manifesto", c_manifesto}, - {"ls", c_ls}, - {"pwd", c_pwd}, - {"cd", c_cd}, + {"help", c_help, NULL, NULL, NULL}, + {"?", c_help, NULL, NULL, NULL}, + {"open", c_open, NULL, NULL, NULL}, + {"close", c_close, NULL, NULL, NULL}, + {"info", c_info, NULL, NULL, NULL}, + {"seek", c_seek, NULL, NULL, NULL}, + {"pos", c_pos, NULL, NULL, NULL}, + {"size", c_size, NULL, NULL, NULL}, + {"blk", c_blk, NULL, NULL, NULL}, + {"read", c_read, NULL, NULL, NULL}, + {"dump", c_dump, NULL, NULL, NULL}, + {"dumpx", c_dumpx, NULL, NULL, NULL}, + {"dumps", c_dumps, NULL, NULL, NULL}, + {"write", c_write, NULL, NULL, NULL}, + {"writes", c_writes, NULL, NULL, NULL}, + {"resize", c_resize, NULL, NULL, NULL}, + {"flags", c_flags, NULL, NULL, NULL}, + {"manifesto", c_manifesto, NULL, NULL, NULL}, + {"ls", c_ls, NULL, NULL, NULL}, + {"pwd", c_pwd, NULL, NULL, NULL}, + {"cd", c_cd, NULL, NULL, NULL}, //{"create", c_create}, //{"th", c_th}, //{"tw", c_tw}, - {NULL, NULL } + {NULL, NULL , NULL, NULL, NULL}, }; @@ -423,6 +426,7 @@ cmd_table_t tab[] = { int main( int argc, char **argv ) { const int sz_buf = 1024; + int err; uint8_t in_buf[sz_buf]; int ret_read; int new_c=0, new_r=0, old_r=0, old_c=0; @@ -445,6 +449,14 @@ int main( int argc, char **argv ) cmd_in_buf_t cmd_in; cmd_buf_clean( &cmd_in ); + //clean cmd manager structure that is global + memset(&cmd_mng, 0, sizeof(cmd_mng)); + + //register command table + cmd_mng.table = tab; + cmd_mng.flag_history = 0; + cmd_mng.flag_autocomplete = 1; + if ( term_init( &ts ) == -1 ) printf("Some err when init\n"); @@ -493,6 +505,7 @@ int main( int argc, char **argv ) //cmd_buf_print( &cmd_in, 2 ); cmd_in.buf[cmd_in.cur_sz] = '\n'; cmd_in.buf[cmd_in.cur_sz+1] = 0; + #warning "Auto complete" cmd_tab_autocomplete( cmd_in.buf ); //cmd_buf_print( &cmd_in, 2 ); write(1,"$",1); @@ -538,11 +551,13 @@ int main( int argc, char **argv ) continue; } */ - + + /* iter = ptr->next; args = cmd_arg_create( iter ); cmd_tok_destroy( ptr->next ); ptr->next = NULL; + */ /* for (i=0; i<args->argc; i++) @@ -551,14 +566,18 @@ int main( int argc, char **argv ) } */ - + /* if (cmd_exec(tab, args) != 0) { printf("!Unknown command\n"); + }*/ + err = cmd_mng_exec( &cmd_mng, cmd_in.buf, cmd_in.cur_sz ); + if (err!=CMD_EOK) + { + printf("Unknow command\n"); } - - cmd_arg_destroy( args ); + //cmd_arg_destroy( args ); cmd_buf_clean( &cmd_in ); write(1,"$",1); @@ -566,6 +585,8 @@ int main( int argc, char **argv ) } + cmd_mng_free( &cmd_mng ); + term_clr_scr( &ts ); term_set_orig_mode( &ts ); |