summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2012-06-15 14:15:11 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2012-06-15 14:15:11 +0200
commitedba01f5030a04ca6f56cb5865464c400ec7069d (patch)
treee80e5736d91764eee6d2ec6b3d73d5a987b1015a
parente1a8cfa936f6676366cbdda319a3439c00220de6 (diff)
parent4f919bc4b1cecf9e4cfe25d21a7292bee3ee018b (diff)
Merge branch 'master' of https://git.oftal.dk/munia
-rw-r--r--src/messageparser.cc34
-rw-r--r--src/muniacli.cc10
2 files changed, 23 insertions, 21 deletions
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..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':
@@ -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);