summaryrefslogtreecommitdiffstats
path: root/src/sm-helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sm-helper.c')
-rw-r--r--src/sm-helper.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/sm-helper.c b/src/sm-helper.c
index f9e7ec3..b598faa 100644
--- a/src/sm-helper.c
+++ b/src/sm-helper.c
@@ -15,6 +15,7 @@
*/
#include "sm-helper.h"
+#include "sm-def.h"
#include <stdlib.h>
#include <string.h>
#include <limits.h>
@@ -93,6 +94,31 @@ REQ_ERROR get_value_int32(const struct afb_req request, const char *source, int3
return REQ_OK;
}
+REQ_ERROR get_sink_id(const afb_req request, const char* key, uint16_t* out_sink_id){
+ AFB_DEBUG("");
+ REQ_ERROR result = REQ_FAIL;
+ const char* requested_sink_str = afb_req_value (request, key);
+ json_object* test = afb_req_json(request);
+ AFB_DEBUG("%s", json_object_to_json_string_ext(test, JSON_C_TO_STRING_PRETTY));
+
+ if(0 == strcmp(requested_sink_str, "default")){
+ *out_sink_id = DEFAULT_SINK;
+ AFB_INFO("sinkID(endpointID) is attached as default sinkID as %d", DEFAULT_SINK);
+ result = REQ_OK;
+ }
+ else{
+ result = get_value_uint16(request, key, out_sink_id);
+ AFB_INFO("sinkID(endpointID) is %d", *out_sink_id);
+ }
+
+ if(REQ_OK != result){
+ AFB_INFO("can't parse %s, result %d", key, result);
+ afb_req_fail_f(request,"wrong-request","can't parse %s, result: %d", key, result);
+ return result;
+ }
+ return REQ_OK;
+}
+
void sm_add_object_to_json_object(struct json_object* j_obj, int count,...)
{
va_list args;