aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-api-ws.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-03-27 11:23:51 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-03-27 11:23:51 +0200
commit44f21bd2a3b50f92669223cdafe79993654c1e19 (patch)
treeb8656cf9c11f25183bd95822c085ce35a459a9e5 /src/afb-api-ws.c
parentfeccdb76f572a5fad947475c21b5b9aff696b04b (diff)
Simplify functions for calls
For historical reasons, the call to apis was passing the length of the api and the length of the verb. The reason was to avoid a copy of strings. But the copy occured only for HTTP requests. Having this implementation is of small interest and compromise future changes. This patch simplify things. Change-Id: I8157724c6c721b6797cd0eab52b07e1b8d6eb5f8 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-api-ws.c')
-rw-r--r--src/afb-api-ws.c12
1 files changed, 3 insertions, 9 deletions
diff --git a/src/afb-api-ws.c b/src/afb-api-ws.c
index a56cfbef..89b83bc5 100644
--- a/src/afb-api-ws.c
+++ b/src/afb-api-ws.c
@@ -431,12 +431,6 @@ static int api_ws_write_uint32(struct writebuf *wb, uint32_t value)
return 1;
}
-static int api_ws_write_string_nz(struct writebuf *wb, const char *value, size_t length)
-{
- uint32_t len = (uint32_t)length;
- return (size_t)len == length && ++len && api_ws_write_uint32(wb, len) && api_ws_write_put(wb, value, length) && api_ws_write_char(wb, '\0');
-}
-
static int api_ws_write_string_length(struct writebuf *wb, const char *value, size_t length)
{
uint32_t len = (uint32_t)++length;
@@ -815,7 +809,7 @@ static void api_ws_client_on_binary(void *closure, char *data, size_t size)
}
/* on call, propagate it to the ws service */
-static void api_ws_client_call_cb(void * closure, struct afb_req req, struct afb_context *context, const char *verb, size_t lenverb)
+static void api_ws_client_call_cb(void * closure, struct afb_req req, struct afb_context *context, const char *verb)
{
int rc;
struct api_ws_memo *memo;
@@ -837,7 +831,7 @@ static void api_ws_client_call_cb(void * closure, struct afb_req req, struct afb
goto internal_error;
if (!api_ws_write_uint32(&wb, memo->msgid)
|| !api_ws_write_uint32(&wb, (uint32_t)context->flags)
- || !api_ws_write_string_nz(&wb, verb, lenverb)
+ || !api_ws_write_string(&wb, verb)
|| !api_ws_write_string(&wb, afb_session_uuid(context->session))
|| !api_ws_write_string_length(&wb, raw, szraw))
goto overflow;
@@ -988,7 +982,7 @@ static void api_ws_server_called(struct api_ws_client *client, struct readbuf *r
/* makes the call */
areq.itf = &afb_api_ws_req_itf;
areq.closure = wreq;
- afb_apis_call_(areq, &wreq->context, client->api, verb);
+ afb_apis_call(areq, &wreq->context, client->api, verb);
api_ws_server_req_unref(wreq);
return;