summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-04-21 11:23:52 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-04-21 11:23:52 +0200
commit601218349522d6590478ee979c312cf5e516c701 (patch)
tree7bb638fdd288b795434c7ebbb0e873bc01cb2647
parent727e705706be47066893bd483458c23e4c4e173c (diff)
afb-client-demo: Handle comments
Change-Id: I39287c5b5bba8b3ec18dc36e58a0d0102c5b48d6 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-client-demo.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/afb-client-demo.c b/src/afb-client-demo.c
index 4cbc9c7a..754c57e7 100644
--- a/src/afb-client-demo.c
+++ b/src/afb-client-demo.c
@@ -226,9 +226,12 @@ static int io_event_callback(sd_event_source *src, int fd, uint32_t revents, voi
rest[0] = i; while(i < count && line[i] != '\n') i++; rest[1] = i;
if (i == count) break;
line[i++] = 0;
- if (api[0] == api[1] || verb[0] == verb[1]) {
- if (api[0] != api[1] || verb[0] != verb[1])
- fprintf(stderr, "bad line: %s\n", line+pos);
+ if (api[0] == api[1]) {
+ /* empty line */
+ } else if (line[api[0]] == '#') {
+ /* comment */
+ } else if (verb[0] == verb[1]) {
+ fprintf(stderr, "verb missing, bad line: %s\n", line+pos);
} else {
line[api[1]] = line[verb[1]] = 0;
emit(line + api[0], line + verb[0], line + rest[0]);