extern "C" {
# endif
-#define API __attribute__((visibility("default")))
-#define likely(x) __builtin_expect(x, 1)
-#define unlikely(x) __builtin_expect(x, 0)
-
/**
* @brief Enumeration for error codes of Bundle.
* @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
bundle_free(b); // Free the bundle
* @endcode
*/
-API bundle *bundle_create(void);
+bundle *bundle_create(void);
/**
bundle_free(b); // Free the bundle
* @endcode
*/
-API int bundle_free(bundle *b);
+int bundle_free(bundle *b);
/**
bundle_free(b);
* @endcode
*/
-API int bundle_add_str_array(bundle *b, const char *key, const char **str_array, const int len);
+int bundle_add_str_array(bundle *b, const char *key, const char **str_array, const int len);
/**
bundle_free(b);
* @endcode
*/
-API int bundle_del(bundle *b, const char *key);
+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);
+const char **bundle_get_str_array(bundle *b, const char *key, int *len);
/**
bundle_free(b);
* @endcode
*/
-API int bundle_get_count(bundle *b);
+int bundle_get_count(bundle *b);
/**
* @pre @a b must be a valid bundle object.
* @see bundle_type_t
*/
-API int bundle_get_type(bundle *b, const char *key);
+int bundle_get_type(bundle *b, const char *key);
/**
bundle_free(b_dup);
* @endcode
*/
-API bundle *bundle_dup(bundle *b_from);
+bundle *bundle_dup(bundle *b_from);
/**
}
* @endcode
*/
-API void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data);
+void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data);
/**
* @pre @a kv must be a valid bundle_keyval_t object.
* @see bundle_foreach()
*/
-API int bundle_keyval_get_type(bundle_keyval_t *kv);
+int bundle_keyval_get_type(bundle_keyval_t *kv);
/**
* @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);
+int bundle_keyval_type_is_array(bundle_keyval_t *kv);
/**
* @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);
+int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *size);
/**
* @post @a array_val, @a array_len, @a array_element_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);
+int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val, unsigned int *array_len, size_t **array_element_size);
/**
bundle_free(b);
* @endcode
*/
-API int bundle_encode(bundle *b, bundle_raw **r, int *len);
+int bundle_encode(bundle *b, bundle_raw **r, int *len);
/**
bundle_free(b_dup);
* @endcode
*/
-API bundle *bundle_decode(const bundle_raw *r, const int len);
+bundle *bundle_decode(const bundle_raw *r, const int len);
/**
bundle_free(b);
* @endcode
*/
-API int bundle_add_str(bundle *b, const char *key, const char *str);
+int bundle_add_str(bundle *b, const char *key, const char *str);
/**
bundle_free(b);
* @endcode
*/
-API int bundle_add_byte(bundle *b, const char *key, const void *bytes, const size_t size);
+int bundle_add_byte(bundle *b, const char *key, const void *bytes, const size_t size);
/**
v = NULL;
* @endcode
*/
-API int bundle_get_str(bundle *b, const char *key, char **str);
+int bundle_get_str(bundle *b, const char *key, char **str);
/**
bundle_free(b); // After freeing b, v and n become a dangling pointer
* @endcode
*/
-API int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size);
+int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size);
/**
* @brief Adds an 'array of byte sequences' type key-value pair into a bundle.
* @see bundle_get_byte_array()
* @see bundle_set_byte_array_element()
*/
-API int bundle_add_byte_array(bundle *b, const char *key, const unsigned int len);
+int bundle_add_byte_array(bundle *b, const char *key, const unsigned int len);
/**
* @brief Sets an element of an array of byte sequences.
* @see bundle_add_byte_array()
* @see bundle_get_byte_array()
*/
-API int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned int idx, const void *bytes, const size_t size);
+int bundle_set_byte_array_element(bundle *b, const char *key, const unsigned int idx, const void *bytes, const size_t size);
/**
* @brief Gets the array of byte sequences with the given key.
* @see bundle_add_byte_array()
* @see bundle_set_byte_array_element()
*/
-API int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, unsigned int *len, unsigned int **array_element_size);
+int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array, unsigned int *len, unsigned int **array_element_size);
#ifdef __cplusplus
}
* @{
*/
-#include "bundle.h"
+#include <bundle.h>
#ifdef __cplusplus
extern "C" {
bundle_free(b);
@endcode
*/
-API int bundle_add(bundle *b, const char *key, const char *val);
+int bundle_add(bundle *b, const char *key, const char *val);
/**
* @brief Gets a value with a given key.
val = NULL;
@endcode
*/
-API const char *bundle_get_val(bundle *b, const char *key);
+const char *bundle_get_val(bundle *b, const char *key);
/**
* @brief Iterates a callback function for each key-value pairs in a given bundle.
}
@endcode
*/
-API void bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *cb_data);
+void bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *cb_data);
/**
* @brief Determines whether the type of a key-value pair is measurable.
* @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);
+int bundle_keyval_type_is_measurable(bundle_keyval_t *kv);
/**
* @brief Duplicates key-value pair.
* @retval @c NULL - Failure
* @pre @a kv must be a valid bundle_keyval_t object.
*/
-API bundle_keyval_t *bundle_keyval_dup(const bundle_keyval_t *kv);
+bundle_keyval_t *bundle_keyval_dup(const bundle_keyval_t *kv);
/**
* @brief Frees the encoded rawdata.
* @pre @a r is a valid rawdata generated by bundle_encode().
* @see bundle_encode()
*/
-API int bundle_free_encoded_rawdata(bundle_raw **r);
+int bundle_free_encoded_rawdata(bundle_raw **r);
/**
* @brief Encodes a bundle to the bundle_raw format.
bundle_free(b);
@endcode
*/
-API int bundle_encode_raw(bundle *b, bundle_raw **r, int *len);
+int bundle_encode_raw(bundle *b, bundle_raw **r, int *len);
/**
* @brief Deserializes bundle_raw and gets a bundle object.
bundle_free(b_dup);
@endcode
*/
-API bundle *bundle_decode_raw(const bundle_raw *r, const int len);
+bundle *bundle_decode_raw(const bundle_raw *r, const int len);
/**
* @brief Exports bundle to @a argv.
bundle_free(b);
@endcode
*/
-API int bundle_export_to_argv(bundle *b, char ***argv);
+int bundle_export_to_argv(bundle *b, char ***argv);
/**
* @brief Frees the exported @a argv.
bundle_free(b);
@endcode
*/
-API int bundle_free_exported_argv(int argc, char ***argv);
+int bundle_free_exported_argv(int argc, char ***argv);
/**
* @brief Imports a bundle from @a argv.
}
@endcode
*/
-API bundle *bundle_import_from_argv(int argc, char **argv);
+bundle *bundle_import_from_argv(int argc, char **argv);
/**
* @brief Sets a value of string array elements.
bundle_free(b);
@endcode
*/
-API int bundle_set_str_array_element(bundle *b, const char *key, const unsigned int idx, const char *val);
+int bundle_set_str_array_element(bundle *b, const char *key, const unsigned int idx, const char *val);
/**
* @brief Creates a JSON data from bundle.
free(json);
@endcode
*/
-API int bundle_to_json(bundle *b, char **json);
+int bundle_to_json(bundle *b, char **json);
/**
* @breif Creates a bundle object from json.
bundle_free(b);
@endcode
*/
-API int bundle_from_json(const char *json, bundle **b);
+int bundle_from_json(const char *json, bundle **b);
/**
* @breif Compares the bundle 1, 2.
* @retval @c -1 Invalid parameter
* @retval @c 1 It is not identical
*/
-API int bundle_compare(bundle *b1, bundle *b2);
+int bundle_compare(bundle *b1, bundle *b2);
/**
* @brief Initializes a byte array type key-value pair into a bundle.
*
* @see bundle_set_byte_array_element()
*/
-API int bundle_init_byte_array(bundle *b, const char *key, const unsigned int len);
+int bundle_init_byte_array(bundle *b, const char *key, const unsigned int len);
#ifdef __cplusplus
}
#include "bundle.h"
#include "bundle_internal.h"
+#include "bundle_log.h"
+#include "bundle_private.h"
#include "keyval.h"
#include "keyval_array.h"
#include "keyval_type.h"
-#include "bundle_log.h"
#define CHECKSUM_LENGTH 32
#define TAG_IMPORT_EXPORT_CHECK "`zaybxcwdveuftgsh`"
}
/* APIs */
-bundle *bundle_create(void)
+API bundle *bundle_create(void)
{
bundle *b = NULL;
return NULL;
}
-int bundle_free(bundle *b)
+API int bundle_free(bundle *b)
{
keyval_t *kv;
keyval_t *tmp_kv;
return BUNDLE_ERROR_NONE;
}
-int bundle_add_str(bundle *b, const char *key, const char *str)
+API int bundle_add_str(bundle *b, const char *key, const char *str)
{
if (!str)
return BUNDLE_ERROR_INVALID_PARAMETER;
return _bundle_add_kv(b, key, str, strlen(str) + 1, BUNDLE_TYPE_STR, 1);
}
-int bundle_get_str(bundle *b, const char *key, char **str)
+API int bundle_get_str(bundle *b, const char *key, char **str)
{
return _bundle_get_val(b, key, BUNDLE_TYPE_STR, (void **)str,
NULL, NULL, NULL);
}
-int bundle_add(bundle *b, const char *key, const char *val)
+API int bundle_add(bundle *b, const char *key, const char *val)
{
return bundle_add_str(b, key, val);
}
-int bundle_del(bundle *b, const char *key)
+API int bundle_del(bundle *b, const char *key)
{
keyval_t *kv;
keyval_t *prev_kv = NULL;
return BUNDLE_ERROR_NONE;
}
-const char *bundle_get_val(bundle *b, const char *key)
+API const char *bundle_get_val(bundle *b, const char *key)
{
char *val = NULL;
int ret = BUNDLE_ERROR_NONE;
*count += 1;
}
-int bundle_get_count(bundle *b)
+API int bundle_get_count(bundle *b)
{
int count = 0;
return count;
}
-void bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *data)
+API void bundle_iterate(bundle *b, bundle_iterate_cb_t callback, void *data)
{
keyval_t *kv;
set_last_result(BUNDLE_ERROR_NONE);
}
-void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data)
+API void bundle_foreach(bundle *b, bundle_iterator_t iter, void *user_data)
{
keyval_t *kv;
}
/* keyval functions */
-int bundle_keyval_get_type(bundle_keyval_t *kv)
+API int bundle_keyval_get_type(bundle_keyval_t *kv)
{
if (kv == NULL) {
set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
return kv->type;
}
-int bundle_keyval_type_is_array(bundle_keyval_t *kv)
+API int bundle_keyval_type_is_array(bundle_keyval_t *kv)
{
if (kv == NULL) {
set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
return keyval_type_is_array(kv->type);
}
-int bundle_keyval_type_is_measurable(bundle_keyval_t *kv)
+API int bundle_keyval_type_is_measurable(bundle_keyval_t *kv)
{
if (kv == NULL) {
set_last_result(BUNDLE_ERROR_INVALID_PARAMETER);
return keyval_type_is_measurable(kv->type);
}
-int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val, size_t *size)
+API int bundle_keyval_get_basic_val(bundle_keyval_t *kv, void **val,
+ size_t *size)
{
return keyval_get_data(kv, NULL, val, size);
}
-int bundle_keyval_get_array_val(bundle_keyval_t *kv, void ***array_val,
+API 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);
}
-bundle_keyval_t *bundle_keyval_dup(const bundle_keyval_t *kv)
+API bundle_keyval_t *bundle_keyval_dup(const bundle_keyval_t *kv)
{
bundle_keyval_t *ret_kv = NULL;
void *byte = NULL;
return ret_kv;
}
-bundle *bundle_dup(bundle *b_from)
+API bundle *bundle_dup(bundle *b_from)
{
bundle *b_to;
keyval_t *kv_from;
return NULL;
}
-int bundle_encode(bundle *b, bundle_raw **r, int *len)
+API int bundle_encode(bundle *b, bundle_raw **r, int *len)
{
keyval_t *kv;
unsigned char *m;
return BUNDLE_ERROR_NONE;
}
-int bundle_free_encoded_rawdata(bundle_raw **r)
+API int bundle_free_encoded_rawdata(bundle_raw **r)
{
if (!*r)
return BUNDLE_ERROR_INVALID_PARAMETER; /* TC_FIX - double free sigabrt handling */
return BUNDLE_ERROR_NONE;
}
-bundle *bundle_decode(const bundle_raw *r, const int data_size)
+API bundle *bundle_decode(const bundle_raw *r, const int data_size)
{
bundle *b;
bundle_raw *p_r;
int idx;
};
-int bundle_encode_raw(bundle *b, bundle_raw **r, int *len)
+API int bundle_encode_raw(bundle *b, bundle_raw **r, int *len)
{
keyval_t *kv = NULL;
unsigned char *m = NULL;
return BUNDLE_ERROR_NONE;
}
-bundle *bundle_decode_raw(const bundle_raw *r, const int data_size)
+API bundle *bundle_decode_raw(const bundle_raw *r, const int data_size)
{
bundle *b = NULL;
bundle_raw *p_r = NULL;
free(byte);
}
-int bundle_export_to_argv(bundle *b, char ***argv)
+API int bundle_export_to_argv(bundle *b, char ***argv)
{
struct _argv_idx vi;
int argc;
return argc;
}
-int bundle_free_exported_argv(int argc, char ***argv)
+API int bundle_free_exported_argv(int argc, char ***argv)
{
int i;
return BUNDLE_ERROR_NONE;
}
-bundle *bundle_import_from_argv(int argc, char **argv)
+API bundle *bundle_import_from_argv(int argc, char **argv)
{
int idx;
int type;
return b;
}
-int bundle_get_type(bundle *b, const char *key)
+API int bundle_get_type(bundle *b, const char *key)
{
keyval_t *kv = _bundle_find_kv(b, key);
return keyval_array_set_element(kva, idx, (void *)val, size);
}
-int bundle_add_str_array(bundle *b, const char *key, const char **str_array,
+API 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);
}
/* LCOV_EXCL_STOP */
-const char **bundle_get_str_array(bundle *b, const char *key, int *len)
+API const char **bundle_get_str_array(bundle *b, const char *key, int *len)
{
int ret = BUNDLE_ERROR_NONE;
const char **arr_val = NULL;
}
/* LCOV_EXCL_START */
-int bundle_compare(bundle *b1, bundle *b2)
+API int bundle_compare(bundle *b1, bundle *b2)
{
keyval_t *kv1;
keyval_t *kv2;
}
/* LCOV_EXCL_STOP */
-int bundle_set_str_array_element(bundle *b, const char *key,
+API int bundle_set_str_array_element(bundle *b, const char *key,
const unsigned int idx, const char *val)
{
if (!val)
idx, val, strlen(val) + 1);
}
-int bundle_add_byte(bundle *b, const char *key, const void *bytes,
+API int bundle_add_byte(bundle *b, const char *key, const void *bytes,
const size_t size)
{
return _bundle_add_kv(b, key, bytes, size, BUNDLE_TYPE_BYTE, 1);
}
-int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size)
+API int bundle_get_byte(bundle *b, const char *key, void **bytes, size_t *size)
{
return _bundle_get_val(b, key, BUNDLE_TYPE_BYTE, (void **)bytes,
size, NULL, NULL);
}
-int bundle_add_byte_array(bundle *b, const char *key, const unsigned int len)
+API int bundle_add_byte_array(bundle *b, const char *key,
+ const unsigned int len)
{
return bundle_init_byte_array(b, key, len);
}
-int bundle_init_byte_array(bundle *b, const char *key, const unsigned int len)
+API int bundle_init_byte_array(bundle *b, const char *key,
+ const unsigned int len)
{
return _bundle_add_kv(b, key, NULL, 0, BUNDLE_TYPE_BYTE_ARRAY, len);
}
-int bundle_get_byte_array(bundle *b, const char *key, void ***byte_array,
+API 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, (size_t **)array_element_size);
+ int ret;
+
+ ret = _bundle_get_val(b, key, BUNDLE_TYPE_BYTE_ARRAY,
+ (void **)byte_array, NULL, len,
+ (size_t **)array_element_size);
+ return ret;
}
-int bundle_set_byte_array_element(bundle *b, const char *key,
+API int bundle_set_byte_array_element(bundle *b, const char *key,
const unsigned int idx, const void *bytes, const size_t size)
{
return bundle_set_array_val(b, key, BUNDLE_TYPE_BYTE_ARRAY,
#include "bundle.h"
#include "bundle_internal.h"
+#include "bundle_private.h"
static void __add_json_data_from_bundle(const char *key,
const int type,
}
}
-int bundle_to_json(bundle *b, char **json)
+API int bundle_to_json(bundle *b, char **json)
{
JsonObject *object;
JsonNode *node;
}
}
-int bundle_from_json(const char *json, bundle **b)
+API int bundle_from_json(const char *json, bundle **b)
{
GError *error = NULL;
JsonParser *parser;
--- /dev/null
+/*
+ * Copyright (c) 2020 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 __BUNDLE_PRIVATE_H__
+#define __BUNDLE_PRIVATE_H__
+
+#ifdef API
+#undef API
+#endif
+#define API __attribute__((visibility("default")))
+
+#ifdef likely
+#undef likely
+#endif
+#define likely(x) __builtin_expect(x, 1)
+
+#ifdef unlikely
+#undef unlikely
+#endif
+#define unlikely(x) __builtin_expect(x, 0)
+
+#endif /* __BUNDLE_PRIVATE_H__ */
#include <stdlib.h>
#include <string.h>
-#include "keyval_array.h"
-#include "keyval.h"
-#include "keyval_type.h"
#include "bundle.h"
#include "bundle_log.h"
+#include "bundle_private.h"
+#include "keyval.h"
+#include "keyval_array.h"
+#include "keyval_type.h"
static keyval_method_collection_t method = {
(keyval_method_free_t) keyval_array_free,