Modify Error type
authoryoungman <yman.jung@samsung.com>
Wed, 3 Jun 2015 10:34:35 +0000 (19:34 +0900)
committerYoungjae Shin <yj99.shin@samsung.com>
Mon, 8 Jun 2015 10:41:17 +0000 (19:41 +0900)
Change-Id: I4f43c94510c681d355013ad3922aa4b01adaac96
Signed-off-by: youngman <yman.jung@samsung.com>
17 files changed:
lib/CMakeLists.txt
lib/ic-client.c
lib/ic-device.c
lib/ic-ioty.cpp
lib/ic-options.c
lib/ic-query.c
lib/ic-repr-list.c
lib/ic-repr-obj.c
lib/ic-repr-value.c [changed mode: 0644->0755]
lib/ic-repr.c [changed mode: 0644->0755]
lib/ic-response.c
lib/ic-utils.c
lib/ic.c
lib/include/iotcon-errors.h [changed mode: 0644->0755]
lib/include/iotcon-representation.h
packaging/iotcon.spec
test/crud-test-server.c [changed mode: 0644->0755]

index beaf170e788e46373f4c5e5b5ff3246f74d25cfd..85859df63b2927adcc97757d731d2c8c24747947 100644 (file)
@@ -2,7 +2,7 @@ INCLUDE_DIRECTORIES(include)
 
 FILE(GLOB CLIENT_SRCS *.c *.cpp)
 
-pkg_check_modules(client_pkgs REQUIRED glib-2.0 dlog json-glib-1.0)
+pkg_check_modules(client_pkgs REQUIRED glib-2.0 dlog json-glib-1.0 capi-base-common)
 INCLUDE_DIRECTORIES(${client_pkgs_INCLUDE_DIRS})
 LINK_DIRECTORIES(${client_pkgs_LIBRARY_DIRS})
 
index eb6c19f8e230f2a289032cedbf2a30b8aee35991..745601102aa5a9636a7964b3a2874b49790b5a9a 100755 (executable)
@@ -35,11 +35,11 @@ API int iotcon_find_resource(const char *host_addr, const char *resource_type,
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == host_addr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == cb, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == host_addr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
        if (resource_type && (IOTCON_RESOURCE_TYPE_LENGTH_MAX < strlen(resource_type))) {
                ERR("The length of resource_type(%s) is invalid", resource_type);
-               return IOTCON_ERROR_NONE;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
        ret = ic_ioty_find_resource(host_addr, resource_type, cb, user_data);
@@ -157,7 +157,7 @@ API int iotcon_client_get_interfaces(iotcon_client_h resource)
 API int iotcon_client_set_options(iotcon_client_h resource,
                iotcon_options_h header_options)
 {
-       RETV_IF(NULL == resource, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
 
        if (resource->header_options)
                iotcon_options_free(resource->header_options);
@@ -174,8 +174,8 @@ API int iotcon_get(iotcon_client_h resource, iotcon_query_h query,
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == resource, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == cb, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_get(resource, query, cb, user_data);
        if (IOTCON_ERROR_NONE != ret)
@@ -191,9 +191,9 @@ API int iotcon_put(iotcon_client_h resource, iotcon_repr_h repr,
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == resource, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == cb, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_put(resource, repr, query, cb, user_data);
        if (IOTCON_ERROR_NONE != ret)
@@ -209,9 +209,9 @@ API int iotcon_post(iotcon_client_h resource, iotcon_repr_h repr,
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == resource, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == cb, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_post(resource, repr, query, cb, user_data);
        if (IOTCON_ERROR_NONE != ret)
@@ -226,8 +226,8 @@ API int iotcon_delete(iotcon_client_h resource, iotcon_on_delete_cb cb, void *us
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == resource, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == cb, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_delete_res(resource, cb, user_data);
        if (IOTCON_ERROR_NONE != ret)
@@ -246,8 +246,8 @@ API int iotcon_observer_start(iotcon_client_h resource,
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == resource, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == cb, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_observe(resource, observe_type, query, cb, user_data);
        if (IOTCON_ERROR_NONE != ret)
@@ -262,7 +262,7 @@ API int iotcon_observer_stop(iotcon_client_h resource)
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == resource, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_cancel_observe(resource);
        if (IOTCON_ERROR_NONE != ret)
index d60b7c31c48bd68a52a918f027f975cc33ad47ad..14e8ebd0fa7565983eee0246093b98dabf9abc11 100755 (executable)
@@ -45,13 +45,13 @@ API int iotcon_register_device_info(
        if (manufacturer_name
                        && (IOTCON_MANUFACTURER_NAME_LENGTH_MAX < strlen(manufacturer_name))) {
                ERR("The length of manufacturer_name(%s) is invalid.", manufacturer_name);
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
        if (manufacturer_url
                        && (IOTCON_MANUFACTURER_URL_LENGTH_MAX < strlen(manufacturer_url))) {
                ERR("The length of manufacturer_url(%s) is invalid.", manufacturer_url);
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
        device_info.device_name = device_name;
@@ -81,8 +81,8 @@ API int iotcon_get_device_info(const char *host_address, iotcon_device_info_cb c
        FN_CALL;
        int ret = IOTCON_ERROR_NONE;
 
-       RETV_IF(NULL == host_address, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == cb, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == host_address, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_get_device_info(host_address, cb, user_data);
        if (IOTCON_ERROR_NONE != ret) {
index 11a68d8bf9d6ffe3b6fa9a1fc3ec541269352b02..4426b152de778e878b3b07f0a21a3ded72d11468 100755 (executable)
@@ -612,8 +612,8 @@ extern "C" int ic_ioty_unregister_res(iotcon_resource_h resource_handle)
 
 extern "C" int ic_ioty_convert_interface_string(const char *src, iotcon_interface_e *dest)
 {
-       RETV_IF(NULL == src, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == dest, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
 
        string interface_str(src);
 
@@ -632,7 +632,7 @@ extern "C" int ic_ioty_convert_interface_string(const char *src, iotcon_interfac
        else {
                ERR("Invalid interface");
                *dest = IOTCON_INTERFACE_NONE;
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
        return IOTCON_ERROR_NONE;
@@ -657,7 +657,7 @@ static int _ic_ioty_convert_interface_flag(iotcon_interface_e src, string &dest)
        default:
                ERR("Invalid interface");
                dest = "";
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
        return IOTCON_ERROR_NONE;
 }
@@ -1169,7 +1169,7 @@ extern "C" int ic_ioty_observe(iotcon_client_h resource,
        }
        else {
                ERR("Invalid observe_type");
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
        ocResource = _ic_ioty_create_oc_resource(resource);
index 00d68eaeee4cf71947325390eda734abd84cfceb..e90c548cbf1ee994c78f15d02755500dcb0a8d80 100755 (executable)
@@ -62,15 +62,15 @@ API int iotcon_options_insert(iotcon_options_h options, unsigned short id,
 {
        FN_CALL;
 
-       RETV_IF(NULL == options, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
        RETVM_IF(IOTCON_OPTIONS_MAX <= g_hash_table_size(options->hash),
-                       IOTCON_ERROR_MEMORY, "Options already have maximum elements.");
+                       IOTCON_ERROR_OUT_OF_MEMORY, "Options already have maximum elements.");
 
        RETVM_IF(((id < IOTCON_OPTIONID_MIN) || (IOTCON_OPTIONID_MAX < id)),
-                       IOTCON_ERROR_PARAM, "Invalid id(%d)", id);
+                       IOTCON_ERROR_INVALID_PARAMETER, "Invalid id(%d)", id);
 
-       RETV_IF(NULL == data, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_OPTION_DATA_LENGTH_MAX < strlen(data), IOTCON_ERROR_PARAM,
+       RETV_IF(NULL == data, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_OPTION_DATA_LENGTH_MAX < strlen(data), IOTCON_ERROR_INVALID_PARAMETER,
                        "The length of option data(%s) is invalid.", data);
 
        g_hash_table_insert(options->hash, GUINT_TO_POINTER(id), ic_utils_strdup(data));
@@ -83,12 +83,12 @@ API int iotcon_options_delete(iotcon_options_h options, unsigned short id)
 {
        gboolean ret;
 
-       RETV_IF(NULL == options, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = g_hash_table_remove(options->hash, GUINT_TO_POINTER(id));
        if (FALSE == ret) {
                ERR("g_hash_table_remove() Fail");
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
        return IOTCON_ERROR_NONE;
 }
@@ -114,8 +114,8 @@ API int iotcon_options_foreach(iotcon_options_h options,
        GHashTableIter iter;
        gpointer key, value;
 
-       RETV_IF(NULL == options, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == cb, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == options, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        g_hash_table_iter_init(&iter, options->hash);
        while (g_hash_table_iter_next(&iter, &key, &value)) {
index b5b5558b351e7e9aaef30f2b682d5a2b049a062e..e96cb73ef5c87a2428b3e9195b6b3d48c64d8c87 100755 (executable)
@@ -51,16 +51,16 @@ API int iotcon_query_insert(iotcon_query_h query, const char *key, const char *v
 {
        int query_len;
 
-       RETV_IF(NULL == query, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == value, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
 
        /* first query : ?key=value
         * Rest of query : &key=value */
        query_len = strlen(key) + strlen(value) + 2;
        if (IOTCON_QUERY_LENGTH_MAX < (query->len + query_len)) {
                ERR("Length of query is invalid.");
-               return IOTCON_ERROR_MEMORY;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        g_hash_table_insert(query->hash, ic_utils_strdup(key), ic_utils_strdup(value));
@@ -76,13 +76,13 @@ API int iotcon_query_delete(iotcon_query_h query, const char *key)
        int query_len;
        char *value;
 
-       RETV_IF(NULL == query, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_hash_table_lookup(query->hash, key);
        if (NULL == value) {
                ERR("g_hash_table_lookup() Fail");
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
        query_len = strlen(key) + strlen(value) + 2;
@@ -90,7 +90,7 @@ API int iotcon_query_delete(iotcon_query_h query, const char *key)
        ret = g_hash_table_remove(query->hash, key);
        if (FALSE == ret) {
                ERR("g_hash_table_remove() Fail");
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
        query->len -= query_len;
 
@@ -118,8 +118,8 @@ API int iotcon_query_foreach(iotcon_query_h query, iotcon_query_foreach_cb cb,
        GHashTableIter iter;
        gpointer key, value;
 
-       RETV_IF(NULL == query, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == cb, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == query, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == cb, IOTCON_ERROR_INVALID_PARAMETER);
 
        g_hash_table_iter_init(&iter, query->hash);
        while (g_hash_table_iter_next(&iter, &key, &value)) {
index 5171034dfd82abd365dbad13af8a7594aaa268a5..a993944752ff81b399112ef4f1a12b155b04feb3 100755 (executable)
@@ -81,14 +81,14 @@ API int iotcon_list_insert_int(iotcon_list_h list, int val, int pos)
 {
        iotcon_value_h value;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_INT != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_INT != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
 
        value = ic_value_new_int(val);
        if (NULL == value) {
                ERR("ic_value_new_int(%d) Fail", val);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        return ic_list_insert(list, value, pos);
@@ -99,14 +99,14 @@ API int iotcon_list_insert_bool(iotcon_list_h list, bool val, int pos)
 {
        iotcon_value_h value;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_BOOL != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_BOOL != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
 
        value = ic_value_new_bool(val);
        if (NULL == value) {
                ERR("ic_value_new_bool(%d) Fail", val);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        return ic_list_insert(list, value, pos);
@@ -117,14 +117,14 @@ API int iotcon_list_insert_double(iotcon_list_h list, double val, int pos)
 {
        iotcon_value_h value;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_DOUBLE != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_DOUBLE != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
 
        value = ic_value_new_double(val);
        if (NULL == value) {
                ERR("ic_value_new_double(%f) Fail", val);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        return ic_list_insert(list, value, pos);
@@ -135,15 +135,15 @@ API int iotcon_list_insert_str(iotcon_list_h list, char *val, int pos)
 {
        iotcon_value_h value;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_STR != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_STR != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
 
        value = ic_value_new_str(val);
        if (NULL == value) {
                ERR("ic_value_new_str(%s) Fail", val);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        return ic_list_insert(list, value, pos);
@@ -154,15 +154,15 @@ API int iotcon_list_insert_list(iotcon_list_h list, iotcon_list_h val, int pos)
 {
        iotcon_value_h value;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_LIST != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_LIST != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
 
        value = ic_value_new_list(val);
        if (NULL == value) {
                ERR("ic_value_new_list(%p) Fail", val);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        ic_list_inc_ref_count(val);
@@ -175,15 +175,15 @@ API int iotcon_list_insert_repr(iotcon_list_h list, iotcon_repr_h val, int pos)
 {
        iotcon_value_h value;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_REPR != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_REPR != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
 
        value = ic_value_new_repr(val);
        if (NULL == value) {
                ERR("ic_value_new_repr(%p) Fail", val);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
        ic_repr_inc_ref_count(val);
 
@@ -196,9 +196,9 @@ API int iotcon_list_get_nth_int(iotcon_list_h list, int pos, int *val)
        int ival, ret;
        iotcon_value_h value;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == list->list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == list->list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_list_nth_data(list->list, pos);
        if (NULL == value) {
@@ -209,7 +209,7 @@ API int iotcon_list_get_nth_int(iotcon_list_h list, int pos, int *val)
        ret = ic_value_get_int(value, &ival);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("ic_value_get_int() Fail(%d)", ret);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_REPRESENTATION;
        }
 
        *val = ival;
@@ -224,9 +224,9 @@ API int iotcon_list_get_nth_bool(iotcon_list_h list, int pos, bool *val)
        bool bval;
        iotcon_value_h value;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == list->list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == list->list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_list_nth_data(list->list, pos);
        if (NULL == value) {
@@ -237,7 +237,7 @@ API int iotcon_list_get_nth_bool(iotcon_list_h list, int pos, bool *val)
        ret = ic_value_get_bool(value, &bval);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("ic_value_get_bool() Fail(%d)", ret);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_REPRESENTATION;
        }
 
        *val = bval;
@@ -252,9 +252,9 @@ API int iotcon_list_get_nth_double(iotcon_list_h list, int pos, double *val)
        double dbval;
        iotcon_value_h value;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == list->list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == list->list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_list_nth_data(list->list, pos);
        if (NULL == value) {
@@ -265,7 +265,7 @@ API int iotcon_list_get_nth_double(iotcon_list_h list, int pos, double *val)
        ret = ic_value_get_double(value, &dbval);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("ic_value_get_double() Fail(%d)", ret);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_REPRESENTATION;
        }
 
        *val = dbval;
@@ -280,9 +280,9 @@ API int iotcon_list_get_nth_str(iotcon_list_h list, int pos, const char **val)
        const char *strval;
        iotcon_value_h value;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == list->list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == list->list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_list_nth_data(list->list, pos);
        if (NULL == value) {
@@ -293,7 +293,7 @@ API int iotcon_list_get_nth_str(iotcon_list_h list, int pos, const char **val)
        ret = ic_value_get_str(value, &strval);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("ic_value_get_str() Fail(%d)", ret);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_REPRESENTATION;
        }
 
        *val = strval;
@@ -308,9 +308,9 @@ API int iotcon_list_get_nth_list(iotcon_list_h src, int pos, iotcon_list_h *dest
        iotcon_value_h value;
        iotcon_list_h list_val;
 
-       RETV_IF(NULL == src, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == src->list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == dest, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == src->list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_list_nth_data(src->list, pos);
        if (NULL == value) {
@@ -321,7 +321,7 @@ API int iotcon_list_get_nth_list(iotcon_list_h src, int pos, iotcon_list_h *dest
        ret = ic_value_get_list(value, &list_val);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("ic_value_get_list() Fail(%d)", ret);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_REPRESENTATION;
        }
 
        *dest = list_val;
@@ -336,9 +336,9 @@ API int iotcon_list_get_nth_repr(iotcon_list_h list, int pos, iotcon_repr_h *rep
        iotcon_value_h value;
        iotcon_repr_h repr_val;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == list->list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == list->list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_list_nth_data(list->list, pos);
        if (NULL == value) {
@@ -349,7 +349,7 @@ API int iotcon_list_get_nth_repr(iotcon_list_h list, int pos, iotcon_repr_h *rep
        ret = ic_value_get_repr(value, &repr_val);
        if (IOTCON_ERROR_NONE != ret) {
                ERR("ic_value_get_list() Fail(%d)", ret);
-               return IOTCON_ERROR_FAIL;
+               return IOTCON_ERROR_REPRESENTATION;
        }
 
        *repr = repr_val;
@@ -362,10 +362,10 @@ static int _ic_list_del_nth_value(iotcon_list_h list, int pos, iotcon_types_e va
 {
        iotcon_value_h value;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == list->list, IOTCON_ERROR_PARAM);
-       RETVM_IF(value_type != list->type, IOTCON_ERROR_PARAM, "IOTCON_ERROR_PARAM(%d)",
-                       list->type);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == list->list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(value_type != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "IOTCON_ERROR_PARAMETER(%d)", list->type);
 
        value = g_list_nth_data(list->list, pos);
        if (NULL == value) {
@@ -465,8 +465,8 @@ API int iotcon_list_del_nth_repr(iotcon_list_h list, int pos)
 
 API int iotcon_list_get_type(iotcon_list_h list, int *type)
 {
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == type, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == type, IOTCON_ERROR_INVALID_PARAMETER);
 
        *type = list->type;
 
@@ -485,7 +485,7 @@ API unsigned int iotcon_list_get_length(iotcon_list_h list)
 
 int ic_list_remove(iotcon_list_h list, iotcon_value_h val)
 {
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
 
        list->list = g_list_remove(list->list, val);
 
@@ -495,7 +495,7 @@ int ic_list_remove(iotcon_list_h list, iotcon_value_h val)
 
 int ic_list_insert(iotcon_list_h list, iotcon_value_h value, int pos)
 {
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
 
        list->list = g_list_insert(list->list, value, pos);
 
@@ -509,10 +509,10 @@ API int iotcon_list_foreach_int(iotcon_list_h list, iotcon_list_int_fn fn,
        int index = 0;
        ic_basic_s *real = NULL;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_INT != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
-       RETV_IF(NULL == fn, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_INT != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
+       RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
        cur = list->list;
        while (cur) {
@@ -534,10 +534,10 @@ API int iotcon_list_foreach_bool(iotcon_list_h list, iotcon_list_bool_fn fn,
        int index = 0;
        ic_basic_s *real = NULL;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_BOOL != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
-       RETV_IF(NULL == fn, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_BOOL != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
+       RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
        cur = list->list;
        while (cur) {
@@ -559,10 +559,10 @@ API int iotcon_list_foreach_double(iotcon_list_h list, iotcon_list_double_fn fn,
        int index = 0;
        ic_basic_s *real = NULL;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_DOUBLE != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
-       RETV_IF(NULL == fn, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_DOUBLE != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
+       RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
        cur = list->list;
        while (cur) {
@@ -584,10 +584,10 @@ API int iotcon_list_foreach_str(iotcon_list_h list, iotcon_list_str_fn fn,
        int index = 0;
        ic_basic_s *real = NULL;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_STR != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
-       RETV_IF(NULL == fn, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_STR != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
+       RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
        cur = list->list;
        while (cur) {
@@ -609,10 +609,10 @@ API int iotcon_list_foreach_list(iotcon_list_h list, iotcon_list_list_fn fn,
        GList *cur = NULL;
        ic_val_list_s *real = NULL;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_LIST != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
-       RETV_IF(NULL == fn, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_LIST != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
+       RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
        cur = list->list;
        while (cur) {
@@ -633,10 +633,10 @@ API int iotcon_list_foreach_repr(iotcon_list_h list, iotcon_list_repr_fn fn, voi
        GList *cur = NULL;
        ic_val_repr_s *real = NULL;
 
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_REPR != list->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       list->type);
-       RETV_IF(NULL == fn, IOTCON_ERROR_PARAM);;
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_REPR != list->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", list->type);
+       RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);;
 
        cur = list->list;
        while (cur) {
@@ -876,20 +876,20 @@ static int _ic_list_clone_value(iotcon_list_h list, iotcon_list_h ret_list)
                value = _ic_list_get_nth_value(list, i);
                if (list->type != value->type) {
                        ERR("Type Mismatching(list:%d, value:%d)", list->type, value->type);
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_INVALID_TYPE;
                }
 
                copied_value = ic_value_clone(value);
                if (NULL == copied_value) {
                        ERR("ic_value_clone() Fail");
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
 
                ret = ic_list_insert(ret_list, copied_value, -1);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("ic_list_insert() Fail");
                        ic_value_free(copied_value);
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
        }
 
@@ -909,27 +909,27 @@ static int _ic_list_clone_list(iotcon_list_h list, iotcon_list_h ret_list)
                ret = iotcon_list_get_nth_list(list, i, &list_val);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("iotcon_list_get_nth_list() Fail(%d)", ret);
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
 
                copied_list = ic_list_clone(list_val);
                if (NULL == copied_list) {
                        ERR("ic_list_clone() Fail");
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
 
                value = ic_value_new_list(copied_list);
                if (NULL == value) {
                        ERR("ic_value_new_list(%p) Fail", copied_list);
                        iotcon_list_free(copied_list);
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
 
                ret = ic_list_insert(ret_list, value, -1);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("ic_list_insert(%d) Fail", ret);
                        ic_value_free(value);
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
        }
 
@@ -948,27 +948,27 @@ static int _ic_list_clone_repr(iotcon_list_h list, iotcon_list_h ret_list)
                ret = iotcon_list_get_nth_repr(list, i, &repr_val);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("iotcon_list_get_nth_repr() Fail");
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
 
                copied_repr = iotcon_repr_clone(repr_val);
                if (NULL == copied_repr) {
                        ERR("_ic_repr_clone_repr() Fail");
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
 
                value = ic_value_new_repr(copied_repr);
                if (NULL == value) {
                        ERR("ic_value_new_repr(%p) Fail", copied_repr);
                        iotcon_repr_free(copied_repr);
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
 
                ret = ic_list_insert(ret_list, value, -1);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("ic_list_insert(%d) Fail", ret);
                        ic_value_free(value);
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
        }
 
index 88bf7416b3197775ea9ef86e76f5b772b1bac6cc..6766b858d3a6888c6f41050875cd397f47af1164 100755 (executable)
@@ -42,7 +42,7 @@ int ic_obj_del_value(iotcon_repr_h repr, const char *key,
 
        if (value_type != value->type) {
                ERR("Type matching Fail(input:%d, saved:%d)", value_type, value->type);
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
        ret = g_hash_table_remove(repr->hash_table, key);
@@ -58,9 +58,9 @@ API int iotcon_repr_get_int(iotcon_repr_h repr, const char *key, int *val)
 {
        iotcon_value_h value;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_hash_table_lookup(repr->hash_table, key);
        if (NULL == value) {
@@ -69,7 +69,10 @@ API int iotcon_repr_get_int(iotcon_repr_h repr, const char *key, int *val)
        }
 
        ic_basic_s *real = (ic_basic_s*)value;
-       RETV_IF(IOTCON_TYPE_INT != real->type, IOTCON_ERROR_FAIL);
+       if (IOTCON_TYPE_INT != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
 
        *val = real->val.i;
 
@@ -80,13 +83,13 @@ API int iotcon_repr_set_int(iotcon_repr_h repr, const char *key, int val)
 {
        iotcon_value_h value;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = ic_value_new_int(val);
        if (NULL == value) {
                ERR("ic_value_new_int(%d) Fail", val);
-               return IOTCON_ERROR_MEMORY;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        g_hash_table_replace(repr->hash_table, ic_utils_strdup(key), value);
@@ -98,8 +101,8 @@ API int iotcon_repr_del_int(iotcon_repr_h repr, const char *key)
 {
        int ret;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_obj_del_value(repr, key, IOTCON_TYPE_INT);
        if (IOTCON_ERROR_NONE != ret)
@@ -113,9 +116,9 @@ API int iotcon_repr_get_bool(iotcon_repr_h repr, const char *key, bool *val)
        ic_basic_s *real = NULL;
        iotcon_value_h value = NULL;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_hash_table_lookup(repr->hash_table, key);
        if (NULL == value) {
@@ -124,7 +127,10 @@ API int iotcon_repr_get_bool(iotcon_repr_h repr, const char *key, bool *val)
        }
 
        real = (ic_basic_s*)value;
-       RETV_IF(IOTCON_TYPE_BOOL != real->type, IOTCON_ERROR_FAIL);
+       if (IOTCON_TYPE_BOOL != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
 
        *val = real->val.b;
 
@@ -135,13 +141,13 @@ API int iotcon_repr_set_bool(iotcon_repr_h repr, const char *key, bool val)
 {
        iotcon_value_h value = NULL;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = ic_value_new_bool(val);
        if (NULL == value) {
                ERR("ic_value_new_bool(%d) Fail", val);
-               return IOTCON_ERROR_MEMORY;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        g_hash_table_replace(repr->hash_table, ic_utils_strdup(key), value);
@@ -165,9 +171,9 @@ API int iotcon_repr_get_double(iotcon_repr_h repr, const char *key, double *val)
        ic_basic_s *real = NULL;
        iotcon_value_h value = NULL;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_hash_table_lookup(repr->hash_table, key);
        if (NULL == value) {
@@ -176,7 +182,10 @@ API int iotcon_repr_get_double(iotcon_repr_h repr, const char *key, double *val)
        }
 
        real = (ic_basic_s*)value;
-       RETV_IF(IOTCON_TYPE_DOUBLE != real->type, IOTCON_ERROR_FAIL);
+       if (IOTCON_TYPE_DOUBLE != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
 
        *val = real->val.d;
 
@@ -187,13 +196,13 @@ API int iotcon_repr_set_double(iotcon_repr_h repr, const char *key, double val)
 {
        iotcon_value_h value = NULL;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = ic_value_new_double(val);
        if (NULL == value) {
                ERR("ic_value_new_double(%f) Fail", val);
-               return IOTCON_ERROR_MEMORY;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        g_hash_table_replace(repr->hash_table, ic_utils_strdup(key), value);
@@ -205,8 +214,8 @@ API int iotcon_repr_del_double(iotcon_repr_h repr, const char *key)
 {
        int ret;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_obj_del_value(repr, key, IOTCON_TYPE_DOUBLE);
        if (IOTCON_ERROR_NONE != ret)
@@ -220,9 +229,9 @@ API int iotcon_repr_get_str(iotcon_repr_h repr, const char *key, char **val)
        ic_basic_s *real = NULL;
        iotcon_value_h value = NULL;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_hash_table_lookup(repr->hash_table, key);
        if (NULL == value) {
@@ -231,7 +240,10 @@ API int iotcon_repr_get_str(iotcon_repr_h repr, const char *key, char **val)
        }
 
        real = (ic_basic_s*)value;
-       RETV_IF(IOTCON_TYPE_STR != real->type, IOTCON_ERROR_FAIL);
+       if (IOTCON_TYPE_STR != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
 
        *val = real->val.s;
 
@@ -242,14 +254,14 @@ API int iotcon_repr_set_str(iotcon_repr_h repr, const char *key, char *val)
 {
        iotcon_value_h value = NULL;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = ic_value_new_str(val);
        if (NULL == value) {
                ERR("ic_value_new_str(%s) Fail", val);
-               return IOTCON_ERROR_MEMORY;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        g_hash_table_replace(repr->hash_table, ic_utils_strdup(key), value);
@@ -261,8 +273,8 @@ API int iotcon_repr_del_str(iotcon_repr_h repr, const char *key)
 {
        int ret;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_obj_del_value(repr, key, IOTCON_TYPE_STR);
        if (IOTCON_ERROR_NONE != ret)
@@ -294,13 +306,13 @@ API int iotcon_repr_set_null(iotcon_repr_h repr, const char *key)
 {
        iotcon_value_h value = NULL;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = ic_value_new_null();
        if (NULL == value) {
                ERR("ic_value_new_null() Fail");
-               return IOTCON_ERROR_MEMORY;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        g_hash_table_replace(repr->hash_table, ic_utils_strdup(key), value);
@@ -312,8 +324,8 @@ API int iotcon_repr_del_null(iotcon_repr_h repr, const char *key)
 {
        int ret;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_obj_del_value(repr, key, IOTCON_TYPE_NULL);
        if (IOTCON_ERROR_NONE != ret)
@@ -327,9 +339,9 @@ API int iotcon_repr_get_list(iotcon_repr_h repr, const char *key, iotcon_list_h
        iotcon_value_h value = NULL;
        ic_val_list_s *real = NULL;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_hash_table_lookup(repr->hash_table, key);
        if (NULL == value) {
@@ -338,7 +350,10 @@ API int iotcon_repr_get_list(iotcon_repr_h repr, const char *key, iotcon_list_h
        }
 
        real = (ic_val_list_s*)value;
-       RETV_IF(IOTCON_TYPE_LIST != real->type, IOTCON_ERROR_FAIL);
+       if (IOTCON_TYPE_LIST != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
 
        *list = real->list;
 
@@ -349,14 +364,14 @@ API int iotcon_repr_set_list(iotcon_repr_h repr, const char *key, iotcon_list_h
 {
        iotcon_value_h value = NULL;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == list, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == list, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = ic_value_new_list(list);
        if (NULL == value) {
                ERR("ic_value_new_list() Fail");
-               return IOTCON_ERROR_MEMORY;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
        ic_list_inc_ref_count(list);
 
@@ -369,8 +384,8 @@ API int iotcon_repr_del_list(iotcon_repr_h repr, const char *key)
 {
        int ret;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_obj_del_value(repr, key, IOTCON_TYPE_LIST);
        if (IOTCON_ERROR_NONE != ret)
@@ -385,9 +400,9 @@ API int iotcon_repr_get_repr(iotcon_repr_h src, const char *key, iotcon_repr_h *
        ic_val_repr_s *real = NULL;
        iotcon_value_h value = NULL;
 
-       RETV_IF(NULL == src, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == dest, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == src, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == dest, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_hash_table_lookup(src->hash_table, key);
        if (NULL == value) {
@@ -396,7 +411,10 @@ API int iotcon_repr_get_repr(iotcon_repr_h src, const char *key, iotcon_repr_h *
        }
 
        real = (ic_val_repr_s*)value;
-       RETV_IF(IOTCON_TYPE_REPR != real->type, IOTCON_ERROR_FAIL);
+       if (IOTCON_TYPE_REPR != real->type) {
+               ERR("Invalid Type(%d)", real->type);
+               return IOTCON_ERROR_INVALID_TYPE;
+       }
 
        *dest = real->repr;
 
@@ -407,14 +425,14 @@ API int iotcon_repr_set_repr(iotcon_repr_h repr, const char *key, iotcon_repr_h
 {
        iotcon_value_h value = NULL;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == val, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == val, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = ic_value_new_repr(val);
        if (NULL == value) {
                ERR("ic_value_new_repr(%p) Fail", val);
-               return IOTCON_ERROR_MEMORY;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
        ic_repr_inc_ref_count(val);
 
@@ -427,8 +445,8 @@ API int iotcon_repr_del_repr(iotcon_repr_h repr, const char *key)
 {
        int ret;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_obj_del_value(repr, key, IOTCON_TYPE_REPR);
        if (IOTCON_ERROR_NONE != ret)
@@ -441,9 +459,9 @@ API int iotcon_repr_get_type(iotcon_repr_h repr, const char *key, int *type)
 {
        iotcon_value_h value = NULL;
 
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == type, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == type, IOTCON_ERROR_INVALID_PARAMETER);
 
        value = g_hash_table_lookup(repr->hash_table, key);
        if (NULL == value) {
@@ -457,9 +475,9 @@ API int iotcon_repr_get_type(iotcon_repr_h repr, const char *key, int *type)
 
 int ic_obj_set_value(iotcon_repr_h repr, const char *key, iotcon_value_h value)
 {
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == value, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
 
        g_hash_table_replace(repr->hash_table, ic_utils_strdup(key), value);
 
@@ -480,9 +498,9 @@ static inline int _ic_obj_to_json(GHashTable *hash, iotcon_str_list_s *key_list,
        JsonNode *child_node = NULL;
        JsonArray *child_array = NULL;
 
-       RETV_IF(NULL == hash, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key_list, IOTCON_ERROR_PARAM);
-       RETV_IF(index < 0, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == hash, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key_list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(index < 0, IOTCON_ERROR_INVALID_PARAMETER);
 
        key = iotcon_str_list_nth_data(key_list, index);
        value = g_hash_table_lookup(hash, key);
@@ -499,7 +517,7 @@ static inline int _ic_obj_to_json(GHashTable *hash, iotcon_str_list_s *key_list,
                child_node = ic_value_to_json(value);
                if (NULL == child_node) {
                        ERR("ic_value_to_json() Fail");
-                       return IOTCON_ERROR_PARAM;
+                       return IOTCON_ERROR_INVALID_PARAMETER;
                }
                json_object_set_member(json_obj, key, child_node);
                break;
@@ -507,13 +525,13 @@ static inline int _ic_obj_to_json(GHashTable *hash, iotcon_str_list_s *key_list,
                ret = ic_value_get_list(value, &child_list);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("ic_value_get_list() Fail(%d)", ret);
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
 
                child_array = ic_list_to_json(child_list);
                if (NULL == child_array) {
                        ERR("ic_list_to_json() Fail");
-                       return IOTCON_ERROR_PARAM;
+                       return IOTCON_ERROR_INVALID_PARAMETER;
                }
                child_node = json_node_new(JSON_NODE_ARRAY);
                json_node_set_array(child_node, child_array);
@@ -523,13 +541,13 @@ static inline int _ic_obj_to_json(GHashTable *hash, iotcon_str_list_s *key_list,
                ret = ic_value_get_repr(value, &child_repr);
                if (IOTCON_ERROR_NONE != ret) {
                        ERR("ic_value_get_repr() Fail(%d)", ret);
-                       return IOTCON_ERROR_FAIL;
+                       return IOTCON_ERROR_REPRESENTATION;
                }
 
                child_obj = ic_obj_to_json(child_repr);
                if (NULL == child_obj) {
                        ERR("ic_obj_to_json() Fail");
-                       return IOTCON_ERROR_PARAM;
+                       return IOTCON_ERROR_INVALID_PARAMETER;
                }
                child_node = json_node_new(JSON_NODE_OBJECT);
                json_node_set_object(child_node, child_obj);
@@ -537,7 +555,7 @@ static inline int _ic_obj_to_json(GHashTable *hash, iotcon_str_list_s *key_list,
                break;
        default:
                ERR("Invalid type(%d)", type);
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
        return IOTCON_ERROR_NONE;
@@ -585,10 +603,10 @@ static inline int _ic_obj_from_json(JsonObject *obj, GList *key_list, unsigned i
 {
        char *key;
 
-       RETV_IF(NULL == obj, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == key_list, IOTCON_ERROR_PARAM);
-       RETV_IF(index < 0, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == ret_repr, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == obj, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == key_list, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(index < 0, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == ret_repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        key = g_list_nth_data(key_list, index);
 
@@ -596,13 +614,13 @@ static inline int _ic_obj_from_json(JsonObject *obj, GList *key_list, unsigned i
        JsonNode *child_node = json_object_get_member(obj, key);
        if (NULL == child_node) {
                ERR("json_object_get_member() Fail");
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
        if (JSON_NODE_HOLDS_NULL(child_node) || JSON_NODE_HOLDS_VALUE(child_node)) {
                iotcon_value_h value = ic_value_from_json(child_node);
                if (NULL == value) {
                        ERR("ic_value_from_json() Fail");
-                       return IOTCON_ERROR_PARAM;
+                       return IOTCON_ERROR_INVALID_PARAMETER;
                }
                ic_obj_set_value(ret_repr, key, value);
        }
@@ -613,14 +631,14 @@ static inline int _ic_obj_from_json(JsonObject *obj, GList *key_list, unsigned i
                iotcon_list_h list = ic_list_from_json(child_array);
                if (NULL == list) {
                        ERR("ic_list_from_json() Fail");
-                       return IOTCON_ERROR_PARAM;
+                       return IOTCON_ERROR_INVALID_PARAMETER;
                }
 
                value = ic_value_new_list(list);
                if (NULL == value) {
                        ERR("ic_value_new_list() Fail");
                        iotcon_list_free(list);
-                       return IOTCON_ERROR_MEMORY;
+                       return IOTCON_ERROR_OUT_OF_MEMORY;
                }
 
                ic_obj_set_value(ret_repr, key, value);
@@ -632,21 +650,21 @@ static inline int _ic_obj_from_json(JsonObject *obj, GList *key_list, unsigned i
                iotcon_repr_h repr = ic_obj_from_json(child_obj);
                if (NULL == repr) {
                        ERR("ic_obj_from_json() Fail");
-                       return IOTCON_ERROR_PARAM;
+                       return IOTCON_ERROR_INVALID_PARAMETER;
                }
 
                value = ic_value_new_repr(repr);
                if (NULL == value) {
                        ERR("ic_value_new_repr(%p) Fail", repr);
                        iotcon_repr_free(repr);
-                       return IOTCON_ERROR_MEMORY;
+                       return IOTCON_ERROR_OUT_OF_MEMORY;
                }
 
                ic_obj_set_value(ret_repr, key, value);
        }
        else {
                ERR("node type(%d) Fail", json_node_get_node_type(child_node));
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
        return IOTCON_ERROR_NONE;
old mode 100644 (file)
new mode 100755 (executable)
index 3c41c7d..4bce4a5
@@ -170,9 +170,9 @@ int ic_value_get_int(iotcon_value_h value, int *val)
 {
        ic_basic_s *real = (ic_basic_s*)value;
 
-       RETV_IF(NULL == value, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_INT != real->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       real->type);
+       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_INT != real->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", real->type);
 
        *val = real->val.i;
 
@@ -183,9 +183,9 @@ int ic_value_get_bool(iotcon_value_h value, bool *val)
 {
        ic_basic_s *real = (ic_basic_s*)value;
 
-       RETV_IF(NULL == value, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_BOOL != real->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       real->type);
+       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_BOOL != real->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", real->type);
 
        *val = real->val.b;
 
@@ -196,9 +196,9 @@ int ic_value_get_double(iotcon_value_h value, double *val)
 {
        ic_basic_s *real = (ic_basic_s*)value;
 
-       RETV_IF(NULL == value, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_DOUBLE != real->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       real->type);
+       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_DOUBLE != real->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", real->type);
 
        *val = real->val.d;
 
@@ -209,9 +209,9 @@ int ic_value_get_str(iotcon_value_h value, const char **val)
 {
        ic_basic_s *real = (ic_basic_s*)value;
 
-       RETV_IF(NULL == value, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_STR != real->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       real->type);
+       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_STR != real->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", real->type);
 
        *val = real->val.s;
 
@@ -223,9 +223,9 @@ int ic_value_get_list(iotcon_value_h value, iotcon_list_h *list)
 {
        ic_val_list_s *real = (ic_val_list_s*)value;
 
-       RETV_IF(NULL == value, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_LIST != real->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       real->type);
+       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_LIST != real->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", real->type);
 
        *list = real->list;
 
@@ -236,9 +236,9 @@ int ic_value_get_repr(iotcon_value_h value, iotcon_repr_h *repr)
 {
        ic_val_repr_s *real = (ic_val_repr_s*)value;
 
-       RETV_IF(NULL == value, IOTCON_ERROR_PARAM);
-       RETVM_IF(IOTCON_TYPE_REPR != real->type, IOTCON_ERROR_PARAM, "Invalid Type(%d)",
-                       real->type);
+       RETV_IF(NULL == value, IOTCON_ERROR_INVALID_PARAMETER);
+       RETVM_IF(IOTCON_TYPE_REPR != real->type, IOTCON_ERROR_INVALID_PARAMETER,
+                       "Invalid Type(%d)", real->type);
 
        *repr = real->repr;
 
old mode 100644 (file)
new mode 100755 (executable)
index 729e17b..df9798b
@@ -15,6 +15,7 @@
  */
 
 #include <stdlib.h>
+#include <string.h>
 #include <errno.h>
 #include <limits.h>
 #include <glib.h>
@@ -74,8 +75,8 @@ API iotcon_repr_h iotcon_repr_new()
 
 API int iotcon_repr_get_uri(iotcon_repr_h repr, const char **uri)
 {
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == uri, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == uri, IOTCON_ERROR_INVALID_PARAMETER);
 
        *uri = repr->uri;
 
@@ -84,17 +85,18 @@ API int iotcon_repr_get_uri(iotcon_repr_h repr, const char **uri)
 
 API int iotcon_repr_set_uri(iotcon_repr_h repr, const char *uri)
 {
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        free(repr->uri);
        repr->uri = NULL;
 
-       if (NULL != uri) {
-               repr->uri = ic_utils_strdup(uri);
-               if (NULL == repr->uri) {
-                       ERR("ic_utils_strdup() Fail");
-                       return IOTCON_ERROR_MEMORY;
-               }
+       if (NULL == uri)
+               return IOTCON_ERROR_NONE;
+
+       repr->uri = strdup(uri);
+       if (NULL == repr->uri) {
+               ERR("strdup() Fail");
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        return IOTCON_ERROR_NONE;
@@ -102,8 +104,8 @@ API int iotcon_repr_set_uri(iotcon_repr_h repr, const char *uri)
 
 API int iotcon_repr_get_resource_types(iotcon_repr_h repr, iotcon_str_list_s **types)
 {
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == types, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == types, IOTCON_ERROR_INVALID_PARAMETER);
 
        *types = repr->res_types;
 
@@ -112,7 +114,7 @@ API int iotcon_repr_get_resource_types(iotcon_repr_h repr, iotcon_str_list_s **t
 
 API int iotcon_repr_set_resource_types(iotcon_repr_h repr, iotcon_str_list_s *types)
 {
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        iotcon_str_list_free(repr->res_types);
        repr->res_types = NULL;
@@ -132,7 +134,7 @@ API int iotcon_repr_get_resource_interfaces(iotcon_repr_h repr)
 
 API int iotcon_repr_set_resource_interfaces(iotcon_repr_h repr, int ifaces)
 {
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        repr->interfaces = ifaces;
 
@@ -141,8 +143,8 @@ API int iotcon_repr_set_resource_interfaces(iotcon_repr_h repr, int ifaces)
 
 API int iotcon_repr_append_child(iotcon_repr_h parent, iotcon_repr_h child)
 {
-       RETV_IF(NULL == parent, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == child, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
 
        ic_repr_inc_ref_count(child);
        parent->children = g_list_append(parent->children, child);
@@ -155,8 +157,8 @@ API int iotcon_repr_foreach_children(iotcon_repr_h parent, iotcon_children_fn fn
 {
        GList *list, *next;
 
-       RETV_IF(NULL == parent, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == fn, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == fn, IOTCON_ERROR_INVALID_PARAMETER);
 
        list = parent->children;
        while (list) {
@@ -179,9 +181,9 @@ API unsigned int iotcon_repr_get_children_count(iotcon_repr_h parent)
 
 API int iotcon_repr_get_nth_child(iotcon_repr_h parent, int pos, iotcon_repr_h *child)
 {
-       RETV_IF(NULL == parent, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == parent->children, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == child, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == parent->children, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
 
        *child = g_list_nth_data(parent->children, pos);
        if (NULL == *child) {
@@ -210,8 +212,8 @@ API iotcon_str_list_s* iotcon_repr_get_key_list(iotcon_repr_h repr)
 
 API int iotcon_repr_get_keys_count(iotcon_repr_h repr)
 {
-       RETV_IF(NULL == repr, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == repr->hash_table, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == repr, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == repr->hash_table, IOTCON_ERROR_INVALID_PARAMETER);
 
        return g_hash_table_size(repr->hash_table);
 }
index 450105a00607145f47afa8e02fa66a35da8cbb60..f88797c62924a7a95bb7b264267df6b97d0d911f 100755 (executable)
@@ -83,7 +83,7 @@ API int iotcon_response_set(iotcon_response_h resp, iotcon_response_property_e p
                value = va_arg(args, int);
                if (value < IOTCON_RESPONSE_RESULT_OK || IOTCON_RESPONSE_RESULT_MAX <= value) {
                        ERR("Invalid value(%d)", value);
-                       return IOTCON_ERROR_PARAM;
+                       return IOTCON_ERROR_INVALID_PARAMETER;
                }
                resp->result = value;
                break;
@@ -124,8 +124,8 @@ API int iotcon_response_send(iotcon_response_h resp)
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == resp, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == resp->repr, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == resp, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == resp->repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_send_res_response_data(resp);
        if (IOTCON_ERROR_NONE != ret)
index 95a155e66c02c1960ccadfa227d1ca35ab499ff8..1566450e3d85b34cb056bfa318902841c9da2732 100755 (executable)
@@ -154,7 +154,7 @@ API unsigned int iotcon_str_list_length(iotcon_str_list_s *str_list)
 API int iotcon_str_list_foreach(iotcon_str_list_s *str_list, iotcon_string_foreach_cb cb,
                void *user_data)
 {
-       RETV_IF(NULL == str_list, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == str_list, IOTCON_ERROR_INVALID_PARAMETER);
 
        while (str_list) {
                if (false == cb(str_list->string, user_data))
index 267fa340b97eec2041e8c505089f2d6e11072b35..631894dc04e177e245b309158e6448645f111712 100755 (executable)
--- a/lib/ic.c
+++ b/lib/ic.c
@@ -155,7 +155,7 @@ API int iotcon_bind_interface(iotcon_resource_h resource, iotcon_interface_e ifa
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == resource, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_bind_iface_to_res(resource->handle, iface);
        if (IOTCON_ERROR_NONE != ret)
@@ -170,11 +170,11 @@ API int iotcon_bind_type(iotcon_resource_h resource, const char *resource_type)
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == resource, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == resource_type, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == resource_type, IOTCON_ERROR_INVALID_PARAMETER);
        if (IOTCON_RESOURCE_TYPE_LENGTH_MAX < strlen(resource_type)) {
                ERR("The length of resource_type(%s) is invalid", resource_type);
-               return IOTCON_ERROR_PARAM;
+               return IOTCON_ERROR_INVALID_PARAMETER;
        }
 
        ret = ic_ioty_bind_type_to_res(resource->handle, resource_type);
@@ -190,8 +190,8 @@ API int iotcon_bind_resource(iotcon_resource_h parent, iotcon_resource_h child)
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == parent, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == child, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == parent, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == child, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_bind_res(parent->handle, child->handle);
        if (IOTCON_ERROR_NONE != ret)
@@ -256,7 +256,7 @@ API int iotcon_unsubscribe_presence(iotcon_presence_h handle)
        FN_CALL;
        int ret;
 
-       RETV_IF(NULL == handle, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == handle, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_unsubscribe_presence(handle);
        if (IOTCON_ERROR_NONE != ret)
@@ -300,10 +300,10 @@ API int iotcon_notify(iotcon_resource_h resource, iotcon_notimsg_h msg,
 {
        int ret;
 
-       RETV_IF(NULL == resource, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == observers, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == msg, IOTCON_ERROR_PARAM);
-       RETV_IF(NULL == msg->repr, IOTCON_ERROR_PARAM);
+       RETV_IF(NULL == resource, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == observers, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == msg, IOTCON_ERROR_INVALID_PARAMETER);
+       RETV_IF(NULL == msg->repr, IOTCON_ERROR_INVALID_PARAMETER);
 
        ret = ic_ioty_send_notify(resource->handle, msg, observers);
        if (IOTCON_ERROR_NONE != ret)
old mode 100644 (file)
new mode 100755 (executable)
index d6c5a2b..0055809
 #ifndef __IOT_CONNECTIVITY_MANAGER_ERRORS_H__
 #define __IOT_CONNECTIVITY_MANAGER_ERRORS_H__
 
+#include <tizen.h>
+
 /**
  * @ingroup CAPI_IOT_CONNECTIVITY_MODULE
  * @brief Enumerations of Iotcon error codes.
  * @since_tizen 3.0
  */
+
+#ifndef TIZEN_ERROR_IOTCON
+#define TIZEN_ERROR_IOTCON -0x09000000
+#endif
+
 typedef enum
 {
-       IOTCON_ERROR_NONE = 0, /**< Successful*/
-       IOTCON_ERROR_MEMORY = -1, /**< Out of memory */
-       IOTCON_ERROR_GDBUS = -2,
-       IOTCON_ERROR_ENVIRONMENT = -3,
-       IOTCON_ERROR_SYSTEM = -4,
-       IOTCON_ERROR_PLUGIN = -5,
-       IOTCON_ERROR_PARAM = -6, /**< Invalid parameter */
-       IOTCON_ERROR_ALREADY = -7,
-       IOTCON_ERROR_BUSY = -8, /**< Device or resource busy */
-       IOTCON_ERROR_NOT_SUPPORT = -9,
-       IOTCON_ERROR_DISABLE = -10,
-       IOTCON_ERROR_IOTIVITY = -11, /**< Iotivity errors */
-       IOTCON_ERROR_NO_DATA = -12, /**< No data available */
-       IOTCON_ERROR_FAIL = -13, /**< Fail */
+       IOTCON_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful*/
+       IOTCON_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
+       IOTCON_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
+       IOTCON_ERROR_NO_DATA = TIZEN_ERROR_NO_DATA, /**< No data available */
+       IOTCON_ERROR_IOTIVITY = TIZEN_ERROR_IOTCON | 0x01, /**< Iotivity errors */
+       IOTCON_ERROR_REPRESENTATION = TIZEN_ERROR_IOTCON | 0x02, /**< Representation errors */
+       IOTCON_ERROR_INVALID_TYPE = TIZEN_ERROR_IOTCON | 0x03, /**< Invalid type */
 }iotcon_error_e;
 
 #endif /* __IOT_CONNECTIVITY_MANAGER_ERRORS_H__ */
index 7a0c6acc09b88ac3ba13bf1aeba3ca826c311661..11edcce3ef84ba7ee1fa8fe727db1bceef60e76b 100755 (executable)
@@ -36,8 +36,8 @@ iotcon_repr_h iotcon_repr_clone(const iotcon_repr_h src);
  *
  * @return 0 on success, otherwise a negative error value.
  * @retval #IOTCON_ERROR_NONE  Successful
- * @retval #IOTCON_ERROR_MEMORY  Out of memory
- * @retval #IOTCON_ERROR_PARAM  Invalid parameter
+ * @retval #IOTCON_ERROR_OUT_OF_MEMORY  Out of memory
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  */
 int iotcon_repr_set_uri(iotcon_repr_h repr, const char *uri);
 int iotcon_repr_get_uri(iotcon_repr_h repr, const char **uri);
@@ -53,7 +53,7 @@ int iotcon_repr_get_uri(iotcon_repr_h repr, const char **uri);
  *
  * @return 0 on success, otherwise a negative error value.
  * @retval #IOTCON_ERROR_NONE  Successful
- * @retval #IOTCON_ERROR_PARAM  Invalid parameter
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  */
 int iotcon_repr_set_resource_types(iotcon_repr_h repr, iotcon_str_list_s *types);
 int iotcon_repr_get_resource_types(iotcon_repr_h repr, iotcon_str_list_s **types);
@@ -72,8 +72,8 @@ int iotcon_repr_get_resource_interfaces(iotcon_repr_h repr);
  *
  * @return 0 on success, otherwise a negative error value.
  * @retval #IOTCON_ERROR_NONE  Successful
- * @retval #IOTCON_ERROR_MEMORY  Out of memory
- * @retval #IOTCON_ERROR_PARAM  Invalid parameter
+ * @retval #IOTCON_ERROR_OUT_OF_MEMORY  Out of memory
+ * @retval #IOTCON_ERROR_INVALID_PARAMETER  Invalid parameter
  */
 int iotcon_repr_set_int(iotcon_repr_h repr, const char *key, int val);
 int iotcon_repr_set_bool(iotcon_repr_h repr, const char *key, bool val);
index 8edfb4d85310f557472034871ee7842581195be5..10d6899c37212541393dc4cf93fe0a8811a35781 100644 (file)
@@ -12,6 +12,7 @@ BuildRequires:  iotivity-devel
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(json-glib-1.0)
 BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(capi-base-common)
 
 
 %description
old mode 100644 (file)
new mode 100755 (executable)
index d17e00a..66710e9
@@ -45,13 +45,13 @@ static iotcon_error_e _set_door_resource()
        my_door.type = strdup("core.door");
        if (NULL == my_door.type) {
                ERR("strdup(core.door) Fail");
-               return IOTCON_ERROR_MEMORY;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        my_door.uri = strdup("/a/door");
        if (NULL == my_door.uri) {
                ERR("strdup(/a/door) Fail");
-               return IOTCON_ERROR_MEMORY;
+               return IOTCON_ERROR_OUT_OF_MEMORY;
        }
 
        return IOTCON_ERROR_NONE;