--- upstream/dynamips-0.2.5/hypervisor.c 2007/10/06 16:01:44 1 +++ upstream/dynamips-0.2.6-RC1/hypervisor.c 2007/10/06 16:03:58 2 @@ -58,6 +58,20 @@ return(0); } +/* Parser test */ +static int cmd_parser_test(hypervisor_conn_t *conn,int argc,char *argv[]) +{ + int i; + + for(i=0;iactive) { - if (!m_fgets(buffer,sizeof(buffer),conn->in)) + if (!fgets(buffer,sizeof(buffer),conn->in)) break; if (!*buffer) continue; /* Tokenize command line */ - tokens = NULL; - res = parser_tokenize(buffer,&tok_list,&tok_count); + res = parser_scan_buffer(&ctx,buffer,strlen(buffer)); - if (res != 0) { - hypervisor_send_reply(conn,HSC_ERR_PARSING,1,"Parse error: %s", - parser_strerror(res)); - continue; - } + if (res != 0) { + tokens = NULL; - if (tok_count < 2) { - hypervisor_send_reply(conn,HSC_ERR_PARSING,1, - "At least a module and a command " - "must be specified"); - goto free_tokens; - } + if (ctx.error != 0) { + hypervisor_send_reply(conn,HSC_ERR_PARSING,1,"Parse error: %s", + parser_strerror(&ctx)); + goto free_tokens; + } + + if (ctx.tok_count < 2) { + hypervisor_send_reply(conn,HSC_ERR_PARSING,1, + "At least a module and a command " + "must be specified"); + goto free_tokens; + } - /* Map token list to an array */ - tokens = parser_map_array(tok_list,tok_count); + /* Map token list to an array */ + tokens = parser_map_array(&ctx); - if (!tokens) { - hypervisor_send_reply(conn,HSC_ERR_PARSING,1,"No memory"); - goto free_tokens; - } - - /* Execute command */ - m_log("hypervisor_exec","%s\n",buffer); - hypervisor_exec_cmd(conn,tokens[0],tokens[1],tok_count-2,&tokens[2]); + if (!tokens) { + hypervisor_send_reply(conn,HSC_ERR_PARSING,1,"No memory"); + goto free_tokens; + } + + /* Execute command */ + //m_log("hypervisor_exec","%s\n",buffer); + hypervisor_exec_cmd(conn,tokens[0],tokens[1],ctx. + tok_count-2,&tokens[2]); - free_tokens: - free(tokens); - parser_free_tokens(tok_list); + free_tokens: + free(tokens); + tokens = NULL; + parser_context_free(&ctx); + } } + free(tokens); + parser_context_free(&ctx); return NULL; } @@ -518,6 +543,7 @@ hypervisor_atmsw_init(); hypervisor_ethsw_init(); hypervisor_vm_init(); + hypervisor_vm_debug_init(); hypervisor_c7200_init(); hypervisor_c3600_init();