aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-05-29 14:56:50 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-05-29 14:56:50 +0200
commit6f1126ae2c585afc34d0bb06f3763e3a82ee3d37 (patch)
tree02b01bbdeaab1d0dff462eb3db108981d75eea3e
parent090379fdaf6ed1860dcff21424135ad71ead0cd2 (diff)
Cleanup legacy internal functions
The functions afb_req_raw and afb_req_send are internal. They are now no more visible from bindings. Change-Id: I1f250a1800168a9c3772375477bf37a501f134a0 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--include/afb/afb-req-itf.h16
-rw-r--r--src/afb-hook.c23
-rw-r--r--src/afb-hook.h35
-rw-r--r--src/afb-xreq.c43
4 files changed, 20 insertions, 97 deletions
diff --git a/include/afb/afb-req-itf.h b/include/afb/afb-req-itf.h
index 1d60daee..34d73dd2 100644
--- a/include/afb/afb-req-itf.h
+++ b/include/afb/afb-req-itf.h
@@ -56,8 +56,8 @@ struct afb_req_itf {
void (*success)(void *closure, struct json_object *obj, const char *info);
void (*fail)(void *closure, const char *status, const char *info);
- const char *(*raw)(void *closure, size_t *size);
- void (*send)(void *closure, const char *buffer, size_t size);
+ /*legacy raw */void (*spare1)(void *closure);
+ /*legacy send*/void (*spare2)(void *closure);
void *(*context_get)(void *closure);
void (*context_set)(void *closure, void *value, void (*free_value)(void*));
@@ -388,15 +388,3 @@ static inline int afb_req_subcall_sync(struct afb_req req, const char *api, cons
return req.itf->subcallsync(req.closure, api, verb, args, result);
}
-/* internal use */
-static inline const char *afb_req_raw(struct afb_req req, size_t *size)
-{
- return req.itf->raw(req.closure, size);
-}
-
-/* internal use */
-static inline void afb_req_send(struct afb_req req, const char *buffer, size_t size)
-{
- req.itf->send(req.closure, buffer, size);
-}
-
diff --git a/src/afb-hook.c b/src/afb-hook.c
index c1f93fab..5786f194 100644
--- a/src/afb-hook.c
+++ b/src/afb-hook.c
@@ -134,16 +134,6 @@ static void hook_xreq_fail_default_cb(void * closure, const struct afb_xreq *xre
_hook_xreq_(xreq, "fail(%s, %s)", status, info);
}
-static void hook_xreq_raw_default_cb(void * closure, const struct afb_xreq *xreq, const char *buffer, size_t size)
-{
- _hook_xreq_(xreq, "raw() -> %.*s", (int)size, buffer);
-}
-
-static void hook_xreq_send_default_cb(void * closure, const struct afb_xreq *xreq, const char *buffer, size_t size)
-{
- _hook_xreq_(xreq, "send(%.*s)", (int)size, buffer);
-}
-
static void hook_xreq_context_get_default_cb(void * closure, const struct afb_xreq *xreq, void *value)
{
_hook_xreq_(xreq, "context_get() -> %p", value);
@@ -211,8 +201,6 @@ static struct afb_hook_xreq_itf hook_xreq_default_itf = {
.hook_xreq_get = hook_xreq_get_default_cb,
.hook_xreq_success = hook_xreq_success_default_cb,
.hook_xreq_fail = hook_xreq_fail_default_cb,
- .hook_xreq_raw = hook_xreq_raw_default_cb,
- .hook_xreq_send = hook_xreq_send_default_cb,
.hook_xreq_context_get = hook_xreq_context_get_default_cb,
.hook_xreq_context_set = hook_xreq_context_set_default_cb,
.hook_xreq_addref = hook_xreq_addref_default_cb,
@@ -280,17 +268,6 @@ void afb_hook_xreq_fail(const struct afb_xreq *xreq, const char *status, const c
_HOOK_XREQ_(fail, xreq, status, info);
}
-const char *afb_hook_xreq_raw(const struct afb_xreq *xreq, const char *buffer, size_t size)
-{
- _HOOK_XREQ_(raw, xreq, buffer, size);
- return buffer;
-}
-
-void afb_hook_xreq_send(const struct afb_xreq *xreq, const char *buffer, size_t size)
-{
- _HOOK_XREQ_(send, xreq, buffer, size);
-}
-
void *afb_hook_xreq_context_get(const struct afb_xreq *xreq, void *value)
{
_HOOK_XREQ_(context_get, xreq, value);
diff --git a/src/afb-hook.h b/src/afb-hook.h
index d1f6371a..85361a68 100644
--- a/src/afb-hook.h
+++ b/src/afb-hook.h
@@ -40,20 +40,18 @@ struct afb_hook_xreq;
#define afb_hook_flag_req_get 0x000008
#define afb_hook_flag_req_success 0x000010
#define afb_hook_flag_req_fail 0x000020
-#define afb_hook_flag_req_raw 0x000040
-#define afb_hook_flag_req_send 0x000080
-#define afb_hook_flag_req_context_get 0x000100
-#define afb_hook_flag_req_context_set 0x000200
-#define afb_hook_flag_req_addref 0x000400
-#define afb_hook_flag_req_unref 0x000800
-#define afb_hook_flag_req_session_close 0x001000
-#define afb_hook_flag_req_session_set_LOA 0x002000
-#define afb_hook_flag_req_subscribe 0x004000
-#define afb_hook_flag_req_unsubscribe 0x010800
-#define afb_hook_flag_req_subcall 0x020000
-#define afb_hook_flag_req_subcall_result 0x040000
-#define afb_hook_flag_req_subcallsync 0x080000
-#define afb_hook_flag_req_subcallsync_result 0x100000
+#define afb_hook_flag_req_context_get 0x000040
+#define afb_hook_flag_req_context_set 0x000080
+#define afb_hook_flag_req_addref 0x000100
+#define afb_hook_flag_req_unref 0x000200
+#define afb_hook_flag_req_session_close 0x000400
+#define afb_hook_flag_req_session_set_LOA 0x000800
+#define afb_hook_flag_req_subscribe 0x001000
+#define afb_hook_flag_req_unsubscribe 0x002000
+#define afb_hook_flag_req_subcall 0x004000
+#define afb_hook_flag_req_subcall_result 0x010800
+#define afb_hook_flag_req_subcallsync 0x020000
+#define afb_hook_flag_req_subcallsync_result 0x040000
/* common flags */
#define afb_hook_flags_req_life (afb_hook_flag_req_begin|afb_hook_flag_req_end)
@@ -68,14 +66,11 @@ struct afb_hook_xreq;
#define afb_hook_flags_req_ref (afb_hook_flag_req_addref|afb_hook_flag_req_unref)
#define afb_hook_flags_req_context (afb_hook_flag_req_context_get|afb_hook_flag_req_context_set)
-/* internal flags */
-#define afb_hook_flags_req_internal (afb_hook_flag_req_raw|afb_hook_flag_req_send)
-
/* predefined groups */
#define afb_hook_flags_req_common (afb_hook_flags_req_life|afb_hook_flags_req_args|afb_hook_flags_req_result\
|afb_hook_flags_req_session|afb_hook_flags_req_event|afb_hook_flags_req_subcall)
#define afb_hook_flags_req_extra (afb_hook_flags_req_common|afb_hook_flags_req_ref|afb_hook_flags_req_context)
-#define afb_hook_flags_req_all (afb_hook_flags_req_extra|afb_hook_flags_req_internal)
+#define afb_hook_flags_req_all (afb_hook_flags_req_extra)
struct afb_hook_xreq_itf {
void (*hook_xreq_begin)(void * closure, const struct afb_xreq *xreq);
@@ -84,8 +79,6 @@ struct afb_hook_xreq_itf {
void (*hook_xreq_get)(void * closure, const struct afb_xreq *xreq, const char *name, struct afb_arg arg);
void (*hook_xreq_success)(void * closure, const struct afb_xreq *xreq, struct json_object *obj, const char *info);
void (*hook_xreq_fail)(void * closure, const struct afb_xreq *xreq, const char *status, const char *info);
- void (*hook_xreq_raw)(void * closure, const struct afb_xreq *xreq, const char *buffer, size_t size);
- void (*hook_xreq_send)(void * closure, const struct afb_xreq *xreq, const char *buffer, size_t size);
void (*hook_xreq_context_get)(void * closure, const struct afb_xreq *xreq, void *value);
void (*hook_xreq_context_set)(void * closure, const struct afb_xreq *xreq, void *value, void (*free_value)(void*));
void (*hook_xreq_addref)(void * closure, const struct afb_xreq *xreq);
@@ -113,8 +106,6 @@ extern struct json_object *afb_hook_xreq_json(const struct afb_xreq *xreq, struc
extern struct afb_arg afb_hook_xreq_get(const struct afb_xreq *xreq, const char *name, struct afb_arg arg);
extern void afb_hook_xreq_success(const struct afb_xreq *xreq, struct json_object *obj, const char *info);
extern void afb_hook_xreq_fail(const struct afb_xreq *xreq, const char *status, const char *info);
-extern const char *afb_hook_xreq_raw(const struct afb_xreq *xreq, const char *buffer, size_t size);
-extern void afb_hook_xreq_send(const struct afb_xreq *xreq, const char *buffer, size_t size);
extern void *afb_hook_xreq_context_get(const struct afb_xreq *xreq, void *value);
extern void afb_hook_xreq_context_set(const struct afb_xreq *xreq, void *value, void (*free_value)(void*));
extern void afb_hook_xreq_addref(const struct afb_xreq *xreq);
diff --git a/src/afb-xreq.c b/src/afb-xreq.c
index 9478f154..527692c6 100644
--- a/src/afb-xreq.c
+++ b/src/afb-xreq.c
@@ -85,24 +85,6 @@ static void xreq_fail_cb(void *closure, const char *status, const char *info)
}
}
-static const char *xreq_raw_cb(void *closure, size_t *size)
-{
- struct afb_xreq *xreq = closure;
- const char *result = json_object_to_json_string(xreq_json_cb(xreq));
- if (size != NULL)
- *size = strlen(result);
- return result;
-}
-
-static void xreq_send_cb(void *closure, const char *buffer, size_t size)
-{
- struct json_object *obj = json_tokener_parse(buffer);
- if (!obj == !buffer)
- xreq_success_cb(closure, obj, "fake send");
- else
- xreq_fail_cb(closure, "fake-send-failed", "fake send");
-}
-
static void *xreq_context_get_cb(void *closure)
{
struct afb_xreq *xreq = closure;
@@ -283,21 +265,6 @@ static void xreq_hooked_fail_cb(void *closure, const char *status, const char *i
xreq_fail_cb(closure, status, info);
}
-static const char *xreq_hooked_raw_cb(void *closure, size_t *size)
-{
- size_t s;
- const char *r = xreq_raw_cb(closure, size ? : &s);
- struct afb_xreq *xreq = closure;
- return afb_hook_xreq_raw(xreq, r, *(size ? : &s));
-}
-
-static void xreq_hooked_send_cb(void *closure, const char *buffer, size_t size)
-{
- struct afb_xreq *xreq = closure;
- afb_hook_xreq_send(xreq, buffer, size);
- xreq_send_cb(closure, buffer, size);
-}
-
static void *xreq_hooked_context_get_cb(void *closure)
{
void *r = xreq_context_get_cb(closure);
@@ -405,8 +372,6 @@ const struct afb_req_itf xreq_itf = {
.get = xreq_get_cb,
.success = xreq_success_cb,
.fail = xreq_fail_cb,
- .raw = xreq_raw_cb,
- .send = xreq_send_cb,
.context_get = xreq_context_get_cb,
.context_set = xreq_context_set_cb,
.addref = xreq_addref_cb,
@@ -424,8 +389,6 @@ const struct afb_req_itf xreq_hooked_itf = {
.get = xreq_hooked_get_cb,
.success = xreq_hooked_success_cb,
.fail = xreq_hooked_fail_cb,
- .raw = xreq_hooked_raw_cb,
- .send = xreq_hooked_send_cb,
.context_get = xreq_hooked_context_get_cb,
.context_set = xreq_hooked_context_set_cb,
.addref = xreq_hooked_addref_cb,
@@ -486,7 +449,11 @@ void afb_xreq_fail_f(struct afb_xreq *xreq, const char *status, const char *info
const char *afb_xreq_raw(struct afb_xreq *xreq, size_t *size)
{
- return afb_req_raw(to_req(xreq), size);
+ struct json_object *obj = xreq_json_cb(xreq);
+ const char *result = json_object_to_json_string(obj);
+ if (size != NULL)
+ *size = strlen(result);
+ return result;
}
void afb_xreq_addref(struct afb_xreq *xreq)