tizen 2.3.1 release tizen_2.3.1 submit/tizen_2.3.1/20150915.080426 tizen_2.3.1_release
authorjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:17:14 +0000 (22:17 +0900)
committerjk7744.park <jk7744.park@samsung.com>
Tue, 8 Sep 2015 13:17:14 +0000 (22:17 +0900)
23 files changed:
.gitignore [new file with mode: 0755]
CMakeLists.txt
TC/unit/Makefile [changed mode: 0644->0755]
TC/unit/tslist [changed mode: 0644->0755]
TC/unit/utc_ApplicationFW_bundle_decode_func.c
TC/unit/utc_ApplicationFW_bundle_encode_func.c
TC/unit/utc_ApplicationFW_bundle_export_to_argv_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_bundle_import_from_argv_func.c [new file with mode: 0755]
TC/unit/utc_ApplicationFW_bundle_iterate_func.c
bundle.manifest [new file with mode: 0644]
doc/bundle_doc.h [new file with mode: 0755]
image/SLP_bundle_PG_images_encode_decode.png [new file with mode: 0644]
image/SLP_bundle_PG_images_export_import.png [new file with mode: 0644]
image/SLP_bundle_PG_images_logical_view.png [new file with mode: 0644]
include/SLP_bundle_PG.h
include/bundle.h
include/keyval_array.h
packaging/bundle.spec
src/bundle.c [changed mode: 0755->0644]
src/keyval.c
src/keyval_array.c
src/keyval_type.c
test/TC_bundle.c

diff --git a/.gitignore b/.gitignore
new file mode 100755 (executable)
index 0000000..20effdd
--- /dev/null
@@ -0,0 +1,21 @@
+build_log
+*.log
+*.pyc
+usr
+opt
+*.o
+*.os
+*.exe
+packages
+binaries
+*.ipk
+*~
+.*swp
+.cproject
+.project
+Debug
+Release
+cmake_tmp
+*-stamp
+tags
+cscope.out
index 9a298eb..986321d 100644 (file)
@@ -14,13 +14,14 @@ FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
 ENDFOREACH(flag)
 
+set(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
 
 ### Local include directories
 include_directories(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src)
 
 ### Build
-add_library(bundle SHARED 
+add_library(bundle SHARED
                src/bundle.c
                src/keyval_type.c
                src/keyval.c
@@ -40,12 +41,12 @@ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/bundle.pc.in ${CMAKE_BINARY_DIR}/bundle.pc @O
 install(TARGETS bundle
        DESTINATION lib
        )
-install(FILES 
-       ${CMAKE_SOURCE_DIR}/include/bundle.h 
-       ${CMAKE_SOURCE_DIR}/include/SLP_bundle_PG.h 
+install(FILES
+       ${CMAKE_SOURCE_DIR}/include/bundle.h
+       ${CMAKE_SOURCE_DIR}/include/SLP_bundle_PG.h
        DESTINATION include/
                )
-install(FILES ${CMAKE_BINARY_DIR}/bundle.pc 
+install(FILES ${CMAKE_BINARY_DIR}/bundle.pc
                DESTINATION lib/pkgconfig/
                )
 
old mode 100644 (file)
new mode 100755 (executable)
index 2d8e954..4db9778
@@ -1,6 +1,6 @@
 CC ?= gcc
 
-TARGETS = utc_ApplicationFW_bundle_create_func utc_ApplicationFW_bundle_free_func utc_ApplicationFW_bundle_add_func utc_ApplicationFW_bundle_del_func utc_ApplicationFW_bundle_get_val_func utc_ApplicationFW_bundle_get_count_func utc_ApplicationFW_bundle_dup_func utc_ApplicationFW_bundle_iterate_func utc_ApplicationFW_bundle_encode_func utc_ApplicationFW_bundle_decode_func
+TARGETS = utc_ApplicationFW_bundle_create_func utc_ApplicationFW_bundle_free_func utc_ApplicationFW_bundle_add_func utc_ApplicationFW_bundle_del_func utc_ApplicationFW_bundle_get_val_func utc_ApplicationFW_bundle_get_count_func utc_ApplicationFW_bundle_dup_func utc_ApplicationFW_bundle_iterate_func utc_ApplicationFW_bundle_encode_func utc_ApplicationFW_bundle_decode_func utc_ApplicationFW_bundle_import_from_argv_func utc_ApplicationFW_bundle_export_to_argv_func
 
 PKGS = bundle
 
old mode 100644 (file)
new mode 100755 (executable)
index 3217a8f..bf1b5d6
@@ -8,3 +8,5 @@
 /unit/utc_ApplicationFW_bundle_iterate_func
 /unit/utc_ApplicationFW_bundle_encode_func
 /unit/utc_ApplicationFW_bundle_decode_func
+/unit/utc_ApplicationFW_bundle_export_to_argv_func
+/unit/utc_ApplicationFW_bundle_import_from_argv_func
index e84fec5..d3a33f1 100644 (file)
@@ -72,6 +72,10 @@ static void utc_ApplicationFW_bundle_decode_func_01(void)
        }
        
        r = bundle_encode(b, &raw, &len);
+       if(BUNDLE_ERROR_NONE != r){
+               tet_result(TET_FAIL);
+               goto cleanup;
+       }
        if(NULL == raw) {
                tet_result(TET_UNINITIATED);
                goto cleanup;
index 026cb0e..f00342a 100644 (file)
@@ -68,8 +68,12 @@ static void utc_ApplicationFW_bundle_encode_func_01(void)
                tet_result(TET_UNINITIATED);
                goto cleanup;
        }
-       
        r = bundle_encode(b, &raw, &len);
+        if(BUNDLE_ERROR_NONE != r){
+               tet_result(TET_FAIL);
+               goto cleanup;
+       }
+
        if(NULL == raw) {
                tet_result(TET_FAIL);
                goto cleanup;
diff --git a/TC/unit/utc_ApplicationFW_bundle_export_to_argv_func.c b/TC/unit/utc_ApplicationFW_bundle_export_to_argv_func.c
new file mode 100755 (executable)
index 0000000..ad07155
--- /dev/null
@@ -0,0 +1,120 @@
+#include <tet_api.h>
+#include <bundle.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_bundle_export_to_argv_func_01(void);
+static void utc_ApplicationFW_bundle_export_to_argv_func_02(void);
+static void utc_ApplicationFW_bundle_export_to_argv_func_03(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_bundle_export_to_argv_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_bundle_export_to_argv_func_02, NEGATIVE_TC_IDX },
+       { utc_ApplicationFW_bundle_export_to_argv_func_03, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of bundle_export_to_argv()
+ */
+static void utc_ApplicationFW_bundle_export_to_argv_func_01(void)
+{
+       int r = 0;
+        bundle *b = NULL;
+        char **argv1 = NULL;
+
+        b = bundle_create();
+        if(!b) {
+                tet_result(TET_UNINITIATED);
+                return;
+        }
+
+        r = bundle_add(b, "k1", "val1");
+        if(r != 0) {
+                tet_result(TET_UNINITIATED);
+                return;
+        }
+
+        r = bundle_add(b, "k2", "val2");
+        if(r != 0) {
+                tet_result(TET_UNINITIATED);
+                return;
+        }
+
+        r = bundle_export_to_argv(b,&argv1);
+       if (r < 0) {
+               tet_infoline("bundle_export_to_argv() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of bundle_export_to_argv()
+ */
+static void utc_ApplicationFW_bundle_export_to_argv_func_02(void)
+{
+       int r = 0;
+        bundle *b = NULL;
+
+        b = bundle_create();
+        if(!b) {
+                tet_result(TET_UNINITIATED);
+                return;
+        }
+
+        r = bundle_add(b, "k1", "val1");
+        if(r != 0) {
+                tet_result(TET_UNINITIATED);
+                return;
+        }
+
+        r = bundle_add(b, "k2", "val2");
+        if(r != 0) {
+                tet_result(TET_UNINITIATED);
+                return;
+        }
+
+        r = bundle_export_to_argv(b,NULL);
+       if (r != -1) {
+               tet_infoline("bundle_export_to_argv() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of  bundle_export_to_argv()
+ */
+static void utc_ApplicationFW_bundle_export_to_argv_func_03(void)
+{
+       int r = 0;
+        char **argv1 = NULL;
+
+       r = bundle_export_to_argv(NULL, &argv1);
+       if (r != -1) {
+               tet_infoline("bundle_export_to_argv() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
diff --git a/TC/unit/utc_ApplicationFW_bundle_import_from_argv_func.c b/TC/unit/utc_ApplicationFW_bundle_import_from_argv_func.c
new file mode 100755 (executable)
index 0000000..075bff7
--- /dev/null
@@ -0,0 +1,91 @@
+#include <tet_api.h>
+#include <bundle.h>
+
+static void startup(void);
+static void cleanup(void);
+
+void (*tet_startup)(void) = startup;
+void (*tet_cleanup)(void) = cleanup;
+
+static void utc_ApplicationFW_bundle_import_from_argv_func_01(void);
+static void utc_ApplicationFW_bundle_import_from_argv_func_02(void);
+
+enum {
+       POSITIVE_TC_IDX = 0x01,
+       NEGATIVE_TC_IDX,
+};
+
+struct tet_testlist tet_testlist[] = {
+       { utc_ApplicationFW_bundle_import_from_argv_func_01, POSITIVE_TC_IDX },
+       { utc_ApplicationFW_bundle_import_from_argv_func_02, NEGATIVE_TC_IDX },
+       { NULL, 0 }
+};
+
+static void startup(void)
+{
+}
+
+static void cleanup(void)
+{
+}
+
+/**
+ * @brief Positive test case of bundle_import_from_argv()
+ */
+static void utc_ApplicationFW_bundle_import_from_argv_func_01(void)
+{
+       bundle *b = NULL;
+       int argc = 0;
+       char **argv = NULL;
+       int r = 0;
+        bundle *b_new = NULL;
+        char **argv1 = NULL;
+
+        b = bundle_create();
+        if(!b) {
+                tet_result(TET_UNINITIATED);
+                return;
+        }
+
+        r = bundle_add(b, "k1", "val1");
+        if(r != 0) {
+                tet_result(TET_UNINITIATED);
+                return;
+        }
+
+        r = bundle_add(b, "k2", "val2");
+        if(r != 0) {
+                tet_result(TET_UNINITIATED);
+                return;
+        }
+
+        argc = bundle_export_to_argv(b,&argv);
+       if (argc < 0) {
+                tet_result(TET_UNINITIATED);
+               return;
+       }
+
+       b_new = bundle_import_from_argv(argc, argv);
+       if (b_new == NULL) {
+               tet_infoline("bundle_import_from_argv() failed in positive test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
+
+/**
+ * @brief Negative test case of bundle_import_from_argv()
+ */
+static void utc_ApplicationFW_bundle_import_from_argv_func_02(void)
+{
+       bundle *b = NULL;
+       int argc = 3;
+       b = bundle_import_from_argv(argc, NULL);
+       if (b != NULL) {
+               tet_infoline("bundle_import_from_argv() failed in negative test case");
+               tet_result(TET_FAIL);
+               return;
+       }
+       tet_result(TET_PASS);
+}
index a773b0d..9f7aba5 100644 (file)
@@ -64,8 +64,6 @@ cb_test(const char *k, const char *v, void *data)
  */
 static void utc_ApplicationFW_bundle_iterate_func_01(void)
 {
-       int r = 0;
-
        bundle *b = bundle_create();
        if(!b) {
                tet_result(TET_UNINITIATED);
diff --git a/bundle.manifest b/bundle.manifest
new file mode 100644 (file)
index 0000000..97e8c31
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_"/>
+       </request>
+</manifest>
diff --git a/doc/bundle_doc.h b/doc/bundle_doc.h
new file mode 100755 (executable)
index 0000000..198fecc
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef __TIZEN_CORE_LIB_BUNDLE_DOC_H__
+#define __TIZEN_CORE_LIB_BUNDLE_DOC_H__
+
+/**
+ * @ingroup CAPI_APPLICATION_FRAMEWORK
+ * @defgroup CORE_LIB_BUNDLE_MODULE Bundle
+ * @brief  A simple string-based dictionary ADT.
+ *
+ * @section CORE_LIB_BUNDLE_MODULE_HEADER Required Header
+ *   \#include <bundle.h>
+ *
+ * @section CORE_LIB_BUNDLE_MODULE_OVERVIEW Overview
+ *  Bundle is a string based Dictionary ADT. A dictionary is an ordered or unordered list of key element pairs, where keys are used to locate elements in the list.
+*
+*/
+
+#endif /* __TIZEN_CORE_LIB_BUNDLE_DOC_H__ */
diff --git a/image/SLP_bundle_PG_images_encode_decode.png b/image/SLP_bundle_PG_images_encode_decode.png
new file mode 100644 (file)
index 0000000..96cc725
Binary files /dev/null and b/image/SLP_bundle_PG_images_encode_decode.png differ
diff --git a/image/SLP_bundle_PG_images_export_import.png b/image/SLP_bundle_PG_images_export_import.png
new file mode 100644 (file)
index 0000000..fd7202f
Binary files /dev/null and b/image/SLP_bundle_PG_images_export_import.png differ
diff --git a/image/SLP_bundle_PG_images_logical_view.png b/image/SLP_bundle_PG_images_logical_view.png
new file mode 100644 (file)
index 0000000..b2bbaf7
Binary files /dev/null and b/image/SLP_bundle_PG_images_logical_view.png differ
index 92be786..65993de 100755 (executable)
  * @{
 
 <h1 class="pg">Introduction</h1>
-bundle is a simple dictionary ADT to be used in UI-gadget, AUL, and other libraries in application framework. <br>
-bundle can store a number of string key-value pairs, get value by key, duplicate itself, and encode/decode to convert itself into binary data. <br>
 
+<p> Bundle is a string based Dictionary ADT. A dictionary is an ordered or unordered list of key element pairs, where keys are used to locate elements in the list. </p><br/>
 
-<h1 class="pg">Functional architecture diagram</h1>
-\image html SLP_bundle_PG_image01.png "Picture 1. Functional architecture"
-
-A bundle object, created by bundle_create(), can add/delete key/value pairs, get a value with a key, and get number of key/value pairs in it. <br>
-A bundle object can be duplicated by bundle_dup(). <br>
-bundle_encode() can encode a bundle object into byte code(bundle_raw == unsigned char *). This byte code can be decoded into a new bundle object, by bundle_decode(). <br>
-All bundle objects must be freed by bundle_free(). <br>
+<p> ADT(Abstract data type) An Abstract Data type is defined as a mathematical model of the data objects that make up a data type as well
+as the functions that operate on these objects.</p>
 
 <h1 class="pg">Features</h1>
 <ul>
+       <li> Bundle provides string based Dictionary ADT to
+               map/store key-value pairs. Eg. Clock </li>
+       <li> Bundle  provides Application Data Exchange (ADE):
+               <ul>
+                       <li> Transfer application argument between caller and callee by creating a bundle and storing key-value pairs in it. </li>
+                       <li> This bundle object can be passed between applications by encoding and decoding the bundle objects. </li>
+               </ul> </li>
+
+</ul>
+
+<h1 class="pg">Properties</h1>
+<ul>
        <li>Only string type is allowed for key and value.</li>
        <li>Each key and value is duplicated into the bundle object.</li>
        <li>Unlimited number of key/value pairs. (Memory limit is still to be considered)</li>
        <li>No key overlap : You cannot assign new values with existing key.</li>
 </ul>
 
+<h1 class="pg">Bundle Logical View diagram</h1>
+\image html SLP_bundle_PG_images_logical_view.png "Picture 1. Logical view"
+
+
+<h1 class="pg">Functional architecture diagram</h1>
+\image html SLP_bundle_PG_image01.png "Picture 2. Functional architecture"
+
+<p> Bundle requests are received by the Bundle interface. It passes the requests to bundle manager. Bundle Manager checks the type of the request and handles it accordingly. If string key-value needs to be handled in the request it interacts with String manager to provide the required functionality. If the request is based on array of string key-value pair then, Bundle manager interacts with Array manager to provide the required functionality.</p>
+
+<h1 class="pg"> Bundle encode decode life cycle </h1>
+\image html SLP_bundle_PG_images_encode_decode.png "Picture 2. Encode decode life cycle"
+
+<h1 class="pg"> Bundle export import life cycle </h1>
+\image html SLP_bundle_PG_images_export_import.png "Picture 2. Export import life cycle"
+
 <h1 class="pg">API list and description</h1>
 <ul>
        <li>bundle_create() : Create a bundle object.</li>
@@ -64,15 +85,17 @@ All bundle objects must be freed by bundle_free(). <br>
        <li></li>
 </ul>
 
-<h1 class="pg">Sample code</h1>
-bundle library is very easy to use, and the sample code below would enough to understand how to use bundle. <br>
-Detailed API instructions are in API reference in doxygen document.
+<h1 class="pg">Programming Guide</h1>
+<p> bundle library is very easy to use, and the sample code below would enough to understand how to use bundle. </p><br>
+<p>Detailed API instructions are in API reference in doxygen document.</p>
 <h2 class="pg">Note</h2>
 <ul>
        <li>Only string type(char *) keys/values are allowed.</li>
        <li>A bundle object must be freed certainly by bundle_free(). </li>
        <li>Values retrived by bundle_get_val() cannot be modified.<br> If you want to modify value string, duplicate it.</li>
 </ul>
+<h2 class="pg"> Header file </h2>
+<p> header file name: <strong> bundle.h </strong></p>
 <h2 class="pg">Code</h2>
 @code
 #include <stdio.h>
@@ -108,7 +131,7 @@ main(int argc, char **argv)
 
        // count = 2
        count = bundle_get_count(b);
-       
+
        // Delete an item with key "a"
        bundle_del(b, "a");
 
index d12cd06..a53fa09 100755 (executable)
 
 /**
  * @file bundle.h
- * @version 0.1
- * @brief    This file declares API of bundle library
+ * @brief    This file declares has API of the bundle library
  */
 
 /**
- * @addtogroup APPLICATION_FRAMEWORK
- * @{
- *
- * @defgroup bundle
- * @version    0.1
- *
- * @section    Header to use them:
- * @code
- * #include <bundle.h>
- * @endcode
- *
- * @addtogroup bundle
+ * @addtogroup CORE_LIB_BUNDLE_MODULE
  * @{
  */
 
 #include <errno.h>
 #include <stddef.h>
+#include <tizen_error.h>
 
 #ifdef __cplusplus
 extern "C" {
 # endif
 
-#define API    __attribute__((visibility("default")))
+#define API    __attribute__((visibility("default")))
 #define likely(x) __builtin_expect(x,1)
 #define unlikely(x) __builtin_expect(x,0)
 
 /**
- * bundle is an opaque type pointing a bundle object
+ * @brief Enumeration for error code of Bundle.
+ *
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
+typedef enum
+{
+       BUNDLE_ERROR_NONE = TIZEN_ERROR_NONE,                                   /**< Successful */
+       BUNDLE_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY,                 /**< Out of memory */
+       BUNDLE_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER,         /**< Invalid parameter */
+       BUNDLE_ERROR_KEY_NOT_AVAILABLE = TIZEN_ERROR_KEY_NOT_AVAILABLE, /**< Required key not available */
+       BUNDLE_ERROR_KEY_EXISTS = TIZEN_ERROR_BUNDLE | 0x01     /**< Key exists */
+} bundle_error_e;
+
+/**
+ * @brief The bundle handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  */
 typedef struct _bundle_t bundle;
 
 /**
- * bundle_raw is an encoded data type
+ * @brief The encoded data type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @see bundle_encode()
  * @see bundle_decode()
  */
@@ -71,32 +76,39 @@ typedef unsigned char bundle_raw;
 
 
 /**
- * Each bundle keyval have a type.
+ * @brief Enumeration for key-value pair types.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  */
 enum bundle_type_property {
-       BUNDLE_TYPE_ARRAY = 0x0100,
-       BUNDLE_TYPE_PRIMITIVE = 0x0200,
-       BUNDLE_TYPE_MEASURABLE = 0x0400
+       BUNDLE_TYPE_ARRAY = 0x0100,     /**< Array type */
+       BUNDLE_TYPE_PRIMITIVE = 0x0200, /**< Primitive type */
+       BUNDLE_TYPE_MEASURABLE = 0x0400 /**< Measurable type */
 };
 
+/**
+ * @brief Enumeration for bundle types.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ */
 enum bundle_type {
-       BUNDLE_TYPE_NONE = -1,
-       BUNDLE_TYPE_ANY = 0,
-       BUNDLE_TYPE_STR = 1 | BUNDLE_TYPE_MEASURABLE,   /* Default */
-       BUNDLE_TYPE_STR_ARRAY = BUNDLE_TYPE_STR | BUNDLE_TYPE_ARRAY | BUNDLE_TYPE_MEASURABLE,
-       BUNDLE_TYPE_BYTE = 2,
-       BUNDLE_TYPE_BYTE_ARRAY = BUNDLE_TYPE_BYTE | BUNDLE_TYPE_ARRAY
+       BUNDLE_TYPE_NONE = -1,  /**< None */
+       BUNDLE_TYPE_ANY = 0,    /**< Any type */
+       BUNDLE_TYPE_STR = 1 | BUNDLE_TYPE_MEASURABLE,   /**< String type (Default) */
+       BUNDLE_TYPE_STR_ARRAY = BUNDLE_TYPE_STR | BUNDLE_TYPE_ARRAY | BUNDLE_TYPE_MEASURABLE,   /**< String array type */
+       BUNDLE_TYPE_BYTE = 2,   /**< Byte type */
+       BUNDLE_TYPE_BYTE_ARRAY = BUNDLE_TYPE_BYTE | BUNDLE_TYPE_ARRAY   /**< Byte array type */
 };
 
 /**
- * A keyval object in a bundle.
+ * @brief The key-value pair handle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @see bundle_iterator_t
  */
 typedef struct keyval_t bundle_keyval_t;
 
 
 /**
- * bundle_iterator is a new iterator function type for bundle_foreach()
+ * @brief Called for every key-value pair.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @see bundle_foreach()
  */
 typedef void (*bundle_iterator_t) (
@@ -108,22 +120,24 @@ typedef void (*bundle_iterator_t) (
 
 
 /**
- * bundle_iterate_cb_t is an iterator function type for bundle_iterate()
+ * @internal
+ * @brief Called for every key-value pair.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks This type is obsolete. You must not use this type any more.
  * @see bundle_iterate()
- * @remark This type is obsolete. Do not use this type any more.
  */
 typedef void (*bundle_iterate_cb_t) (const char *key, const char *val, void *data);
 
 
-/** 
- * @brief      Create a bundle object.
- * @pre                        None
- * @post               None
+/**
+ * @brief Creates a bundle object.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @return     The bundle object
+ * @retval     @c NULL - Failure
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_OUT_OF_MEMORY       Out of memory
  * @see                        bundle_free()
- * @return     bundle object
- * @retval     NULL    on failure creating an object
- * @remark     When NULL is returned, errno is set to one of the following values; \n
- *                     ENOMEM : No memory to create an object
  *
  @code
  #include <bundle.h>
@@ -134,15 +148,14 @@ typedef void (*bundle_iterate_cb_t) (const char *key, const char *val, void *dat
 API bundle*            bundle_create(void);
 
 /**
- * @brief              Free given bundle object with key/values in it
- * @pre                        b must be a valid bundle object.
- * @post               None
+ * @brief Frees the given bundle object with key-value pairs in it.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object to be freed
+ * @return             The operation result;
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @pre                        @a b must be a valid bundle object.
  * @see                        bundle_create()
- * @param[in]  b       bundle object to be freed
- * @return             Operation result;
- * @retval             0 success
- * @retval             -1 failure
- * @remark             None
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
@@ -150,24 +163,22 @@ API bundle*               bundle_create(void);
  @endcode
  */
 API int                        bundle_free(bundle *b);
+
 /**
- * @brief              Add a string array type key-value pair into bundle. 
- * @pre                        b must be a valid bundle object.
- * @post               None
+ * @brief Adds a strings array type key-value pair into a given bundle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @param[in]  str_array The string type value; if @c NULL, an empty array is created; you can change an item with
+ * @param[in]  len The length of the array
+ * @return             The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @retval BUNDLE_ERROR_KEY_EXISTS     Key already exists
+ * @retval BUNDLE_ERROR_OUT_OF_MEMORY  Out of memory
+ * @pre                        @a b must be a valid bundle object.
  * @see                        bundle_get_str_array()
- * @see                        bundle_set_str_array_element()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @param[in]  str_array string type value. If NULL, empty array is created. You can change an item with 
- * @param[in]  len Length of array.
- * @return             Operation result
- * @retval             0       success
- * @retval             -1      failure
  *
- * @remark             When -1 is returned, errno is set to one of the following values; \n
-                               EKEYREJECTED : key is rejected (NULL or sth) \n
-                               EPERM : key is already exist, not permitted to overwrite value \n
-                               EINVAL : b or val is not valid (NULL or sth) \n
  @code
  #include <bundle.h>
  char *sa = { "aaa", "bbb", "ccc" };   // A string array of length 3
@@ -177,22 +188,21 @@ API int                   bundle_free(bundle *b);
  @endcode
  */
 API int bundle_add_str_array(bundle *b, const char *key, const char **str_array, const int len);
+
 /**
- * @brief              Add a string type key-value pair into bundle. 
- * @pre                        b must be a valid bundle object.
- * @post               None
+ * @internal
+ * @brief Adds a string type key-value pair into a given bundle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @param[in]  val     The value
+ * @return             The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @retval BUNDLE_ERROR_KEY_EXISTS     Key already exists
+ * @retval BUNDLE_ERROR_OUT_OF_MEMORY  Out of memory
+ * @pre                        @a b must be a valid bundle object.
  * @see                        bundle_add_str()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @param[in]  val     value
- * @return             Operation result
- * @retval             0       success
- * @retval             -1      failure
- *
- * @remark             When -1 is returned, errno is set to one of the following values; \n
-                               EKEYREJECTED : key is rejected (NULL or sth) \n
-                               EPERM : key is already exist, not permitted to overwrite value \n
-                               EINVAL : b or val is not valid (NULL or sth) \n
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
@@ -204,53 +214,46 @@ API int bundle_add_str_array(bundle *b, const char *key, const char **str_array,
 API int                                bundle_add(bundle *b, const char *key, const char *val);
 
 /**
- * @brief              Delete val with given key
- * @pre                        b must be a valid bundle object.
- * @post               None
- * @see                        None
- * @param[in]  b       bundle object
- * @param[in]  key     given key
- * @return             Operation result
- * @retval             0       Success
- * @retval             -1      Failure
- *
- * @remark             When -1 is returned, errno is set to one of the following values; \n
-                               EINVAL : b is invalid (NULL or sth) \n
-                               ENOKEY : No key exist \n
-                               EKEYREJECTED : key is invalid (NULL or sth) \n
+ * @brief Deletes a key-value object with the given key.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The given key
+ * @return             The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @retval BUNDLE_ERROR_KEY_NOT_AVAILABLE      Key not available
+ * @pre                        @a b must be a valid bundle object.
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
- bundle_add(b, "foo_key", "bar_val"); // add a key-val pair
+ bundle_add_str(b, "foo_key", "bar_val"); // add a key-val pair
  bundle_del(b, "foo_key"); // del "foo_key" from b
 
  bundle_free(b);
  @endcode
  */
 API int                                bundle_del(bundle *b, const char* key);
+
 /**
- * @brief              Get string array value from key
- * @pre                        b must be a valid bundle object.
- * @post               None
+ * @brief Gets a string array from a given key.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks            You MUST NOT free or modify the returned string!
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @param[out] len     The array length
+ * @return             The pointer to the array of strings
+ * @retval             @c NULL - Key not found
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @exception BUNDLE_ERROR_KEY_NOT_AVAILABLE   Key not available
+ * @pre                        @a b must be a valid bundle object.
  * @see                        bundle_add_str_array()
- * @see                        bundle_set_str_array_element()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @param[out] len     array length
- * @return             Pointer to array of  string
- * @retval             NULL    If key is not found, returns NULL.
- * @remark             DO NOT free or modify returned string!
-                               When NULL is returned, errno is set to one of the following values; \n
-                               EINVAL : b is invalid \n
-                               ENOKEY : No key exists \n
-                               EKEYREJECTED : invalid key (NULL or sth) \n
  @code
  #include <bundle.h>
  bundle *b = bundle_create();
- bundle_add_str_array(b, "foo", NULL, 3); // add a key-val pair
- bundle_set_str_array_element(b, "foo", 0, "aaa");
- bundle_set_str_array_element(b, "foo", 1, "bbb");
- bundle_set_str_array_element(b, "foo", 2, "ccc");
+ char *sa = { "aaa", "bbb", "ccc" };   // A string array of length 3
+ bundle_add_str_array(b, "foo", sa, 3); // add a key-val pair
 
  char **str_array = NULL;
  int len_str_array = 0;
@@ -261,26 +264,27 @@ API int                           bundle_del(bundle *b, const char* key);
  bundle_free(b);
  @endcode
  */
-
 API const char** bundle_get_str_array(bundle *b, const char *key,int *len);
+
 /**
- * @brief              Get value from key
- * @pre                        b must be a valid bundle object.
- * @post               None
+ * @internal
+ * @brief Gets a value with a given key.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks            You MUST NOT free or modify the returned string!
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @return             The pointer for the value string
+ * @retval             @c NULL - Key not found
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @exception BUNDLE_ERROR_KEY_NOT_AVAILABLE   Key not available
+ * @pre                        @a b must be a valid bundle object.
  * @see                        bundle_get_str()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @return             Pointer for value string
- * @retval             NULL    If key is not found, returns NULL.
- * @remark             DO NOT free or modify returned string!
-                               When NULL is returned, errno is set to one of the following values; \n
-                               EINVAL : b is invalid \n
-                               ENOKEY : No key exists \n
-                               EKEYREJECTED : invalid key (NULL or sth) \n
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
- bundle_add(b, "foo_key", "bar_val"); // add a key-val pair
+ bundle_add_str(b, "foo", "bar"); //add a key-val pair
  char *val = bundle_get_val(b, "foo_key");     // val = "bar_val"
 
  bundle_free(b);       // After freeing b, val becomes a dangling pointer.
@@ -290,19 +294,17 @@ API const char** bundle_get_str_array(bundle *b, const char *key,int *len);
 API const char*                bundle_get_val(bundle *b, const char *key);
 
 /**
- * @brief      Get the number of bundle items
- * @pre                        b must be a valid bundle object.
- * @post               None
- * @see                        None
- * @param[in]  b       bundle object
- * @return             Number of bundle items
- * @remark             None
+ * @brief Gets the number of bundle items.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object
+ * @return             The number of bundle items
+ * @pre                        @a b must be a valid bundle object.
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
- bundle_add(b, "key1", "val1"); // add a key-val pair
+ bundle_add_str(b, "key1", "val1"); //add a key-val pair
  int count = bundle_get_count(b);      // count=1
- bundle_add(b, "key2", "val2"); // add another key-val pair
+ bundle_add_str(b, "key2", "val2"); // add another key-val pair
  count = bundle_get_count(b); // count=2
 
  bundle_free(b);
@@ -310,36 +312,39 @@ API const char*           bundle_get_val(bundle *b, const char *key);
  */
 API int                                bundle_get_count(bundle *b);
 
-
 /**
- * @brief      Get a type of a value with certain key
- * @pre                b must be a valid bundle object
- * @post       None
- * @see                bundle_type_t
+ * @brief Gets the type of a value with a given key.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
  * @param[in]  b       A bundle
- * @param[in]  key     A key in bundle
- * @return     Type of a key in b
- * @remark
+ * @param[in]  key     A key in the bundle
+ * @return     The type of a key in @a b
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @exception BUNDLE_ERROR_KEY_NOT_AVAILABLE   Key not available
+ * @pre                @a b must be a valid bundle object.
+ * @see                bundle_type_t
  @code
  @endcode
  */
 API int bundle_get_type(bundle *b, const char *key);
 
-
 /**
- * @brief      Duplicate given bundle object
- * @pre                        b must be a valid bundle object.
- * @post               None
- * @see                        None
- * @param[in]  b_from  bundle object to be duplicated
- * @return             New bundle object
- * @retval             NULL    Failure
- * @remark             None
+ * @internal
+ * @brief Duplicates a given bundle object.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @param[in]  b_from  the bundle object to be duplicated
+ * @return             The new bundle object
+ * @retval             @c NULL - Failure
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @pre                        @a b must be a valid bundle object.
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
- bundle_add(b, "foo_key", "bar_val"); // add a key-val pair
- bundle *b_dup = bundle_dup(b);        // duplicate b 
+ bundle_add_str(b, "foo_key", "bar_val"); // add a key-val pair
+ bundle *b_dup = bundle_dup(b);        // duplicate b
 
  bundle_free(b);
  bundle_free(b_dup);
@@ -348,16 +353,20 @@ API int bundle_get_type(bundle *b, const char *key);
 API bundle *           bundle_dup(bundle *b_from);
 
 /**
- * @brief      iterate callback function with each key/val pairs in bundle. (NOTE: Only BUNDLE_TYPE_STR type values come!)
- * @pre                        b must be a valid bundle object.
- * @post               None
- * @see                        None
- * @param[in]  b       bundle object
- * @param[in]  callback        iteration callback function
- * @param[in]  data    data for callback function
- * @remark             This function is obsolete, and does not give values whose types are not BUNDLE_TYPE_STR.
+ * @internal
+ * @brief Iterates a callback function for each key-value pairs in a given bundle.
+ * @details (NOTE: Only BUNDLE_TYPE_STR type values come!)
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @remarks            This function is obsolete and does not give values whose types are not BUNDLE_TYPE_STR.
+ * @param[in]  b       The bundle object
+ * @param[in]  callback        The iteration callback function
+ * @param[in]  cb_data The data for callback function
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @pre                        @a b must be a valid bundle object.
  @code
@include <stdio.h>
#include <stdio.h>
  #include <bundle.h>
  void sample_cb(const char *k, const char *v, void *data) {
    printf("%s -> %s\n", k, v);
@@ -365,28 +374,34 @@ API bundle *              bundle_dup(bundle *b_from);
 
  int main(void) {
         bundle *b = bundle_create(); // Create new bundle object
-        bundle_add(b, "k1", "v1"); // add a key-val pair
-        bundle_add(b, "k2", "v2"); // add a key-val pair
-        bundle_add(b, "k3", "v3"); // add a key-val pair
-        bundle_iterate(b, sample_cb, NULL);    // iterate sample_cb for each key/val
+        bundle_add_str(b, "k1", "v1"); // add a key-val pair
+        bundle_add_str(b, "k2", "v2"); // add a key-val pair
+        bundle_add_str(b, "k3", "v3"); // add a key-val pair
+        bundle_iterate(b, sample_cb, NULL);    // iterate sample_cb() for each key/val
         return 0;
- } 
+ }
  @endcode
  */
 API void                       bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *cb_data);
 
-
 /**
- * @brief      iterate callback function with each key/val pairs in bundle. (Supports all types of value)
- * @pre                        b must be a valid bundle object.
- * @post               None
- * @see                        bundle_keyval_get_type bundle_keyval_type_is_array bundle_keyval_get_basic_val bundle_keyval_get_array_val
- * @param[in]  b       bundle object
- * @param[in]  iter    iteration callback function
- * @param[in]  user_data       data for callback function
- * @remark             This function supports all types.
+ * @brief Iterates a callback function for each key-value pair in a given bundle.
+ * @details Supports all types of values.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @remarks            This function supports all types.
+ * @param[in]  b       The bundle object
+ * @param[in]  iter    The iteration callback function
+ * @param[in]  user_data       The data for the callback function
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @pre                        @a b must be a valid bundle object.
+ * @see                        bundle_keyval_get_type()
+ * @see                        bundle_keyval_type_is_array()
+ * @see                        bundle_keyval_get_basic_val()
+ * @see                        bundle_keyval_get_array_val()
  @code
@include <stdio.h>
#include <stdio.h>
  #include <bundle.h>
  void sample_cb(const char *key, const int type, const bundle_keyval_t *kv, void *user_data) {
    void *basic_val = NULL;
@@ -401,138 +416,153 @@ API void                        bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *cb_data
         // Do something...
    }
    else {
-     bundle_keyval_get_basic_val(kv, &basic_val, &size);
+     bundle_keyval_get_basic_val(kv, &basic_val, &basic_size);
         // Do something...
    }
  }
+
  int main(void) {
         bundle *b = bundle_create(); // Create new bundle object
         bundle_add_str(b, "k1", "v1"); // add a key-val pair
         bundle_add_byte(b, "k2", "v2", 3); // add a key-val pair
         char *s_arr[] = {"abc", "bcd", "cde"};
         bundle_add_str_array(b, "k3", s_arr, 3); // add a key-val pair
-        bundle_iterate(b, sample_cb, NULL);    // iterate sample_cb for each key/val
+        bundle_foreach(b, sample_cb, NULL);    // iterate sample_cb() for each key/val
         return 0;
- } 
+ }
  @endcode
  */
 API void                       bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data);
 
-
 /**
- * @brief      Get type for a bundle_keyval_t object.
- * @pre                kv must be a valid bundle_keyval_t object.
- * @post       None
- * @see                bundle_foreach
+ * @brief Gets the type of a key-value pair.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
  * @param[in]  kv      A bundle_keyval_t object
- * @return     Type of kv
- * @retval     -1      Operation failure.      errno is set.
- * @remark
+ * @return     The type of @a kv
+ * @retval     @c -1 - Failure
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @pre                @a kv must be a valid bundle_keyval_t object.
+ * @see                bundle_foreach()
  */
 API int bundle_keyval_get_type(bundle_keyval_t *kv);
 
-
 /**
- * @brief      Determine if kv is array type or not.
- * @pre                kv must be a valid bundle_keyval_t object.
- * @post       None
- * @see                bundle_foreach
+ * @brief Determines whether the  type of a key-value pair is array.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
  * @param[in]  kv      A bundle_keyval_t object
- * @return             Operation result
- * @retval             1       kv is an array.
- * @retval             0       kv is not an array.
- * @remark
+ * @return             The operation result
+ * @retval             @c 1 - @a kv is an array
+ * @retval             @c 0 - @a kv is not an array
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @pre                @a kv must be a valid bundle_keyval_t object.
+ * @see                bundle_foreach()
  */
 API int bundle_keyval_type_is_array(bundle_keyval_t *kv);
 
+/**
+ * @internal
+ * @brief Determines whether the type of a key-value pair is measurable.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @param[in]  kv      A bundle_keyval_t object
+ * @return             The operation result
+ * @retval             @c 1 - @a kv is an measurable
+ * @retval             @c 0 - @a kv is not an measurable
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @pre                @a kv must be a valid bundle_keyval_t object.
+ * @see                bundle_foreach()
+ */
+API int bundle_keyval_type_is_measurable(bundle_keyval_t *kv);
 
 /**
- * @brief      Get value and size of the value from kv of basic type.
- * @pre                kv must be a valid bundle_keyval_t object.
- * @post       val, size are set.
- * @see                bundle_foreach
+ * @brief Gets the value and size of the value from a key-value pair of basic type.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks    You must not free @a val.
  * @param[in]  kv              A bundle_keyval_t object
- * @param[out] val             Value
- * @param[out] size    Size of val
- * @return     Operation result
- * @retval     0       Success
- * @remark     Do not free val.
+ * @param[out] val             The value
+ * @param[out] size    The size of @a val
+ * @return     The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @pre                @a kv must be a valid bundle_keyval_t object.
+ * @post       @a val and @a size are set.
+ * @see                bundle_foreach()
  */
 API int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *size);
 
-
 /**
- * @brief      Get value array, length of array, and size of each array item
- * @pre                kv must be a valid bundle_keyval_t object.
- * @post       array_val, array_len, array_item_size are set.
- * @see                bundle_foreach
+ * @brief Gets the value array, length of the array, and size of each array item.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @param[in]  kv              A bundle_keyval_t object
- * @param[out] array_val       Array pointer of values
- * @param[out] array_len       Length of array_val
- * @param[out] array_element_size      Array of size of each array element
- * @return     Operation result
- * @retval     0       Success
- * @retval     0       Failure
- * @remark
+ * @param[out] array_val       The array pointer of values
+ * @param[out] array_len       The length of @a array_val
+ * @param[out] array_element_size      The array of size of each array element
+ * @return     The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @pre                @a kv must be a valid bundle_keyval_t object.
+ * @post       @a array_val, @a array_len, @a array_item_size are set.
+ * @see                bundle_foreach()
  */
 API int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, unsigned int *array_len, size_t **array_element_size);
 
-
 /**
- * @brief      Encode bundle to bundle_raw format (uses base64 format)
- * @pre                        b must be a valid bundle object.
- * @post               None
- * @see                        None
- * @param[in]  b       bundle object
- * @param[out] r       returned bundle_raw data(byte data)
- *                                     r MUST BE FREED by free(r).
- * @param[out] len     size of r (in bytes)
- * @return     size of raw data
- * @retval             0               Success
- * @retval             -1              Failure
- * @remark             None
+ * @brief Encodes a bundle to the bundle_raw format (uses base64 format).
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object
+ * @param[out] r       The returned bundle_raw data(byte data)
+ *                                     @a r MUST BE FREED by free(r)
+ * @param[out] len     The size of @a r (in bytes)
+ * @return     The size of the raw data
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @pre                        @a b must be a valid bundle object.
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
- bundle_add(b, "foo_key", "bar_val"); // add a key-val pair
+ bundle_add_str(b, "foo_key", "bar_val"); // add a key-val pair
  bundle_raw *r;
  int len;
  bundle_encode(b, &r, &len);   // encode b
 
- bundle_free_encoded_rawdata(r);
  bundle_free(b);
  @endcode
  */
 API int                                bundle_encode(bundle *b, bundle_raw **r, int *len);
 
 /**
- * @brief      Free encoded rawdata from memory
- * @pre                r is a valid rawdata generated by bundle_encode().
- * @post       None
- * @see                bundle_encode
- * @param[in]  r       is a rawdata
- * @return             Operation result
- * @retval             0       Success
- * @retval             -1      Failure
- * @reamark    None
+ * @internal
+ * @brief Frees the encoded rawdata.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  r       The rawdata
+ * @return             The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @pre                @a r is a valid rawdata generated by bundle_encode().
+ * @see                bundle_encode()
  */
 API int                                bundle_free_encoded_rawdata(bundle_raw **r);
 
 /**
- * @brief      deserialize bundle_raw, and get bundle object
- * @pre                        b must be a valid bundle object.
- * @post               None
- * @see                        None
- * @param[in]  r       bundle_raw data to be converted to bundle object
- * @param[in]  len     size of r
- * @return     bundle object
- * @retval     NULL    Failure
- * @remark             None
+ * @brief Deserializes bundle_raw and gets the bundle object.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @param[in]  r       The bundle_raw data to be converted to bundle object
+ * @param[in]  len     The size of @a r
+ * @return     The bundle object
+ * @retval     @c NULL - Failure
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @pre                        @a b must be a valid bundle object.
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
- bundle_add(b, "foo_key", "bar_val"); // add a key-val pair
+ bundle_add_str(b, "foo_key", "bar_val"); // add a key-val pair
 
  bundle_raw *encoded_b;
  int len;
@@ -548,33 +578,94 @@ API int                           bundle_free_encoded_rawdata(bundle_raw **r);
  */
 API bundle *           bundle_decode(const bundle_raw *r, const int len);
 
+/**
+ * @internal
+ * @brief Encodes a bundle to the bundle_raw format.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object
+ * @param[out] r       The returned bundle_raw data(byte data)
+ *                                     @a r MUST BE FREED by free(r)
+ * @param[out] len     The size of @a r (in bytes)
+ * @return     The size of the raw data
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @retval BUNDLE_ERROR_OUT_OF_MEMORY  Out of memory
+ * @pre                        @a b must be a valid bundle object.
+ @code
+ #include <bundle.h>
+ bundle *b = bundle_create(); // Create new bundle object
+ bundle_add_str(b, "foo_key", "bar_val"); // add a key-val pair
+ bundle_raw *r;
+ int len;
+ bundle_encode_raw(b, &r, &len);       // encode b
+
+ bundle_free(b);
+ @endcode
+ */
+API int                                bundle_encode_raw(bundle *b, bundle_raw **r, int *len);
 
 /**
- * @brief      Export bundle to argv
- * @pre                b is a valid bundle object.
- * @post       argv is a pointer of newly allocated memory. It must be freed. 
- *          Each item of argv points the string in the bundle object b. If b is freed, argv will have garbage pointers. DO NOT FREE b BEFORE ACCESSING argv!!
- * @see                bundle_import_from_argv
- * @param[in]  b       bundle object
- * @param[out] argv    Pointer of string array.
- *                      This array has NULL values for first and last item.
- *                      First NULL is for argv[0], and last NULL is a terminator for execv().
- * @return     Number of item in argv. This value is equal to actual count of argv - 1. (Last NULL terminator is not counted.)
- * @retval     -1              Function failure. Check errno to get the reason.
- * @remark     None
+ * @internal
+ * @brief Deserializes bundle_raw and gets a bundle object.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @param[in]  r       The bundle_raw data to be converted to a bundle object
+ * @param[in]  len     The size of @a r
+ * @return     The bundle object
+ * @retval     @c NULL - Failure
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @pre                        @a b must be a valid bundle object.
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
- bundle_add(b, "foo_key", "bar_val"); // add a key-val pair
+ bundle_add_str(b, "foo_key", "bar_val"); // add a key-val pair
+
+ bundle_raw *encoded_b;
+ int len;
+ bundle_encode(b, &encoded_b, &len);   // encode b
+
+ bundle *b_dup;
+ b_dup = bundle_decode_raw(encoded_b, len);    // decoded bundle object
+
+ bundle_free(b);
+ free(encoded_b);
+ bundle_free(b_dup);
+ @endcode
+ */
+API bundle *           bundle_decode_raw(const bundle_raw *r, const int len);
+
+/**
+ * @internal
+ * @brief Exports bundle to @a argv.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @param[in]  b       The bundle object
+ * @param[out] argv    The pointer of the string array; \n
+ *                      This array has NULL values for the first and last item; \n
+ *                      First NULL is for argv[0], and last NULL is a terminator for execv() \n
+ * @return     The number of item in @a argv. This value is equal to the actual count of argv - 1. (Last NULL terminator is not counted.)
+ * @retval     @c -1 - Failure
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @exception BUNDLE_ERROR_OUT_OF_MEMORY       Out of memory
+ * @pre                @a b is a valid bundle object.
+ * @post       @a argv is a pointer of newly allocated memory. It must be freed.
+ *          Each item of @a argv points to the string in the bundle object @a b. If @a b is freed, @a argv will have garbage pointers. DO NOT FREE @a b BEFORE ACCESSING @a argv!!
+ * @see                bundle_import_from_argv()
+ @code
+ #include <bundle.h>
+ bundle *b = bundle_create(); // Create new bundle object
+ bundle_add_str(b, "foo_key", "bar_val"); // add a key-val pair
 
  int argc = 0;
  char **argv = NULL;
  argc = bundle_export_to_argv(b, &argv);       // export to argv
  if(0 > argc) error("export failure");
+
  int i;
  for(i=0; i < argc; i++) {
-   printf("%s\n", argv[i]);            // print argv 
+   printf("%s\n", argv[i]);            // print argv
  }
  bundle_free_exported_argv(argc, argv);        // argv must be freed after being used.
 
@@ -584,20 +675,21 @@ API bundle *              bundle_decode(const bundle_raw *r, const int len);
 API int                                bundle_export_to_argv(bundle *b, char ***argv);
 
 /**
- * @brief      Free exported argv
- * @pre                argv is a valid string array generated from bundle_export_to_argv().
- * @post       None
- * @see                bundle_export_to_argv
- * @param[in]  argc    number of args, which is the return value of bundle_export_to_argv().
- * @param[in]  argv array from bundle_export_to_argv().
- * @return     Operation result.
- * @retval     0       on success
- * @retval     -1      on failure
- * @remark     You must not use this API when you use global argv.
+ * @internal
+ * @brief Frees the exported @a argv.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks    You must not use this API when you use global @a argv.
+ * @param[in]  argc    The number of args, which is the return value of bundle_export_to_argv()
+ * @param[in]  argv The array from bundle_export_to_argv()
+ * @return     The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @pre                @a argv is a valid string array generated from bundle_export_to_argv().
+ * @see                bundle_export_to_argv()
  @code
  bundle *b = bundle_create();
  bundle_add_str(b, "foo", "bar");
+
  int argc = 0;
  char **argv = NULL;
  argc = bundle_export_to_argv(b, &argv);
@@ -605,7 +697,7 @@ API int                             bundle_export_to_argv(bundle *b, char ***argv);
 
  // Use argv...
 
- bundle_free_export_argv(argc, argv);
+ bundle_free_exported_argv(argc, argv);
  argv = NULL;
 
  bundle_free(b);
@@ -614,15 +706,20 @@ API int                           bundle_export_to_argv(bundle *b, char ***argv);
 API int                                bundle_free_exported_argv(int argc, char ***argv);
 
 /**
- * @brief      import a bundle from argv
- * @pre                argv is a valid string array, which is created by bundle_export_to_argv().
- * @post       Returned bundle b must be freed.
- * @see                bundle_export_to_argv
- * @param[in]  argc    argument count
- * @param[in]  argv    argument vector
- * @return     New bundle object
- * @retval     NULL    Function failure
- * @remark     None
+ * @internal
+ * @brief Imports a bundle from @a argv.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
+ * @param[in]  argc    The argument count
+ * @param[in]  argv    The argument vector
+ * @return     The new bundle object
+ * @retval     @c NULL - Failure
+ * @exception BUNDLE_ERROR_NONE        Success
+ * @exception BUNDLE_ERROR_INVALID_PARAMETER   Invalid parameter
+ * @exception BUNDLE_ERROR_OUT_OF_MEMORY       Out of memory
+ * @pre                @a argv is a valid string array, which is created by bundle_export_to_argv().
+ * @post       The returned bundle @a b must be freed.
+ * @see                bundle_export_to_argv()
  @code
  #include <bundle.h>
 
@@ -637,23 +734,19 @@ API int                           bundle_free_exported_argv(int argc, char ***argv);
  */
 API bundle *           bundle_import_from_argv(int argc, char **argv);
 
-#if 0
 /**
- * @brief              Add a string type key-value pair into bundle. 
- * @pre                        b must be a valid bundle object.
- * @post               None
+ * @brief Adds a string type key-value pair into a bundle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @param[in]  str The string type value
+ * @return             The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @retval BUNDLE_ERROR_KEY_EXISTS     Key already exists
+ * @retval BUNDLE_ERROR_OUT_OF_MEMORY  Out of memory
+ * @pre                        @a b must be a valid bundle object.
  * @see                        bundle_get_str()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @param[in]  str string type value
- * @return             Operation result
- * @retval             0       success
- * @retval             -1      failure
- *
- * @remark             When -1 is returned, errno is set to one of the following values; \n
-                               EKEYREJECTED : key is rejected (NULL or sth) \n
-                               EPERM : key is already exist, not permitted to overwrite value \n
-                               EINVAL : b or val is not valid (NULL or sth) \n
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
@@ -665,23 +758,19 @@ API bundle *              bundle_import_from_argv(int argc, char **argv);
 API int bundle_add_str(bundle *b, const char *key, const char *str);
 
 /**
- * @brief              Set a value of string array element
- * @pre                        b must be a valid bundle object.
- * @post               None
+ * @internal
+ * @brief Sets a value of string array elements.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @param[in]  idx The index of the array element to be changed
+ * @param[in]  val The string type value; if @c NULL, an empty array is created; you can change an item with
+ * @return             The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @pre                        @a b must be a valid bundle object.
  * @see                        bundle_add_str_array()
  * @see                        bundle_get_str_array()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @param[in]  idx index of array element to be changed
- * @param[in]  val string type value. If NULL, empty array is created. You can change an item with 
- * @return             Operation result
- * @retval             0       success
- * @retval             -1      failure
- *
- * @remark             When -1 is returned, errno is set to one of the following values; \n
-                               EKEYREJECTED : key is rejected (NULL or sth) \n
-                               EPERM : key is already exist, not permitted to overwrite value \n
-                               EINVAL : b or val is not valid (NULL or sth) \n
  @code
  #include <bundle.h>
  bundle *b = bundle_create();
@@ -702,51 +791,48 @@ API int bundle_add_str(bundle *b, const char *key, const char *str);
 API int bundle_set_str_array_element(bundle *b, const char *key, const unsigned int idx, const char *val);
 
 /**
- * @brief              Add a byte type key-value pair into bundle. 
- * @pre                        b must be a valid bundle object.
- * @post               None
+ * @brief Adds a byte type key-value pair into a bundle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @param[in]  byte The string type value
+ * @param[in]  size The size of @a byte
+ * @return             The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @retval BUNDLE_ERROR_KEY_EXISTS     Key already exists
+ * @retval BUNDLE_ERROR_OUT_OF_MEMORY  Out of memory
+ * @pre                        @a b must be a valid bundle object.
  * @see                        bundle_get_byte()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @param[in]  byte string type value
- * @param[in]  size size of byte
- * @return             Operation result
- * @retval             0       success
- * @retval             -1      failure
- *
- * @remark             When -1 is returned, errno is set to one of the following values; \n
-                               EKEYREJECTED : key is rejected (NULL or sth) \n
-                               EPERM : key is already exist, not permitted to overwrite value \n
-                               EINVAL : b or val is not valid (NULL or sth) \n
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
  bundle_add_byte(b, "foo", "bar\0", 4); // add a key-val pair
 
+ int number = 12345;
+ bundle_add_byte(b, "number", &number, sizeof(int));
+
  bundle_free(b);
  @endcode
  */
-
 API int bundle_add_byte(bundle *b, const char *key, const void *byte, const size_t size);
 
 /**
- * @brief              Add a byte array type key-value pair into bundle. 
- * @pre                        b must be a valid bundle object.
- * @post               None
- * @see                        bundle_get_str_array()
+ * @internal
+ * @brief Adds a byte array type key-value pair into a bundle.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @param[in]  byte_array  Not used
+ * @param[in]  len The length of the array to be created
+ * @return             The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @retval BUNDLE_ERROR_KEY_EXISTS     Key already exists
+ * @retval BUNDLE_ERROR_OUT_OF_MEMORY  Out of memory
+ * @pre                        @a b must be a valid bundle object.
+ * @see                        bundle_get_byte_array()
  * @see                        bundle_set_byte_array_element()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @param[in]  byte_array  Not used.
- * @param[in]  len Length of array to be created
- * @return             Operation result
- * @retval             0       success
- * @retval             -1      failure
- *
- * @remark             When -1 is returned, errno is set to one of the following values; \n
-                               EKEYREJECTED : key is rejected (NULL or sth) \n
-                               EPERM : key is already exist, not permitted to overwrite value \n
-                               EINVAL : b or val is not valid (NULL or sth) \n
  @code
  #include <bundle.h>
  bundle *b = bundle_create();
@@ -762,28 +848,26 @@ API int bundle_add_byte(bundle *b, const char *key, const void *byte, const size
 API int bundle_add_byte_array(bundle *b, const char *key, void **byte_array, const unsigned int len);
 
 /**
- * @brief              Set a value of byte array element
- * @pre                        b must be a valid bundle object.
- * @post               None
- * @see                        bundle_add_str_array()
- * @see                        bundle_get_str_array()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @param[in]  idx index of array element to be changed
- * @param[in]  val string type value. If NULL, empty array is created. You can change an item with 
- * @param[in]  size Size of value in byte
+ * @internal
+ * @brief Sets the value of the byte array element.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @param[in]  idx The index of the array element to be changed
+ * @param[in]  val The string type value; if @c NULL, an empty array is created; you can change an item with
+ * @param[in]  size The size of the value in bytes
  * @return             Operation result
- * @retval             0       success
- * @retval             -1      failure
- *
- * @remark             When -1 is returned, errno is set to one of the following values; \n
-                               EKEYREJECTED : key is rejected (NULL or sth) \n
-                               EPERM : key is already exist, not permitted to overwrite value \n
-                               EINVAL : b or val is not valid (NULL or sth) \n
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @retval BUNDLE_ERROR_KEY_NOT_AVAILABLE      Key not available
+ * @pre                        @a b must be a valid bundle object.
+ * @see                        bundle_add_byte_array()
+ * @see                        bundle_get_byte_array()
  @code
  #include <bundle.h>
  bundle *b = bundle_create();
  bundle_add_byte_array(b, "foo", NULL, 3); // add a key-val pair
+
  bundle_set_byte_array_element(b, "foo", 0, "aaa\0", 4);
  bundle_set_byte_array_element(b, "foo", 1, "bbb\0", 4);
  bundle_set_byte_array_element(b, "foo", 2, "ccc\0", 4);
@@ -791,7 +875,7 @@ API int bundle_add_byte_array(bundle *b, const char *key, void **byte_array, con
  unsigned char **byte_array = NULL;
  int len_byte_array = 0;
 
- byte_array=bundle_get_str_array(b, "foo", &len_byte_array);
+ bundle_get_byte_array(b, "foo", &byte_array, &len_byte_array, &size_byte_array);
  // byte_array = { "aaa\0", "bbb\0", "ccc\0" }, and len_byte_array = 3
 
  bundle_free(b);
@@ -800,21 +884,18 @@ API int bundle_add_byte_array(bundle *b, const char *key, void **byte_array, con
 API int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned int idx, const void *val, const size_t size);
 
 /**
- * @brief              Get string value from key
- * @pre                        b must be a valid bundle object.
- * @post               None
+ * @brief Gets the string value with the given key.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks            You must not free str!
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @param[out] str The returned value
+ * @return             The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @retval BUNDLE_ERROR_KEY_NOT_AVAILABLE      Key not available
+ * @pre                        @a b must be a valid bundle object.
  * @see                        bundle_add_str()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @param[out] str returned value
- * @return             Operation result
- * @retval             0 on success
- * @retval             -1 on failure
- * @remark             Do not free str!
-                               When -1 is returned, errno is set to one of the following values; \n
-                               EINVAL : b is invalid \n
-                               ENOKEY : No key exists \n
-                               EKEYREJECTED : invalid key (NULL or sth) \n
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
@@ -830,54 +911,55 @@ API int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned
 API int bundle_get_str(bundle *b, const char *key, char **str);
 
 /**
- * @brief              Get byte value from key
- * @pre                        b must be a valid bundle object.
- * @post               None
+ * @brief Gets the byte value with the given key.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks            You must not free @a byte!
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @param[out] byte The returned value
+ * @param[out] size The size of the byte
+ * @return             The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @retval BUNDLE_ERROR_KEY_NOT_AVAILABLE      Key not available
+ * @pre                        @a b must be a valid bundle object.
  * @see                        bundle_add_byte()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @param[out] byte returned value
- * @param[out] size Size of byte
- * @return             Operation result
- * @retval             0 on success
- * @retval             -1 on failure
- * @remark             Do not free str!
-                               When -1 is returned, errno is set to one of the following values; \n
-                               EINVAL : b is invalid \n
-                               ENOKEY : No key exists \n
-                               EKEYREJECTED : invalid key (NULL or sth) \n
  @code
  #include <bundle.h>
  bundle *b = bundle_create(); // Create new bundle object
- bundle_add_byte(b, "foo", "bar\0", 4); // add a key-val pair
+ bundle_add_byte(b, "foo", "bar\0", 4); // add string to bundle
+ int number = 12345;
+ bundle_add_byte(b, "number", (const void**)&number, sizeof(int)); // add integer to bundle
 
  unsigned char *v = NULL;
- bundle_get_str(b, "foo", &v); // v = "bar\0"
+ size_t v_size;
+ bundle_get_byte(b, "foo", (void**)&v, &v_size);    // v = "bar\0"
+ int *n = NULL;
+ size_t n_size;
+ bundle_get_byte(b, "number", (void**)&n, &n_size); // number = 12345
 
- bundle_free(b);       // After freeing b, v becomes a dangling pointer.
+ bundle_free(b);       // After freeing b, v and n becomes a dangling pointer.
  @endcode
  */
 API int bundle_get_byte(bundle *b, const char *key, void **byte, size_t *size);
 
 /**
- * @brief              Get byte array value from key
- * @pre                        b must be a valid bundle object.
- * @post               None
- * @see                        bundle_add_str_array()
- * @see                        bundle_set_str_array_element()
- * @param[in]  b       bundle object
- * @param[in]  key     key
- * @param[out] byte_array returned value
- * @param[out] len     array length
- * @param[out] array_element_size      an array of sizes of each byte_array element
- * @return             Operation result
- * @retval             0 on success
- * @retval             -1 on failure
- * @remark             Do not free str!
-                               When -1 is returned, errno is set to one of the following values; \n
-                               EINVAL : b is invalid \n
-                               ENOKEY : No key exists \n
-                               EKEYREJECTED : invalid key (NULL or sth) \n
+ * @internal
+ * @brief Gets the byte array value with the given key.
+ * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
+ * @remarks            You must not free str!
+ * @param[in]  b       The bundle object
+ * @param[in]  key     The key
+ * @param[out] byte_array The returned value
+ * @param[out] len     The array length
+ * @param[out] array_element_size      an array of sizes of each @a byte_array element
+ * @return             The operation result
+ * @retval BUNDLE_ERROR_NONE   Success
+ * @retval BUNDLE_ERROR_INVALID_PARAMETER      Invalid parameter
+ * @retval BUNDLE_ERROR_KEY_NOT_AVAILABLE      Key not available
+ * @pre                        @a b must be a valid bundle object.
+ * @see                        bundle_add_byte_array()
+ * @see                        bundle_set_byte_array_element()
  @code
  #include <bundle.h>
  bundle *b = bundle_create();
@@ -890,14 +972,13 @@ API int bundle_get_byte(bundle *b, const char *key, void **byte, size_t *size);
  int len_byte_array = 0;
  size_t *size_byte_array = NULL;
 
- byte_array = bundle_get_str_array(b, "foo", &len_byte_array, &size_byte_array);
+ bundle_get_byte_array(b, "foo", &byte_array, &len_byte_array, &size_byte_array);
  // byte_array = { "aaa\0", "bbb\0", "ccc\0" }, len_byte_array = 3, and size_byte_array = { 4, 4, 4 }
 
  bundle_free(b);
  @endcode
  */
 API int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, unsigned int *len, unsigned int **array_element_size);
-#endif
 
 
 #ifdef __cplusplus
index afdf52c..66cf31d 100755 (executable)
@@ -50,3 +50,4 @@ size_t keyval_array_decode(void *byte, keyval_array_t **kva);
 int keyval_array_copy_array(keyval_array_t *kva, void **array_val, unsigned int array_len, size_t (*measure_val_len)(void * val));
 int keyval_array_get_data(keyval_array_t *kva, int *type,void ***array_val, unsigned int *len, size_t **array_element_size);
 int keyval_array_set_element(keyval_array_t *kva, int idx, void *val, size_t size);
+int keyval_array_is_idx_valid(keyval_array_t *kva, int idx);
index b9d743b..c9cdb67 100644 (file)
@@ -1,23 +1,20 @@
-
 Name:       bundle
 Summary:    String key-val dictionary ADT
-Version:    0.1.22
+Version:    0.1.36
 Release:    1
 Group:      System/Libraries
-License:    Apache License, Version 2.0
+License:    Apache-2.0
 Source0:    bundle-%{version}.tar.gz
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 BuildRequires:  cmake
 BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(dlog)
-
+BuildRequires:  pkgconfig(capi-base-common)
 
 %description
 Simple string key-val dictionary ADT
 
-
-
 %package devel
 Summary:    String key-val dictionary ADT (devel)
 Group:      Development/Libraries
@@ -26,36 +23,31 @@ Requires:   %{name} = %{version}-%{release}
 %description devel
 Simple string key-val dictionary ADT (devel)
 
-
 %prep
 %setup -q -n %{name}-%{version}
 
-
 %build
+export CFLAGS="$CFLAGS -Wall -Werror -Wno-unused-function"
 cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
 
-
 make %{?jobs:-j%jobs}
 
 %install
 rm -rf %{buildroot}
 %make_install
 
-
-
+mkdir -p %{buildroot}/usr/share/license
+cp LICENSE %{buildroot}/usr/share/license/%{name}
 
 %post -p /sbin/ldconfig
 
 %postun -p /sbin/ldconfig
 
-
-
-
-
 %files
+%manifest bundle.manifest
 %defattr(-,root,root,-)
 %{_libdir}/libbundle.so.*
-
+/usr/share/license/%{name}
 
 %files devel
 %defattr(-,root,root,-)
@@ -63,4 +55,3 @@ rm -rf %{buildroot}
 %{_includedir}/SLP_bundle_PG.h
 %{_libdir}/pkgconfig/bundle.pc
 %{_libdir}/libbundle.so
-
old mode 100755 (executable)
new mode 100644 (file)
index 53df434..296451d
@@ -35,7 +35,6 @@
 
 #include <stdlib.h>            /* calloc, free */
 #include <string.h>            /* strdup */
-#include <errno.h>
 
 #define CHECKSUM_LENGTH 32
 #define TAG_IMPORT_EXPORT_CHECK "`zaybxcwdveuftgsh`"
@@ -53,17 +52,22 @@ static keyval_t *
 _bundle_find_kv(bundle *b, const char *key)
 {
        keyval_t *kv;
-
-       if(NULL == b) { errno  = EINVAL; return NULL; }
-       if(NULL == key) { errno = EKEYREJECTED; return NULL; }
+       if(NULL == b) {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
+       if(NULL == key) {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
 
        kv = b->kv_head;
        while (kv != NULL) {
                if(0 == strcmp(key, kv->key)) return kv;
                kv = kv->next;
-       } 
+       }
        /* Not found */
-       errno = ENOKEY;
+       set_last_result(BUNDLE_ERROR_KEY_NOT_AVAILABLE);
        return NULL;
 }
 
@@ -81,23 +85,24 @@ _bundle_append_kv(bundle *b, keyval_t *new_kv)
                while (NULL != kv->next) kv = kv->next;
                kv->next = new_kv;
        }
-       return 0;
+       return BUNDLE_ERROR_NONE;
 }
 
 static int
 _bundle_add_kv(bundle *b, const char *key, const void *val, const size_t size, const int type, const unsigned int len)
 {
        /* basic value check */
-       if(NULL == b) { errno = EINVAL; return -1; }
-       if(NULL == key) { errno = EKEYREJECTED; return -1; }
-       if(0 == strlen(key)) { errno = EKEYREJECTED; return -1; }
+       if(NULL == b)
+               return BUNDLE_ERROR_INVALID_PARAMETER;
+       if(NULL == key)
+               return BUNDLE_ERROR_INVALID_PARAMETER;
+       if(0 == strlen(key))
+               return BUNDLE_ERROR_INVALID_PARAMETER;
 
        keyval_t *kv = _bundle_find_kv(b, key);
        if(kv) {        /* Key already exists */
-               errno = EPERM;
-               return -1;
+               return BUNDLE_ERROR_KEY_EXISTS;
        }
-       errno = 0;
 
        keyval_t *new_kv = NULL;
        if(keyval_type_is_array(type)) {
@@ -110,13 +115,12 @@ _bundle_add_kv(bundle *b, const char *key, const void *val, const size_t size, c
                new_kv = keyval_new(NULL, key, type, val, size);
        }
        if(!new_kv) {
-               // NOTE: errno is already set. (ENOMEM, ...)
-               return -1;
+               return BUNDLE_ERROR_OUT_OF_MEMORY;
        }
 
        _bundle_append_kv(b, new_kv);
 
-       return 0;
+       return BUNDLE_ERROR_NONE;
 
 }
 
@@ -125,12 +129,10 @@ _bundle_get_val(bundle *b, const char *key, const int type, void **val, size_t *
 {
        keyval_t *kv = _bundle_find_kv(b, key);
        if(!kv) {       /* Key doesn't exist */
-               /* NOTE: errno is already set. */
-               return -1;
+               return get_last_result();
        }
        if(BUNDLE_TYPE_ANY != type && type != kv->type) {
-               errno = ENOTSUP;
-               return -1;
+               return BUNDLE_ERROR_INVALID_PARAMETER;
        }
 
        if(keyval_type_is_array(type)) {
@@ -141,7 +143,7 @@ _bundle_get_val(bundle *b, const char *key, const int type, void **val, size_t *
                keyval_get_data(kv, NULL, val, size);
        }
 
-       return 0;
+       return BUNDLE_ERROR_NONE;
 }
 
 /** global initialization
@@ -152,7 +154,7 @@ _bundle_global_init(void)
 {
        static int _is_done = 0;
        if(_is_done) return;
-       
+
        // Run init functions
        keyval_type_init();
 
@@ -166,32 +168,31 @@ bundle *
 bundle_create(void)
 {
        bundle *b = NULL;
-       
+
        _bundle_global_init();
 
        b = calloc(1, sizeof(bundle));  /* fill mem with NULL */
        if(NULL == b) {
                BUNDLE_EXCEPTION_PRINT("Unable to allocate memory for bundle\n");
-               errno = ENOMEM;
+               set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
                goto EXCEPTION;
        }
 
+       set_last_result(BUNDLE_ERROR_NONE);
        return b;
 
 EXCEPTION:
-       if(NULL != b) bundle_free(b);
        return NULL;
 }
 
 int
 bundle_free(bundle *b)
 {
-       keyval_t *kv, *tmp_kv; 
+       keyval_t *kv, *tmp_kv;
 
        if(NULL == b) {
                BUNDLE_EXCEPTION_PRINT("Bundle is already freed\n");
-               errno = EINVAL;
-               return -1;
+               return BUNDLE_ERROR_INVALID_PARAMETER;
        }
 
        /* Free keyval list */
@@ -205,13 +206,14 @@ bundle_free(bundle *b)
        /* free bundle */
        free(b);
 
-       return 0;
+       return BUNDLE_ERROR_NONE;
 }
 // str type
 int
 bundle_add_str(bundle *b, const char *key, const char *str)
 {
-       if(!str) { errno = EINVAL; return -1; }
+       if(!str)
+               return BUNDLE_ERROR_INVALID_PARAMETER;
        return _bundle_add_kv(b, key, str, strlen(str)+1, BUNDLE_TYPE_STR, 1);
 }
 
@@ -233,17 +235,21 @@ bundle_del(bundle *b, const char *key)
        keyval_t *kv = NULL, *prev_kv = NULL;
 
        /* basic value check */
-       if(NULL == b) { errno = EINVAL; return -1; }
-       if(NULL == key) { errno = EKEYREJECTED; return -1; }
-       if(0 == strlen(key)) { errno = EKEYREJECTED; return -1; }
+       if(NULL == b)
+               return BUNDLE_ERROR_INVALID_PARAMETER;
+       if(NULL == key)
+               return BUNDLE_ERROR_INVALID_PARAMETER;
+       if(0 == strlen(key))
+               return BUNDLE_ERROR_INVALID_PARAMETER;
 
        kv = b->kv_head;
        while (kv != NULL) {
                if(0 == strcmp(key, kv->key)) break;
                prev_kv = kv;
                kv = kv->next;
-       } 
-       if (NULL == kv) { errno = ENOKEY; return -1; }
+       }
+       if (NULL == kv)
+               return BUNDLE_ERROR_KEY_NOT_AVAILABLE;
        else {
                if(NULL != prev_kv) {
                        prev_kv->next = kv->next;
@@ -251,7 +257,7 @@ bundle_del(bundle *b, const char *key)
                if(kv == b->kv_head) b->kv_head = kv->next;
                kv->method->free(kv, 1);
        }
-       return 0;
+       return BUNDLE_ERROR_NONE;
 
 }
 
@@ -259,9 +265,10 @@ const char *
 bundle_get_val(bundle *b, const char *key)
 {
        char *val = NULL;
-       int r = 0;
+       int ret = 0;
+       ret = bundle_get_str(b, key, &val);
+       set_last_result(ret);
 
-       r = bundle_get_str(b, key, &val);
        return val;
 
 }
@@ -288,51 +295,81 @@ bundle_get_count (bundle *b)
 void
 bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *data)
 {
-       keyval_t *kv = b->kv_head;
-       if(callback) {
-               while(NULL != kv) {
-                       callback(kv->key, kv->val, data);
-                       kv = kv->next;
-               }
+       keyval_t *kv;
+
+       if (NULL == b || NULL == callback) {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return;
+       }
+
+       kv = b->kv_head;
+       while (NULL != kv) {
+               callback(kv->key, kv->val, data);
+               kv = kv->next;
        }
+       set_last_result(BUNDLE_ERROR_NONE);
 }
 
 void
 bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data)
 {
-       if(NULL==b)
-       {
+       if (NULL == b || NULL == iter) {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
                return;         /*TC_FIX if b=NULL- error handling */
        }
+
        keyval_t *kv = b->kv_head;
-       if(iter) {
-               while(NULL != kv) {
-                       iter(kv->key, kv->type, kv, user_data);
-                       kv = kv->next;
-               }
+       while (NULL != kv) {
+               iter(kv->key, kv->type, kv, user_data);
+               kv = kv->next;
        }
+       set_last_result(BUNDLE_ERROR_NONE);
 }
 
 /* keyval functions */
-int 
+int
 bundle_keyval_get_type(bundle_keyval_t *kv)
 {
+       if(NULL == kv)
+       {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return -1;
+       }
+       set_last_result(BUNDLE_ERROR_NONE);
        return kv->type;
 }
 
-int 
+int
 bundle_keyval_type_is_array(bundle_keyval_t *kv)
 {
+       if(NULL == kv)
+       {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return -1;
+       }
+       set_last_result(BUNDLE_ERROR_NONE);
        return keyval_type_is_array(kv->type);
 }
 
-int 
+int
+bundle_keyval_type_is_measurable(bundle_keyval_t *kv)
+{
+       if(NULL == kv)
+       {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return -1;
+       }
+       set_last_result(BUNDLE_ERROR_NONE);
+       return keyval_type_is_measurable(kv->type);
+}
+
+int
 bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *size)
 {
        return keyval_get_data(kv, NULL, val, size);
 }
 
-int 
+int
 bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, unsigned int *array_len, size_t **array_item_size)
 {
        return keyval_array_get_data((keyval_array_t *)kv, NULL, array_val, array_len, array_item_size);
@@ -355,9 +392,13 @@ bundle_dup(bundle *b_from)
        bundle *b_to = NULL;
        int i;
 
-       if(NULL == b_from) { errno = EINVAL; return NULL; }
+       if(NULL == b_from) {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
        b_to = bundle_create();
-       if(NULL == b_to) return NULL;
+       if(NULL == b_to)
+               return NULL;
 
        keyval_t *kv_from = b_from->kv_head;
        keyval_t *kv_to = NULL;
@@ -397,10 +438,8 @@ bundle_encode(bundle *b, bundle_raw **r, int *len)
        size_t byte_len;
        gchar *chksum_val;
 
-       if(NULL == b) {
-               errno = EINVAL;
-               return -1;
-       }
+       if (NULL == b || NULL == r || NULL == len)
+               return BUNDLE_ERROR_INVALID_PARAMETER;
 
        /* calculate memory size */
        size_t msize = 0;       // Sum of required size
@@ -411,7 +450,8 @@ bundle_encode(bundle *b, bundle_raw **r, int *len)
                kv = kv->next;
        }
        m = calloc(msize+CHECKSUM_LENGTH, sizeof(unsigned char));
-       if(unlikely(NULL == m ))  { errno = ENOMEM; return -1; }
+       if(unlikely(NULL == m ))
+               return BUNDLE_ERROR_INVALID_PARAMETER;
 
        p_m = m+CHECKSUM_LENGTH;        /* temporary pointer */
 
@@ -430,7 +470,7 @@ bundle_encode(bundle *b, bundle_raw **r, int *len)
        }
 
        /*compute checksum from the data*/
-       chksum_val = g_compute_checksum_for_string(G_CHECKSUM_MD5,m+CHECKSUM_LENGTH,msize);
+       chksum_val = g_compute_checksum_for_string(G_CHECKSUM_MD5, (const char *)(m+CHECKSUM_LENGTH), msize);
        /*prefix checksum to the data */
        memcpy(m,chksum_val,CHECKSUM_LENGTH);
        if ( NULL != r ) {
@@ -441,17 +481,18 @@ bundle_encode(bundle *b, bundle_raw **r, int *len)
        free(m);
        g_free(chksum_val);/*free checksum string */
 
-       return 0;
+       return BUNDLE_ERROR_NONE;
 }
 
 int
 bundle_free_encoded_rawdata(bundle_raw **r)
 {
-       if(!*r) return -1;              /*TC_FIX - double free sigabrt handling */
+       if(!*r)
+               return BUNDLE_ERROR_INVALID_PARAMETER;          /*TC_FIX - double free sigabrt handling */
 
        free(*r);
        *r=NULL;
-       return 0;
+       return BUNDLE_ERROR_NONE;
 }
 
 bundle *
@@ -460,6 +501,8 @@ bundle_decode(const bundle_raw *r, const int data_size)
        bundle *b;
        bundle_raw *p_r;
        unsigned char *d_str;
+       gint state = 0;
+       guint save = 0;
        unsigned int d_len_raw;
        unsigned char *d_r;
        unsigned int d_len;
@@ -467,26 +510,45 @@ bundle_decode(const bundle_raw *r, const int data_size)
        gchar* compute_cksum;
 
        if(NULL == r) {
-               errno = EINVAL;
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
                return NULL;
        }
 
        extract_cksum = calloc(CHECKSUM_LENGTH+1, sizeof(char));
        if(unlikely(NULL== extract_cksum))
        {
-               errno = ENOMEM;
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
+
+       /* base 64 decode of input string
+        * Since base64 encodes 3 bytes in 4 chars (+3 may be needed in case of non-zero state)
+        * refer to: https://developer.gnome.org/glib/stable/glib-Base64-Encoding.html#g-base64-decode-step
+        */
+       d_str = malloc((data_size / 4) * 3 + 3);
+       if (unlikely(NULL == d_str)) {
+               set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
+               free(extract_cksum);
+               return NULL;
+       }
+
+       d_len_raw = g_base64_decode_step((char *)r, data_size, d_str, &state, &save);
+       if (d_len_raw < CHECKSUM_LENGTH) {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               free(d_str);
+               free(extract_cksum);
                return NULL;
        }
 
-       /* base 64 decode of input string*/
-       d_str = g_base64_decode((char*)r, &d_len_raw);
        /*extract checksum from the received string */
-       strncpy(extract_cksum,d_str,CHECKSUM_LENGTH);
+       strncpy(extract_cksum,(const char*)d_str,CHECKSUM_LENGTH);
        /* compute checksum for the data */
-       compute_cksum = g_compute_checksum_for_string(G_CHECKSUM_MD5,d_str+CHECKSUM_LENGTH,d_len_raw-CHECKSUM_LENGTH);
+       compute_cksum = g_compute_checksum_for_string(G_CHECKSUM_MD5, (const char *)(d_str+CHECKSUM_LENGTH), d_len_raw-CHECKSUM_LENGTH);
        /*compare checksum values- extracted from the received string and computed from the data */
        if(strcmp(extract_cksum,compute_cksum)!=0)
        {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               free(d_str);
                free(extract_cksum);
                g_free(compute_cksum);
                return NULL;
@@ -496,6 +558,14 @@ bundle_decode(const bundle_raw *r, const int data_size)
 
        /* re-construct bundle */
        b = bundle_create();
+       if (b == NULL)
+       {
+               free(d_str);
+               free(extract_cksum);
+               g_free(compute_cksum);
+               set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
 
        p_r = (bundle_raw *)d_r;
 
@@ -524,6 +594,7 @@ bundle_decode(const bundle_raw *r, const int data_size)
        g_free(compute_cksum);
        free(d_str);
 
+       set_last_result(BUNDLE_ERROR_NONE);
        return b;
 }
 
@@ -533,8 +604,150 @@ struct _argv_idx {
        int idx;
 };
 
+int
+bundle_encode_raw(bundle *b, bundle_raw **r, int *len)
+{
+       keyval_t *kv = NULL;
+       unsigned char *m = NULL;
+       unsigned char *p_m = NULL;
+       unsigned char *byte = NULL;
+       size_t byte_len;
+       gchar *chksum_val = NULL;
+
+       if(NULL == b || NULL == r) {
+               return BUNDLE_ERROR_INVALID_PARAMETER;
+       }
+
+       /* calculate memory size */
+       size_t msize = 0;       // Sum of required size
+
+       kv = b->kv_head;
+       while(kv != NULL) {
+               msize += kv->method->get_encoded_size(kv);
+               kv = kv->next;
+       }
+       m = calloc(msize+CHECKSUM_LENGTH, sizeof(unsigned char));
+       if(unlikely(NULL == m ))
+               return BUNDLE_ERROR_OUT_OF_MEMORY;
+
+       p_m = m+CHECKSUM_LENGTH;        /* temporary pointer */
+
+       kv = b->kv_head;
+       while(kv != NULL) {
+               byte = NULL;
+               byte_len = 0;
+
+               kv->method->encode(kv, &byte, &byte_len);
+               memcpy(p_m, byte, byte_len);
+
+               p_m += byte_len;
+               kv = kv->next;
+
+               free(byte);
+       }
+
+       /*compute checksum from the data*/
+       chksum_val = g_compute_checksum_for_string(G_CHECKSUM_MD5, (const char *)(m+CHECKSUM_LENGTH), msize);
+       /*prefix checksum to the data */
+       memcpy(m,chksum_val,CHECKSUM_LENGTH);
+       /*if ( NULL != r ) {
+               *r =(unsigned char*)g_base64_encode(m,msize+CHECKSUM_LENGTH);
+               if ( NULL != len ) *len = strlen((char*)*r);
+       }
+       free(m);*/
+       *r = m;
+       *len = msize+CHECKSUM_LENGTH;
+       g_free(chksum_val);/*free checksum string */
+
+       return BUNDLE_ERROR_NONE;
+}
+
+bundle *
+bundle_decode_raw(const bundle_raw *r, const int data_size)
+{
+       bundle *b = NULL;
+       bundle_raw *p_r = NULL;
+       unsigned char *d_str = NULL;
+       unsigned int d_len_raw;
+       unsigned char *d_r = NULL;
+       unsigned int d_len;
+       char *extract_cksum = NULL;
+       gchar* compute_cksum = NULL;
+
+       if(NULL == r) {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
+
+       extract_cksum = calloc(CHECKSUM_LENGTH+1, sizeof(char));
+       if(unlikely(NULL== extract_cksum))
+       {
+               set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
+
+       /* base 64 decode of input string*/
+       //d_str = g_base64_decode((char*)r, &d_len_raw);
+       d_str = (unsigned char *)r;
+       d_len_raw = data_size;
+       /*extract checksum from the received string */
+       strncpy(extract_cksum,(const char*)d_str,CHECKSUM_LENGTH);
+       /* compute checksum for the data */
+       compute_cksum = g_compute_checksum_for_string(G_CHECKSUM_MD5, (const char *)(d_str+CHECKSUM_LENGTH), d_len_raw-CHECKSUM_LENGTH);
+       /*compare checksum values- extracted from the received string and computed from the data */
+       if(strcmp(extract_cksum,compute_cksum)!=0)
+       {
+               free(extract_cksum);
+               g_free(compute_cksum);
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
+       d_r = d_str+CHECKSUM_LENGTH;
+       d_len= d_len_raw-CHECKSUM_LENGTH;
+
+       /* re-construct bundle */
+       b = bundle_create();
+       if (b == NULL)
+       {
+               free(extract_cksum);
+               g_free(compute_cksum);
+               set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
 
-void 
+       p_r = (bundle_raw *)d_r;
+
+       size_t bytes_read;
+       keyval_t *kv;
+
+       while(p_r < d_r + d_len - 1) {
+               kv = NULL;      // To get a new kv
+
+               // Find type, and use decode function according to type
+               int type = keyval_get_type_from_encoded_byte(p_r);
+
+               if(keyval_type_is_array(type)) {
+                       bytes_read = keyval_array_decode(p_r, (keyval_array_t **) &kv);
+               }
+               else {
+                       bytes_read = keyval_decode(p_r, &kv);
+               }
+
+               if(kv) _bundle_append_kv(b, kv);
+               else { break; }
+               p_r += bytes_read;
+       }
+
+       free(extract_cksum);
+       g_free(compute_cksum);
+       //free(d_str);
+
+       set_last_result(BUNDLE_ERROR_NONE);
+       return b;
+}
+
+
+void
 _iter_export_to_argv(const char *key, const int type, const keyval_t *kv, void *user_data)
 {
        struct _argv_idx *vi = (struct _argv_idx *)user_data;
@@ -556,7 +769,7 @@ _iter_export_to_argv(const char *key, const int type, const keyval_t *kv, void *
                BUNDLE_EXCEPTION_PRINT("bundle: failed to encode byte\n");
                return;
        }
-       
+
        vi->argv[vi->idx + 1] =(char*)encoded_byte;
        (vi->idx) += 2;
 
@@ -568,10 +781,18 @@ bundle_export_to_argv(bundle *b, char ***argv)
 {
        int argc, item_count;
 
+       if ( b == NULL || argv == NULL ) {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return -1;
+       }
+
        item_count = bundle_get_count(b);
        argc = 2 * item_count + 2;      /* 2 more count for argv[0] and arv[1] = encoded */
        *argv = calloc(argc + 1, sizeof(char *));
-       if(!*argv) return -1;
+       if(!*argv) {
+               set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
+               return -1;
+       }
 
        struct _argv_idx vi;
        vi.argc = argc;
@@ -582,48 +803,57 @@ bundle_export_to_argv(bundle *b, char ***argv)
 
        bundle_foreach(b, _iter_export_to_argv, &vi);
 
+       set_last_result(BUNDLE_ERROR_NONE);
        return argc;
 }
 
 int bundle_free_exported_argv(int argc, char ***argv)
 {
-       if(!*argv) return -1;           /*TC_FIX : fix for double free- sigabrt */
-       
+       if(1 > argc)
+               return BUNDLE_ERROR_INVALID_PARAMETER;
+
+       if (!*argv || argc < 2)
+               return BUNDLE_ERROR_INVALID_PARAMETER;
+
        int i;
-       for(i=1; i < argc; i+=2) {
-               free((*argv)[i+1]);
+       for(i=3; i < argc; i+=2) {
+               free((*argv)[i]);       /* need to free value from g_base64_encode() */
        }
 
        free(*argv);
        *argv= NULL;
-       return 0;
+       return BUNDLE_ERROR_NONE;
 }
 
-bundle *
-bundle_import_from_argv(int argc, char **argv)
+
+bundle * bundle_import_from_argv(int argc, char **argv)
 {
-       if(!argv) return NULL;  /* TC_FIX error handling for argv =NULL*/
+       if(!argv) {
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
+               return NULL;  /* TC_FIX error handling for argv =NULL*/
+       }
 
        bundle *b = bundle_create();
-       if(!b) return NULL;
-
+       if (!b) {
+               set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
+               return NULL;
+       }
 
-       /*
-       int i;
-       for(i=0; i<argc; i++) {
-               BUNDLE_LOG_PRINT("[bundle-dbg] argv[%d]='%s'\n", i, argv[i]);
+       if (argc < 2) {
+               set_last_result(BUNDLE_ERROR_NONE);
+               return b;
        }
-       */
 
-       if(!argv[1]||strcmp(argv[1],TAG_IMPORT_EXPORT_CHECK))
-       {
-       /*BUNDLE_LOG_PRINT("\nit is not encoded");*/
+
+       if (!argv[1] || strcmp(argv[1],TAG_IMPORT_EXPORT_CHECK)) {
                int idx;
                for (idx = 1; idx < argc; idx = idx + 2) {        /*start idx from one as argv[1] is user given argument*/
-                       bundle_add(b, argv[idx], argv[idx + 1]);
+                       if (idx + 1 < argc)
+                               bundle_add(b, argv[idx], argv[idx + 1]);
                }
                return b;
        }
+
        /*BUNDLE_LOG_PRINT("\nit is encoded");*/
        int idx, type;
        keyval_t *kv = NULL;
@@ -639,7 +869,11 @@ bundle_import_from_argv(int argc, char **argv)
 
                // base64_decode
                byte = g_base64_decode(encoded_byte, &byte_size);
-               if(NULL == byte) goto err_cleanup;
+               if(NULL == byte) {
+                       if(b)
+                               set_last_result(bundle_free(b));
+                       return NULL;
+               }
 
                type = keyval_get_type_from_encoded_byte(byte);
                if(keyval_type_is_array(type)) {
@@ -660,24 +894,18 @@ bundle_import_from_argv(int argc, char **argv)
                free(byte);
                byte = NULL;
        }
+       set_last_result(BUNDLE_ERROR_NONE);
        return b;
-
-
-err_cleanup:
-       if(b) bundle_free(b);
-       if(byte) free(byte);
-       return NULL;
-
 }
 
 
-int
+       int
 bundle_get_type(bundle *b, const char *key)
 {
        keyval_t *kv = _bundle_find_kv(b, key);
        if(kv) return kv->type;
        else {
-               errno = ENOKEY;
+               set_last_result(BUNDLE_ERROR_KEY_NOT_AVAILABLE);
                return BUNDLE_TYPE_NONE;
        }
 }
@@ -685,61 +913,58 @@ bundle_get_type(bundle *b, const char *key)
 // array functions
 /** Get length of an array
  */
-unsigned int
+       unsigned int
 bundle_get_array_len(bundle *b, const char *key)
 {
-       return 0;
+       return BUNDLE_ERROR_NONE;
 }
 
 /** Get size of an item in byte, of given pointer
  */
-size_t
+       size_t
 bundle_get_array_val_size(bundle *b, const char *key, const void *val_ptr)
 {
-       return 0;
+       return BUNDLE_ERROR_NONE;
 }
-/*static int
+static int
 bundle_set_array_val(bundle *b, const char *key, const int type, const unsigned int idx, const void *val, const size_t size)
 {
-       //void **array = NULL;
+//void **array = NULL;
 
        keyval_t *kv = _bundle_find_kv(b, key);
-       if(NULL == kv) return -1;
+       if(NULL == kv)
+               return get_last_result();
 
        if(type != kv->type) {
-               errno = EINVAL;
-               return -1;
+               return BUNDLE_ERROR_INVALID_PARAMETER;
        }
 
        if(! keyval_type_is_array(kv->type)) {  // TODO: Is this needed?
-               errno = EINVAL;
-               return -1;
+               return BUNDLE_ERROR_INVALID_PARAMETER;
        }
 
        keyval_array_t *kva = (keyval_array_t *)kv;
 
        if(! keyval_array_is_idx_valid(kva, idx)) {
-               errno = EINVAL;
-               return -1;
+               return BUNDLE_ERROR_INVALID_PARAMETER;
        }
 
        if(!kva->array_val) {   // NULL value test (TODO: is this needed?)
-               errno = ENOMEM;
-               return -1;
+               return BUNDLE_ERROR_INVALID_PARAMETER;
        }
 
-       return keyval_array_set_element(kva, idx, val, size);
-}*/
+       return keyval_array_set_element(kva, idx, (void *)val, size);
+}
 
 
-int
+       int
 bundle_add_str_array(bundle *b, const char *key, const char **str_array, const int len)
 {
        return _bundle_add_kv(b, key, str_array, 0, BUNDLE_TYPE_STR_ARRAY, len);
 }
 
 
-int
+       int
 bundle_get_val_array(bundle *b, const char *key, char ***str_array, int *len)
 {
        return _bundle_get_val(b, key, BUNDLE_TYPE_STR_ARRAY, (void **) str_array, NULL,(unsigned int *)len, NULL);
@@ -747,16 +972,17 @@ bundle_get_val_array(bundle *b, const char *key, char ***str_array, int *len)
 
 const char ** bundle_get_str_array(bundle *b, const char *key,int *len)
 {
+       int ret = BUNDLE_ERROR_NONE;
        const char **arr_val = NULL;
-       int r = 0;
 
-       r = bundle_get_val_array(b,key,(char***)&arr_val,len);
-       return arr_val;
+       ret = bundle_get_val_array(b,key,(char***)&arr_val,len);
+       set_last_result(ret);
 
+       return arr_val;
 }
 
 
-int
+       int
 bundle_compare(bundle *b1, bundle *b2)
 {
        if(!b1 || !b2) return -1;
@@ -776,49 +1002,45 @@ bundle_compare(bundle *b1, bundle *b2)
 
 
 
-#if 0
-int
+       int
 bundle_set_str_array_element(bundle *b, const char *key, const unsigned int idx, const char *val)
 {
        if(!val) {
-               errno = EINVAL;
-               return -1;
+               return BUNDLE_ERROR_INVALID_PARAMETER;
        }
        return bundle_set_array_val(b, key, BUNDLE_TYPE_STR_ARRAY, idx, val, strlen(val)+1);
 }
 
 
-// byte type 
-int
+// byte type
+       int
 bundle_add_byte(bundle *b, const char *key, const void *byte, const size_t size)
 {
        return _bundle_add_kv(b, key, byte, size, BUNDLE_TYPE_BYTE, 1);
 }
 
-int
+       int
 bundle_get_byte(bundle *b, const char *key, void **byte, size_t *size)
 {
        return _bundle_get_val(b, key, BUNDLE_TYPE_BYTE, (void **) byte, size, NULL, NULL);
 }
 
-int
+       int
 bundle_add_byte_array(bundle *b, const char *key, void **byte_array, const unsigned int len)
 {
        return _bundle_add_kv(b, key, byte_array, 0, BUNDLE_TYPE_BYTE_ARRAY, len);
 }
 
-int
+       int
 bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, unsigned int *len, unsigned int **array_element_size)
 {
        return _bundle_get_val(b, key, BUNDLE_TYPE_BYTE_ARRAY, (void **)byte_array, NULL, len, array_element_size);
 }
 
 
-int
+       int
 bundle_set_byte_array_element(bundle *b, const char *key, const unsigned int idx, const void *val, const size_t size)
 {
        return bundle_set_array_val(b, key, BUNDLE_TYPE_BYTE_ARRAY, idx, val, size);
 }
 
-#endif
-
index 5397f90..b43e245 100755 (executable)
@@ -29,9 +29,8 @@
 #include "keyval_type.h"
 #include "keyval.h"
 #include "bundle_log.h"
+#include "bundle.h"
 #include <stdlib.h>
-#include <errno.h>
-extern int errno;
 
 static keyval_method_collection_t method = {
        keyval_free,
@@ -47,10 +46,10 @@ keyval_new(keyval_t *kv, const char *key, const int type, const void *val, const
        int must_free_obj;
        must_free_obj = kv ? 0 : 1;
 
-       if(!kv) {       
+       if(!kv) {
                kv = calloc(1, sizeof(keyval_t));
                if(!kv) {
-                       //errno = ENOMEM;       // set by calloc
+                       set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
                        return NULL;
                }
        }
@@ -62,7 +61,7 @@ keyval_new(keyval_t *kv, const char *key, const int type, const void *val, const
        }
        kv->key = strdup(key);
        if(!kv->key) {
-               //errno = ENOMEM;       // set by strdup
+               set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
                keyval_free(kv, must_free_obj);
                return NULL;
        }
@@ -70,11 +69,11 @@ keyval_new(keyval_t *kv, const char *key, const int type, const void *val, const
        // elementa of primitive types
        kv->type = type;
        kv->size = size;
-       
+
        if(size) {
                kv->val = calloc(1, size);              // allocate memory unconditionally !
                if(!kv->val) {
-                       errno = ENOMEM;
+                       set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
                        keyval_free(kv, 1);
                        return NULL;
                }
@@ -114,8 +113,10 @@ keyval_free(keyval_t *kv, int do_free_object)
 int
 keyval_get_data(keyval_t *kv, int *type, void **val, size_t *size)
 {
-       if(!kv) return -EINVAL;
-       if(keyval_type_is_array(kv->type)) return -EINVAL;
+       if(!kv)
+               return BUNDLE_ERROR_INVALID_PARAMETER;
+       if(keyval_type_is_array(kv->type))
+               return BUNDLE_ERROR_INVALID_PARAMETER;
 
        if(type) *type = kv->type;
        if(val) *val = kv->val;
index af2aa12..fca2fad 100755 (executable)
@@ -34,7 +34,6 @@
 
 #include <stdlib.h>
 #include <string.h>
-#include <errno.h>
 
 
 static keyval_method_collection_t method = {
@@ -54,7 +53,7 @@ keyval_array_new(keyval_array_t *kva, const char *key, const int type, const voi
        if(!kva) {
                kva = calloc(1, sizeof(keyval_array_t));
                if(unlikely(NULL==kva)) {
-                       errno = ENOMEM;
+                       set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
                        return NULL;
                }
        }
@@ -63,7 +62,7 @@ keyval_array_new(keyval_array_t *kva, const char *key, const int type, const voi
        keyval_t *kv = keyval_new((keyval_t *)kva, key, type, NULL, 0);
        if(unlikely(NULL==kv))
        {
-                       errno = ENOMEM;
+                       set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
                        return NULL;
        }
 
@@ -73,20 +72,20 @@ keyval_array_new(keyval_array_t *kva, const char *key, const int type, const voi
 
        // Set array value, if exist
        if(kva->array_val) {
-               errno=EINVAL;
+               set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
                if(must_free_obj) keyval_array_free(kva, 1);
                return NULL;
        }
        kva->array_val = calloc(len, sizeof(void *));
        if(!(kva->array_val)) {
-               errno = ENOMEM;
+               set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
                keyval_array_free(kva, 1);
                return NULL;
        }
        // array_element_size
        kva->array_element_size = calloc(len, sizeof(size_t));
        if(!(kva->array_element_size)) {
-               errno = ENOMEM;
+               set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
                keyval_array_free(kva, 1);
                return NULL;
        }
@@ -168,7 +167,7 @@ keyval_array_copy_array(keyval_array_t *kva, void **array_val, unsigned int arra
        for(i=0; i < array_len; i++) {
                kva->array_val[i] = malloc(measure_size(array_val[i]));
                if(!(kva->array_val[i])) {
-                       errno = ENOMEM;
+                       set_last_result(BUNDLE_ERROR_OUT_OF_MEMORY);
                        goto cleanup_exit;
                }
                memcpy(kva->array_val[i], array_val[i], measure_size(array_val[i]));
@@ -205,16 +204,14 @@ keyval_array_set_element(keyval_array_t *kva, int idx, void *val, size_t size)
                }
                else {
                        // Error case!
-                       errno = EINVAL;
-                       return -1;
+                       return BUNDLE_ERROR_INVALID_PARAMETER;
                }
        }
        else {
                // Normal case. Copy value into the array.
                kva->array_val[idx] = malloc(size);
                if(!(kva->array_val[idx])) {
-                       errno = ENOMEM;
-                       return -1;
+                       return BUNDLE_ERROR_OUT_OF_MEMORY;
                }
                if(val) {
                        memcpy(kva->array_val[idx], val, size); // val
@@ -222,16 +219,18 @@ keyval_array_set_element(keyval_array_t *kva, int idx, void *val, size_t size)
                }
        }
 
-       return 0;
+       return BUNDLE_ERROR_NONE;
 }
 
 int
 keyval_array_get_data(keyval_array_t *kva, int *type,
                void ***array_val, unsigned int *len, size_t **array_element_size)
 {
-       if(!kva) return -EINVAL;
+       if(!kva)
+               return BUNDLE_ERROR_INVALID_PARAMETER;
        keyval_t *kv = (keyval_t *)kva;
-       if(!keyval_type_is_array(kv->type)) return -EINVAL;
+       if(!keyval_type_is_array(kv->type))
+               return BUNDLE_ERROR_INVALID_PARAMETER;
        
        // Return values
        if(type) *type = kv->type;
@@ -239,7 +238,7 @@ keyval_array_get_data(keyval_array_t *kva, int *type,
        if(len) *len = kva->len;
        if(array_element_size) *array_element_size = kva->array_element_size;
 
-       return 0;
+       return BUNDLE_ERROR_NONE;
 }
 
 size_t
@@ -274,10 +273,6 @@ keyval_array_encode(keyval_array_t *kva, void **byte, size_t *byte_len)
        size_t sz_key = strlen(kv->key) + 1;
        static const unsigned int sz_len = sizeof(int);
        size_t sz_array_element_size = kva->len * sizeof(size_t);
-       size_t sz_array_val = 0;
-       for(i=0; i < kva->len; i++) {
-               sz_array_val += kva->array_element_size[i];
-       }
 
        // Allocate memory
        *byte_len = keyval_array_get_encoded_size(kva);
index 38db370..0f69eee 100755 (executable)
 void
 keyval_type_init(void)
 {
-       static int is_done;
-       is_done = 0;
+       static int is_done = 0;
+
        if(is_done) return;
 
        // Still do nothing
-       
        is_done = 1;
 }
 
index 03e0c26..b4d8742 100755 (executable)
@@ -354,7 +354,8 @@ int TC_bundle_export_to_argv_invalid()
        char **argv1=NULL;
 
 /*CASE1:INVALID b= null,FIXED : segmentation fault in(put check for bundle=null) bundle_foreach (b=0x0, iter=0x4001322c <_iter_export_to_argv>, user_data=0xbead0a24)*/        
-       argc1=bundle_export_to_argv(b_null,&argv1);     
+       argc1 = bundle_export_to_argv(b_null,&argv1);
+       assert( argc1 >= 0);
        return SUCCESS;
 
 }