summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-10-11 13:11:06 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-10-11 13:11:06 +0200
commitf11c11123f8cc43fc6e810b6c3dd911eb697826e (patch)
treeee9e3d1a737798327f71009835b5eb5962512db4
parent7832d70f259bbb1f40ca5164f2128000519a16fe (diff)
afb-proto-ws: remove dependencies
Remove dependencies to verbose and to afb-common. Change-Id: I140f2cd7c159e9be994ab7b786a164d605d1b1dc Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afb-proto-ws.c23
-rw-r--r--src/afb-proto-ws.h7
-rw-r--r--src/afb-stub-ws.c5
3 files changed, 13 insertions, 22 deletions
diff --git a/src/afb-proto-ws.c b/src/afb-proto-ws.c
index 24f70e5e..3c8922cd 100644
--- a/src/afb-proto-ws.c
+++ b/src/afb-proto-ws.c
@@ -33,14 +33,10 @@
#include <pthread.h>
#include <json-c/json.h>
-#include <systemd/sd-event.h>
-
-#include "afb-common.h"
#include "afb-ws.h"
#include "afb-msg-json.h"
#include "afb-proto-ws.h"
-#include "verbose.h"
struct afb_proto_ws;
@@ -358,7 +354,6 @@ int afb_proto_ws_call_success(struct afb_proto_ws_call *call, struct json_object
goto success;
}
}
- ERROR("error while sending success");
success:
return rc;
}
@@ -378,7 +373,6 @@ int afb_proto_ws_call_fail(struct afb_proto_ws_call *call, const char *status, c
goto success;
}
}
- ERROR("error while sending fail");
success:
return rc;
}
@@ -422,7 +416,6 @@ int afb_proto_ws_call_subcall(struct afb_proto_ws_call *call, const char *api, c
}
}
}
- ERROR("error while sending subcall");
success:
return rc;
}
@@ -442,7 +435,6 @@ int afb_proto_ws_call_subscribe(struct afb_proto_ws_call *call, const char *even
goto success;
}
}
- ERROR("error while subscribing event");
success:
return rc;
}
@@ -462,7 +454,6 @@ int afb_proto_ws_call_unsubscribe(struct afb_proto_ws_call *call, const char *ev
goto success;
}
}
- ERROR("error while subscribing event");
success:
return rc;
}
@@ -510,14 +501,12 @@ static int client_msg_call_get(struct afb_proto_ws *protows, struct readbuf *rb,
/* get event data from the message */
if (!readbuf_uint32(rb, &callid)) {
- ERROR("Invalid message");
return 0;
}
/* get the call */
*call = client_call_search(protows, callid);
if (*call == NULL) {
- ERROR("message not found");
return 0;
}
@@ -1098,7 +1087,7 @@ static const struct afb_ws_itf server_ws_itf =
/*****************************************************/
-static struct afb_proto_ws *afb_proto_ws_create(int fd, const struct afb_proto_ws_server_itf *itfs, const struct afb_proto_ws_client_itf *itfc, void *closure, const struct afb_ws_itf *itf)
+static struct afb_proto_ws *afb_proto_ws_create(struct sd_event *eloop, int fd, const struct afb_proto_ws_server_itf *itfs, const struct afb_proto_ws_client_itf *itfc, void *closure, const struct afb_ws_itf *itf)
{
struct afb_proto_ws *protows;
@@ -1108,7 +1097,7 @@ static struct afb_proto_ws *afb_proto_ws_create(int fd, const struct afb_proto_w
else {
fcntl(fd, F_SETFD, FD_CLOEXEC);
fcntl(fd, F_SETFL, O_NONBLOCK);
- protows->ws = afb_ws_create(afb_common_get_event_loop(), fd, itf, protows);
+ protows->ws = afb_ws_create(eloop, fd, itf, protows);
if (protows->ws != NULL) {
protows->fd = fd;
protows->refcount = 1;
@@ -1124,14 +1113,14 @@ static struct afb_proto_ws *afb_proto_ws_create(int fd, const struct afb_proto_w
return NULL;
}
-struct afb_proto_ws *afb_proto_ws_create_client(int fd, const struct afb_proto_ws_client_itf *itf, void *closure)
+struct afb_proto_ws *afb_proto_ws_create_client(struct sd_event *eloop, int fd, const struct afb_proto_ws_client_itf *itf, void *closure)
{
- return afb_proto_ws_create(fd, NULL, itf, closure, &proto_ws_client_ws_itf);
+ return afb_proto_ws_create(eloop, fd, NULL, itf, closure, &proto_ws_client_ws_itf);
}
-struct afb_proto_ws *afb_proto_ws_create_server(int fd, const struct afb_proto_ws_server_itf *itf, void *closure)
+struct afb_proto_ws *afb_proto_ws_create_server(struct sd_event *eloop, int fd, const struct afb_proto_ws_server_itf *itf, void *closure)
{
- return afb_proto_ws_create(fd, itf, NULL, closure, &server_ws_itf);
+ return afb_proto_ws_create(eloop, fd, itf, NULL, closure, &server_ws_itf);
}
void afb_proto_ws_unref(struct afb_proto_ws *protows)
diff --git a/src/afb-proto-ws.h b/src/afb-proto-ws.h
index a3d4a0dd..103e37ab 100644
--- a/src/afb-proto-ws.h
+++ b/src/afb-proto-ws.h
@@ -18,6 +18,7 @@
#pragma once
+struct sd_event;
struct afb_proto_ws;
struct afb_proto_ws_call;
struct afb_proto_ws_subcall;
@@ -25,9 +26,11 @@ struct afb_proto_ws_describe;
struct afb_proto_ws_client_itf
{
+ /* can't be NULL */
void (*on_reply_success)(void *closure, void *request, struct json_object *result, const char *info);
void (*on_reply_fail)(void *closure, void *request, const char *status, const char *info);
+ /* can be NULL */
void (*on_event_create)(void *closure, const char *event_name, int event_id);
void (*on_event_remove)(void *closure, const char *event_name, int event_id);
void (*on_event_subscribe)(void *closure, void *request, const char *event_name, int event_id);
@@ -44,8 +47,8 @@ struct afb_proto_ws_server_itf
void (*on_describe)(void *closure, struct afb_proto_ws_describe *describe);
};
-extern struct afb_proto_ws *afb_proto_ws_create_client(int fd, const struct afb_proto_ws_client_itf *itf, void *closure);
-extern struct afb_proto_ws *afb_proto_ws_create_server(int fd, const struct afb_proto_ws_server_itf *itf, void *closure);
+extern struct afb_proto_ws *afb_proto_ws_create_client(struct sd_event *eloop, int fd, const struct afb_proto_ws_client_itf *itf, void *closure);
+extern struct afb_proto_ws *afb_proto_ws_create_server(struct sd_event *eloop, int fd, const struct afb_proto_ws_server_itf *itf, void *closure);
extern void afb_proto_ws_unref(struct afb_proto_ws *protows);
extern void afb_proto_ws_addref(struct afb_proto_ws *protows);
diff --git a/src/afb-stub-ws.c b/src/afb-stub-ws.c
index 7637f22c..8533c797 100644
--- a/src/afb-stub-ws.c
+++ b/src/afb-stub-ws.c
@@ -33,7 +33,6 @@
#include <pthread.h>
#include <json-c/json.h>
-#include <systemd/sd-event.h>
#include <afb/afb-event.h>
@@ -611,9 +610,9 @@ static struct afb_stub_ws *afb_stub_ws_create(int fd, const char *apiname, struc
errno = ENOMEM;
else {
if (client)
- stubws->proto = afb_proto_ws_create_client(fd, &client_itf, stubws);
+ stubws->proto = afb_proto_ws_create_client(afb_common_get_event_loop(), fd, &client_itf, stubws);
else
- stubws->proto = afb_proto_ws_create_server(fd, &server_itf, stubws);
+ stubws->proto = afb_proto_ws_create_server(afb_common_get_event_loop(), fd, &server_itf, stubws);
if (stubws->proto != NULL) {
strcpy(stubws->apiname, apiname);
stubws->apiset = afb_apiset_addref(apiset);