From eb8b23218f73f7ac92ea0fa3bcef71d40c355bf0 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Thu, 14 Jun 2012 11:55:15 +0200 Subject: Fixed quoting. --- src/messageparser.cc | 34 ++++++++++++++++------------------ src/muniacli.cc | 8 ++++++-- 2 files changed, 22 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/messageparser.cc b/src/messageparser.cc index ea5e615..5714c88 100644 --- a/src/messageparser.cc +++ b/src/messageparser.cc @@ -49,37 +49,35 @@ inline static void parse_into_msg_tokens(std::string& data, if(prev_ch != '\\') inside_quote = !inside_quote; else { -// printf("Appending %c\n", ch); token += ch; } break; case ' ': if(inside_quote) { -// printf("Appending %c\n", ch); + //printf("Appending %c\n", ch); token += ch; - break; } - if(token.empty()) continue; // skip multiple white spaces and pre white space + else { + if(token.empty()) continue; // skip multiple white spaces and pre white space // printf("Adding token %s\n", token.c_str()); - tokenVector.push_back(token); - token.clear(); + tokenVector.push_back(token); + token.clear(); + } break; case ';': if(inside_quote) { -// printf("Appending %c\n", ch); token += ch; - break; - } -// printf("Adding msg...\n"); - if(!token.empty()) { - tokenVector.push_back(token); } - msgTokensList.push_back(tokenVector); - tokenVector.clear(); - token.clear(); + else { + if(!token.empty()) { + tokenVector.push_back(token); + } + msgTokensList.push_back(tokenVector); + tokenVector.clear(); + token.clear(); + } break; default: -// printf("Appending %c\n", ch); token += ch; break; } @@ -123,7 +121,7 @@ inline static void create_msg_list(MsgTokensList& msgTokensList, else if(t[origin] == "create") m.cmd = cmd::create; else if(t[origin] == "remove") m.cmd = cmd::remove; else if(t[origin] == "move") m.cmd = cmd::move; - else if(t[origin] == "update") m.cmd = cmd::update; + else if(t[origin] == "update") m.cmd = cmd::update; else m.cmd = cmd::error; // printf("Number of tokens %d\n", t.size()); @@ -131,7 +129,7 @@ inline static void create_msg_list(MsgTokensList& msgTokensList, switch(m.cmd) { case cmd::observe: { if(t.size() != origin+1+1) { - printf("W1: rong number of parameters\n"); + printf("Wrong number of parameters\n"); continue; } m.observe.id = atoi(t[origin+1].c_str()); diff --git a/src/muniacli.cc b/src/muniacli.cc index 14f543e..b6e5bbf 100644 --- a/src/muniacli.cc +++ b/src/muniacli.cc @@ -340,21 +340,25 @@ int main(int argc, char** argv) switch(cmd) { case CREATE: msgs = "create " + taskbyid + ";"; + msgs += "observe " + taskbyid + ";"; break; case LIST: - msgs = "observe " + taskbyid; //+ + msgs = "observe " + taskbyid + ";"; //+ // "; unobserve " + task + ";"; break; case REMOVE: msgs = "remove " + taskbyid + ";"; break; case UPDATE: - msgs = "update " + taskbyid + " " + cmd_opts; + msgs = "update " + taskbyid + " \"" + cmd_opts + "\"; "; + msgs += "observe " + taskbyid + ";"; break; case DEFAULT: break; } +// printf("msgs: %s\n", msgs.c_str()); + /* if(!interactive && argc - optionscount < 3) { fprintf(stderr, "%s", USAGE); -- cgit v1.2.3 From 4f919bc4b1cecf9e4cfe25d21a7292bee3ee018b Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Fri, 15 Jun 2012 13:28:34 +0200 Subject: Fixed remove. --- src/muniacli.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/muniacli.cc b/src/muniacli.cc index b6e5bbf..11b4829 100644 --- a/src/muniacli.cc +++ b/src/muniacli.cc @@ -281,7 +281,7 @@ int main(int argc, char** argv) int n = 0; while(n >= 0) { - n = getopt_long(argc, argv, "p:iN:I:CLR:U:hH:", options, NULL); + n = getopt_long(argc, argv, "p:iN:I:CLRU:hH:", options, NULL); if(n < 0) continue; switch(n) { case 'i': -- cgit v1.2.3