# HG changeset patch # User John Tsiombikas # Date 1402347444 -10800 # Node ID fd45cf0fc912ca963280fd84ae5ea8b52b1f9c7e # Parent 5e27c85e79cab2880504d1dc9e0c0c4526ef4e5c load console command diff -r 5e27c85e79ca -r fd45cf0fc912 src/main.cc --- a/src/main.cc Mon Jun 09 18:40:30 2014 +0300 +++ b/src/main.cc Mon Jun 09 23:57:24 2014 +0300 @@ -574,11 +574,35 @@ static void con_parse(const char *line) { - printf("got line: %s\n", line); + char *buf = (char*)alloca(strlen(line) + 1); + strcpy(buf, line); - if(erb_proc_cmd(erb, line) == -1) { - con.puts("invalid command\n"); + std::vector args; + char *tok; + + while((tok = strtok(buf, " \n\r\v\t"))) { + buf = 0; + args.push_back(tok); + } + args.push_back(0); + int argc = args.size() - 1; + + if(strcmp(args[0], "exit") == 0) { + exit(0); + } else if(strcmp(args[0], "load") == 0) { + for(int i=1; i