diff options
author | Stephane Desneux <stephane.desneux@iot.bzh> | 2016-07-12 16:14:51 +0200 |
---|---|---|
committer | Stephane Desneux <stephane.desneux@iot.bzh> | 2016-07-12 14:35:23 +0000 |
commit | 404f24c13cb45bd3e9ca837bc033fd6840cbf669 (patch) | |
tree | bbc282179848f319c8a2e21193413ab9ddc03064 | |
parent | bca90021828565bddb8624e8f6370bf4959cbfbf (diff) |
afb-client-demo/afb-ws: remove dependency on afb-common.*
afb-common.* files are not public and so not distributed
in any development package. This makes difficult to create
a client with sources out-of-tree.
Change-Id: Ib2edd48f864f55821ab590442efdf6d1e2fdcd58
Signed-off-by: Stephane Desneux <stephane.desneux@iot.bzh>
-rw-r--r-- | src/afb-client-demo.c | 7 | ||||
-rw-r--r-- | src/afb-ws-client.c | 16 | ||||
-rw-r--r-- | src/afb-ws-client.h | 4 | ||||
-rw-r--r-- | src/export-afbwsc.map | 1 |
4 files changed, 22 insertions, 6 deletions
diff --git a/src/afb-client-demo.c b/src/afb-client-demo.c index 6f494a6a..1ead5f74 100644 --- a/src/afb-client-demo.c +++ b/src/afb-client-demo.c @@ -1,4 +1,4 @@ -/* +/* * Copyright (C) 2015, 2016 "IoT.bzh" * Author "Fulup Ar Foll" * Author José Bollo <jose.bollo@iot.bzh> @@ -30,7 +30,6 @@ #include <systemd/sd-event.h> -#include "afb-common.h" /* TODO: remove dependency to afb-common.h */ #include "afb-wsj1.h" #include "afb-ws-client.h" @@ -85,7 +84,7 @@ int main(int ac, char **av, char **env) if (ac == 2) { /* get requests from stdin */ fcntl(0, F_SETFL, O_NONBLOCK); - sd_event_add_io(afb_common_get_event_loop(), &evsrc, 0, EPOLLIN, io_event_callback, NULL); + sd_event_add_io(afb_ws_client_get_event_loop(), &evsrc, 0, EPOLLIN, io_event_callback, NULL); } else { /* the request is defined by the arguments */ exonrep = 1; @@ -94,7 +93,7 @@ int main(int ac, char **av, char **env) /* loop until end */ for(;;) - sd_event_run(afb_common_get_event_loop(), 30000000); + sd_event_run(afb_ws_client_get_event_loop(), 30000000); return 0; } diff --git a/src/afb-ws-client.c b/src/afb-ws-client.c index e9c1a906..de44a398 100644 --- a/src/afb-ws-client.c +++ b/src/afb-ws-client.c @@ -29,6 +29,7 @@ #include <fcntl.h> #include "afb-wsj1.h" +#include "afb-common.h" /**************** WebSocket handshake ****************************/ @@ -111,7 +112,7 @@ static char *strjoin(int count, const char **strings, const char *separ) /* creates the http message for the request */ static int make_request(char **request, const char *path, const char *host, const char *key, const char *protocols) { - int rc = asprintf(request, + int rc = asprintf(request, "GET %s HTTP/1.1\r\n" "Host: %s\r\n" "Upgrade: websocket\r\n" @@ -314,7 +315,7 @@ invalid: errno = EINVAL; error: return -1; - + } @@ -406,4 +407,15 @@ static char *makequery(const char *path, const char *uuid, const char *token) } #endif +/* + * + * Returns the internal event loop coming from afb-common + * + * Returns the handle to the event loop + */ +struct sd_event *afb_ws_client_get_event_loop() +{ + return afb_common_get_event_loop(); +} + diff --git a/src/afb-ws-client.h b/src/afb-ws-client.h index f2aee7d0..cac4c782 100644 --- a/src/afb-ws-client.h +++ b/src/afb-ws-client.h @@ -27,3 +27,7 @@ struct afb_wsj1_itf; * Returns NULL in case of failure with errno set appriately. */ extern struct afb_wsj1 *afb_ws_client_connect_wsj1(const char *uri, struct afb_wsj1_itf *itf, void *closure); + +struct sd_event; +extern struct sd_event *afb_ws_client_get_event_loop(); + diff --git a/src/export-afbwsc.map b/src/export-afbwsc.map index c775a16f..ac7dea58 100644 --- a/src/export-afbwsc.map +++ b/src/export-afbwsc.map @@ -1,6 +1,7 @@ { global: afb_ws_client_connect_wsj1; + afb_ws_client_get_event_loop; afb_wsj1_*; afb_common_*; local: |