X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-client-demo.c;h=754c57e73e436daeddf3a8125b20af03ee288f27;hb=d5296ff2254d084f290e112bc1bee1a3b0453eab;hp=e8ee2f1118a066231a0038b2a2703b7a0c355f99;hpb=1ea6bd0f466a10d29f12801aa35fb6d2b30443a1;p=src%2Fapp-framework-binder.git diff --git a/src/afb-client-demo.c b/src/afb-client-demo.c index e8ee2f11..754c57e7 100644 --- a/src/afb-client-demo.c +++ b/src/afb-client-demo.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2015, 2016 "IoT.bzh" + * Copyright (C) 2015, 2016, 2017 "IoT.bzh" * Author "Fulup Ar Foll" * Author José Bollo * @@ -111,6 +111,7 @@ int main(int ac, char **av, char **env) static void on_hangup(void *closure, struct afb_wsj1 *wsj1) { printf("ON-HANGUP\n"); + fflush(stdout); exit(0); } @@ -119,6 +120,7 @@ static void on_call(void *closure, const char *api, const char *verb, struct afb { int rc; printf("ON-CALL %s/%s(%s)\n", api, verb, afb_wsj1_msg_object_s(msg)); + fflush(stdout); rc = afb_wsj1_reply_error_s(msg, "\"unimplemented\"", NULL); if (rc < 0) fprintf(stderr, "replying failed: %m\n"); @@ -128,12 +130,14 @@ static void on_call(void *closure, const char *api, const char *verb, struct afb static void on_event(void *closure, const char *event, struct afb_wsj1_msg *msg) { printf("ON-EVENT %s(%s)\n", event, afb_wsj1_msg_object_s(msg)); + fflush(stdout); } /* called when wsj1 receives a reply */ static void on_reply(void *closure, struct afb_wsj1_msg *msg) { printf("ON-REPLY %s: %s\n", (char*)closure, afb_wsj1_msg_object_s(msg)); + fflush(stdout); free(closure); callcount--; if (exonrep && !callcount) @@ -222,9 +226,13 @@ 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]) - fprintf(stderr, "bad line: %s\n", line+pos); - else { + 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]); }