Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / resource / csdk / stack / samples / linux / secure / common.cpp
index 7c04494..6eb7521 100644 (file)
@@ -19,7 +19,7 @@
 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 #include "common.h"
 
-#include "ocsecurity.h"
+#include "ocstack.h"
 #include "logger.h"
 #include <stdio.h>
 #include <stdlib.h>
 
 #define TAG "sample-common"
 
-OCStackResult SetCredentials(const char* filename) {
-
-    FILE *fp = NULL;
-    uint8_t *data = NULL;
-    struct stat st;
-    OCStackResult ret = OC_STACK_ERROR;
-
-    fp = fopen(filename, "rb");
-    if (fp)
-    {
-        if (stat(filename, &st) == 0)
-        {
-            data = (uint8_t*)malloc(st.st_size);
-            if (data)
-            {
-                if (fread(data, 1, st.st_size, fp) == (size_t)st.st_size)
-                {
-                    // Provide credentials to OC Stack
-                    ret = OCSecSetConfigData((OCSecConfigData *)data,
-                            st.st_size);
-                }
-                else
-                {
-                    OC_LOG_V(FATAL, TAG, "Error in reading file %s", filename);
-                }
-            }
-        }
-        fclose(fp);
-    }
-    else
-    {
-        OC_LOG_V(FATAL, TAG, "Unable to open %s file", filename);
-    }
-
-    free(data);
-
-    return ret;
-}
-
 const char *getResult(OCStackResult result) {
     switch (result) {
     case OC_STACK_OK:
@@ -103,6 +64,8 @@ const char *getResult(OCStackResult result) {
         return "OC_STACK_SLOW_RESOURCE";
     case OC_STACK_NO_OBSERVERS:
         return "OC_STACK_NO_OBSERVERS";
+    case OC_STACK_UNAUTHORIZED_REQ:
+        return "OC_STACK_UNAUTHORIZED_REQ";
     #ifdef WITH_PRESENCE
     case OC_STACK_PRESENCE_STOPPED:
         return "OC_STACK_PRESENCE_STOPPED";