aboutsummaryrefslogtreecommitdiffstats
path: root/src/sm-helper.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/sm-helper.c')
-rw-r--r--src/sm-helper.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/sm-helper.c b/src/sm-helper.c
index f9e7ec3..a02d772 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,36 @@ 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* default_sink = 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(default_sink == NULL) {
+ afb_req_fail(request, "wrong request", NULL);
+ return REQ_FAIL;
+ }
+ else{
+ if((strlen("default") == strlen(default_sink)) &&
+ (0 == strncmp("default", default_sink, strlen("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 REQ_FAIL;
+ }
+ return REQ_OK;
+}
+
void sm_add_object_to_json_object(struct json_object* j_obj, int count,...)
{
va_list args;