summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2009-07-02 12:52:32 -0400
committerStephen Gallagher <sgallagh@redhat.com>2009-07-02 20:02:27 -0400
commit09c4b073ca0bdf8d208cbcc7e84a7d33629213d2 (patch)
treeeec88a1aeac5ac25f1e9e9cf77c90093c7c8c125 /common
parentbe22e71411a8dd25b452f4ebdd91d840b503d394 (diff)
downloadsssd-09c4b073ca0bdf8d208cbcc7e84a7d33629213d2.tar.gz
sssd-09c4b073ca0bdf8d208cbcc7e84a7d33629213d2.tar.bz2
sssd-09c4b073ca0bdf8d208cbcc7e84a7d33629213d2.zip
Changing function names for collection API.
Patch prepends prefix "col_" to all functions related to collection. This caused some formatiing issues so the alignement was addressed too.
Diffstat (limited to 'common')
-rw-r--r--common/collection/collection.c1122
-rw-r--r--common/collection/collection.h827
-rw-r--r--common/collection/collection_cnv.c1512
-rw-r--r--common/collection/collection_queue.c182
-rw-r--r--common/collection/collection_queue.h68
-rw-r--r--common/collection/collection_queue_ut.c36
-rw-r--r--common/collection/collection_stack.c180
-rw-r--r--common/collection/collection_stack.h69
-rw-r--r--common/collection/collection_stack_ut.c44
-rw-r--r--common/collection/collection_tools.c206
-rw-r--r--common/collection/collection_tools.h54
-rw-r--r--common/collection/collection_ut.c726
-rw-r--r--common/ini/ini_config.c274
-rw-r--r--common/ini/ini_config_ut.c176
14 files changed, 2778 insertions, 2698 deletions
diff --git a/common/collection/collection.c b/common/collection/collection.c
index f7918879..b0bee08f 100644
--- a/common/collection/collection.c
+++ b/common/collection/collection.c
@@ -74,67 +74,67 @@ struct collection_item dummy = { NULL, "", 0, COL_TYPE_END, 0, NULL };
/******************** FUNCTION DECLARATIONS ****************************/
/* Have to declare those due to function cross referencing */
-static int find_item_and_do(struct collection_item *ci,
- const char *property_to_find,
- int type,
- int mode_flags,
- item_fn item_handler,
- void *custom_data,
- int action);
+static int col_find_item_and_do(struct collection_item *ci,
+ const char *property_to_find,
+ int type,
+ int mode_flags,
+ col_item_fn item_handler,
+ void *custom_data,
+ int action);
/* Traverse callback for find & delete function */
-static int act_traverse_handler(struct collection_item *head,
- struct collection_item *previous,
- struct collection_item *current,
- void *passed_traverse_data,
- item_fn user_item_handler,
- void *custom_data,
- int *stop);
+static int col_act_traverse_handler(struct collection_item *head,
+ struct collection_item *previous,
+ struct collection_item *current,
+ void *passed_traverse_data,
+ col_item_fn user_item_handler,
+ void *custom_data,
+ int *stop);
/* Traverse handler to find parent of the item */
-static int parent_traverse_handler(struct collection_item *head,
- struct collection_item *previous,
- struct collection_item *current,
- void *traverse_data,
- item_fn user_item_handler,
- void *custom_data,
- int *stop);
+static int col_parent_traverse_handler(struct collection_item *head,
+ struct collection_item *previous,
+ struct collection_item *current,
+ void *traverse_data,
+ col_item_fn user_item_handler,
+ void *custom_data,
+ int *stop);
/* Traverse callback signature */
typedef int (*internal_item_fn)(struct collection_item *head,
struct collection_item *previous,
struct collection_item *current,
void *traverse_data,
- item_fn user_item_handler,
+ col_item_fn user_item_handler,
void *custom_data,
int *stop);
/* Function to walk_items */
-static int walk_items(struct collection_item *ci,
- int mode_flags,
- internal_item_fn traverse_handler,
- void *traverse_data,
- item_fn user_item_handler,
- void *custom_data);
+static int col_walk_items(struct collection_item *ci,
+ int mode_flags,
+ internal_item_fn traverse_handler,
+ void *traverse_data,
+ col_item_fn user_item_handler,
+ void *custom_data);
/* Function to get sub collection */
-static int get_subcollection(const char *property,
- int property_len,
- int type,
- void *data,
- int length,
- void *found,
- int *dummy);
+static int col_get_subcollection(const char *property,
+ int property_len,
+ int type,
+ void *data,
+ int length,
+ void *found,
+ int *dummy);
/* Function to destroy collection */
-void destroy_collection(struct collection_item *ci);
+void col_destroy_collection(struct collection_item *ci);
/******************** SUPPLEMENTARY FUNCTIONS ****************************/
/* BASIC OPERATIONS */
/* Function that checks if property can be added */
-static int validate_property(const char *property)
+static int col_validate_property(const char *property)
{
- TRACE_FLOW_STRING("validate_property", "Entry point.");
+ TRACE_FLOW_STRING("col_validate_property", "Entry point.");
/* Only alpha numeric characters are allowed in names of the properties */
int invalid = 0;
const char *check;
@@ -147,19 +147,19 @@ static int validate_property(const char *property)
}
check++;
}
- TRACE_FLOW_NUMBER("validate_property. Returning ", invalid);
+ TRACE_FLOW_NUMBER("col_validate_property. Returning ", invalid);
return invalid;
}
/* Function that cleans the item */
-void delete_item(struct collection_item *item)
+void col_delete_item(struct collection_item *item)
{
struct collection_item *other_collection;
- TRACE_FLOW_STRING("delete_item","Entry point.");
+ TRACE_FLOW_STRING("col_delete_item","Entry point.");
if (item == NULL) {
- TRACE_FLOW_STRING("delete_item","Nothing to delete!");
+ TRACE_FLOW_STRING("col_delete_item","Nothing to delete!");
return;
}
@@ -168,7 +168,7 @@ void delete_item(struct collection_item *item)
/* Our data is a pointer to a whole external collection so dereference
* it or delete */
other_collection = *((struct collection_item **)(item->data));
- destroy_collection(other_collection);
+ col_destroy_collection(other_collection);
}
TRACE_INFO_STRING("Deleting property:", item->property);
@@ -179,27 +179,27 @@ void delete_item(struct collection_item *item)
free(item);
- TRACE_FLOW_STRING("delete_item","Exit.");
+ TRACE_FLOW_STRING("col_delete_item","Exit.");
}
/* A generic function to allocate a property item */
-static int allocate_item(struct collection_item **ci, const char *property,
- void *item_data,int length, int type)
+static int col_allocate_item(struct collection_item **ci, const char *property,
+ void *item_data,int length, int type)
{
struct collection_item *item = NULL;
int error = 0;
errno = 0;
- TRACE_FLOW_STRING("allocate_item", "Entry point.");
+ TRACE_FLOW_STRING("col_allocate_item", "Entry point.");
TRACE_INFO_NUMBER("Will be using type:", type);
/* Check the length */
if (length >= COL_MAX_DATA) {
- TRACE_ERROR_STRING("allocate_item", "Data to long.");
+ TRACE_ERROR_STRING("col_allocate_item", "Data to long.");
return EMSGSIZE;
}
- if (validate_property(property)) {
+ if (col_validate_property(property)) {
TRACE_ERROR_STRING("Invalid chracters in the property name", property);
return EINVAL;
}
@@ -208,7 +208,7 @@ static int allocate_item(struct collection_item **ci, const char *property,
item = (struct collection_item *)malloc(sizeof(struct collection_item));
if (item == NULL) {
error = errno;
- TRACE_ERROR_STRING("allocate_item", "Malloc failed.");
+ TRACE_ERROR_STRING("col_allocate_item", "Malloc failed.");
return error;
}
@@ -219,8 +219,8 @@ static int allocate_item(struct collection_item **ci, const char *property,
item->property = strdup(property);
if (item->property == NULL) {
error = errno;
- TRACE_ERROR_STRING("allocate_item", "Failed to dup property.");
- delete_item(item);
+ TRACE_ERROR_STRING("col_allocate_item", "Failed to dup property.");
+ col_delete_item(item);
return error;
}
@@ -240,8 +240,8 @@ static int allocate_item(struct collection_item **ci, const char *property,
/* Deal with data */
item->data = malloc(length);
if (item->data == NULL) {
- TRACE_ERROR_STRING("allocate_item", "Failed to dup data.");
- delete_item(item);
+ TRACE_ERROR_STRING("col_allocate_item", "Failed to dup data.");
+ col_delete_item(item);
return errno;
}
memcpy(item->data, item_data, length);
@@ -259,7 +259,7 @@ static int allocate_item(struct collection_item **ci, const char *property,
TRACE_INFO_STRING("Item property", item->property);
TRACE_INFO_NUMBER("Item property type", item->type);
TRACE_INFO_NUMBER("Item data length", item->length);
- TRACE_FLOW_STRING("allocate_item", "Success exit.");
+ TRACE_FLOW_STRING("col_allocate_item", "Success exit.");
return 0;
}
@@ -276,17 +276,18 @@ struct property_search {
};
/* Find the parent of the item with given name */
-static int find_property(struct collection_item *collection,
- const char *refprop,
- int index,
- int use_type,
- int type,
- struct collection_item **parent)
+static int col_find_property(struct collection_item *collection,
+ const char *refprop,
+ int index,
+ int use_type,
+ int type,
+ struct collection_item **parent)
{
- TRACE_FLOW_STRING("find_property", "Entry.");
struct property_search ps;
int i = 0;
+ TRACE_FLOW_STRING("col_find_property", "Entry.");
+
*parent = NULL;
ps.property = refprop;
@@ -306,36 +307,37 @@ static int find_property(struct collection_item *collection,
}
/* We do not care about error here */
- (void)walk_items(collection, COL_TRAVERSE_ONELEVEL, parent_traverse_handler,
- (void *)parent, NULL, (void *)&ps);
+ (void)col_walk_items(collection, COL_TRAVERSE_ONELEVEL,
+ col_parent_traverse_handler,
+ (void *)parent, NULL, (void *)&ps);
if (*parent) {
/* Item is found in the collection */
- TRACE_FLOW_STRING("find_property", "Exit - item found");
+ TRACE_FLOW_STRING("col_find_property", "Exit - item found");
return 1;
}
/* Item is not found */
- TRACE_FLOW_STRING("find_property", "Exit - item NOT found");
+ TRACE_FLOW_STRING("col_find_property", "Exit - item NOT found");
return 0;
}
/* Insert item into the current collection */
-int insert_item_into_current(struct collection_item *collection,
- struct collection_item *item,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags)
+int col_insert_item_into_current(struct collection_item *collection,
+ struct collection_item *item,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags)
{
struct collection_header *header = NULL;
struct collection_item *parent = NULL;
struct collection_item *current = NULL;
int refindex = 0;
- TRACE_FLOW_STRING("insert_item_into_current", "Entry point");
+ TRACE_FLOW_STRING("col_insert_item_into_current", "Entry point");
/* Do best effort on the item */
if ((!item) || (item->next)) {
@@ -344,11 +346,11 @@ int insert_item_into_current(struct collection_item *collection,
}
if (collection == NULL) {
- TRACE_INFO_STRING("insert_item_into_current",
+ TRACE_INFO_STRING("col_insert_item_into_current",
"Collection accepting is NULL");
if (item->type == COL_TYPE_COLLECTION) {
/* This is a special case of self creation */
- TRACE_INFO_STRING("insert_item_into_current",
+ TRACE_INFO_STRING("col_insert_item_into_current",
"Adding header item to new collection.");
collection = item;
}
@@ -373,39 +375,39 @@ int insert_item_into_current(struct collection_item *collection,
TRACE_INFO_STRING("Insert without check", "");
break;
case COL_INSERT_DUPOVER: /* Find item and overwrite - ignore disposition */
- if (find_property(collection, item->property, 0, 0, 0, &parent)) {
+ if (col_find_property(collection, item->property, 0, 0, 0, &parent)) {
current = parent->next;
item->next = current->next;
parent->next = item;
- delete_item(current);
+ col_delete_item(current);
header->count--;
- TRACE_FLOW_STRING("insert_item_into_current", "Dup overwrite exit");
+ TRACE_FLOW_STRING("col_insert_item_into_current", "Dup overwrite exit");
return EOK;
}
/* Not found so we fall thorough and add as requested */
break;
case COL_INSERT_DUPOVERT: /* Find item by name and type and overwrite - ignore disposition */
- if (find_property(collection, item->property, 0, 1, item->type, &parent)) {
+ if (col_find_property(collection, item->property, 0, 1, item->type, &parent)) {
current = parent->next;
item->next = current->next;
parent->next = item;
- delete_item(current);
+ col_delete_item(current);
header->count--;
- TRACE_FLOW_STRING("insert_item_into_current", "Dup overwrite exit");
+ TRACE_FLOW_STRING("col_insert_item_into_current", "Dup overwrite exit");
return EOK;
}
/* Not found so we fall thorough and add as requested */
break;
- case COL_INSERT_DUPERROR: if (find_property(collection, item->property, 0, 0, 0, &parent)) {
+ case COL_INSERT_DUPERROR: if (col_find_property(collection, item->property, 0, 0, 0, &parent)) {
/* Return error */
TRACE_ERROR_NUMBER("Duplicate property", EEXIST);
return EEXIST;
}
break;
- case COL_INSERT_DUPERRORT: if (find_property(collection, item->property, 0, 1, item->type, &parent)) {
+ case COL_INSERT_DUPERRORT: if (col_find_property(collection, item->property, 0, 1, item->type, &parent)) {
/* Return error */
TRACE_ERROR_NUMBER("Duplicate property of the same type", EEXIST);
return EEXIST;
@@ -413,10 +415,10 @@ int insert_item_into_current(struct collection_item *collection,
break;
case COL_INSERT_DUPMOVE: /* Find item and delete */
- if (find_property(collection, item->property, 0, 0, 0, &parent)) {
+ if (col_find_property(collection, item->property, 0, 0, 0, &parent)) {
current = parent->next;
parent->next = current->next;
- delete_item(current);
+ col_delete_item(current);
header->count--;
}
/* Now add item according to the disposition */
@@ -425,11 +427,11 @@ int insert_item_into_current(struct collection_item *collection,
case COL_INSERT_DUPMOVET: /* Find item and delete */
TRACE_INFO_STRING("Property:", item->property);
TRACE_INFO_NUMBER("Type:", item->type);
- if (find_property(collection, item->property, 0, 1, item->type, &parent)) {
+ if (col_find_property(collection, item->property, 0, 1, item->type, &parent)) {
TRACE_INFO_NUMBER("Current:", (unsigned)(parent->next));
current = parent->next;
parent->next = current->next;
- delete_item(current);
+ col_delete_item(current);
header->count--;
}
/* Now add item according to the disposition */
@@ -468,7 +470,7 @@ int insert_item_into_current(struct collection_item *collection,
}
/* We need to find property */
- if (find_property(collection, refprop, 0, 0, 0, &parent)) {
+ if (col_find_property(collection, refprop, 0, 0, 0, &parent)) {
item->next = parent->next;
parent->next = item;
header->count++;
@@ -486,7 +488,7 @@ int insert_item_into_current(struct collection_item *collection,
}
/* We need to find property */
- if (find_property(collection, refprop, 0, 0, 0, &parent)) {
+ if (col_find_property(collection, refprop, 0, 0, 0, &parent)) {
parent = parent->next;
if (parent->next) {
/* It is not the last item */
@@ -546,7 +548,7 @@ int insert_item_into_current(struct collection_item *collection,
else refindex = index;
/* We need to find property based on index */
- if (find_property(collection, item->property, refindex, 0, 0, &parent)) {
+ if (col_find_property(collection, item->property, refindex, 0, 0, &parent)) {
item->next = parent->next;
parent->next = item;
header->count++;
@@ -570,17 +572,17 @@ int insert_item_into_current(struct collection_item *collection,
TRACE_INFO_NUMBER("Item type.", item->type);
TRACE_INFO_NUMBER("Number of items in collection now is.", header->count);
- TRACE_FLOW_STRING("insert_item_into_current", "Exit");
+ TRACE_FLOW_STRING("col_insert_item_into_current", "Exit");
return EOK;
}
/* Extract item from the current collection */
-int extract_item_from_current(struct collection_item *collection,
- int disposition,
- const char *refprop,
- int index,
- int type,
- struct collection_item **ret_ref)
+int col_extract_item_from_current(struct collection_item *collection,
+ int disposition,
+ const char *refprop,
+ int index,
+ int type,
+ struct collection_item **ret_ref)
{
struct collection_header *header = NULL;
struct collection_item *parent = NULL;
@@ -589,7 +591,7 @@ int extract_item_from_current(struct collection_item *collection,
int refindex = 0;
int use_type = 0;
- TRACE_FLOW_STRING("extract_item_current", "Entry point");
+ TRACE_FLOW_STRING("col_extract_item_from_current", "Entry point");
/* Check that collection is not empty */
if ((collection == NULL) || (collection->type != COL_TYPE_COLLECTION)) {
@@ -637,7 +639,7 @@ int extract_item_from_current(struct collection_item *collection,
/* We have to do it in two steps */
/* First find the property that is mentioned */
- if (find_property(collection, refprop, 0, use_type, type, &found)) {
+ if (col_find_property(collection, refprop, 0, use_type, type, &found)) {
/* We found the requested property */
if (found->next == collection->next) {
/* The referenced property is the first in the list */
@@ -668,7 +670,7 @@ int extract_item_from_current(struct collection_item *collection,
}
/* We need to find property */
- if (find_property(collection, refprop, 0, use_type, type, &parent)) {
+ if (col_find_property(collection, refprop, 0, use_type, type, &parent)) {
current = parent->next;
if (current->next) {
*ret_ref = current->next;
@@ -726,7 +728,7 @@ int extract_item_from_current(struct collection_item *collection,
else refindex = index;
/* We need to find property based on index */
- if (find_property(collection, refprop, refindex, use_type, type, &parent)) {
+ if (col_find_property(collection, refprop, refindex, use_type, type, &parent)) {
*ret_ref = parent->next;
parent->next = (*ret_ref)->next;
/* If we removed the last element adjust header */
@@ -753,23 +755,23 @@ int extract_item_from_current(struct collection_item *collection,
TRACE_INFO_NUMBER("Item type.", (*ret_ref)->type);
TRACE_INFO_NUMBER("Number of items in collection now is.", header->count);
- TRACE_FLOW_STRING("extract_item_from_current", "Exit");
+ TRACE_FLOW_STRING("col_extract_item_from_current", "Exit");
return EOK;
}
/* Extract item from the collection */
-int extract_item(struct collection_item *collection,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- int type,
- struct collection_item **ret_ref)
+int col_extract_item(struct collection_item *collection,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ int type,
+ struct collection_item **ret_ref)
{
struct collection_item *col = NULL;
int error = 0;
- TRACE_FLOW_STRING("extract_item", "Entry point");
+ TRACE_FLOW_STRING("col_extract_item", "Entry point");
/* Check that collection is not empty */
if ((collection == NULL) || (collection->type != COL_TYPE_COLLECTION)) {
@@ -783,11 +785,11 @@ int extract_item(struct collection_item *collection,
}
else {
TRACE_INFO_STRING("Subcollection id not null, searching", subcollection);
- error = find_item_and_do(collection, subcollection,
- COL_TYPE_COLLECTIONREF,
- COL_TRAVERSE_DEFAULT,
- get_subcollection, (void *)(&col),
- COLLECTION_ACTION_FIND);
+ error = col_find_item_and_do(collection, subcollection,
+ COL_TYPE_COLLECTIONREF,
+ COL_TRAVERSE_DEFAULT,
+ col_get_subcollection, (void *)(&col),
+ COLLECTION_ACTION_FIND);
if (error) {
TRACE_ERROR_NUMBER("Search for subcollection returned error:", error);
return error;
@@ -801,35 +803,35 @@ int extract_item(struct collection_item *collection,
}
/* Extract from the current collection */
- error = extract_item_from_current(col,
- disposition,
- refprop,
- index,
- type,
- ret_ref);
+ error = col_extract_item_from_current(col,
+ disposition,
+ refprop,
+ index,
+ type,
+ ret_ref);
if (error) {
TRACE_ERROR_NUMBER("Failed extract item into current collection", error);
return error;
}
- TRACE_FLOW_STRING("extract_item", "Exit");
+ TRACE_FLOW_STRING("col_extract_item", "Exit");
return EOK;
}
/* Insert the item into the collection or subcollection */
-int insert_item(struct collection_item *collection,
- const char *subcollection,
- struct collection_item *item,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags)
+int col_insert_item(struct collection_item *collection,
+ const char *subcollection,
+ struct collection_item *item,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags)
{
int error;
struct collection_item *acceptor = NULL;
- TRACE_FLOW_STRING("insert_item", "Entry point.");
+ TRACE_FLOW_STRING("col_insert_item", "Entry point.");
/* Do best effort on the item */
if ((!item) || (item->next)) {
@@ -849,11 +851,11 @@ int insert_item(struct collection_item *collection,
}
else {
TRACE_INFO_STRING("Subcollection id not null, searching", subcollection);
- error = find_item_and_do(collection, subcollection,
- COL_TYPE_COLLECTIONREF,
- COL_TRAVERSE_DEFAULT,
- get_subcollection, (void *)(&acceptor),
- COLLECTION_ACTION_FIND);
+ error = col_find_item_and_do(collection, subcollection,
+ COL_TYPE_COLLECTIONREF,
+ COL_TRAVERSE_DEFAULT,
+ col_get_subcollection, (void *)(&acceptor),
+ COLLECTION_ACTION_FIND);
if (error) {
TRACE_ERROR_NUMBER("Search for subcollection returned error:", error);
return error;
@@ -867,12 +869,12 @@ int insert_item(struct collection_item *collection,
}
/* Instert item to the current collection */
- error = insert_item_into_current(acceptor,
- item,
- disposition,
- refprop,
- index,
- flags);
+ error = col_insert_item_into_current(acceptor,
+ item,
+ disposition,
+ refprop,
+ index,
+ flags);
if (error) {
TRACE_ERROR_NUMBER("Failed to insert item into current collection", error);
@@ -888,68 +890,68 @@ int insert_item(struct collection_item *collection,
* This is internal function so we do not check parameters.
* See external wrapper below.
*/
-static int insert_property_with_ref_int(struct collection_item *collection,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- int type,
- void *data,
- int length,
- struct collection_item **ret_ref)
+static int col_insert_property_with_ref_int(struct collection_item *collection,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ int type,
+ void *data,
+ int length,
+ struct collection_item **ret_ref)
{
struct collection_item *item = NULL;
int error;
- TRACE_FLOW_STRING("insert_property_with_ref_int", "Entry point.");
+ TRACE_FLOW_STRING("col_insert_property_with_ref_int", "Entry point.");
/* Create a new property out of the given parameters */
- error = allocate_item(&item, property, data, length, type);
+ error = col_allocate_item(&item, property, data, length, type);
if (error) {
TRACE_ERROR_NUMBER("Failed to allocate item", error);
return error;
}
/* Send the property to the insert_item function */
- error = insert_item(collection,
- subcollection,
- item,
- disposition,
- refprop,
- index,
- flags);
+ error = col_insert_item(collection,
+ subcollection,
+ item,
+ disposition,
+ refprop,
+ index,
+ flags);
if (error) {
TRACE_ERROR_NUMBER("Failed to insert item", error);
- delete_item(item);
+ col_delete_item(item);
return error;
}
if (ret_ref) *ret_ref = item;
- TRACE_FLOW_STRING("insert_property_with_ref_int", "Exit");
+ TRACE_FLOW_STRING("col_insert_property_with_ref_int", "Exit");
return EOK;
}
/* This is public function so we need to check the validity
* of the arguments.
*/
-int insert_property_with_ref(struct collection_item *collection,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- int type,
- void *data,
- int length,
- struct collection_item **ret_ref)
+int col_insert_property_with_ref(struct collection_item *collection,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ int type,
+ void *data,
+ int length,
+ struct collection_item **ret_ref)
{
int error;
- TRACE_FLOW_STRING("insert_property_with_ref", "Entry point.");
+ TRACE_FLOW_STRING("col_insert_property_with_ref", "Entry point.");
/* Check that collection is not empty */
if (collection == NULL) {
@@ -957,33 +959,33 @@ int insert_property_with_ref(struct collection_item *collection,
return EINVAL;
}
- error = insert_property_with_ref_int(collection,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- type,
- data,
- length,
- ret_ref);
-
- TRACE_FLOW_NUMBER("insert_property_with_ref_int Returning:", error);
+ error = col_insert_property_with_ref_int(collection,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ type,
+ data,
+ length,
+ ret_ref);
+
+ TRACE_FLOW_NUMBER("col_insert_property_with_ref_int Returning:", error);
return error;
}
/* TRAVERSE HANDLERS */
/* Special handler to just set a flag if the item is found */
-static int is_in_item_handler(const char *property,
- int property_len,
- int type,
- void *data,
- int length,
- void *found,
- int *dummy)
+static int col_is_in_item_handler(const char *property,
+ int property_len,
+ int type,
+ void *data,
+ int length,
+ void *found,
+ int *dummy)
{
- TRACE_FLOW_STRING("is_in_item_handler", "Entry.");
+ TRACE_FLOW_STRING("col_is_in_item_handler", "Entry.");
TRACE_INFO_STRING("Property:", property);
TRACE_INFO_NUMBER("Property length:", property_len);
TRACE_INFO_NUMBER("Type:", type);
@@ -991,21 +993,21 @@ static int is_in_item_handler(const char *property,
*((int *)(found)) = COL_MATCH;
- TRACE_FLOW_STRING("is_in_item_handler", "Success Exit.");
+ TRACE_FLOW_STRING("col_is_in_item_handler", "Success Exit.");
return EOK;
}
/* Special handler to retrieve the sub collection */
-static int get_subcollection(const char *property,
- int property_len,
- int type,
- void *data,
- int length,
- void *found,
- int *dummy)
+static int col_get_subcollection(const char *property,
+ int property_len,
+ int type,
+ void *data,
+ int length,
+ void *found,
+ int *dummy)
{
- TRACE_FLOW_STRING("get_subcollection", "Entry.");
+ TRACE_FLOW_STRING("col_get_subcollection", "Entry.");
TRACE_INFO_STRING("Property:", property);
TRACE_INFO_NUMBER("Property length:", property_len);
TRACE_INFO_NUMBER("Type:", type);
@@ -1013,7 +1015,7 @@ static int get_subcollection(const char *property,
*((struct collection_item **)(found)) = *((struct collection_item **)(data));
- TRACE_FLOW_STRING("get_subcollection","Success Exit.");
+ TRACE_FLOW_STRING("col_get_subcollection","Success Exit.");
return EOK;
@@ -1026,22 +1028,22 @@ static int get_subcollection(const char *property,
/* Cleans the collection tree including current item. */
/* The passed in variable should not be used after the call
* as memory is freed!!! */
-static void delete_collection(struct collection_item *ci)
+static void col_delete_collection(struct collection_item *ci)
{
- TRACE_FLOW_STRING("delete_collection", "Entry.");
+ TRACE_FLOW_STRING("col_delete_collection", "Entry.");
if (ci == NULL) {
- TRACE_FLOW_STRING("delete_collection", "Nothing to do Exit.");
+ TRACE_FLOW_STRING("col_delete_collection", "Nothing to do Exit.");
return;
}
TRACE_INFO_STRING("Real work to do","");
- delete_collection(ci->next);
+ col_delete_collection(ci->next);
/* Delete this item */
- delete_item(ci);
- TRACE_FLOW_STRING("delete_collection", "Exit.");
+ col_delete_item(ci);
+ TRACE_FLOW_STRING("col_delete_collection", "Exit.");
}
@@ -1066,14 +1068,14 @@ struct find_name {
};
/* Create a new name */
-static int create_path_data(struct path_data **name_path,
- const char *name, int length,
- const char *property, int property_len)
+static int col_create_path_data(struct path_data **name_path,
+ const char *name, int length,
+ const char *property, int property_len)
{
int error = EOK;
struct path_data *new_name_path;
- TRACE_FLOW_STRING("create_path_data", "Entry.");
+ TRACE_FLOW_STRING("col_create_path_data", "Entry.");
TRACE_INFO_STRING("Constructing path from name:", name);
TRACE_INFO_STRING("Constructing path from property:", property);
@@ -1114,26 +1116,26 @@ static int create_path_data(struct path_data **name_path,
TRACE_INFO_STRING("Constructed path", new_name_path->name);
- TRACE_FLOW_NUMBER("create_path_data. Returning:", error);
+ TRACE_FLOW_NUMBER("col_create_path_data. Returning:", error);
return error;
}
/* Matching item name and type */
-static int match_item(struct collection_item *current,
- struct find_name *traverse_data)
+static int col_match_item(struct collection_item *current,
+ struct find_name *traverse_data)
{
const char *find_str;
const char *start;
const char *data_str;
- TRACE_FLOW_STRING("match_item", "Entry");
+ TRACE_FLOW_STRING("col_match_item", "Entry");
if (traverse_data->type_to_match & current->type) {
/* Check if there is any value to match */
if ((traverse_data->name_to_find == NULL) ||
(*(traverse_data->name_to_find) == '\0')) {
- TRACE_INFO_STRING("match_item",
+ TRACE_INFO_STRING("col_match_item",
"Returning MATCH because there is no search criteria!");
return COL_MATCH;
}
@@ -1159,7 +1161,7 @@ static int match_item(struct collection_item *current,
if (*(find_str-1) == '.') {
/* We matched the property but the search string is
* longer so we need to continue matching */
- TRACE_INFO_STRING("match_item",
+ TRACE_INFO_STRING("col_match_item",
"Need to continue matching");
start = traverse_data->current_path->name;
data_str = &start[traverse_data->current_path->length - 1];
@@ -1167,12 +1169,12 @@ static int match_item(struct collection_item *current,
continue;
}
else {
- TRACE_INFO_STRING("match_item","Returning NO match!");
+ TRACE_INFO_STRING("col_match_item","Returning NO match!");
return COL_NOMATCH;
}
}
else {
- TRACE_INFO_STRING("match_item","Returning MATCH!");
+ TRACE_INFO_STRING("col_match_item","Returning MATCH!");
return COL_MATCH;
}
}
@@ -1181,37 +1183,37 @@ static int match_item(struct collection_item *current,
data_str--;
find_str--;
- TRACE_INFO_NUMBER("Searching:", toupper(*find_str));
+ TRACE_INFO_NUMBER("Searching:", toupper(*find_str));
TRACE_INFO_NUMBER("Have:", toupper(*data_str));
}
}
- TRACE_FLOW_STRING("match_item","Returning NO match!");
+ TRACE_FLOW_STRING("col_match_item","Returning NO match!");
return COL_NOMATCH;
}
/* Function to delete the data that contains search path */
-static void delete_path_data(struct path_data *path)
+static void col_delete_path_data(struct path_data *path)
{
- TRACE_FLOW_STRING("delete_path_data","Entry.");
+ TRACE_FLOW_STRING("col_delete_path_data","Entry.");
if (path != NULL) {
- TRACE_INFO_STRING("delete_path_data", "Item to delete exits.");
+ TRACE_INFO_STRING("col_delete_path_data", "Item to delete exits.");
if (path->previous_path != NULL) {
- TRACE_INFO_STRING("delete_path_data",
+ TRACE_INFO_STRING("col_delete_path_data",
"But previous item to delete exits to. Nesting.");
- delete_path_data(path->previous_path);
+ col_delete_path_data(path->previous_path);
}
if (path->name != NULL) {
- TRACE_INFO_STRING("delete_path_data Deleting path:", path->name);
+ TRACE_INFO_STRING("col_delete_path_data Deleting path:", path->name);
free(path->name);
}
- TRACE_INFO_STRING("delete_path_data", "Deleting path element");
+ TRACE_INFO_STRING("col_delete_path_data", "Deleting path element");
free(path);
}
- TRACE_FLOW_STRING("delete_path_data", "Exit");
+ TRACE_FLOW_STRING("col_delete_path_data", "Exit");
}
@@ -1222,20 +1224,20 @@ static void delete_path_data(struct path_data *path)
Traverse handler accepts: current item,
user provided item handler and user provided custom data. */
/* See below defferent traverse handlers for different cases */
-static int walk_items(struct collection_item *ci,
- int mode_flags,
- internal_item_fn traverse_handler,
- void *traverse_data,
- item_fn user_item_handler,
- void *custom_data) {
-
+static int col_walk_items(struct collection_item *ci,
+ int mode_flags,
+ internal_item_fn traverse_handler,
+ void *traverse_data,
+ col_item_fn user_item_handler,
+ void *custom_data)
+{
struct collection_item *current;
struct collection_item *parent = NULL;
struct collection_item *sub;
int stop = 0;
int error = EOK;
- TRACE_FLOW_STRING("walk_items", "Entry.");
+ TRACE_FLOW_STRING("col_walk_items", "Entry.");
TRACE_INFO_NUMBER("Mode flags:", mode_flags);
current = ci;
@@ -1276,9 +1278,9 @@ static int walk_items(struct collection_item *ci,
TRACE_INFO_STRING("Sub collection name", sub->property);
TRACE_INFO_NUMBER("Header type", sub->type);
/* We need to go into sub collections */
- error = walk_items(sub, mode_flags,
- traverse_handler, traverse_data,
- user_item_handler, custom_data);
+ error = col_walk_items(sub, mode_flags,
+ traverse_handler, traverse_data,
+ user_item_handler, custom_data);
TRACE_INFO_STRING("Returned from sub collection processing", "");
TRACE_INFO_STRING("Done processing item:", current->property);
TRACE_INFO_NUMBER("Done processing item type:", current->type);
@@ -1321,7 +1323,7 @@ static int walk_items(struct collection_item *ci,
custom_data, &stop);
}
- TRACE_FLOW_NUMBER("walk_items. Returns: ", error);
+ TRACE_FLOW_NUMBER("col_walk_items. Returns: ", error);
return error;
}
@@ -1332,19 +1334,19 @@ static int walk_items(struct collection_item *ci,
/* No pattern matching supported in the first implementation. */
/* To refer to child properties use dotted notatation like this: */
/* parent.child.subchild.subsubchild etc. */
-static int find_item_and_do(struct collection_item *ci,
- const char *property_to_find,
- int type,
- int mode_flags,
- item_fn item_handler,
- void *custom_data,
- int action)
+static int col_find_item_and_do(struct collection_item *ci,
+ const char *property_to_find,
+ int type,
+ int mode_flags,
+ col_item_fn item_handler,
+ void *custom_data,
+ int action)
{
int error = EOK;
struct find_name *traverse_data = NULL;
- TRACE_FLOW_STRING("find_item_and_do", "Entry.");
+ TRACE_FLOW_STRING("col_find_item_and_do", "Entry.");
/* Item handler is always required */
if ((item_handler == NULL) &&
@@ -1370,7 +1372,7 @@ static int find_item_and_do(struct collection_item *ci,
return error;
}
- TRACE_INFO_STRING("find_item_and_do", "Filling in traverse data.");
+ TRACE_INFO_STRING("col_find_item_and_do", "Filling in traverse data.");
traverse_data->name_to_find = property_to_find;
traverse_data->name_len_to_find = strlen(property_to_find);
@@ -1382,16 +1384,16 @@ static int find_item_and_do(struct collection_item *ci,
mode_flags |= COL_TRAVERSE_END;
- TRACE_INFO_STRING("find_item_and_do", "About to walk the tree.");
+ TRACE_INFO_STRING("col_find_item_and_do", "About to walk the tree.");
TRACE_INFO_NUMBER("Traverse flags", mode_flags);
- error = walk_items(ci, mode_flags, act_traverse_handler,
- (void *)traverse_data, item_handler, custom_data);
+ error = col_walk_items(ci, mode_flags, col_act_traverse_handler,
+ (void *)traverse_data, item_handler, custom_data);
if (traverse_data->current_path != NULL) {
TRACE_INFO_STRING("find_item_and_do",
"Path was not cleared - deleting");
- delete_path_data(traverse_data->current_path);
+ col_delete_path_data(traverse_data->current_path);
}
free(traverse_data);
@@ -1407,10 +1409,10 @@ static int find_item_and_do(struct collection_item *ci,
}
/* Function to replace data in the item */
-static int update_current_item(struct collection_item *current,
- struct update_property *update_data)
+static int col_update_current_item(struct collection_item *current,
+ struct update_property *update_data)
{
- TRACE_FLOW_STRING("update_current_item", "Entry");
+ TRACE_FLOW_STRING("col_update_current_item", "Entry");
/* If type is different or same but it is string or binary we need to
* replace the storage */
@@ -1444,17 +1446,17 @@ static int update_current_item(struct collection_item *current,
/* Traverse handler for simple traverse function */
/* Handler must be able to deal with NULL current item */
-static int simple_traverse_handler(struct collection_item *head,
- struct collection_item *previous,
- struct collection_item *current,
- void *traverse_data,
- item_fn user_item_handler,
- void *custom_data,
- int *stop)
+static int col_simple_traverse_handler(struct collection_item *head,
+ struct collection_item *previous,
+ struct collection_item *current,
+ void *traverse_data,
+ col_item_fn user_item_handler,
+ void *custom_data,
+ int *stop)
{
int error = EOK;
- TRACE_FLOW_STRING("simple_traverse_handler", "Entry.");
+ TRACE_FLOW_STRING("col_simple_traverse_handler", "Entry.");
if (current == NULL) current = &dummy;
@@ -1466,33 +1468,33 @@ static int simple_traverse_handler(struct collection_item *head,
custom_data,
stop);
- TRACE_FLOW_NUMBER("simple_traverse_handler. Returning:", error);
+ TRACE_FLOW_NUMBER("col_simple_traverse_handler. Returning:", error);
return error;
}
/* Traverse handler for to find parent */
-static int parent_traverse_handler(struct collection_item *head,
- struct collection_item *previous,
- struct collection_item *current,
- void *traverse_data,
- item_fn user_item_handler,
- void *custom_data,
- int *stop)
+static int col_parent_traverse_handler(struct collection_item *head,
+ struct collection_item *previous,
+ struct collection_item *current,
+ void *traverse_data,
+ col_item_fn user_item_handler,
+ void *custom_data,
+ int *stop)
{
struct property_search *to_find;
int done = 0;
int match = 0;
- TRACE_FLOW_STRING("parent_traverse_handler", "Entry.");
+ TRACE_FLOW_STRING("col_parent_traverse_handler", "Entry.");
to_find = (struct property_search *)custom_data;
+ TRACE_INFO_NUMBER("Looking for HASH:", (unsigned)(to_find->hash));
+ TRACE_INFO_NUMBER("Current HASH:", (unsigned)(current->phash));
+
/* Check hashes first */
if(to_find->hash == current->phash) {
- TRACE_INFO_NUMBER("Looking for HASH:", (unsigned)(to_find->hash));
- TRACE_INFO_NUMBER("Current HASH:", (unsigned)(current->phash));
-
/* Check type if we are asked to use type */
if ((to_find->use_type) && (!(to_find->type & current->type))) {
TRACE_FLOW_STRING("parent_traverse_handler. Returning:","Exit. Hash is Ok, type is not");
@@ -1540,19 +1542,19 @@ static int parent_traverse_handler(struct collection_item *head,
}
- TRACE_FLOW_STRING("parent_traverse_handler. Returning:","Exit");
+ TRACE_FLOW_STRING("col_parent_traverse_handler. Returning:","Exit");
return EOK;
}
/* Traverse callback for find & delete function */
-static int act_traverse_handler(struct collection_item *head,
- struct collection_item *previous,
- struct collection_item *current,
- void *passed_traverse_data,
- item_fn user_item_handler,
- void *custom_data,
- int *stop)
+static int col_act_traverse_handler(struct collection_item *head,
+ struct collection_item *previous,
+ struct collection_item *current,
+ void *passed_traverse_data,
+ col_item_fn user_item_handler,
+ void *custom_data,
+ int *stop)
{
int error = EOK;
struct find_name *traverse_data = NULL;
@@ -1564,18 +1566,18 @@ static int act_traverse_handler(struct collection_item *head,
int property_len;
struct update_property *update_data;
- TRACE_FLOW_STRING("act_traverse_handler", "Entry.");
+ TRACE_FLOW_STRING("col_act_traverse_handler", "Entry.");
traverse_data = (struct find_name *)passed_traverse_data;
/* We can be called when current points to NULL */
if (current == NULL) {
- TRACE_INFO_STRING("act_traverse_handler",
+ TRACE_INFO_STRING("col_act_traverse_handler",
"Special call at the end of the collection.");
temp = traverse_data->current_path;
traverse_data->current_path = temp->previous_path;
temp->previous_path = NULL;
- delete_path_data(temp);
+ col_delete_path_data(temp);
traverse_data->given_name = NULL;
traverse_data->given_len = 0;
TRACE_FLOW_NUMBER("Handling end of collection - removed path. Returning:", error);
@@ -1585,7 +1587,7 @@ static int act_traverse_handler(struct collection_item *head,
/* Create new path at the beginning of a new sub collection */
if (current->type == COL_TYPE_COLLECTION) {
- TRACE_INFO_STRING("act_traverse_handler",
+ TRACE_INFO_STRING("col_act_traverse_handler",
"Processing collection handle.");
/* Create new path */
@@ -1610,12 +1612,12 @@ static int act_traverse_handler(struct collection_item *head,
property_len = current->property_len;
}
- TRACE_INFO_STRING("act_traverse_handler", "About to create path data.");
+ TRACE_INFO_STRING("col_act_traverse_handler", "About to create path data.");
- error = create_path_data(&(traverse_data->current_path),
- name, length, property, property_len);
+ error = col_create_path_data(&(traverse_data->current_path),
+ name, length, property, property_len);
- TRACE_INFO_NUMBER("create_path_data returned:", error);
+ TRACE_INFO_NUMBER("col_create_path_data returned:", error);
return error;
}
@@ -1629,7 +1631,7 @@ static int act_traverse_handler(struct collection_item *head,
TRACE_INFO_STRING("Processing item with property:", current->property);
/* Do here what we do with items */
- if (match_item(current, traverse_data)) {
+ if (col_match_item(current, traverse_data)) {
TRACE_INFO_STRING("Matched item:", current->property);
switch (traverse_data->action) {
case COLLECTION_ACTION_FIND:
@@ -1672,7 +1674,7 @@ static int act_traverse_handler(struct collection_item *head,
/* Previous can't be NULL here becuase we never delete
* header elements */
previous->next = current->next;
- delete_item(current);
+ col_delete_item(current);
TRACE_INFO_STRING("Did the delete of the item.", "");
break;
@@ -1688,7 +1690,7 @@ static int act_traverse_handler(struct collection_item *head,
if (custom_data != NULL) {
update_data = (struct update_property *)custom_data;
update_data->found = COL_MATCH;
- error = update_current_item(current, update_data);
+ error = col_update_current_item(current, update_data);
}
else {
TRACE_ERROR_STRING("Error - update data is required", "");
@@ -1704,26 +1706,26 @@ static int act_traverse_handler(struct collection_item *head,
*stop = 1;
}
- TRACE_FLOW_NUMBER("act_traverse_handler returning", error);
+ TRACE_FLOW_NUMBER("col_act_traverse_handler returning", error);
return error;
}
/* Traverse handler for copy function */
-static int copy_traverse_handler(struct collection_item *head,
- struct collection_item *previous,
- struct collection_item *current,
- void *passed_traverse_data,
- item_fn user_item_handler,
- void *custom_data,
- int *stop)
+static int col_copy_traverse_handler(struct collection_item *head,
+ struct collection_item *previous,
+ struct collection_item *current,
+ void *passed_traverse_data,
+ col_item_fn user_item_handler,
+ void *custom_data,
+ int *stop)
{
int error = EOK;
struct collection_item *parent;
struct collection_item *item;
struct collection_item *new_collection = NULL;
- TRACE_FLOW_STRING("copy_traverse_handler", "Entry.");
+ TRACE_FLOW_STRING("col_copy_traverse_handler", "Entry.");
parent = (struct collection_item *)passed_traverse_data;
@@ -1737,9 +1739,9 @@ static int copy_traverse_handler(struct collection_item *head,
TRACE_INFO_STRING("Found a subcollection we need to copy. Name:",
item->property);
- error = copy_collection(&new_collection,
- *((struct collection_item **)(item->data)),
- item->property);
+ error = col_copy_collection(&new_collection,
+ *((struct collection_item **)(item->data)),
+ item->property);
if (error) {
TRACE_ERROR_NUMBER("Copy subcollection returned error:", error);
return error;
@@ -1747,17 +1749,17 @@ static int copy_traverse_handler(struct collection_item *head,
/* Add new item to a collection
* all references are now sub collections */
- error = insert_property_with_ref_int(parent,
- NULL,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- item->property,
- COL_TYPE_COLLECTIONREF,
- (void *)(&new_collection),
- sizeof(struct collection_item **),
- NULL);
+ error = col_insert_property_with_ref_int(parent,
+ NULL,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ item->property,
+ COL_TYPE_COLLECTIONREF,
+ (void *)(&new_collection),
+ sizeof(struct collection_item **),
+ NULL);
if (error) {
TRACE_ERROR_NUMBER("Add property returned error:", error);
return error;
@@ -1765,24 +1767,24 @@ static int copy_traverse_handler(struct collection_item *head,
}
else {
- error = insert_property_with_ref_int(parent,
- NULL,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- item->property,
- item->type,
- item->data,
- item->length,
- NULL);
+ error = col_insert_property_with_ref_int(parent,
+ NULL,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ item->property,
+ item->type,
+ item->data,
+ item->length,
+ NULL);
if (error) {
TRACE_ERROR_NUMBER("Add property returned error:", error);
return error;
}
}
- TRACE_FLOW_NUMBER("copy_traverse_handler returning", error);
+ TRACE_FLOW_NUMBER("col_copy_traverse_handler returning", error);
return error;
}
@@ -1794,14 +1796,14 @@ static int copy_traverse_handler(struct collection_item *head,
/* CREATE */
/* Function that creates an named collection of a given class*/
-int create_collection(struct collection_item **ci, const char *name,
- unsigned cclass)
+int col_create_collection(struct collection_item **ci, const char *name,
+ unsigned cclass)
{
struct collection_item *handle = NULL;
struct collection_header header;
int error = EOK;
- TRACE_FLOW_STRING("create_collection", "Entry.");
+ TRACE_FLOW_STRING("col_create_collection", "Entry.");
/* Prepare header */
header.last = NULL;
@@ -1810,24 +1812,24 @@ int create_collection(struct collection_item **ci, const char *name,
header.cclass = cclass;
/* Create a collection type property */
- error = insert_property_with_ref_int(NULL,
- NULL,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- name,
- COL_TYPE_COLLECTION,
- &header,
- sizeof(header),
- &handle);
+ error = col_insert_property_with_ref_int(NULL,
+ NULL,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ name,
+ COL_TYPE_COLLECTION,
+ &header,
+ sizeof(header),
+ &handle);
if (error) return error;
*ci = handle;
- TRACE_FLOW_STRING("create_collection", "Success Exit.");
+ TRACE_FLOW_STRING("col_create_collection", "Success Exit.");
return 0;
}
@@ -1835,11 +1837,11 @@ int create_collection(struct collection_item **ci, const char *name,
/* DESTROY */
/* Function that destroys a collection */
-void destroy_collection(struct collection_item *ci)
+void col_destroy_collection(struct collection_item *ci)
{
struct collection_header *header;
- TRACE_FLOW_STRING("destroy_collection", "Entry.");
+ TRACE_FLOW_STRING("col_destroy_collection", "Entry.");
/* Do not try to delete NULL */
if (ci == NULL) return;
@@ -1860,10 +1862,10 @@ void destroy_collection(struct collection_item *ci)
header->reference_count);
}
else {
- delete_collection(ci);
+ col_delete_collection(ci);
}
- TRACE_FLOW_STRING("destroy_collection", "Exit.");
+ TRACE_FLOW_STRING("col_destroy_collection", "Exit.");
}
@@ -1874,16 +1876,16 @@ void destroy_collection(struct collection_item *ci)
/* Create a deep copy of the current collection. */
/* Referenced collections of the donor are copied as sub collections. */
-int copy_collection(struct collection_item **collection_copy,
- struct collection_item *collection_to_copy,
- const char *name_to_use)
+int col_copy_collection(struct collection_item **collection_copy,
+ struct collection_item *collection_to_copy,
+ const char *name_to_use)
{
int error = EOK;
struct collection_item *new_collection = NULL;
const char *name;
struct collection_header *header;
- TRACE_FLOW_STRING("copy_collection", "Entry.");
+ TRACE_FLOW_STRING("col_copy_collection", "Entry.");
/* Determine what name to use */
if (name_to_use != NULL)
@@ -1894,19 +1896,20 @@ int copy_collection(struct collection_item **collection_copy,
header = (struct collection_header *)collection_to_copy->data;
/* Create a new collection */
- error = create_collection(&new_collection, name, header->cclass);
+ error = col_create_collection(&new_collection, name, header->cclass);
if (error) {
- TRACE_ERROR_NUMBER("Create_cllection failed returning", error);
+ TRACE_ERROR_NUMBER("col_create_collection failed returning", error);
return error;
}
- error = walk_items(collection_to_copy, COL_TRAVERSE_ONELEVEL,
- copy_traverse_handler, new_collection, NULL, NULL);
+ error = col_walk_items(collection_to_copy, COL_TRAVERSE_ONELEVEL,
+ col_copy_traverse_handler, new_collection,
+ NULL, NULL);
if (!error) *collection_copy = new_collection;
- else destroy_collection(new_collection);
+ else col_destroy_collection(new_collection);
- TRACE_FLOW_NUMBER("copy_collection returning", error);
+ TRACE_FLOW_NUMBER("col_copy_collection returning", error);
return error;
}
@@ -1914,15 +1917,15 @@ int copy_collection(struct collection_item **collection_copy,
/* EXTRACTION */
/* Extract collection */
-int get_collection_reference(struct collection_item *ci, /* High level collection */
- struct collection_item **acceptor, /* The pointer that will accept extracted handle */
- const char *collection_to_find) /* Name to of the collection */
+int col_get_collection_reference(struct collection_item *ci,
+ struct collection_item **acceptor,
+ const char *collection_to_find)
{
struct collection_header *header;
struct collection_item *subcollection = NULL;
int error = EOK;
- TRACE_FLOW_STRING("get_collection_reference", "Entry.");
+ TRACE_FLOW_STRING("col_get_collection_reference", "Entry.");
if ((ci == NULL) ||
(ci->type != COL_TYPE_COLLECTION) ||
@@ -1935,12 +1938,12 @@ int get_collection_reference(struct collection_item *ci, /* High level
/* Find a sub collection */
TRACE_INFO_STRING("We are given subcollection name - search it:",
collection_to_find);
- error = find_item_and_do(ci, collection_to_find,
- COL_TYPE_COLLECTIONREF,
- COL_TRAVERSE_DEFAULT,
- get_subcollection,
- (void *)(&subcollection),
- COLLECTION_ACTION_FIND);
+ error = col_find_item_and_do(ci, collection_to_find,
+ COL_TYPE_COLLECTIONREF,
+ COL_TRAVERSE_DEFAULT,
+ col_get_subcollection,
+ (void *)(&subcollection),
+ COLLECTION_ACTION_FIND);
if (error) {
TRACE_ERROR_NUMBER("Search failed returning error", error);
return error;
@@ -1958,13 +1961,13 @@ int get_collection_reference(struct collection_item *ci, /* High level
TRACE_INFO_NUMBER("Ref count after increment:", header->reference_count);
*acceptor = subcollection;
- TRACE_FLOW_STRING("get_collection_reference", "Success Exit.");
+ TRACE_FLOW_STRING("col_get_collection_reference", "Success Exit.");
return EOK;
}
/* Get collection - if current item is a reference get a real collection from it. */
-int get_reference_from_item(struct collection_item *ci,
- struct collection_item **acceptor)
+int col_get_reference_from_item(struct collection_item *ci,
+ struct collection_item **acceptor)
{
struct collection_header *header;
struct collection_item *subcollection = NULL;
@@ -1987,7 +1990,7 @@ int get_reference_from_item(struct collection_item *ci,
TRACE_INFO_NUMBER("Ref count after increment:", header->reference_count);
*acceptor = subcollection;
- TRACE_FLOW_STRING("get_reference_from_item", "Success Exit.");
+ TRACE_FLOW_STRING("col_get_reference_from_item", "Success Exit.");
return EOK;
}
@@ -1995,16 +1998,11 @@ int get_reference_from_item(struct collection_item *ci,
/* Add collection to collection */
/* FIXME - allow to add collection to a collection with disposition */
-int add_collection_to_collection(
- struct collection_item *ci, /* Collection handle to with we add another collection */
- const char *sub_collection_name, /* Name of the sub collection to which
- collection needs to be added as a property.
- If NULL high level collection is assumed. */
- const char *as_property, /* Name of the collection property.
- If NULL, same property as the name of
- the collection being added will be used. */
- struct collection_item *collection_to_add, /* Collection to add */
- int mode) /* How this collection needs to be added */
+int col_add_collection_to_collection(struct collection_item *ci,
+ const char *sub_collection_name,
+ const char *as_property,
+ struct collection_item *collection_to_add,
+ int mode)
{
struct collection_item *acceptor = NULL;
const char *name_to_use;
@@ -2012,7 +2010,7 @@ int add_collection_to_collection(
struct collection_item *collection_copy;
int error = EOK;
- TRACE_FLOW_STRING("add_collection_to_collection", "Entry.");
+ TRACE_FLOW_STRING("col_add_collection_to_collection", "Entry.");
if ((ci == NULL) ||
(ci->type != COL_TYPE_COLLECTION) ||
@@ -2027,12 +2025,12 @@ int add_collection_to_collection(
/* Find a sub collection */
TRACE_INFO_STRING("We are given subcollection name - search it:",
sub_collection_name);
- error = find_item_and_do(ci, sub_collection_name,
- COL_TYPE_COLLECTIONREF,
- COL_TRAVERSE_DEFAULT,
- get_subcollection,
- (void *)(&acceptor),
- COLLECTION_ACTION_FIND);
+ error = col_find_item_and_do(ci, sub_collection_name,
+ COL_TYPE_COLLECTIONREF,
+ COL_TRAVERSE_DEFAULT,
+ col_get_subcollection,
+ (void *)(&acceptor),
+ COLLECTION_ACTION_FIND);
if (error) {
TRACE_ERROR_NUMBER("Search failed returning error", error);
return error;
@@ -2066,17 +2064,17 @@ int add_collection_to_collection(
collection_to_add->property);
/* Create a pointer to external collection */
/* For future thread safety: Transaction start -> */
- error = insert_property_with_ref_int(acceptor,
- NULL,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- name_to_use,
- COL_TYPE_COLLECTIONREF,
- (void *)(&collection_to_add),
- sizeof(struct collection_item **),
- NULL);
+ error = col_insert_property_with_ref_int(acceptor,
+ NULL,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ name_to_use,
+ COL_TYPE_COLLECTIONREF,
+ (void *)(&collection_to_add),
+ sizeof(struct collection_item **),
+ NULL);
TRACE_INFO_NUMBER("Type of the header element after adding property:",
collection_to_add->type);
@@ -2107,17 +2105,17 @@ int add_collection_to_collection(
TRACE_INFO_STRING("Header name we are adding to.",
acceptor->property);
- error = insert_property_with_ref_int(acceptor,
- NULL,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- name_to_use,
- COL_TYPE_COLLECTIONREF,
- (void *)(&collection_to_add),
- sizeof(struct collection_item **),
- NULL);
+ error = col_insert_property_with_ref_int(acceptor,
+ NULL,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ name_to_use,
+ COL_TYPE_COLLECTIONREF,
+ (void *)(&collection_to_add),
+ sizeof(struct collection_item **),
+ NULL);
TRACE_INFO_NUMBER("Adding property returned:", error);
@@ -2128,8 +2126,8 @@ int add_collection_to_collection(
TRACE_INFO_STRING("Name we will use.", name_to_use);
/* For future thread safety: Transaction start -> */
- error = copy_collection(&collection_copy,
- collection_to_add, name_to_use);
+ error = col_copy_collection(&collection_copy,
+ collection_to_add, name_to_use);
if (error) return error;
TRACE_INFO_STRING("We have a collection copy.", collection_copy->property);
@@ -2137,17 +2135,17 @@ int add_collection_to_collection(
TRACE_INFO_STRING("Acceptor collection.", acceptor->property);
TRACE_INFO_NUMBER("Acceptor collection type.", acceptor->type);
- error = insert_property_with_ref_int(acceptor,
- NULL,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- name_to_use,
- COL_TYPE_COLLECTIONREF,
- (void *)(&collection_copy),
- sizeof(struct collection_item **),
- NULL);
+ error = col_insert_property_with_ref_int(acceptor,
+ NULL,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ name_to_use,
+ COL_TYPE_COLLECTIONREF,
+ (void *)(&collection_copy),
+ sizeof(struct collection_item **),
+ NULL);
/* -> Transaction end */
TRACE_INFO_NUMBER("Adding property returned:", error);
@@ -2157,7 +2155,7 @@ int add_collection_to_collection(
error = EINVAL;
}
- TRACE_FLOW_NUMBER("add_collection_to_collection returning:", error);
+ TRACE_FLOW_NUMBER("col_add_collection_to_collection returning:", error);
return error;
}
@@ -2165,48 +2163,48 @@ int add_collection_to_collection(
/* Function to traverse the entire collection including optionally
* sub collections */
-int traverse_collection(struct collection_item *ci,
- int mode_flags,
- item_fn item_handler,
- void *custom_data)
+int col_traverse_collection(struct collection_item *ci,
+ int mode_flags,
+ col_item_fn item_handler,
+ void *custom_data)
{
int error = EOK;
- TRACE_FLOW_STRING("traverse_collection", "Entry.");
+ TRACE_FLOW_STRING("col_traverse_collection", "Entry.");
- error = walk_items(ci, mode_flags, simple_traverse_handler,
- NULL, item_handler, custom_data);
+ error = col_walk_items(ci, mode_flags, col_simple_traverse_handler,
+ NULL, item_handler, custom_data);
if ((error != 0) && (error != EINTR_INTERNAL)) {
TRACE_ERROR_NUMBER("Error walking tree", error);
return error;
}
- TRACE_FLOW_STRING("traverse_collection", "Success exit.");
+ TRACE_FLOW_STRING("col_traverse_collection", "Success exit.");
return EOK;
}
/* CHECK */
/* Convenience function to check if specific property is in the collection */
-int is_item_in_collection(struct collection_item *ci,
- const char *property_to_find,
- int type,
- int mode_flags,
- int *found)
+int col_is_item_in_collection(struct collection_item *ci,
+ const char *property_to_find,
+ int type,
+ int mode_flags,
+ int *found)
{
int error;
- TRACE_FLOW_STRING("is_item_in_collection","Entry.");
+ TRACE_FLOW_STRING("col_is_item_in_collection","Entry.");
*found = COL_NOMATCH;
- error = find_item_and_do(ci, property_to_find,
- type, mode_flags,
- is_in_item_handler,
- (void *)found,
- COLLECTION_ACTION_FIND);
+ error = col_find_item_and_do(ci, property_to_find,
+ type, mode_flags,
+ col_is_in_item_handler,
+ (void *)found,
+ COLLECTION_ACTION_FIND);
- TRACE_FLOW_NUMBER("is_item_in_collection returning", error);
+ TRACE_FLOW_NUMBER("col_is_item_in_collection returning", error);
return error;
}
@@ -2214,114 +2212,113 @@ int is_item_in_collection(struct collection_item *ci,
/* Search function. Looks up an item in the collection based on the property.
Essentually it is a traverse function with spacial traversing logic.
*/
-int get_item_and_do(struct collection_item *ci, /* Collection to find things in */
- const char *property_to_find, /* Name to match */
- int type, /* Type filter */
- int mode_flags, /* How to traverse the collection */
- item_fn item_handler, /* Function to call when the item is found */
- void *custom_data) /* Custom data passed around */
+int col_get_item_and_do(struct collection_item *ci,
+ const char *property_to_find,
+ int type,
+ int mode_flags,
+ col_item_fn item_handler,
+ void *custom_data)
{
int error = EOK;
- TRACE_FLOW_STRING("get_item_and_do","Entry.");
+ TRACE_FLOW_STRING("col_get_item_and_do","Entry.");
- error = find_item_and_do(ci, property_to_find,
- type, mode_flags,
- item_handler,
- custom_data,
- COLLECTION_ACTION_FIND);
+ error = col_find_item_and_do(ci, property_to_find,
+ type, mode_flags,
+ item_handler,
+ custom_data,
+ COLLECTION_ACTION_FIND);
- TRACE_FLOW_NUMBER("get_item_and_do returning", error);
+ TRACE_FLOW_NUMBER("col_get_item_and_do returning", error);
return error;
}
/* Get raw item */
-int get_item(struct collection_item *ci, /* Collection to find things in */
- const char *property_to_find, /* Name to match */
- int type, /* Type filter */
- int mode_flags, /* How to traverse the collection */
- struct collection_item **item) /* Found item */
+int col_get_item(struct collection_item *ci,
+ const char *property_to_find,
+ int type,
+ int mode_flags,
+ struct collection_item **item)
{
int error = EOK;
- TRACE_FLOW_STRING("get_item", "Entry.");
+ TRACE_FLOW_STRING("col_get_item", "Entry.");
- error = find_item_and_do(ci, property_to_find,
- type, mode_flags,
- NULL, (void *)item,
- COLLECTION_ACTION_GET);
+ error = col_find_item_and_do(ci, property_to_find,
+ type, mode_flags,
+ NULL, (void *)item,
+ COLLECTION_ACTION_GET);
- TRACE_FLOW_NUMBER("get_item returning", error);
+ TRACE_FLOW_NUMBER("col_get_item returning", error);
return error;
}
/* DELETE */
/* Delete property from the collection */
-int delete_property(struct collection_item *ci, /* Collection to find things in */
- const char *property_to_find, /* Name to match */
- int type, /* Type filter */
- int mode_flags) /* How to traverse the collection */
+int col_delete_property(struct collection_item *ci,
+ const char *property_to_find,
+ int type,
+ int mode_flags)
{
int error = EOK;
int found;
- TRACE_FLOW_STRING("delete_property", "Entry.");
+ TRACE_FLOW_STRING("col_delete_property", "Entry.");
found = COL_NOMATCH;
- error = find_item_and_do(ci, property_to_find,
- type, mode_flags,
- NULL, (void *)(&found),
- COLLECTION_ACTION_DEL);
+ error = col_find_item_and_do(ci, property_to_find,
+ type, mode_flags,
+ NULL, (void *)(&found),
+ COLLECTION_ACTION_DEL);
if ((error == EOK) && (found == COL_NOMATCH))
error = ENOENT;
- TRACE_FLOW_NUMBER("delete_property returning", error);
+ TRACE_FLOW_NUMBER("col_delete_property returning", error);
return error;
}
/* UPDATE */
/* Update property in the collection */
-int update_property(struct collection_item *ci, /* Collection to find things in */
- const char *property_to_find, /* Name to match */
- int type, /* Type of the passed in data */
- void *new_data, /* Pointer to the new data */
- int length, /* Length of the data. For strings should include trailing 0 */
- int mode_flags) /* How to traverse the collection */
-
+int col_update_property(struct collection_item *ci,
+ const char *property_to_find,
+ int type,
+ void *new_data,
+ int length,
+ int mode_flags)
{
int error = EOK;
struct update_property update_data;
- TRACE_FLOW_STRING("update_property", "Entry.");
+ TRACE_FLOW_STRING("col_update_property", "Entry.");
update_data.type = type;
update_data.data = new_data;
update_data.length = length;
update_data.found = COL_NOMATCH;
- error = find_item_and_do(ci, property_to_find,
- type, mode_flags,
- NULL, (void *)(&update_data),
- COLLECTION_ACTION_UPDATE);
+ error = col_find_item_and_do(ci, property_to_find,
+ type, mode_flags,
+ NULL, (void *)(&update_data),
+ COLLECTION_ACTION_UPDATE);
if ((error == EOK) && (update_data.found == COL_NOMATCH))
error = ENOENT;
- TRACE_FLOW_NUMBER("update_property returning", error);
+ TRACE_FLOW_NUMBER("col_update_property returning", error);
return error;
}
/* Function to modify the item */
-int modify_item(struct collection_item *item,
- const char *property,
- int type,
- void *data,
- int length)
+int col_modify_item(struct collection_item *item,
+ const char *property,
+ int type,
+ void *data,
+ int length)
{
- TRACE_FLOW_STRING("modify_item", "Entry");
+ TRACE_FLOW_STRING("col_modify_item", "Entry");
if ((item == NULL) ||
(item->type == COL_TYPE_COLLECTION) ||
@@ -2331,7 +2328,7 @@ int modify_item(struct collection_item *item,
}
if (property != NULL) {
- if (validate_property(property)) {
+ if (col_validate_property(property)) {
TRACE_ERROR_STRING("Invalid chracters in the property name", property);
return EINVAL;
}
@@ -2370,20 +2367,19 @@ int modify_item(struct collection_item *item,
((char *)(item->data))[item->length - 1] = '\0';
}
- TRACE_FLOW_STRING("modify_item", "Exit");
+ TRACE_FLOW_STRING("col_modify_item", "Exit");
return EOK;
}
-
/* Grow iteration stack */
-static int grow_stack(struct collection_iterator *iterator, unsigned desired)
+static int col_grow_stack(struct collection_iterator *iterator, unsigned desired)
{
int grow_by = 0;
struct collection_item **temp;
- TRACE_FLOW_STRING("grow_stack", "Entry.");
+ TRACE_FLOW_STRING("col_grow_stack", "Entry.");
if (desired > iterator->stack_size) {
grow_by = (((desired - iterator->stack_size) / STACK_DEPTH_BLOCK) + 1) * STACK_DEPTH_BLOCK;
@@ -2396,22 +2392,22 @@ static int grow_stack(struct collection_iterator *iterator, unsigned desired)
iterator->stack = temp;
iterator->stack_size += grow_by;
}
- TRACE_FLOW_STRING("grow_stack", "Exit.");
+ TRACE_FLOW_STRING("col_grow_stack", "Exit.");
return EOK;
}
/* Bind iterator to a collection */
-int bind_iterator(struct collection_iterator **iterator,
- struct collection_item *ci,
- int mode_flags)
+int col_bind_iterator(struct collection_iterator **iterator,
+ struct collection_item *ci,
+ int mode_flags)
{
int error;
struct collection_header *header;
struct collection_iterator *iter = NULL;
- TRACE_FLOW_STRING("bind_iterator", "Entry.");
+ TRACE_FLOW_STRING("col_bind_iterator", "Entry.");
/* Do some argument checking first */
if ((iterator == NULL) || (ci == NULL)) {
@@ -2432,7 +2428,7 @@ int bind_iterator(struct collection_iterator **iterator,
iter->flags = mode_flags;
/* Allocate memory for stack */
- error = grow_stack(iter, 1);
+ error = col_grow_stack(iter, 1);
if(error) {
free(iter);
TRACE_ERROR_NUMBER("Error growing stack.", error);
@@ -2448,13 +2444,13 @@ int bind_iterator(struct collection_iterator **iterator,
*iterator = iter;
- TRACE_FLOW_STRING("bind_iterator", "Exit");
+ TRACE_FLOW_STRING("col_bind_iterator", "Exit");
return EOK;
}
/* Stop processing this subcollection and move to the next item in the
* collection 'level' levels up.*/
-int iterate_up(struct collection_iterator *iterator, int level)
+int col_iterate_up(struct collection_iterator *iterator, int level)
{
TRACE_FLOW_STRING("iterate_up", "Entry");
@@ -2468,14 +2464,14 @@ int iterate_up(struct collection_iterator *iterator, int level)
iterator->stack_depth--;
TRACE_INFO_NUMBER("Stack depth at the end:", iterator->stack_depth);
- TRACE_FLOW_STRING("iterate_up", "Exit");
+ TRACE_FLOW_STRING("col_iterate_up", "Exit");
return EOK;
}
/* How deep are we relative to the top level.*/
-int get_iterator_depth(struct collection_iterator *iterator, int *depth)
+int col_get_iterator_depth(struct collection_iterator *iterator, int *depth)
{
- TRACE_FLOW_STRING("iterate_up", "Entry");
+ TRACE_FLOW_STRING("col_get_iterator_depth", "Entry");
if ((iterator == NULL) || (depth == NULL)) {
TRACE_ERROR_NUMBER("Invalid parameter.", EINVAL);
@@ -2485,32 +2481,32 @@ int get_iterator_depth(struct collection_iterator *iterator, int *depth)
*depth = iterator->stack_depth -1;
TRACE_INFO_NUMBER("Stack depth at the end:", iterator->stack_depth);
- TRACE_FLOW_STRING("iterate_up","Exit");
+ TRACE_FLOW_STRING("col_get_iterator_depth","Exit");
return EOK;
}
/* Unbind the iterator from the collection */
-void unbind_iterator(struct collection_iterator *iterator)
+void col_unbind_iterator(struct collection_iterator *iterator)
{
- TRACE_FLOW_STRING("unbind_iterator", "Entry.");
+ TRACE_FLOW_STRING("col_unbind_iterator", "Entry.");
if (iterator != NULL) {
- destroy_collection(iterator->top);
+ col_destroy_collection(iterator->top);
if (iterator->stack != NULL) free(iterator->stack);
free(iterator);
}
- TRACE_FLOW_STRING("unbind_iterator", "Exit");
+ TRACE_FLOW_STRING("col_unbind_iterator", "Exit");
}
/* Get items from the collection one by one following the tree */
-int iterate_collection(struct collection_iterator *iterator,
- struct collection_item **item)
+int col_iterate_collection(struct collection_iterator *iterator,
+ struct collection_item **item)
{
int error;
struct collection_item *current;
struct collection_item *other;
- TRACE_FLOW_STRING("iterate_collection", "Entry.");
+ TRACE_FLOW_STRING("col_iterate_collection", "Entry.");
/* Check if we have storage for item */
if (item == NULL) {
@@ -2545,7 +2541,7 @@ int iterate_collection(struct collection_iterator *iterator,
if ((iterator->flags & COL_TRAVERSE_IGNORE) == 0) {
/* We should not ignore - then move on */
TRACE_INFO_STRING("Collection references are not ignored", "");
- error = grow_stack(iterator, iterator->stack_depth + 1);
+ error = col_grow_stack(iterator, iterator->stack_depth + 1);
if (error) {
TRACE_ERROR_NUMBER("Error growing stack.", error);
return error;
@@ -2635,11 +2631,12 @@ int iterate_collection(struct collection_iterator *iterator,
}
/* Set collection class */
-int set_collection_class(struct collection_item *item, unsigned cclass)
+int col_set_collection_class(struct collection_item *item,
+ unsigned cclass)
{
struct collection_header *header;
- TRACE_FLOW_STRING("set_collection_class", "Entry");
+ TRACE_FLOW_STRING("col_set_collection_class", "Entry");
if (item->type != COL_TYPE_COLLECTION) {
TRACE_INFO_NUMBER("Not a collectin object. Type is", item->type);
@@ -2648,17 +2645,17 @@ int set_collection_class(struct collection_item *item, unsigned cclass)
header = (struct collection_header *)item->data;
header->cclass = cclass;
- TRACE_FLOW_STRING("set_collection_class", "Exit");
+ TRACE_FLOW_STRING("col_set_collection_class", "Exit");
return EOK;
}
/* Get collection class */
-int get_collection_class(struct collection_item *item,
- unsigned *cclass)
+int col_get_collection_class(struct collection_item *item,
+ unsigned *cclass)
{
struct collection_header *header;
- TRACE_FLOW_STRING("get_collection_class", "Entry");
+ TRACE_FLOW_STRING("col_get_collection_class", "Entry");
if (item->type != COL_TYPE_COLLECTION) {
TRACE_ERROR_NUMBER("Not a collection object. Type is", item->type);
@@ -2667,17 +2664,17 @@ int get_collection_class(struct collection_item *item,
header = (struct collection_header *)item->data;
*cclass = header->cclass;
- TRACE_FLOW_STRING("get_collection_class", "Exit");
+ TRACE_FLOW_STRING("col_get_collection_class", "Exit");
return EOK;
}
/* Get collection count */
-int get_collection_count(struct collection_item *item,
- unsigned *count)
+int col_get_collection_count(struct collection_item *item,
+ unsigned *count)
{
struct collection_header *header;
- TRACE_FLOW_STRING("get_collection_count", "Entry");
+ TRACE_FLOW_STRING("col_get_collection_count", "Entry");
if (item->type != COL_TYPE_COLLECTION) {
TRACE_ERROR_NUMBER("Not a collectin object. Type is", item->type);
@@ -2686,21 +2683,21 @@ int get_collection_count(struct collection_item *item,
header = (struct collection_header *)item->data;
*count = header->count;
- TRACE_FLOW_STRING("get_collection_count", "Exit");
+ TRACE_FLOW_STRING("col_get_collection_count", "Exit");
return EOK;
}
/* Convinience function to check if the collection is of the specific class */
/* In case of internal error assumes that collection is not of the right class */
-int is_of_class(struct collection_item *item, unsigned cclass)
+int col_is_of_class(struct collection_item *item, unsigned cclass)
{
int error = EOK;
unsigned ret_class = 0;
- TRACE_FLOW_STRING("is_of_class invoked", "");
+ TRACE_FLOW_STRING("col_is_of_class invoked", "");
- error = get_collection_class(item, &ret_class);
+ error = col_get_collection_class(item, &ret_class);
if (error || (ret_class != cclass))
return 0;
else
@@ -2708,35 +2705,36 @@ int is_of_class(struct collection_item *item, unsigned cclass)
}
/* Get propery */
-const char *get_item_property(struct collection_item *ci,int *property_len)
+const char *col_get_item_property(struct collection_item *ci,
+ int *property_len)
{
if (property_len != NULL) *property_len = ci->property_len;
return ci->property;
}
/* Get type */
-int get_item_type(struct collection_item *ci)
+int col_get_item_type(struct collection_item *ci)
{
return ci->type;
}
/* Get length */
-int get_item_length(struct collection_item *ci)
+int col_get_item_length(struct collection_item *ci)
{
return ci->length;
}
/* Get data */
-const void *get_item_data(struct collection_item *ci)
+const void *col_get_item_data(struct collection_item *ci)
{
return ci->data;
}
/* Set time stamp in the collection - FIXME move to another level */
-int set_timestamp(struct collection_item *ci,
- struct collection_item **timestr_ref,
- struct collection_item **timeint_ref)
+int col_set_timestamp(struct collection_item *ci,
+ struct collection_item **timestr_ref,
+ struct collection_item **timeint_ref)
{
time_t utctime;
struct tm time_struct;
@@ -2746,22 +2744,22 @@ int set_timestamp(struct collection_item *ci,
struct collection_item *timeint = NULL;
int error = EOK;
- TRACE_FLOW_STRING("set_timestamp", "Entry point");
+ TRACE_FLOW_STRING("col_set_timestamp", "Entry point");
utctime = time(NULL);
localtime_r(&utctime, &time_struct);
len = strftime(time_array, TIME_ARRAY_SIZE, DATE_FORMAT, &time_struct);
if (len == 0) {
- TRACE_ERROR_STRING("add_time", "CODING ERROR - INCREASE THE BUFFER");
+ TRACE_ERROR_STRING("col_set_timestamp", "CODING ERROR - INCREASE THE BUFFER");
return EMSGSIZE;
}
TRACE_INFO_STRING("Timestamp:", time_array);
/* Check if we have the timestamp item already */
- error = get_item(ci, TS_NAME, COL_TYPE_STRING,
- COL_TRAVERSE_IGNORE, &timestr);
+ error = col_get_item(ci, TS_NAME, COL_TYPE_STRING,
+ COL_TRAVERSE_IGNORE, &timestr);
if (error) {
TRACE_ERROR_NUMBER("search failed with error:", error);
return error;
@@ -2780,8 +2778,8 @@ int set_timestamp(struct collection_item *ci,
}
else {
/* Add timestamp to the collection */
- error = add_str_property_with_ref(ci, NULL, TS_NAME,
- time_array, len+1, timestr_ref);
+ error = col_add_str_property_with_ref(ci, NULL, TS_NAME,
+ time_array, len+1, timestr_ref);
if (error) {
TRACE_ERROR_NUMBER("failed to add timestamp property:", error);
return error;
@@ -2789,8 +2787,8 @@ int set_timestamp(struct collection_item *ci,
}
/* Check if we have the time item already */
- error = get_item(ci, T_NAME, COL_TYPE_INTEGER,
- COL_TRAVERSE_IGNORE, &timeint);
+ error = col_get_item(ci, T_NAME, COL_TYPE_INTEGER,
+ COL_TRAVERSE_IGNORE, &timeint);
if (error) {
TRACE_ERROR_NUMBER("search failed with error:", error);
return error;
@@ -2803,14 +2801,14 @@ int set_timestamp(struct collection_item *ci,
}
else {
/* Add time to the collection */
- error = add_int_property_with_ref(ci, NULL, T_NAME,
- utctime, timeint_ref);
+ error = col_add_int_property_with_ref(ci, NULL, T_NAME,
+ utctime, timeint_ref);
if (error) {
TRACE_ERROR_NUMBER("failed to add time property:", error);
return error;
}
}
- TRACE_FLOW_STRING("set_timestamp", "Exit point");
+ TRACE_FLOW_STRING("col_set_timestamp", "Exit point");
return EOK;
}
diff --git a/common/collection/collection.h b/common/collection/collection.h
index 28622a50..8bce3c78 100644
--- a/common/collection/collection.h
+++ b/common/collection/collection.h
@@ -183,8 +183,9 @@ struct collection_iterator;
*/
/* Function that creates a named collection */
-int create_collection(struct collection_item **ci, const char *name,
- unsigned cclass);
+int col_create_collection(struct collection_item **ci,
+ const char *name,
+ unsigned cclass);
/* Function that creates a named collection using a memory descriptor */
/* FIXME - function is a placeholder. It is not implemented yet.
@@ -195,101 +196,121 @@ int create_collection(struct collection_item **ci, const char *name,
* b) Define memory functions to use.
*/
/*
-int create_collection_ex(struct collection_item **ci, const char *name,
- unsigned cclass, struct cdescriptor *descrptor);
+int col_create_collection_ex(struct collection_item **ci,
+ const char *name,
+ unsigned cclass,
+ struct cdescriptor *descrptor);
*/
/* Function that destroys a collection */
-void destroy_collection(struct collection_item *ci);
+void col_destroy_collection(struct collection_item *ci);
/* Family of functions that add properties to a collection */
/* See details about subcollection argument above. */
/* Family includes the following convinience functions: */
/* Add a string property to collection. The length should include the
* terminating 0 */
-int add_str_property(struct collection_item *ci, const char *subcollection,
- const char *property, char *string, int length);
+int col_add_str_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ char *string,
+ int length);
/* Add a binary property to collection. */
-int add_binary_property(struct collection_item *ci, const char *subcollection,
- const char *property, void *binary_data, int length);
+int col_add_binary_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ void *binary_data,
+ int length);
/* Add an int property to collection. */
-int add_int_property(struct collection_item *ci, const char *subcollection,
- const char *property, int number);
+int col_add_int_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ int number);
/* Add an unsigned int property. */
-int add_unsigned_property(struct collection_item *ci, const char *subcollection,
- const char *property,unsigned int number);
+int col_add_unsigned_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ unsigned int number);
/* Add a long property. */
-int add_long_property(struct collection_item *ci, const char *subcollection,
- const char *property, long number);
+int col_add_long_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ long number);
/* Add an unsigned long property. */
-int add_ulong_property(struct collection_item *ci, const char *subcollection,
- const char *property, unsigned long number);
+int col_add_ulong_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ unsigned long number);
/* Add a double property. */
-int add_double_property(struct collection_item *ci, const char *subcollection,
- const char *property,double number);
+int col_add_double_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ double number);
/* Add a bool property. */
-int add_bool_property(struct collection_item *ci, const char *subcollection,
- const char *property, unsigned char logical);
+int col_add_bool_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ unsigned char logical);
/* Add any property */
-int add_any_property(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Subcollection */
- const char *property, /* Name */
- int type, /* Data type */
- void *data, /* Pointer to the data */
- int length); /* Length of the data. For
- strings it includes the
- trailing 0 */
+int col_add_any_property(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Subcollection */
+ const char *property, /* Name */
+ int type, /* Data type */
+ void *data, /* Pointer to the data */
+ int length); /* Length of the data. For
+ * strings it includes the
+ * trailing 0 */
/* The functions that add an item and immediately return you this item
* in the ret_ref parameter */
-int add_str_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- char *string, int length,
- struct collection_item **ret_ref);
-int add_binary_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- void *binary_data, int length,
- struct collection_item **ret_ref);
-int add_int_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property, int number,
- struct collection_item **ret_ref);
-int add_unsigned_property_with_ref(struct collection_item *ci,
+int col_add_str_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ char *string, int length,
+ struct collection_item **ret_ref);
+int col_add_binary_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ void *binary_data, int length,
+ struct collection_item **ret_ref);
+int col_add_int_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property, int number,
+ struct collection_item **ret_ref);
+int col_add_unsigned_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property, unsigned int number,
+ struct collection_item **ret_ref);
+int col_add_long_property_with_ref(struct collection_item *ci,
const char *subcollection,
- const char *property, unsigned int number,
+ const char *property, long number,
struct collection_item **ret_ref);
-int add_long_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property, long number,
- struct collection_item **ret_ref);
-int add_ulong_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property, unsigned long number,
- struct collection_item **ret_ref);
-int add_double_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property, double number,
- struct collection_item **ret_ref);
-int add_bool_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property, unsigned char logical,
- struct collection_item **ret_ref);
-int add_any_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- int type, void *data, int length,
- struct collection_item **ret_ref);
+int col_add_ulong_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property, unsigned long number,
+ struct collection_item **ret_ref);
+int col_add_double_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property, double number,
+ struct collection_item **ret_ref);
+int col_add_bool_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property, unsigned char logical,
+ struct collection_item **ret_ref);
+int col_add_any_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ int type, void *data, int length,
+ struct collection_item **ret_ref);
/* FIXME - does not belong here - move to other place */
/* Function to create a timestamp */
/* Automatically adds/updates time and timestamp properties in the
* collection returning references */
-int set_timestamp(struct collection_item *ci,
- struct collection_item **timestr_ref,
- struct collection_item **timeint_ref);
+int col_set_timestamp(struct collection_item *ci,
+ struct collection_item **timestr_ref,
+ struct collection_item **timeint_ref);
/* Update functions */
@@ -299,92 +320,109 @@ int set_timestamp(struct collection_item *ci,
*/
/* Update a string property in the collection.
* Length should include the terminating 0 */
-int update_str_property(struct collection_item *ci, const char *property,
- int mode_flags, char *string,int length);
+int col_update_str_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ char *string,
+ int length);
/* Update a binary property in the collection. */
-int update_binary_property(struct collection_item *ci, const char *property,
- int mode_flags, void *binary_data,int length);
+int col_update_binary_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ void *binary_data,
+ int length);
/* Update an int property in the collection. */
-int update_int_property(struct collection_item *ci, const char *property,
- int mode_flags, int number);
+int col_update_int_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ int number);
/* Update an unsigned int property. */
-int update_unsigned_property(struct collection_item *ci, const char *property,
- int mode_flags, unsigned int number);
+int col_update_unsigned_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ unsigned int number);
/* Update a long property. */
-int update_long_property(struct collection_item *ci, const char *property,
- int mode_flags, long number);
+int col_update_long_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ long number);
/* Update an unsigned long property. */
-int update_ulong_property(struct collection_item *ci, const char *property,
- int mode_flags, unsigned long number);
+int col_update_ulong_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ unsigned long number);
/* Update a double property. */
-int update_double_property(struct collection_item *ci, const char *property,
- int mode_flags, double number);
+int col_update_double_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ double number);
/* Update a double property. */
-int update_bool_property(struct collection_item *ci, const char *property,
- int mode_flags, unsigned char logical);
-
+int col_update_bool_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ unsigned char logical);
/* Update property in the collection */
-int update_property(struct collection_item *ci, /* A collection of items */
- const char *property_to_find,/* Name to match */
- int type, /* Data type */
- void *new_data, /* Pointer to the data */
- int length, /* Length of the data. For
- strings, it includes the
- trailing 0 */
- int mode_flags); /* How to traverse the collection */
-
-
+int col_update_property(struct collection_item *ci, /* A collection of items */
+ const char *property_to_find, /* Name to match */
+ int type, /* Data type */
+ void *new_data, /* Pointer to the data */
+ int length, /* Length of the data. For
+ * strings, it includes the
+ * trailing 0 */
+ int mode_flags); /* How to traverse the collection */
/* Add collection to collection */
-int add_collection_to_collection(struct collection_item *ci, /* Collection handle to with we add another collection */
- const char *sub_collection_name, /* Name of the sub collection to which
- collection needs to be added as a property.
- If NULL high level collection is assumed. */
- const char *as_property, /* Name of the collection property.
- If NULL, same property as the name of
- the collection being added will be used. */
- struct collection_item *collection_to_add, /* Collection to add */
- int mode); /* How this collection needs to be added */
+int col_add_collection_to_collection(struct collection_item *ci, /* Collection handle to with we add
+ * another collection */
+ const char *sub_collection_name, /* Name of the sub collection
+ * to which collection needs to be
+ * added as a property.
+ * If NULL high level collection is assumed. */
+ const char *as_property, /* Name of the collection property.
+ * If NULL, same property as the name of
+ * the collection being added will be used. */
+ struct collection_item *collection_to_add, /* Collection to add */
+ int mode); /* How this collection needs to be added */
/* Create a deep copy of the current collection. */
/* Referenced collections of the donor are copied as sub collections. */
-int copy_collection(struct collection_item **collection_copy,
- struct collection_item *collection_to_copy,
- const char *name_to_use);
+int col_copy_collection(struct collection_item **collection_copy,
+ struct collection_item *collection_to_copy,
+ const char *name_to_use);
/* Signature of the callback that needs to be used when
traversing a collection or looking for a specific item */
-typedef int (*item_fn)(const char *property, /* The name of the property will be passed in this parameter. */
- int property_len, /* Length of the property name will be passed in this parameter. */
- int type, /* Type of the data will be passed in this parameter */
- void *data, /* Pointer to the data will be passed in this parameter */
- int length, /* Length of data will be passed in this parameter */
- void *custom_dat, /* Custom data will be passed in this parameter */
- int *stop); /* Pointer to variable where the handler can put non zero to stop processing */
+typedef int (*col_item_fn)(const char *property, /* The name of the property will be passed in this parameter. */
+ int property_len, /* Length of the property name will be passed in this parameter. */
+ int type, /* Type of the data will be passed in this parameter */
+ void *data, /* Pointer to the data will be passed in this parameter */
+ int length, /* Length of data will be passed in this parameter */
+ void *custom_dat, /* Custom data will be passed in this parameter */
+ int *stop); /* Pointer to variable where the handler can put non zero to stop processing */
/* Function to traverse the entire collection including optionally sub collections */
-int traverse_collection(struct collection_item *ci, /* Collection to traverse */
- int mode_flags, /* Flags defining how to traverse */
- item_fn item_handler, /* Handler called for each item */
- void *custom_data); /* Custom data passed around */
+int col_traverse_collection(struct collection_item *ci, /* Collection to traverse */
+ int mode_flags, /* Flags defining how to traverse */
+ col_item_fn item_handler, /* Handler called for each item */
+ void *custom_data); /* Custom data passed around */
/* Search function. Looks up an item in the collection based on the property.
- Actually it is a traverse function with spacial traversing logic.
- It is the responsibility of the handler to set something in the custom data
- to indicate that the item was found.
- Function will not return error if the item is not found.
- It is the responsibility of the calling application to check
- the data passed in custom_data and see if the item was found and
- that the action was performed.
+ * Actually it is a traverse function with special traversing logic.
+ * It is the responsibility of the handler to set something in the custom data
+ * to indicate that the item was found.
+ * Function will not return error if the item is not found.
+ * It is the responsibility of the calling application to check
+ * the data passed in custom_data and see if the item was found and
+ * that the action was performed.
*/
-int get_item_and_do(struct collection_item *ci, /* A collection of items */
- const char *property_to_find,/* Name to match */
- int type, /* Type filter */
- int mode_flags, /* How to traverse the collection */
- item_fn item_handler, /* Function to call when the item is found */
- void *custom_data); /* Custom data passed around */
+int col_get_item_and_do(struct collection_item *ci, /* A collection of items */
+ const char *property_to_find,/* Name to match */
+ int type, /* Type filter */
+ int mode_flags, /* How to traverse the collection */
+ col_item_fn item_handler, /* Function to call when the item is found */
+ void *custom_data); /* Custom data passed around */
/* Convenience function to get individual item */
/* Caller should be aware that this is not a copy of the item
@@ -395,105 +433,104 @@ int get_item_and_do(struct collection_item *ci, /* A collection of items */
* Working with the internals of the collection item structure directly
* may cause problems in future if the internal implementation changes.
*/
-int get_item(struct collection_item *ci, /* Collection to find things in */
- const char *property_to_find, /* Name to match */
- int type, /* Type filter */
- int mode_flags, /* How to traverse the collection */
- struct collection_item **item); /* Found item */
+int col_get_item(struct collection_item *ci, /* Collection to find things in */
+ const char *property_to_find, /* Name to match */
+ int type, /* Type filter */
+ int mode_flags, /* How to traverse the collection */
+ struct collection_item **item); /* Found item */
/* Group of functions that allows retrieving individual elements of the collection_item
* hiding the internal implementation.
*/
-const char *get_item_property(struct collection_item *ci,int *property_len);
-int get_item_type(struct collection_item *ci);
-int get_item_length(struct collection_item *ci);
-const void *get_item_data(struct collection_item *ci);
+const char *col_get_item_property(struct collection_item *ci,int *property_len);
+int col_get_item_type(struct collection_item *ci);
+int col_get_item_length(struct collection_item *ci);
+const void *col_get_item_data(struct collection_item *ci);
/* If you want to modify the item that you got as a result of iterating through collection
- * or by calling get_item(). If you want to rename item provide a new name in the property
+ * or by calling col_get_item(). If you want to rename item provide a new name in the property
* argument. If you want the data to remain unchanged use 0 as length parameter.
* If item is a reference or collection the call will return error.
* Previous type and data of the item is destroyed.
*/
-int modify_item(struct collection_item *item,
- const char *property,
- int type,
- void *data,
- int length);
+int col_modify_item(struct collection_item *item,
+ const char *property,
+ int type,
+ void *data,
+ int length);
/* Rename the item */
-int modify_item_property(struct collection_item *item,
- const char *property);
+int col_modify_item_property(struct collection_item *item,
+ const char *property);
/* Convenience functions that wrap modify_item().
* They always assign new value.
* To rename the property just use modify_item_property();
*/
-int modify_str_item(struct collection_item *item,
- const char *property,
- char *string,
- int length);
-int modify_binary_item(struct collection_item *item,
- const char *property,
- void *binary_data,
- int length);
-int modify_bool_item(struct collection_item *item,
- const char *property,
- unsigned char logical);
-int modify_int_item(struct collection_item *item,
- const char *property,
- int number);
-int modify_long_item(struct collection_item *item,
- const char *property,
- long number);
-int modify_ulong_item(struct collection_item *item,
- const char *property,
- unsigned long number);
-int modify_unsigned_item(struct collection_item *item,
+int col_modify_str_item(struct collection_item *item,
+ const char *property,
+ char *string,
+ int length);
+int col_modify_binary_item(struct collection_item *item,
+ const char *property,
+ void *binary_data,
+ int length);
+int col_modify_bool_item(struct collection_item *item,
const char *property,
- unsigned number);
-int modify_double_item(struct collection_item *item,
- const char *property,
- double number);
+ unsigned char logical);
+int col_modify_int_item(struct collection_item *item,
+ const char *property,
+ int number);
+int col_modify_long_item(struct collection_item *item,
+ const char *property,
+ long number);
+int col_modify_ulong_item(struct collection_item *item,
+ const char *property,
+ unsigned long number);
+int col_modify_unsigned_item(struct collection_item *item,
+ const char *property,
+ unsigned number);
+int col_modify_double_item(struct collection_item *item,
+ const char *property,
+ double number);
/* Delete property from the collection */
-int delete_property(struct collection_item *ci, /* A collection of items */
- const char *property_to_find, /* Name to match */
- int type, /* Type filter */
- int mode_flags); /* How to traverse the collection */
+int col_delete_property(struct collection_item *ci, /* A collection of items */
+ const char *property_to_find, /* Name to match */
+ int type, /* Type filter */
+ int mode_flags); /* How to traverse the collection */
/* Convenience function to check if the property is indeed in the collection */
-int is_item_in_collection(struct collection_item *ci, /* Collection to find things in */
- const char *property_to_find,/* Name to match */
- int type, /* Type filter */
- int mode_flags, /* How to traverse the collection */
- int *found); /* Boolean that turns to nonzero if the match is found */
+int col_is_item_in_collection(struct collection_item *ci, /* Collection to find things in */
+ const char *property_to_find, /* Name to match */
+ int type, /* Type filter */
+ int mode_flags, /* How to traverse the collection */
+ int *found); /* Boolean that turns to nonzero if the match is found */
/* Get collection - get a pointer to a collection included into another collection */
/* Delete extracted collection after use to decrease reference count. */
-int get_collection_reference(struct collection_item *ci, /* High level collection */
- struct collection_item **acceptor, /* The pointer that will accept extracted handle */
- const char *collection_to_find); /* Name to of the collection */
+int col_get_collection_reference(struct collection_item *ci, /* High level collection */
+ struct collection_item **acceptor, /* The pointer that will accept extracted handle */
+ const char *collection_to_find); /* Name to of the collection */
/* Get collection - if current item is a reference get a real collection from it. */
/* Delete extracted collection after use to decrease reference count. */
-int get_reference_from_item(struct collection_item *ci, /* Reference element of the high level collection */
- struct collection_item **acceptor); /* The pointer that will accept extracted handle */
-
+int col_get_reference_from_item(struct collection_item *ci, /* Reference element of the high level collection */
+ struct collection_item **acceptor); /* The pointer that will accept extracted handle */
/* Bind iterator to a collection */
-int bind_iterator(struct collection_iterator **iterator, /* The iterator to bind */
- struct collection_item *ci, /* Collection to bind iterator to */
- int mode_flags); /* How the collection needs to be iterated */
+int col_bind_iterator(struct collection_iterator **iterator, /* The iterator to bind */
+ struct collection_item *ci, /* Collection to bind iterator to */
+ int mode_flags); /* How the collection needs to be iterated */
/* Unbind the iterator from the collection */
-void unbind_iterator(struct collection_iterator *iterator);
+void col_unbind_iterator(struct collection_iterator *iterator);
/* Get items from the collection one by one following the tree */
-int iterate_collection(struct collection_iterator *iterator,
- struct collection_item **item);
+int col_iterate_collection(struct collection_iterator *iterator,
+ struct collection_item **item);
/* Stop processing this subcollection and move to the next item in the
* collection 'level' levels up.
@@ -501,35 +538,35 @@ int iterate_collection(struct collection_iterator *iterator,
* If 0 - call is a no op.
* If the depth is less than requested level function will return error EINVAL.
*/
-int iterate_up(struct collection_iterator *iterator, int level);
+int col_iterate_up(struct collection_iterator *iterator, int level);
/* How deep are we relative to the top level.*/
-int get_iterator_depth(struct collection_iterator *iterator, int *depth);
+int col_get_iterator_depth(struct collection_iterator *iterator, int *depth);
/* FIXME - Do we need to be able to rewind iterator? */
/* Set collection class */
-int set_collection_class(struct collection_item *item, /* Collection */
- unsigned cclass); /* Collection class */
+int col_set_collection_class(struct collection_item *item, /* Collection */
+ unsigned cclass); /* Collection class */
/* Get collection class */
-int get_collection_class(struct collection_item *item, /* Collection */
- unsigned *cclass); /* Collection class */
+int col_get_collection_class(struct collection_item *item, /* Collection */
+ unsigned *cclass); /* Collection class */
/* Get collection count */
-int get_collection_count(struct collection_item *item, /* Collection */
- unsigned *count); /* Number of elements in
- * this collection.
- * Each subcollection is
- * counted as 1 element.
- * Header is also counted.
- */
+int col_get_collection_count(struct collection_item *item, /* Collection */
+ unsigned *count); /* Number of elements in
+ * this collection.
+ * Each subcollection is
+ * counted as 1 element.
+ * Header is also counted.
+ */
/* Convenience function to check if the collection is of the specific class */
/* In case of internal error assumes that collection is not of the right class */
-int is_of_class(struct collection_item *item, /* Collection */
- unsigned cclass); /* Class of the collection */
+int col_is_of_class(struct collection_item *item, /* Collection */
+ unsigned cclass); /* Class of the collection */
/*
@@ -539,58 +576,58 @@ int is_of_class(struct collection_item *item, /* Collection */
/* Extract the item from the collection */
/* The header will not be considered for extraction. */
-int extract_item(struct collection_item *ci, /* Top collection */
- const char *subcollection, /* Sub collection */
- int disposition, /* Which to extract */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to extract. See notes. */
- int type, /* Type filter */
- struct collection_item **ret_ref); /* Returns the reference back */
+int col_extract_item(struct collection_item *ci, /* Top collection */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Which to extract */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to extract. See notes. */
+ int type, /* Type filter */
+ struct collection_item **ret_ref); /* Returns the reference back */
/* Similar extraction function as above just considers only one level. */
-int extract_item_from_current(struct collection_item *ci, /* Top collection */
- int disposition, /* Which to extract */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to extract. See notes. */
- int type, /* Type filter */
- struct collection_item **ret_ref); /* Returns the reference back */
+int col_extract_item_from_current(struct collection_item *ci, /* Top collection */
+ int disposition, /* Which to extract */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to extract. See notes. */
+ int type, /* Type filter */
+ struct collection_item **ret_ref); /* Returns the reference back */
/* Insert item to the collection */
/* WARNING: Only use this function to insert items
* that were extracted using extract_item().
* NEVER use it with items that were returned
- * by get_item() or add_xxx_property_with_ref() or
- * with insert_xxx_property_with_ref().
+ * by col_get_item() or col_add_xxx_property_with_ref() or
+ * with col_insert_xxx_property_with_ref().
* The fundamental difference is that when you extracted item
- * using extract_item() it stops to be managed by a collection.
+ * using col_extract_item() it stops to be managed by a collection.
* With such item you can:
* a) Insert this item into another (or same) collection
- * b) Get item information using get_item_xxx() functions.
- * c) Destroy item using delete_item().
+ * b) Get item information using col_get_item_xxx() functions.
+ * c) Destroy item using col_delete_item().
* You are required to do either a) or c) with such item.
*/
-int insert_item(struct collection_item *collection, /* Top collection */
- const char *subcollection, /* Sub collection */
- struct collection_item *item, /* Item to insert */
- int disposition, /* What should be the position of the item */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to extract. See notes. */
- unsigned flags); /* Flags that control naming issues */
+int col_insert_item(struct collection_item *collection, /* Top collection */
+ const char *subcollection, /* Sub collection */
+ struct collection_item *item, /* Item to insert */
+ int disposition, /* What should be the position of the item */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to extract. See notes. */
+ unsigned flags); /* Flags that control naming issues */
/* Insert the item into the top level collection (similar to the function above)
* but does not provide access to the sub collection.
*/
-int insert_item_into_current(struct collection_item *collection,
- struct collection_item *item,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags);
+int col_insert_item_into_current(struct collection_item *collection,
+ struct collection_item *item,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags);
/* Function to delete the item */
-void delete_item(struct collection_item *item);
+void col_delete_item(struct collection_item *item);
/* Possible dispositions for insert, extract and delete function(s).
* Not all of these dispositions are implemented day one.
@@ -687,184 +724,184 @@ void delete_item(struct collection_item *item);
*/
/* Insert property with reference */
-int insert_property_with_ref(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- int type, /* Data type */
- void *data, /* Pointer to the data */
- int length, /* Length of the data. For
- * strings it includes the
- * trailing 0
- */
- struct collection_item **ret_ref); /* Returns the reference back */
-
-
-int insert_str_property(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- char *string, /* String */
- int length); /* Length */
-
-int insert_binary_property(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- void *binary_data, /* Binary data */
- int length); /* Length */
-
-
-int insert_int_property(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- int number); /* Integer */
-
-
-int insert_unsinged_property(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- unsigned number); /* Unsigned */
-
-
-int insert_long_property(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- long number); /* Long */
-
-int insert_ulong_property(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- unsigned long number); /* Unsigned long */
-
-int insert_double_property(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- double number); /* Double */
-
-int insert_bool_property(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- unsigned char logical); /* Bool */
-
-
-
-int insert_str_property_with_ref(struct collection_item *ci, /* A collection of items */
+int col_insert_property_with_ref(struct collection_item *ci, /* A collection of items */
const char *subcollection, /* Sub collection */
int disposition, /* Where to insert */
const char *refprop, /* Property to relate to */
int index, /* Index of the property to add */
unsigned flags, /* Flags that control naming issues */
const char *property, /* Name */
- char *string, /* String */
- int length, /* Length */
+ int type, /* Data type */
+ void *data, /* Pointer to the data */
+ int length, /* Length of the data. For
+ * strings it includes the
+ * trailing 0
+ */
struct collection_item **ret_ref); /* Returns the reference back */
-int insert_binary_property_with_ref(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- void *binary_data, /* Binary data */
- int length, /* Length */
- struct collection_item **ret_ref); /* Returns the reference back */
-
-int insert_int_property_with_ref(struct collection_item *ci, /* A collection of items */
+int col_insert_str_property(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ char *string, /* String */
+ int length); /* Length */
+
+int col_insert_binary_property(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ void *binary_data, /* Binary data */
+ int length); /* Length */
+
+
+int col_insert_int_property(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ int number); /* Integer */
+
+
+int col_insert_unsinged_property(struct collection_item *ci, /* A collection of items */
const char *subcollection, /* Sub collection */
int disposition, /* Where to insert */
const char *refprop, /* Property to relate to */
int index, /* Index of the property to add */
unsigned flags, /* Flags that control naming issues */
const char *property, /* Name */
- int number, /* Integer */
- struct collection_item **ret_ref); /* Returns the reference back */
+ unsigned number); /* Unsigned */
-int insert_unsinged_property_with_ref(struct collection_item *ci, /* A collection of items */
+int col_insert_long_property(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ long number); /* Long */
+
+int col_insert_ulong_property(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ unsigned long number); /* Unsigned long */
+
+int col_insert_double_property(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ double number); /* Double */
+
+int col_insert_bool_property(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ unsigned char logical); /* Bool */
+
+
+
+int col_insert_str_property_with_ref(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ char *string, /* String */
+ int length, /* Length */
+ struct collection_item **ret_ref); /* Returns the reference back */
+
+int col_insert_binary_property_with_ref(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ void *binary_data, /* Binary data */
+ int length, /* Length */
+ struct collection_item **ret_ref); /* Returns the reference back */
+
+
+int col_insert_int_property_with_ref(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ int number, /* Integer */
+ struct collection_item **ret_ref); /* Returns the reference back */
+
+
+int col_insert_unsinged_property_with_ref(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ unsigned number, /* Unsigned */
+ struct collection_item **ret_ref); /* Returns the reference back */
+
+int col_insert_long_property_with_ref(struct collection_item *ci, /* A collection of items */
const char *subcollection, /* Sub collection */
int disposition, /* Where to insert */
const char *refprop, /* Property to relate to */
int index, /* Index of the property to add */
unsigned flags, /* Flags that control naming issues */
const char *property, /* Name */
- unsigned number, /* Unsigned */
+ long number, /* Long */
struct collection_item **ret_ref); /* Returns the reference back */
-int insert_long_property_with_ref(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- long number, /* Long */
- struct collection_item **ret_ref); /* Returns the reference back */
-
-int insert_ulong_property_with_ref(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- unsigned long number, /* Unsigned long */
- struct collection_item **ret_ref); /* Returns the reference back */
-
-int insert_double_property_with_ref(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- double number, /* Double */
- struct collection_item **ret_ref); /* Returns the reference back */
-
-int insert_bool_property_with_ref(struct collection_item *ci, /* A collection of items */
- const char *subcollection, /* Sub collection */
- int disposition, /* Where to insert */
- const char *refprop, /* Property to relate to */
- int index, /* Index of the property to add */
- unsigned flags, /* Flags that control naming issues */
- const char *property, /* Name */
- unsigned char logical, /* Bool */
- struct collection_item **ret_ref); /* Returns the reference back */
+int col_insert_ulong_property_with_ref(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ unsigned long number, /* Unsigned long */
+ struct collection_item **ret_ref); /* Returns the reference back */
+
+int col_insert_double_property_with_ref(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ double number, /* Double */
+ struct collection_item **ret_ref); /* Returns the reference back */
+
+int col_insert_bool_property_with_ref(struct collection_item *ci, /* A collection of items */
+ const char *subcollection, /* Sub collection */
+ int disposition, /* Where to insert */
+ const char *refprop, /* Property to relate to */
+ int index, /* Index of the property to add */
+ unsigned flags, /* Flags that control naming issues */
+ const char *property, /* Name */
+ unsigned char logical, /* Bool */
+ struct collection_item **ret_ref); /* Returns the reference back */
#endif
diff --git a/common/collection/collection_cnv.c b/common/collection/collection_cnv.c
index 1ead75f5..1a70600e 100644
--- a/common/collection/collection_cnv.c
+++ b/common/collection/collection_cnv.c
@@ -35,813 +35,838 @@
/* PROPERTIES */
/* Insert string property with positioning */
-int insert_str_property(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- char *string,
- int length)
+int col_insert_str_property(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ char *string,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_string_property", "Entry.");
+ TRACE_FLOW_STRING("col_insert_string_property", "Entry.");
if (length == 0) length = strlen(string) + 1;
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_STRING,
- (void *)string,
- length,
- NULL);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_STRING,
+ (void *)string,
+ length,
+ NULL);
- TRACE_FLOW_NUMBER("insert_string_property returning", error);
+ TRACE_FLOW_NUMBER("col_insert_string_property returning", error);
return error;
}
/* Insert binary property with positioning */
-int insert_binary_property(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- void *binary_data,
- int length)
+int col_insert_binary_property(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ void *binary_data,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_binary_property", "Entry.");
+ TRACE_FLOW_STRING("col_insert_binary_property", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_BINARY,
- binary_data,
- length,
- NULL);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_BINARY,
+ binary_data,
+ length,
+ NULL);
- TRACE_FLOW_NUMBER("insert_binary_property returning", error);
+ TRACE_FLOW_NUMBER("col_insert_binary_property returning", error);
return error;
}
/* Insert integer property with positioning */
-int insert_int_property(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- int number)
+int col_insert_int_property(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ int number)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_int_property", "Entry.");
+ TRACE_FLOW_STRING("col_insert_int_property", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_INTEGER,
- (void *)&number,
- sizeof(int),
- NULL);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_INTEGER,
+ (void *)&number,
+ sizeof(int),
+ NULL);
- TRACE_FLOW_NUMBER("insert_int_property returning", error);
+ TRACE_FLOW_NUMBER("col_insert_int_property returning", error);
return error;
}
/* Insert unsigned property with positioning */
-int insert_unsigned_property(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- unsigned number)
+int col_insert_unsigned_property(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ unsigned number)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_unsigned_property", "Entry.");
+ TRACE_FLOW_STRING("col_insert_unsigned_property", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_UNSIGNED,
- (void *)&number,
- sizeof(unsigned),
- NULL);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_UNSIGNED,
+ (void *)&number,
+ sizeof(unsigned),
+ NULL);
- TRACE_FLOW_NUMBER("insert_unsigned_property returning", error);
+ TRACE_FLOW_NUMBER("col_insert_unsigned_property returning", error);
return error;
}
/* Insert long property with positioning */
-int insert_long_property(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- long number)
+int col_insert_long_property(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ long number)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_long_property", "Entry.");
+ TRACE_FLOW_STRING("col_insert_long_property", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_LONG,
- (void *)&number,
- sizeof(long),
- NULL);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_LONG,
+ (void *)&number,
+ sizeof(long),
+ NULL);
- TRACE_FLOW_NUMBER("insert_long_property returning", error);
+ TRACE_FLOW_NUMBER("col_insert_long_property returning", error);
return error;
}
/* Insert unsigned long property with positioning */
-int insert_ulong_property(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- unsigned long number)
+int col_insert_ulong_property(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ unsigned long number)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_ulong_property", "Entry.");
+ TRACE_FLOW_STRING("col_insert_ulong_property", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_ULONG,
- (void *)&number,
- sizeof(unsigned long),
- NULL);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_ULONG,
+ (void *)&number,
+ sizeof(unsigned long),
+ NULL);
- TRACE_FLOW_NUMBER("insert_ulong_property returning", error);
+ TRACE_FLOW_NUMBER("col_insert_ulong_property returning", error);
return error;
}
/* Insert double property with positioning */
-int insert_double_property(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- double number)
+int col_insert_double_property(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ double number)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_double_property", "Entry.");
+ TRACE_FLOW_STRING("col_insert_double_property", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_DOUBLE,
- (void *)&number,
- sizeof(double),
- NULL);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_DOUBLE,
+ (void *)&number,
+ sizeof(double),
+ NULL);
- TRACE_FLOW_NUMBER("insert_double_property returning", error);
+ TRACE_FLOW_NUMBER("col_insert_double_property returning", error);
return error;
}
/* Insert bool property with positioning */
-int insert_bool_property(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- unsigned char logical)
+int col_insert_bool_property(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ unsigned char logical)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_bool_property", "Entry.");
+ TRACE_FLOW_STRING("col_insert_bool_property", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_BOOL,
- (void *)&logical,
- sizeof(unsigned char),
- NULL);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_BOOL,
+ (void *)&logical,
+ sizeof(unsigned char),
+ NULL);
- TRACE_FLOW_NUMBER("insert_bool_property returning", error);
+ TRACE_FLOW_NUMBER("col_insert_bool_property returning", error);
return error;
}
/* Insert string property with positioning and reference. */
-int insert_str_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- char *string,
- int length,
- struct collection_item **ret_ref)
+int col_insert_str_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ char *string,
+ int length,
+ struct collection_item **ret_ref)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_string_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_insert_string_property_with_ref", "Entry.");
if (length == 0) length = strlen(string) + 1;
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_STRING,
- (void *)string,
- length,
- ret_ref);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_STRING,
+ (void *)string,
+ length,
+ ret_ref);
- TRACE_FLOW_NUMBER("insert_string_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_insert_string_property_with_ref returning", error);
return error;
}
/* Insert binary property with positioning and reference. */
-int insert_binary_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- void *binary_data,
- int length,
- struct collection_item **ret_ref)
+int col_insert_binary_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ void *binary_data,
+ int length,
+ struct collection_item **ret_ref)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_binary_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_insert_binary_property_with_ref", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_BINARY,
- (void *)binary_data,
- length,
- ret_ref);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_BINARY,
+ (void *)binary_data,
+ length,
+ ret_ref);
- TRACE_FLOW_NUMBER("insert_binary_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_insert_binary_property_with_ref returning", error);
return error;
}
/* Insert int property with positioning and reference. */
-int insert_int_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- int number,
- struct collection_item **ret_ref)
+int col_insert_int_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ int number,
+ struct collection_item **ret_ref)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_int_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_insert_int_property_with_ref", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_INTEGER,
- (void *)&number,
- sizeof(int),
- ret_ref);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_INTEGER,
+ (void *)&number,
+ sizeof(int),
+ ret_ref);
- TRACE_FLOW_NUMBER("insert_int_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_insert_int_property_with_ref returning", error);
return error;
}
/* Insert unsigned property with positioning and reference. */
-int insert_unsigned_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- unsigned number,
- struct collection_item **ret_ref)
+int col_insert_unsigned_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ unsigned number,
+ struct collection_item **ret_ref)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_unsigned_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_insert_unsigned_property_with_ref", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_UNSIGNED,
- (void *)&number,
- sizeof(unsigned),
- ret_ref);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_UNSIGNED,
+ (void *)&number,
+ sizeof(unsigned),
+ ret_ref);
- TRACE_FLOW_NUMBER("insert_unsigned_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_insert_unsigned_property_with_ref returning", error);
return error;
}
/* Insert long property with positioning and reference. */
-int insert_long_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- long number,
- struct collection_item **ret_ref)
+int col_insert_long_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ long number,
+ struct collection_item **ret_ref)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_long_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_insert_long_property_with_ref", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_LONG,
- (void *)&number,
- sizeof(long),
- ret_ref);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_LONG,
+ (void *)&number,
+ sizeof(long),
+ ret_ref);
- TRACE_FLOW_NUMBER("insert_long_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_insert_long_property_with_ref returning", error);
return error;
}
/* Insert unsigned long property with positioning and reference. */
-int insert_ulong_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- unsigned long number,
- struct collection_item **ret_ref)
+int col_insert_ulong_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ unsigned long number,
+ struct collection_item **ret_ref)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_ulong_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_insert_ulong_property_with_ref", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_ULONG,
- (void *)&number,
- sizeof(unsigned long),
- ret_ref);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_ULONG,
+ (void *)&number,
+ sizeof(unsigned long),
+ ret_ref);
- TRACE_FLOW_NUMBER("insert_ulong_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_insert_ulong_property_with_ref returning", error);
return error;
}
/* Insert double property with positioning and reference. */
-int insert_double_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- double number,
- struct collection_item **ret_ref)
+int col_insert_double_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ double number,
+ struct collection_item **ret_ref)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_double_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_insert_double_property_with_ref", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_DOUBLE,
- (void *)&number,
- sizeof(double),
- ret_ref);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_DOUBLE,
+ (void *)&number,
+ sizeof(double),
+ ret_ref);
- TRACE_FLOW_NUMBER("insert_double_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_insert_double_property_with_ref returning", error);
return error;
}
/* Insert bool property with positioning and reference. */
-int insert_bool_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- int disposition,
- const char *refprop,
- int index,
- unsigned flags,
- const char *property,
- unsigned char logical,
- struct collection_item **ret_ref)
+int col_insert_bool_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ int disposition,
+ const char *refprop,
+ int index,
+ unsigned flags,
+ const char *property,
+ unsigned char logical,
+ struct collection_item **ret_ref)
{
int error = EOK;
- TRACE_FLOW_STRING("insert_bool_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_insert_bool_property_with_ref", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- disposition,
- refprop,
- index,
- flags,
- property,
- COL_TYPE_BOOL,
- (void *)&logical,
- sizeof(unsigned char),
- ret_ref);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ disposition,
+ refprop,
+ index,
+ flags,
+ property,
+ COL_TYPE_BOOL,
+ (void *)&logical,
+ sizeof(unsigned char),
+ ret_ref);
- TRACE_FLOW_NUMBER("insert_bool_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_insert_bool_property_with_ref returning", error);
return error;
}
/* Add a string property. */
-int add_str_property(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- char *string,
- int length)
+int col_add_str_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ char *string,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("add_str_property", "Entry.");
+ TRACE_FLOW_STRING("col_add_str_property", "Entry.");
- error = insert_str_property(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- string,
- length);
+ error = col_insert_str_property(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ string,
+ length);
- TRACE_FLOW_NUMBER("add_str_property returning", error);
+ TRACE_FLOW_NUMBER("col_add_str_property returning", error);
return error;
}
/* Add a binary property. */
-int add_binary_property(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- void *binary_data,
- int length)
+int col_add_binary_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ void *binary_data,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("add_binary_property", "Entry.");
+ TRACE_FLOW_STRING("col_add_binary_property", "Entry.");
- error = insert_binary_property(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- binary_data,
- length);
+ error = col_insert_binary_property(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ binary_data,
+ length);
- TRACE_FLOW_NUMBER("add_binary_property returning", error);
+ TRACE_FLOW_NUMBER("col_add_binary_property returning", error);
return error;
}
/* Add an int property. */
-int add_int_property(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- int number)
+int col_add_int_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ int number)
{
int error = EOK;
- TRACE_FLOW_STRING("add_int_property", "Entry.");
+ TRACE_FLOW_STRING("col_add_int_property", "Entry.");
- error = insert_int_property(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- number);
+ error = col_insert_int_property(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ number);
- TRACE_FLOW_NUMBER("add_int_property returning", error);
+ TRACE_FLOW_NUMBER("col_add_int_property returning", error);
return error;
}
/* Add an unsigned int property. */
-int add_unsigned_property(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- unsigned int number)
+int col_add_unsigned_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ unsigned int number)
{
int error = EOK;
- TRACE_FLOW_STRING("add_unsigned_property", "Entry.");
+ TRACE_FLOW_STRING("col_add_unsigned_property", "Entry.");
- error = insert_unsigned_property(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- number);
+ error = col_insert_unsigned_property(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ number);
- TRACE_FLOW_NUMBER("add_unsigned_property returning", error);
+ TRACE_FLOW_NUMBER("col_add_unsigned_property returning", error);
return error;
}
/* Add an long property. */
-int add_long_property(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- long number)
+int col_add_long_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ long number)
{
int error = EOK;
- TRACE_FLOW_STRING("add_long_property", "Entry.");
+ TRACE_FLOW_STRING("col_add_long_property", "Entry.");
- error = insert_long_property(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- number);
+ error = col_insert_long_property(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ number);
- TRACE_FLOW_NUMBER("add_long_property returning", error);
+ TRACE_FLOW_NUMBER("col_add_long_property returning", error);
return error;
}
/* Add an unsigned long property. */
-int add_ulong_property(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- unsigned long number)
+int col_add_ulong_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ unsigned long number)
{
int error = EOK;
- TRACE_FLOW_STRING("add_ulong_property", "Entry.");
+ TRACE_FLOW_STRING("col_add_ulong_property", "Entry.");
- error = insert_ulong_property(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- number);
+ error = col_insert_ulong_property(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ number);
- TRACE_FLOW_NUMBER("add_ulong_property returning", error);
+ TRACE_FLOW_NUMBER("col_add_ulong_property returning", error);
return error;
}
/* Add a double property. */
-int add_double_property(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- double number)
+int col_add_double_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ double number)
{
int error = EOK;
- TRACE_FLOW_STRING("add_double_property", "Entry.");
+ TRACE_FLOW_STRING("col_add_double_property", "Entry.");
- error = insert_double_property(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- number);
+ error = col_insert_double_property(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ number);
- TRACE_FLOW_NUMBER("add_double_property returning", error);
+ TRACE_FLOW_NUMBER("col_add_double_property returning", error);
return error;
}
/* Add a bool property. */
-int add_bool_property(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- unsigned char logical)
-{
- int error = EOK;
-
- TRACE_FLOW_STRING("add_bool_property", "Entry.");
-
- error = insert_bool_property(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- logical);
-
- TRACE_FLOW_NUMBER("add_bool_property returning", error);
- return error;
-}
-
-/* A function to add a property */
-int add_any_property(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- int type,
- void *data,
- int length)
+int col_add_bool_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ unsigned char logical)
{
int error = EOK;
- TRACE_FLOW_STRING("add_any_property", "Entry.");
+ TRACE_FLOW_STRING("col_add_bool_property", "Entry.");
- error = insert_property_with_ref(ci,
+ error = col_insert_bool_property(ci,
subcollection,
COL_DSP_END,
NULL,
0,
0,
property,
- type,
- data,
- length,
- NULL);
+ logical);
- TRACE_FLOW_NUMBER("add_any_property returning", error);
+ TRACE_FLOW_NUMBER("col_add_bool_property returning", error);
return error;
}
-/* Add a string property with reference */
-inline int add_str_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- char *string, int length,
- struct collection_item **ref_ret)
+/* A function to add a property */
+int col_add_any_property(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ int type,
+ void *data,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("add_str_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_add_any_property", "Entry.");
- error = insert_str_property_with_ref(ci,
+ error = col_insert_property_with_ref(ci,
subcollection,
COL_DSP_END,
NULL,
0,
0,
property,
- string,
+ type,
+ data,
length,
- ref_ret);
+ NULL);
+
+ TRACE_FLOW_NUMBER("col_add_any_property returning", error);
+ return error;
+}
+
+/* Add a string property with reference */
+int col_add_str_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ char *string, int length,
+ struct collection_item **ref_ret)
+{
+ int error = EOK;
+
+ TRACE_FLOW_STRING("col_add_str_property_with_ref", "Entry.");
- TRACE_FLOW_NUMBER("add_str_property_with_ref returning", error);
+ error = col_insert_str_property_with_ref(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ string,
+ length,
+ ref_ret);
+
+ TRACE_FLOW_NUMBER("col_add_str_property_with_ref returning", error);
return error;
}
/* Add a binary property with reference. */
-int add_binary_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- void *binary_data, int length,
- struct collection_item **ref_ret)
+int col_add_binary_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ void *binary_data, int length,
+ struct collection_item **ref_ret)
{
int error = EOK;
- TRACE_FLOW_STRING("add_binary_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_add_binary_property_with_ref", "Entry.");
- error = insert_binary_property_with_ref(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- binary_data,
- length,
- ref_ret);
+ error = col_insert_binary_property_with_ref(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ binary_data,
+ length,
+ ref_ret);
- TRACE_FLOW_NUMBER("add_binary_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_add_binary_property_with_ref returning", error);
return error;
}
/* Add an int property with reference. */
-int add_int_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- int number,
- struct collection_item **ref_ret)
+int col_add_int_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ int number,
+ struct collection_item **ref_ret)
{
int error = EOK;
- TRACE_FLOW_STRING("add_int_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_add_int_property_with_ref", "Entry.");
- error = insert_int_property_with_ref(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- number,
- ref_ret);
+ error = col_insert_int_property_with_ref(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ number,
+ ref_ret);
- TRACE_FLOW_NUMBER("add_int_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_add_int_property_with_ref returning", error);
return error;
}
/* Add an unsigned int property with reference. */
-int add_unsigned_property_with_ref(struct collection_item *ci,
+int col_add_unsigned_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ unsigned int number,
+ struct collection_item **ref_ret)
+{
+ int error = EOK;
+
+ TRACE_FLOW_STRING("col_add_unsigned_property_with_ref", "Entry.");
+
+ error = col_insert_unsigned_property_with_ref(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ number,
+ ref_ret);
+
+ TRACE_FLOW_NUMBER("col_add_unsigned_property_with_ref returning", error);
+ return error;
+}
+
+/* Add an long property with reference. */
+int col_add_long_property_with_ref(struct collection_item *ci,
const char *subcollection,
const char *property,
- unsigned int number,
+ long number,
struct collection_item **ref_ret)
{
int error = EOK;
- TRACE_FLOW_STRING("add_unsigned_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_add_long_property_with_ref", "Entry.");
- error = insert_unsigned_property_with_ref(ci,
+ error = col_insert_long_property_with_ref(ci,
subcollection,
COL_DSP_END,
NULL,
@@ -851,416 +876,393 @@ int add_unsigned_property_with_ref(struct collection_item *ci,
number,
ref_ret);
- TRACE_FLOW_NUMBER("add_unsigned_property_with_ref returning", error);
- return error;
-}
-
-/* Add an long property with reference. */
-int add_long_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- long number,
- struct collection_item **ref_ret)
-{
- int error = EOK;
-
- TRACE_FLOW_STRING("add_long_property_with_ref", "Entry.");
-
- error = insert_long_property_with_ref(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- number,
- ref_ret);
-
- TRACE_FLOW_NUMBER("add_long_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_add_long_property_with_ref returning", error);
return error;
}
/* Add an unsigned long property with reference. */
-int add_ulong_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- unsigned long number,
- struct collection_item **ref_ret)
+int col_add_ulong_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ unsigned long number,
+ struct collection_item **ref_ret)
{
int error = EOK;
- TRACE_FLOW_STRING("add_ulong_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_add_ulong_property_with_ref", "Entry.");
- error = insert_ulong_property_with_ref(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- number,
- ref_ret);
+ error = col_insert_ulong_property_with_ref(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ number,
+ ref_ret);
- TRACE_FLOW_NUMBER("add_ulong_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_add_ulong_property_with_ref returning", error);
return error;
}
/* Add a double property with reference. */
-int add_double_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- double number,
- struct collection_item **ref_ret)
+int col_add_double_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ double number,
+ struct collection_item **ref_ret)
{
int error = EOK;
- TRACE_FLOW_STRING("add_double_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_add_double_property_with_ref", "Entry.");
- error = insert_double_property_with_ref(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- number,
- ref_ret);
+ error = col_insert_double_property_with_ref(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ number,
+ ref_ret);
- TRACE_FLOW_NUMBER("add_double_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_add_double_property_with_ref returning", error);
return error;
}
/* Add a bool property with reference. */
-int add_bool_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- unsigned char logical,
- struct collection_item **ref_ret)
+int col_add_bool_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ unsigned char logical,
+ struct collection_item **ref_ret)
{
int error = EOK;
- TRACE_FLOW_STRING("add_bool_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_add_bool_property_with_ref", "Entry.");
- error = insert_bool_property_with_ref(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- logical,
- ref_ret);
+ error = col_insert_bool_property_with_ref(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ logical,
+ ref_ret);
- TRACE_FLOW_NUMBER("add_bool_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_add_bool_property_with_ref returning", error);
return error;
}
/* A function to add a property with reference. */
-int add_any_property_with_ref(struct collection_item *ci,
- const char *subcollection,
- const char *property,
- int type,
- void *data,
- int length,
- struct collection_item **ref_ret)
+int col_add_any_property_with_ref(struct collection_item *ci,
+ const char *subcollection,
+ const char *property,
+ int type,
+ void *data,
+ int length,
+ struct collection_item **ref_ret)
{
int error = EOK;
- TRACE_FLOW_STRING("add_any_property_with_ref", "Entry.");
+ TRACE_FLOW_STRING("col_add_any_property_with_ref", "Entry.");
- error = insert_property_with_ref(ci,
- subcollection,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- property,
- type,
- data,
- length,
- ref_ret);
+ error = col_insert_property_with_ref(ci,
+ subcollection,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ property,
+ type,
+ data,
+ length,
+ ref_ret);
- TRACE_FLOW_NUMBER("add_any_property_with_ref returning", error);
+ TRACE_FLOW_NUMBER("col_add_any_property_with_ref returning", error);
return error;
}
/* Update a string property in the collection.
* Length should include the terminating 0 */
-int update_str_property(struct collection_item *ci,
- const char *property,
- int mode_flags,
- char *string,
- int length)
+int col_update_str_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ char *string,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("update_str_property", "Entry.");
+ TRACE_FLOW_STRING("col_update_str_property", "Entry.");
if (length == 0) length = strlen(string) + 1;
- error = update_property(ci, property, COL_TYPE_STRING,
- (void *)string, length, mode_flags);
+ error = col_update_property(ci, property, COL_TYPE_STRING,
+ (void *)string, length, mode_flags);
- TRACE_FLOW_NUMBER("update_str_property Returning", error);
+ TRACE_FLOW_NUMBER("col_update_str_property Returning", error);
return error;
}
/* Update a binary property in the collection. */
-int update_binary_property(struct collection_item *ci,
- const char *property,
- int mode_flags,
- void *binary_data,
- int length)
+int col_update_binary_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ void *binary_data,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("update_binary_property", "Entry.");
+ TRACE_FLOW_STRING("col_update_binary_property", "Entry.");
- error = update_property(ci, property, COL_TYPE_BINARY,
- binary_data, length, mode_flags);
+ error = col_update_property(ci, property, COL_TYPE_BINARY,
+ binary_data, length, mode_flags);
- TRACE_FLOW_NUMBER("update_binary_property Returning", error);
+ TRACE_FLOW_NUMBER("col_update_binary_property Returning", error);
return error;
}
/* Update an int property in the collection. */
-int update_int_property(struct collection_item *ci,
- const char *property,
- int mode_flags,
- int number)
+int col_update_int_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ int number)
{
int error = EOK;
- TRACE_FLOW_STRING("update_int_property", "Entry.");
+ TRACE_FLOW_STRING("col_update_int_property", "Entry.");
- error = update_property(ci, property, COL_TYPE_INTEGER,
- (void *)(&number), sizeof(int), mode_flags);
+ error = col_update_property(ci, property, COL_TYPE_INTEGER,
+ (void *)(&number), sizeof(int), mode_flags);
- TRACE_FLOW_NUMBER("update_int_property Returning", error);
+ TRACE_FLOW_NUMBER("col_update_int_property Returning", error);
return error;
}
/* Update an unsigned int property. */
-int update_unsigned_property(struct collection_item *ci,
- const char *property,
- int mode_flags,
- unsigned int number)
+int col_update_unsigned_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ unsigned int number)
{
int error = EOK;
- TRACE_FLOW_STRING("update_unsigned_property", "Entry.");
+ TRACE_FLOW_STRING("col_update_unsigned_property", "Entry.");
- error = update_property(ci, property, COL_TYPE_UNSIGNED,
- (void *)(&number), sizeof(unsigned int),
- mode_flags);
+ error = col_update_property(ci, property, COL_TYPE_UNSIGNED,
+ (void *)(&number), sizeof(unsigned int),
+ mode_flags);
- TRACE_FLOW_NUMBER("update_unsigned_property Returning", error);
+ TRACE_FLOW_NUMBER("col_update_unsigned_property Returning", error);
return error;
}
/* Update a long property. */
-int update_long_property(struct collection_item *ci,
- const char *property,
- int mode_flags,
- long number)
+int col_update_long_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ long number)
{
int error = EOK;
- TRACE_FLOW_STRING("update_long_property", "Entry.");
+ TRACE_FLOW_STRING("col_update_long_property", "Entry.");
- error = update_property(ci, property, COL_TYPE_LONG,
- (void *)(&number), sizeof(long), mode_flags);
+ error = col_update_property(ci, property, COL_TYPE_LONG,
+ (void *)(&number), sizeof(long),
+ mode_flags);
- TRACE_FLOW_NUMBER("update_long_property Returning", error);
+ TRACE_FLOW_NUMBER("col_update_long_property Returning", error);
return error;
}
/* Update an unsigned long property. */
-int update_ulong_property(struct collection_item *ci,
- const char *property,
- int mode_flags,
- unsigned long number)
+int col_update_ulong_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ unsigned long number)
{
int error = EOK;
- TRACE_FLOW_STRING("update_ulong_property", "Entry.");
+ TRACE_FLOW_STRING("col_update_ulong_property", "Entry.");
- error = update_property(ci, property, COL_TYPE_ULONG,
- (void *)(&number), sizeof(unsigned long),
- mode_flags);
+ error = col_update_property(ci, property, COL_TYPE_ULONG,
+ (void *)(&number), sizeof(unsigned long),
+ mode_flags);
- TRACE_FLOW_NUMBER("update_ulong_property Returning", error);
+ TRACE_FLOW_NUMBER("col_update_ulong_property Returning", error);
return error;
}
/* Update a double property. */
-int update_double_property(struct collection_item *ci,
- const char *property,
- int mode_flags,
- double number)
+int col_update_double_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ double number)
{
int error = EOK;
- TRACE_FLOW_STRING("update_double_property", "Entry.");
+ TRACE_FLOW_STRING("col_update_double_property", "Entry.");
- error = update_property(ci, property, COL_TYPE_DOUBLE,
- (void *)(&number), sizeof(double), mode_flags);
+ error = col_update_property(ci, property, COL_TYPE_DOUBLE,
+ (void *)(&number), sizeof(double),
+ mode_flags);
- TRACE_FLOW_NUMBER("update_double_property Returning", error);
+ TRACE_FLOW_NUMBER("col_update_double_property Returning", error);
return error;
}
/* Update a bool property. */
-int update_bool_property(struct collection_item *ci,
- const char *property,
- int mode_flags,
- unsigned char logical)
+int col_update_bool_property(struct collection_item *ci,
+ const char *property,
+ int mode_flags,
+ unsigned char logical)
{
int error = EOK;
- TRACE_FLOW_STRING("update_bool_property", "Entry.");
+ TRACE_FLOW_STRING("col_update_bool_property", "Entry.");
- error = update_property(ci, property, COL_TYPE_BOOL,
+ error = col_update_property(ci, property, COL_TYPE_BOOL,
(void *)(&logical), sizeof(unsigned char),
mode_flags);
- TRACE_FLOW_NUMBER("update_bool_property Returning", error);
+ TRACE_FLOW_NUMBER("col_update_bool_property Returning", error);
return error;
}
/* Rename item */
-int modify_item_property(struct collection_item *item,
- const char *property)
+int col_modify_item_property(struct collection_item *item,
+ const char *property)
{
int error;
- TRACE_FLOW_STRING("modify_item_property", "Entry");
+ TRACE_FLOW_STRING("col_modify_item_property", "Entry");
- error = modify_item(item, property, 0, NULL, 0);
+ error = col_modify_item(item, property, 0, NULL, 0);
- TRACE_FLOW_STRING("modify_item_property", "Exit");
+ TRACE_FLOW_STRING("col_modify_item_property", "Exit");
return error;
}
/* Convenience functions that wrap modify_item(). */
/* Modify item data to be str */
-int modify_str_item(struct collection_item *item,
- const char *property,
- char *string,
- int length)
+int col_modify_str_item(struct collection_item *item,
+ const char *property,
+ char *string,
+ int length)
{
int len;
int error;
- TRACE_FLOW_STRING("modify_str_item", "Entry");
+ TRACE_FLOW_STRING("col_modify_str_item", "Entry");
if (length != 0) len = length;
else len = strlen(string) + 1;
- error = modify_item(item, property, COL_TYPE_STRING, (void *)string, len);
+ error = col_modify_item(item, property, COL_TYPE_STRING, (void *)string, len);
- TRACE_FLOW_STRING("modify_str_item", "Exit");
+ TRACE_FLOW_STRING("col_modify_str_item", "Exit");
return error;
}
/* Modify item data to be binary */
-int modify_binary_item(struct collection_item *item,
- const char *property,
- void *binary_data,
- int length)
+int col_modify_binary_item(struct collection_item *item,
+ const char *property,
+ void *binary_data,
+ int length)
{
int error;
- TRACE_FLOW_STRING("modify_binary_item", "Entry");
+ TRACE_FLOW_STRING("col_modify_binary_item", "Entry");
- error = modify_item(item, property, COL_TYPE_BINARY, binary_data, length);
+ error = col_modify_item(item, property, COL_TYPE_BINARY, binary_data, length);
- TRACE_FLOW_STRING("modify_binary_item", "Exit");
+ TRACE_FLOW_STRING("col_modify_binary_item", "Exit");
return error;
}
/* Modify item data to be bool */
-int modify_bool_item(struct collection_item *item,
- const char *property,
- unsigned char logical)
+int col_modify_bool_item(struct collection_item *item,
+ const char *property,
+ unsigned char logical)
{
int error;
- TRACE_FLOW_STRING("modify_bool_item", "Entry");
+ TRACE_FLOW_STRING("col_modify_bool_item", "Entry");
- error = modify_item(item, property, COL_TYPE_BOOL, (void *)(&logical), 1);
+ error = col_modify_item(item, property, COL_TYPE_BOOL, (void *)(&logical), 1);
- TRACE_FLOW_STRING("modify_bool_item", "Exit");
+ TRACE_FLOW_STRING("col_modify_bool_item", "Exit");
return error;
}
/* Modify item data to be int */
-int modify_int_item(struct collection_item *item,
- const char *property,
- int number)
+int col_modify_int_item(struct collection_item *item,
+ const char *property,
+ int number)
{
int error;
- TRACE_FLOW_STRING("modify_int_item","Entry");
+ TRACE_FLOW_STRING("col_modify_int_item","Entry");
- error = modify_item(item, property, COL_TYPE_INTEGER,
- (void *)(&number), sizeof(int));
+ error = col_modify_item(item, property, COL_TYPE_INTEGER,
+ (void *)(&number), sizeof(int));
- TRACE_FLOW_STRING("modify_int_item", "Exit");
+ TRACE_FLOW_STRING("col_modify_int_item", "Exit");
return error;
}
/* Modify item data to be long */
-int modify_long_item(struct collection_item *item,
- const char *property,
- long number)
+int col_modify_long_item(struct collection_item *item,
+ const char *property,
+ long number)
{
int error;
- TRACE_FLOW_STRING("modify_long_item", "Entry");
+ TRACE_FLOW_STRING("col_modify_long_item", "Entry");
- error = modify_item(item, property, COL_TYPE_LONG,
- (void *)(&number), sizeof(long));
+ error = col_modify_item(item, property, COL_TYPE_LONG,
+ (void *)(&number), sizeof(long));
- TRACE_FLOW_STRING("modify_long_item", "Exit");
+ TRACE_FLOW_STRING("col_modify_long_item", "Exit");
return error;
}
/* Modify item data to be unigned long */
-int modify_ulong_item(struct collection_item *item,
- const char *property,
- unsigned long number)
+int col_modify_ulong_item(struct collection_item *item,
+ const char *property,
+ unsigned long number)
{
int error;
- TRACE_FLOW_STRING("modify_ulong_item", "Entry");
+ TRACE_FLOW_STRING("col_modify_ulong_item", "Entry");
- error = modify_item(item, property, COL_TYPE_ULONG,
- (void *)(&number), sizeof(unsigned long));
+ error = col_modify_item(item, property, COL_TYPE_ULONG,
+ (void *)(&number), sizeof(unsigned long));
- TRACE_FLOW_STRING("modify_ulong_item", "Exit");
+ TRACE_FLOW_STRING("col_modify_ulong_item", "Exit");
return error;
}
-int modify_unsigned_item(struct collection_item *item,
- const char *property,
- unsigned number)
+int col_modify_unsigned_item(struct collection_item *item,
+ const char *property,
+ unsigned number)
{
int error;
- TRACE_FLOW_STRING("modify_unsigned_item", "Entry");
+ TRACE_FLOW_STRING("col_modify_unsigned_item", "Entry");
- error = modify_item(item, property, COL_TYPE_UNSIGNED,
- (void *)(&number), sizeof(unsigned));
+ error = col_modify_item(item, property, COL_TYPE_UNSIGNED,
+ (void *)(&number), sizeof(unsigned));
- TRACE_FLOW_STRING("modify_unsigned_item", "Exit");
+ TRACE_FLOW_STRING("col_modify_unsigned_item", "Exit");
return error;
}
-int modify_double_item(struct collection_item *item,
- const char *property,
- double number)
+int col_modify_double_item(struct collection_item *item,
+ const char *property,
+ double number)
{
int error;
- TRACE_FLOW_STRING("modify_double_item", "Entry");
+ TRACE_FLOW_STRING("col_modify_double_item", "Entry");
- error = modify_item(item, property, COL_TYPE_DOUBLE,
- (void *)(&number), sizeof(double));
+ error = col_modify_item(item, property, COL_TYPE_DOUBLE,
+ (void *)(&number), sizeof(double));
- TRACE_FLOW_STRING("modify_double_item", "Exit");
+ TRACE_FLOW_STRING("col_modify_double_item", "Exit");
return error;
}
diff --git a/common/collection/collection_queue.c b/common/collection/collection_queue.c
index 0d5c0ac3..73e532e1 100644
--- a/common/collection/collection_queue.c
+++ b/common/collection/collection_queue.c
@@ -25,36 +25,38 @@
#include "trace.h"
/* Function that creates a queue object */
-int create_queue(struct collection_item **queue)
+int col_create_queue(struct collection_item **queue)
{
int error = EOK;
- TRACE_FLOW_STRING("create_queue", "Entry point.");
+ TRACE_FLOW_STRING("col_create_queue", "Entry point.");
- error = create_collection(queue, COL_NAME_QUEUE, COL_CLASS_QUEUE);
+ error = col_create_collection(queue, COL_NAME_QUEUE, COL_CLASS_QUEUE);
- TRACE_FLOW_STRING("create_queue", "Exit.");
+ TRACE_FLOW_STRING("col_create_queue", "Exit.");
return error;
}
/* Function that destroys a queue object */
-void destroy_queue(struct collection_item *queue)
+void col_destroy_queue(struct collection_item *queue)
{
- TRACE_FLOW_STRING("destroy_queue", "Entry point.");
+ TRACE_FLOW_STRING("col_destroy_queue", "Entry point.");
- destroy_collection(queue);
+ col_destroy_collection(queue);
- TRACE_FLOW_STRING("destroy_queue", "Exit");
+ TRACE_FLOW_STRING("col_destroy_queue", "Exit");
}
/* Put a string property into a queue. */
-int enqueue_str_property(struct collection_item *queue,
- const char *property, char *string, int length)
+int col_enqueue_str_property(struct collection_item *queue,
+ const char *property,
+ char *string,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("enqueue_str_property", "Entry point.");
+ TRACE_FLOW_STRING("col_enqueue_str_property", "Entry point.");
/* Check that queue is not empty */
if (queue == NULL) {
@@ -63,24 +65,26 @@ int enqueue_str_property(struct collection_item *queue,
}
/* Make sure it is a queue */
- if (!is_of_class(queue, COL_CLASS_QUEUE)) {
+ if (!col_is_of_class(queue, COL_CLASS_QUEUE)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_str_property(queue, NULL, property, string, length);
+ error = col_add_str_property(queue, NULL, property, string, length);
- TRACE_FLOW_STRING("enqueue_str_property", "Exit.");
+ TRACE_FLOW_STRING("col_enqueue_str_property", "Exit.");
return error;
}
/* Put a binary property into a queue. */
-int enqueue_binary_property(struct collection_item *queue,
- const char *property, void *binary_data, int length)
+int col_enqueue_binary_property(struct collection_item *queue,
+ const char *property,
+ void *binary_data,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("enqueue_binary_property", "Entry point.");
+ TRACE_FLOW_STRING("col_enqueue_binary_property", "Entry point.");
/* Check that queue is not empty */
if (queue == NULL) {
@@ -89,25 +93,26 @@ int enqueue_binary_property(struct collection_item *queue,
}
/* Make sure it is a queue */
- if (!is_of_class(queue, COL_CLASS_QUEUE)) {
+ if (!col_is_of_class(queue, COL_CLASS_QUEUE)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_binary_property(queue, NULL, property, binary_data, length);
+ error = col_add_binary_property(queue, NULL, property, binary_data, length);
- TRACE_FLOW_STRING("enqueue_binary_property", "Exit.");
+ TRACE_FLOW_STRING("col_enqueue_binary_property", "Exit.");
return error;
}
/* Put an int property into a queue. */
-int enqueue_int_property(struct collection_item *queue,
- const char *property, int number)
+int col_enqueue_int_property(struct collection_item *queue,
+ const char *property,
+ int number)
{
int error = EOK;
- TRACE_FLOW_STRING("enqueue_int_property", "Entry point.");
+ TRACE_FLOW_STRING("col_enqueue_int_property", "Entry point.");
/* Check that queue is not empty */
if (queue == NULL) {
@@ -116,24 +121,25 @@ int enqueue_int_property(struct collection_item *queue,
}
/* Make sure it is a queue */
- if (!is_of_class(queue, COL_CLASS_QUEUE)) {
+ if (!col_is_of_class(queue, COL_CLASS_QUEUE)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_int_property(queue, NULL, property, number);
+ error = col_add_int_property(queue, NULL, property, number);
- TRACE_FLOW_STRING("enqueue_int_property", "Exit.");
+ TRACE_FLOW_STRING("col_enqueue_int_property", "Exit.");
return error;
}
/* Put an unsigned int property into a queue. */
-int enqueue_unsigned_property(struct collection_item *queue,
- const char *property, unsigned int number)
+int col_enqueue_unsigned_property(struct collection_item *queue,
+ const char *property,
+ unsigned int number)
{
int error = EOK;
- TRACE_FLOW_STRING("enqueue_unsigned_property", "Entry point.");
+ TRACE_FLOW_STRING("col_enqueue_unsigned_property", "Entry point.");
/* Check that queue is not empty */
if (queue == NULL) {
@@ -142,25 +148,26 @@ int enqueue_unsigned_property(struct collection_item *queue,
}
/* Make sure it is a queue */
- if (!is_of_class(queue, COL_CLASS_QUEUE)) {
+ if (!col_is_of_class(queue, COL_CLASS_QUEUE)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_unsigned_property(queue, NULL, property, number);
+ error = col_add_unsigned_property(queue, NULL, property, number);
- TRACE_FLOW_STRING("enqueue_unsigned_property", "Exit.");
+ TRACE_FLOW_STRING("col_enqueue_unsigned_property", "Exit.");
return error;
}
/* Put a long property. */
-int enqueue_long_property(struct collection_item *queue,
- const char *property, long number)
+int col_enqueue_long_property(struct collection_item *queue,
+ const char *property,
+ long number)
{
int error = EOK;
- TRACE_FLOW_STRING("enqueue_long_property", "Entry point.");
+ TRACE_FLOW_STRING("col_enqueue_long_property", "Entry point.");
/* Check that queue is not empty */
if (queue == NULL) {
@@ -169,24 +176,25 @@ int enqueue_long_property(struct collection_item *queue,
}
/* Make sure it is a queue */
- if (!is_of_class(queue, COL_CLASS_QUEUE)) {
+ if (!col_is_of_class(queue, COL_CLASS_QUEUE)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_long_property(queue, NULL, property, number);
+ error = col_add_long_property(queue, NULL, property, number);
- TRACE_FLOW_STRING("enqueue_long_property", "Exit.");
+ TRACE_FLOW_STRING("col_enqueue_long_property", "Exit.");
return error;
}
/* Put an unsigned long property. */
-int enqueue_ulong_property(struct collection_item *queue,
- const char *property, unsigned long number)
+int col_enqueue_ulong_property(struct collection_item *queue,
+ const char *property,
+ unsigned long number)
{
int error = EOK;
- TRACE_FLOW_STRING("enqueue_ulong_property", "Entry point.");
+ TRACE_FLOW_STRING("col_enqueue_ulong_property", "Entry point.");
/* Check that queue is not empty */
if (queue == NULL) {
@@ -195,24 +203,25 @@ int enqueue_ulong_property(struct collection_item *queue,
}
/* Make sure it is a queue */
- if (!is_of_class(queue, COL_CLASS_QUEUE)) {
+ if (!col_is_of_class(queue, COL_CLASS_QUEUE)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_ulong_property(queue, NULL, property, number);
+ error = col_add_ulong_property(queue, NULL, property, number);
- TRACE_FLOW_STRING("enqueue_ulong_property", "Exit.");
+ TRACE_FLOW_STRING("col_enqueue_ulong_property", "Exit.");
return error;
}
/* Put a double property. */
-int enqueue_double_property(struct collection_item *queue,
- const char *property, double number)
+int col_enqueue_double_property(struct collection_item *queue,
+ const char *property,
+ double number)
{
int error = EOK;
- TRACE_FLOW_STRING("enqueue_double_property", "Entry point.");
+ TRACE_FLOW_STRING("col_enqueue_double_property", "Entry point.");
/* Check that queue is not empty */
if (queue == NULL) {
@@ -221,24 +230,25 @@ int enqueue_double_property(struct collection_item *queue,
}
/* Make sure it is a queue */
- if (!is_of_class(queue, COL_CLASS_QUEUE)) {
+ if (!col_is_of_class(queue, COL_CLASS_QUEUE)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_double_property(queue, NULL, property, number);
+ error = col_add_double_property(queue, NULL, property, number);
TRACE_FLOW_STRING("enqueue_double_property", "Exit.");
return error;
}
/* Put a bool property. */
-int enqueue_bool_property(struct collection_item *queue,
- const char *property, unsigned char logical)
+int col_enqueue_bool_property(struct collection_item *queue,
+ const char *property,
+ unsigned char logical)
{
int error = EOK;
- TRACE_FLOW_STRING("enqueue_bool_property", "Entry point.");
+ TRACE_FLOW_STRING("col_enqueue_bool_property", "Entry point.");
/* Check that queue is not empty */
if (queue == NULL) {
@@ -247,27 +257,27 @@ int enqueue_bool_property(struct collection_item *queue,
}
/* Make sure it is a queue */
- if (!is_of_class(queue, COL_CLASS_QUEUE)) {
+ if (!col_is_of_class(queue, COL_CLASS_QUEUE)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_bool_property(queue, NULL, property, logical);
+ error = col_add_bool_property(queue, NULL, property, logical);
- TRACE_FLOW_STRING("enqueue_bool_property", "Exit.");
+ TRACE_FLOW_STRING("col_enqueue_bool_property", "Exit.");
return error;
}
/* Put any property */
-int enqueue_any_property(struct collection_item *queue,
- const char *property,
- int type,
- void *data,
- int length)
+int col_enqueue_any_property(struct collection_item *queue,
+ const char *property,
+ int type,
+ void *data,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("enqueue_any_property", "Entry point.");
+ TRACE_FLOW_STRING("col_enqueue_any_property", "Entry point.");
/* Check that queue is not empty */
if (queue == NULL) {
@@ -276,24 +286,24 @@ int enqueue_any_property(struct collection_item *queue,
}
/* Make sure it is a queue */
- if (!is_of_class(queue, COL_CLASS_QUEUE)) {
+ if (!col_is_of_class(queue, COL_CLASS_QUEUE)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_any_property(queue, NULL, property, type, data, length);
+ error = col_add_any_property(queue, NULL, property, type, data, length);
- TRACE_FLOW_STRING("enqueue_any_property", "Exit.");
+ TRACE_FLOW_STRING("col_enqueue_any_property", "Exit.");
return error;
}
/* Enqueue item */
-int enqueue_item(struct collection_item *queue,
- struct collection_item *item)
+int col_enqueue_item(struct collection_item *queue,
+ struct collection_item *item)
{
int error = EOK;
- TRACE_FLOW_STRING("enqueue_item", "Entry point.");
+ TRACE_FLOW_STRING("col_enqueue_item", "Entry point.");
/* Check that queue is not empty */
if (queue == NULL) {
@@ -302,29 +312,29 @@ int enqueue_item(struct collection_item *queue,
}
/* Make sure it is a queue */
- if (!is_of_class(queue, COL_CLASS_QUEUE)) {
+ if (!col_is_of_class(queue, COL_CLASS_QUEUE)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = insert_item_into_current(queue,
- item,
- COL_DSP_END,
- NULL,
- 0,
- COL_INSERT_NOCHECK);
+ error = col_insert_item_into_current(queue,
+ item,
+ COL_DSP_END,
+ NULL,
+ 0,
+ COL_INSERT_NOCHECK);
- TRACE_FLOW_STRING("enqueue_item", "Exit.");
+ TRACE_FLOW_STRING("col_enqueue_item", "Exit.");
return error;
}
/* Dequeue item */
-int dequeue_item(struct collection_item *queue,
- struct collection_item **item)
+int col_dequeue_item(struct collection_item *queue,
+ struct collection_item **item)
{
int error = EOK;
- TRACE_FLOW_STRING("dequeue_item", "Entry point.");
+ TRACE_FLOW_STRING("col_dequeue_item", "Entry point.");
/* Check that queue is not empty */
if (queue == NULL) {
@@ -333,18 +343,18 @@ int dequeue_item(struct collection_item *queue,
}
/* Make sure it is a queue */
- if (!is_of_class(queue, COL_CLASS_QUEUE)) {
+ if (!col_is_of_class(queue, COL_CLASS_QUEUE)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = extract_item_from_current(queue,
- COL_DSP_FRONT,
- NULL,
- 0,
- 0,
- item);
+ error = col_extract_item_from_current(queue,
+ COL_DSP_FRONT,
+ NULL,
+ 0,
+ 0,
+ item);
- TRACE_FLOW_STRING("dequeue_item", "Exit.");
+ TRACE_FLOW_STRING("col_dequeue_item", "Exit.");
return error;
}
diff --git a/common/collection/collection_queue.h b/common/collection/collection_queue.h
index 113fcbfb..24bdd65e 100644
--- a/common/collection/collection_queue.h
+++ b/common/collection/collection_queue.h
@@ -29,53 +29,63 @@
#define COL_NAME_QUEUE "queue"
/* Function that creates a queue object */
-int create_queue(struct collection_item **queue);
+int col_create_queue(struct collection_item **queue);
/* Function that destroys a queue object */
-void destroy_queue(struct collection_item *queue);
+void col_destroy_queue(struct collection_item *queue);
/* Family of functions that add property to a queue */
/* Put a string property to queue. */
-int enqueue_str_property(struct collection_item *queue,
- const char *property, char *string, int length);
+int col_enqueue_str_property(struct collection_item *queue,
+ const char *property,
+ char *string,
+ int length);
/* Put a binary property to queue. */
-int enqueue_binary_property(struct collection_item *queue,
- const char *property, void *binary_data, int length);
+int col_enqueue_binary_property(struct collection_item *queue,
+ const char *property,
+ void *binary_data,
+ int length);
/* Put an int property to queue. */
-int enqueue_int_property(struct collection_item *queue,
- const char *property, int number);
+int col_enqueue_int_property(struct collection_item *queue,
+ const char *property,
+ int number);
/* Put an unsigned int property to queue. */
-int enqueue_unsigned_property(struct collection_item *queue,
- const char *property, unsigned int number);
+int col_enqueue_unsigned_property(struct collection_item *queue,
+ const char *property,
+ unsigned int number);
/* Put a long property. */
-int enqueue_long_property(struct collection_item *queue,
- const char *property, long number);
+int col_enqueue_long_property(struct collection_item *queue,
+ const char *property,
+ long number);
/* Put an unsigned long property. */
-int enqueue_ulong_property(struct collection_item *queue,
- const char *property, unsigned long number);
+int col_enqueue_ulong_property(struct collection_item *queue,
+ const char *property,
+ unsigned long number);
/* Put a double property. */
-int enqueue_double_property(struct collection_item *queue,
- const char *property, double number);
+int col_enqueue_double_property(struct collection_item *queue,
+ const char *property,
+ double number);
/* Put a bool property. */
-int enqueue_bool_property(struct collection_item *queue,
- const char *property, unsigned char logical);
+int col_enqueue_bool_property(struct collection_item *queue,
+ const char *property,
+ unsigned char logical);
/* Put any property */
-int enqueue_any_property(struct collection_item *queue, /* Queue */
- const char *property, /* Name */
- int type, /* Data type */
- void *data, /* Pointer to the data */
- int length); /* Length of the data. For
- strings it includes the
- trailing 0 */
+int col_enqueue_any_property(struct collection_item *queue, /* Queue */
+ const char *property, /* Name */
+ int type, /* Data type */
+ void *data, /* Pointer to the data */
+ int length); /* Length of the data. For
+ * strings it includes the
+ * trailing 0 */
/* Push item */
-int enqueue_item(struct collection_item *queue,
- struct collection_item *item);
+int col_enqueue_item(struct collection_item *queue,
+ struct collection_item *item);
/* Get item from queue */
-int dequeue_item(struct collection_item *queue,
- struct collection_item **item);
+int col_dequeue_item(struct collection_item *queue,
+ struct collection_item **item);
#endif
diff --git a/common/collection/collection_queue_ut.c b/common/collection/collection_queue_ut.c
index b4bd5c28..203936ab 100644
--- a/common/collection/collection_queue_ut.c
+++ b/common/collection/collection_queue_ut.c
@@ -42,26 +42,26 @@ int queue_test()
printf("\n\nQUEUE TEST!!!.\n\n\n");
- if((error = create_queue(&queue)) ||
- (error = enqueue_str_property(queue, "item1","value 1" ,0)) ||
- (error = enqueue_int_property(queue, "item2", -1)) ||
- (error = enqueue_unsigned_property(queue, "item3", 1)) ||
- (error = enqueue_long_property(queue, "item4", 100)) ||
- (error = enqueue_ulong_property(queue, "item5", 1000)) ||
- (error = enqueue_double_property(queue, "item6", 1.1)) ||
- (error = enqueue_bool_property(queue, "item7", 1)) ||
- (error = enqueue_binary_property(queue, "item8", binary_dump, sizeof(binary_dump)))) {
+ if((error = col_create_queue(&queue)) ||
+ (error = col_enqueue_str_property(queue, "item1","value 1" ,0)) ||
+ (error = col_enqueue_int_property(queue, "item2", -1)) ||
+ (error = col_enqueue_unsigned_property(queue, "item3", 1)) ||
+ (error = col_enqueue_long_property(queue, "item4", 100)) ||
+ (error = col_enqueue_ulong_property(queue, "item5", 1000)) ||
+ (error = col_enqueue_double_property(queue, "item6", 1.1)) ||
+ (error = col_enqueue_bool_property(queue, "item7", 1)) ||
+ (error = col_enqueue_binary_property(queue, "item8", binary_dump, sizeof(binary_dump)))) {
printf("Failed to enqueue property. Error %d\n", error);
- destroy_collection(queue);
+ col_destroy_collection(queue);
return error;
}
- debug_collection(queue,COL_TRAVERSE_DEFAULT);
+ col_debug_collection(queue,COL_TRAVERSE_DEFAULT);
- error = get_collection_count(queue, &count);
+ error = col_get_collection_count(queue, &count);
if (error) {
printf("Failed to get count. Error %d\n", error);
- destroy_collection(queue);
+ col_destroy_collection(queue);
return error;
}
@@ -70,16 +70,16 @@ int queue_test()
printf("Rotate the queue.\n");
for (i = 0; i < count; i++) {
- if ((error = dequeue_item(queue, &item)) ||
- (error = enqueue_item(queue, item))) {
+ if ((error = col_dequeue_item(queue, &item)) ||
+ (error = col_enqueue_item(queue, item))) {
printf("Failed to dequeue or enqueue items. Error %d\n", error);
- destroy_collection(queue);
+ col_destroy_collection(queue);
return error;
}
- debug_collection(queue,COL_TRAVERSE_DEFAULT);
+ col_debug_collection(queue,COL_TRAVERSE_DEFAULT);
}
- destroy_collection(queue);
+ col_destroy_collection(queue);
TRACE_FLOW_NUMBER("queue_test. Returning", error);
printf("\n\nEND OF QUEUE TEST!!!.\n\n\n");
diff --git a/common/collection/collection_stack.c b/common/collection/collection_stack.c
index 70211220..9290b4e4 100644
--- a/common/collection/collection_stack.c
+++ b/common/collection/collection_stack.c
@@ -25,36 +25,36 @@
#include "trace.h"
/* Function that creates a stack object */
-int create_stack(struct collection_item **stack)
+int col_create_stack(struct collection_item **stack)
{
int error = EOK;
- TRACE_FLOW_STRING("create_stack", "Entry point.");
+ TRACE_FLOW_STRING("col_create_stack", "Entry point.");
- error = create_collection(stack, COL_NAME_STACK, COL_CLASS_STACK);
+ error = col_create_collection(stack, COL_NAME_STACK, COL_CLASS_STACK);
- TRACE_FLOW_STRING("create_stack", "Exit.");
+ TRACE_FLOW_STRING("col_create_stack", "Exit.");
return error;
}
/* Function that destroys a stack object */
-void destroy_stack(struct collection_item *stack)
+void col_destroy_stack(struct collection_item *stack)
{
- TRACE_FLOW_STRING("destroy_stack", "Entry point.");
+ TRACE_FLOW_STRING("col_destroy_stack", "Entry point.");
- destroy_collection(stack);
+ col_destroy_collection(stack);
- TRACE_FLOW_STRING("destroy_stack", "Exit");
+ TRACE_FLOW_STRING("col_destroy_stack", "Exit");
}
-int push_str_property(struct collection_item *stack,
- const char *property, char *string, int length)
+int col_push_str_property(struct collection_item *stack,
+ const char *property, char *string, int length)
{
int error = EOK;
- TRACE_FLOW_STRING("push_str_property", "Entry point.");
+ TRACE_FLOW_STRING("col_push_str_property", "Entry point.");
/* Check that stack is not empty */
if (stack == NULL) {
@@ -63,24 +63,26 @@ int push_str_property(struct collection_item *stack,
}
/* Make sure it is a stack */
- if (!is_of_class(stack, COL_CLASS_STACK)) {
+ if (!col_is_of_class(stack, COL_CLASS_STACK)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_str_property(stack, NULL, property, string, length);
+ error = col_add_str_property(stack, NULL, property, string, length);
- TRACE_FLOW_STRING("push_str_property", "Exit.");
+ TRACE_FLOW_STRING("col_push_str_property", "Exit.");
return error;
}
/* Push a binary property to stack. */
-int push_binary_property(struct collection_item *stack,
- const char *property, void *binary_data, int length)
+int col_push_binary_property(struct collection_item *stack,
+ const char *property,
+ void *binary_data,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("push_binary_property", "Entry point.");
+ TRACE_FLOW_STRING("col_push_binary_property", "Entry point.");
/* Check that stack is not empty */
if (stack == NULL) {
@@ -89,25 +91,26 @@ int push_binary_property(struct collection_item *stack,
}
/* Make sure it is a stack */
- if (!is_of_class(stack, COL_CLASS_STACK)) {
+ if (!col_is_of_class(stack, COL_CLASS_STACK)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_binary_property(stack, NULL, property, binary_data, length);
+ error = col_add_binary_property(stack, NULL, property, binary_data, length);
- TRACE_FLOW_STRING("push_binary_property", "Exit.");
+ TRACE_FLOW_STRING("col_push_binary_property", "Exit.");
return error;
}
/* Push an int property to stack. */
-int push_int_property(struct collection_item *stack,
- const char *property, int number)
+int col_push_int_property(struct collection_item *stack,
+ const char *property,
+ int number)
{
int error = EOK;
- TRACE_FLOW_STRING("push_int_property", "Entry point.");
+ TRACE_FLOW_STRING("col_push_int_property", "Entry point.");
/* Check that stack is not empty */
if (stack == NULL) {
@@ -116,24 +119,25 @@ int push_int_property(struct collection_item *stack,
}
/* Make sure it is a stack */
- if (!is_of_class(stack, COL_CLASS_STACK)) {
+ if (!col_is_of_class(stack, COL_CLASS_STACK)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_int_property(stack, NULL, property, number);
+ error = col_add_int_property(stack, NULL, property, number);
- TRACE_FLOW_STRING("push_int_property", "Exit.");
+ TRACE_FLOW_STRING("col_push_int_property", "Exit.");
return error;
}
/* Push an unsigned int property to stack. */
-int push_unsigned_property(struct collection_item *stack,
- const char *property, unsigned int number)
+int col_push_unsigned_property(struct collection_item *stack,
+ const char *property,
+ unsigned int number)
{
int error = EOK;
- TRACE_FLOW_STRING("push_unsigned_property", "Entry point.");
+ TRACE_FLOW_STRING("col_push_unsigned_property", "Entry point.");
/* Check that stack is not empty */
if (stack == NULL) {
@@ -142,25 +146,26 @@ int push_unsigned_property(struct collection_item *stack,
}
/* Make sure it is a stack */
- if (!is_of_class(stack, COL_CLASS_STACK)) {
+ if (!col_is_of_class(stack, COL_CLASS_STACK)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_unsigned_property(stack, NULL, property, number);
+ error = col_add_unsigned_property(stack, NULL, property, number);
- TRACE_FLOW_STRING("push_unsigned_property", "Exit.");
+ TRACE_FLOW_STRING("col_push_unsigned_property", "Exit.");
return error;
}
/* Push a long property. */
-int push_long_property(struct collection_item *stack,
- const char *property, long number)
+int col_push_long_property(struct collection_item *stack,
+ const char *property,
+ long number)
{
int error = EOK;
- TRACE_FLOW_STRING("push_long_property", "Entry point.");
+ TRACE_FLOW_STRING("col_push_long_property", "Entry point.");
/* Check that stack is not empty */
if (stack == NULL) {
@@ -169,24 +174,25 @@ int push_long_property(struct collection_item *stack,
}
/* Make sure it is a stack */
- if (!is_of_class(stack, COL_CLASS_STACK)) {
+ if (!col_is_of_class(stack, COL_CLASS_STACK)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_long_property(stack, NULL, property, number);
+ error = col_add_long_property(stack, NULL, property, number);
- TRACE_FLOW_STRING("push_long_property", "Exit.");
+ TRACE_FLOW_STRING("col_push_long_property", "Exit.");
return error;
}
/* Push an unsigned long property. */
-int push_ulong_property(struct collection_item *stack,
- const char *property, unsigned long number)
+int col_push_ulong_property(struct collection_item *stack,
+ const char *property,
+ unsigned long number)
{
int error = EOK;
- TRACE_FLOW_STRING("push_ulong_property", "Entry point.");
+ TRACE_FLOW_STRING("col_push_ulong_property", "Entry point.");
/* Check that stack is not empty */
if (stack == NULL) {
@@ -195,24 +201,25 @@ int push_ulong_property(struct collection_item *stack,
}
/* Make sure it is a stack */
- if (!is_of_class(stack, COL_CLASS_STACK)) {
+ if (!col_is_of_class(stack, COL_CLASS_STACK)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_ulong_property(stack, NULL, property, number);
+ error = col_add_ulong_property(stack, NULL, property, number);
- TRACE_FLOW_STRING("push_ulong_property", "Exit.");
+ TRACE_FLOW_STRING("col_push_ulong_property", "Exit.");
return error;
}
/* Push a double property. */
-int push_double_property(struct collection_item *stack,
- const char *property, double number)
+int col_push_double_property(struct collection_item *stack,
+ const char *property,
+ double number)
{
int error = EOK;
- TRACE_FLOW_STRING("push_double_property", "Entry point.");
+ TRACE_FLOW_STRING("col_push_double_property", "Entry point.");
/* Check that stack is not empty */
if (stack == NULL) {
@@ -221,24 +228,25 @@ int push_double_property(struct collection_item *stack,
}
/* Make sure it is a stack */
- if (!is_of_class(stack, COL_CLASS_STACK)) {
+ if (!col_is_of_class(stack, COL_CLASS_STACK)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_double_property(stack, NULL, property, number);
+ error = col_add_double_property(stack, NULL, property, number);
- TRACE_FLOW_STRING("push_double_property", "Exit.");
+ TRACE_FLOW_STRING("col_push_double_property", "Exit.");
return error;
}
/* Push a bool property. */
-int push_bool_property(struct collection_item *stack,
- const char *property, unsigned char logical)
+int col_push_bool_property(struct collection_item *stack,
+ const char *property,
+ unsigned char logical)
{
int error = EOK;
- TRACE_FLOW_STRING("push_bool_property", "Entry point.");
+ TRACE_FLOW_STRING("col_push_bool_property", "Entry point.");
/* Check that stack is not empty */
if (stack == NULL) {
@@ -247,27 +255,27 @@ int push_bool_property(struct collection_item *stack,
}
/* Make sure it is a stack */
- if (!is_of_class(stack, COL_CLASS_STACK)) {
+ if (!col_is_of_class(stack, COL_CLASS_STACK)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_bool_property(stack, NULL, property, logical);
+ error = col_add_bool_property(stack, NULL, property, logical);
TRACE_FLOW_STRING("push_double_property", "Exit.");
return error;
}
/* Push any property */
-int push_any_property(struct collection_item *stack,
- const char *property,
- int type,
- void *data,
- int length)
+int col_push_any_property(struct collection_item *stack,
+ const char *property,
+ int type,
+ void *data,
+ int length)
{
int error = EOK;
- TRACE_FLOW_STRING("push_bool_property", "Entry point.");
+ TRACE_FLOW_STRING("col_push_any_property", "Entry point.");
/* Check that stack is not empty */
if (stack == NULL) {
@@ -276,24 +284,24 @@ int push_any_property(struct collection_item *stack,
}
/* Make sure it is a stack */
- if (!is_of_class(stack, COL_CLASS_STACK)) {
+ if (!col_is_of_class(stack, COL_CLASS_STACK)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = add_any_property(stack, NULL, property, type, data, length);
+ error = col_add_any_property(stack, NULL, property, type, data, length);
- TRACE_FLOW_STRING("push_bool_property", "Exit.");
+ TRACE_FLOW_STRING("col_push_any_property", "Exit.");
return error;
}
/* Push item */
-int push_item(struct collection_item *stack,
- struct collection_item *item)
+int col_push_item(struct collection_item *stack,
+ struct collection_item *item)
{
int error = EOK;
- TRACE_FLOW_STRING("push_item", "Entry point.");
+ TRACE_FLOW_STRING("col_push_item", "Entry point.");
/* Check that stack is not empty */
if (stack == NULL) {
@@ -302,29 +310,29 @@ int push_item(struct collection_item *stack,
}
/* Make sure it is a stack */
- if (!is_of_class(stack, COL_CLASS_STACK)) {
+ if (!col_is_of_class(stack, COL_CLASS_STACK)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = insert_item_into_current(stack,
- item,
- COL_DSP_END,
- NULL,
- 0,
- COL_INSERT_NOCHECK);
+ error = col_insert_item_into_current(stack,
+ item,
+ COL_DSP_END,
+ NULL,
+ 0,
+ COL_INSERT_NOCHECK);
- TRACE_FLOW_STRING("push_item", "Exit.");
+ TRACE_FLOW_STRING("col_push_item", "Exit.");
return error;
}
/* Pop_item */
-int pop_item(struct collection_item *stack,
- struct collection_item **item)
+int col_pop_item(struct collection_item *stack,
+ struct collection_item **item)
{
int error = EOK;
- TRACE_FLOW_STRING("pop_item", "Entry point.");
+ TRACE_FLOW_STRING("col_pop_item", "Entry point.");
/* Check that stack is not empty */
if (stack == NULL) {
@@ -333,18 +341,18 @@ int pop_item(struct collection_item *stack,
}
/* Make sure it is a stack */
- if (!is_of_class(stack, COL_CLASS_STACK)) {
+ if (!col_is_of_class(stack, COL_CLASS_STACK)) {
TRACE_ERROR_STRING("Wrong class", "");
return EINVAL;
}
- error = extract_item_from_current(stack,
- COL_DSP_END,
- NULL,
- 0,
- 0,
- item);
+ error = col_extract_item_from_current(stack,
+ COL_DSP_END,
+ NULL,
+ 0,
+ 0,
+ item);
- TRACE_FLOW_STRING("pop_item", "Exit.");
+ TRACE_FLOW_STRING("col_pop_item", "Exit.");
return error;
}
diff --git a/common/collection/collection_stack.h b/common/collection/collection_stack.h
index 447b3df5..ef52767f 100644
--- a/common/collection/collection_stack.h
+++ b/common/collection/collection_stack.h
@@ -29,53 +29,62 @@
#define COL_NAME_STACK "stack"
/* Function that creates a stack object */
-int create_stack(struct collection_item **stack);
+int col_create_stack(struct collection_item **stack);
/* Function that destroys a stack object */
-void destroy_stack(struct collection_item *stack);
+void col_destroy_stack(struct collection_item *stack);
/* Family of functions that push property to stack */
/* Push a string property to stack. */
-int push_str_property(struct collection_item *stack,
- const char *property, char *string, int length);
+int col_push_str_property(struct collection_item *stack,
+ const char *property,
+ char *string,
+ int length);
/* Push a binary property to stack. */
-int push_binary_property(struct collection_item *stack,
- const char *property, void *binary_data, int length);
+int col_push_binary_property(struct collection_item *stack,
+ const char *property,
+ void *binary_data,
+ int length);
/* Push an int property to stack. */
-int push_int_property(struct collection_item *stack,
- const char *property, int number);
+int col_push_int_property(struct collection_item *stack,
+ const char *property,
+ int number);
/* Push an unsigned int property to stack. */
-int push_unsigned_property(struct collection_item *stack,
- const char *property, unsigned int number);
+int col_push_unsigned_property(struct collection_item *stack,
+ const char *property,
+ unsigned int number);
/* Push a long property. */
-int push_long_property(struct collection_item *stack,
- const char *property, long number);
+int col_push_long_property(struct collection_item *stack,
+ const char *property,
+ long number);
/* Push an unsigned long property. */
-int push_ulong_property(struct collection_item *stack,
- const char *property, unsigned long number);
+int col_push_ulong_property(struct collection_item *stack,
+ const char *property,
+ unsigned long number);
/* Push a double property. */
-int push_double_property(struct collection_item *stack,
- const char *property, double number);
+int col_push_double_property(struct collection_item *stack,
+ const char *property,
+ double number);
/* Push a bool property. */
-int push_bool_property(struct collection_item *stack,
- const char *property, unsigned char logical);
+int col_push_bool_property(struct collection_item *stack,
+ const char *property,
+ unsigned char logical);
/* Push any property */
-int push_any_property(struct collection_item *stack, /* Stack */
- const char *property, /* Name */
- int type, /* Data type */
- void *data, /* Pointer to the data */
- int length); /* Length of the data. For
- strings it includes the
- trailing 0 */
+int col_push_any_property(struct collection_item *stack, /* Stack */
+ const char *property, /* Name */
+ int type, /* Data type */
+ void *data, /* Pointer to the data */
+ int length); /* Length of the data. For
+ * strings it includes the
+ * trailing 0 */
/* Push item */
-int push_item(struct collection_item *stack,
- struct collection_item *item);
+int col_push_item(struct collection_item *stack,
+ struct collection_item *item);
/* Pop item */
-int pop_item(struct collection_item *stack,
- struct collection_item **item);
-
+int col_pop_item(struct collection_item *stack,
+ struct collection_item **item);
#endif
diff --git a/common/collection/collection_stack_ut.c b/common/collection/collection_stack_ut.c
index 667af103..b3337c77 100644
--- a/common/collection/collection_stack_ut.c
+++ b/common/collection/collection_stack_ut.c
@@ -42,51 +42,51 @@ int stack_test()
printf("\n\nSTACK TEST!!!.\n\n\n");
- if ((error = create_stack(&stack)) ||
- (error = push_str_property(stack, "item1", "value 1", 0)) ||
- (error = push_int_property(stack, "item2", -1)) ||
- (error = push_unsigned_property(stack, "item3", 1)) ||
- (error = push_long_property(stack, "item4", 100)) ||
- (error = push_ulong_property(stack, "item5", 1000)) ||
- (error = push_double_property(stack, "item6", 1.1)) ||
- (error = push_bool_property(stack, "item7", 1)) ||
- (error = push_binary_property(stack, "item8", binary_dump, sizeof(binary_dump)))) {
+ if ((error = col_create_stack(&stack)) ||
+ (error = col_push_str_property(stack, "item1", "value 1", 0)) ||
+ (error = col_push_int_property(stack, "item2", -1)) ||
+ (error = col_push_unsigned_property(stack, "item3", 1)) ||
+ (error = col_push_long_property(stack, "item4", 100)) ||
+ (error = col_push_ulong_property(stack, "item5", 1000)) ||
+ (error = col_push_double_property(stack, "item6", 1.1)) ||
+ (error = col_push_bool_property(stack, "item7", 1)) ||
+ (error = col_push_binary_property(stack, "item8", binary_dump, sizeof(binary_dump)))) {
printf("Failed to push property. Error %d\n", error);
- destroy_collection(stack);
+ col_destroy_collection(stack);
return error;
}
- debug_collection(stack, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(stack, COL_TRAVERSE_DEFAULT);
printf("Swapping last two items by popping and pushing them back.\n");
- if ((error = pop_item(stack, &item1)) ||
- (error = pop_item(stack, &item2))) {
+ if ((error = col_pop_item(stack, &item1)) ||
+ (error = col_pop_item(stack, &item2))) {
printf("Failed to pop items. Error %d\n", error);
- destroy_collection(stack);
+ col_destroy_collection(stack);
return error;
}
printf("\nPopped two last items.\n");
- debug_collection(stack, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(stack, COL_TRAVERSE_DEFAULT);
printf("\nLast item.\n");
- debug_item(item1);
+ col_debug_item(item1);
printf("\nPrevious item.\n");
- debug_item(item2);
+ col_debug_item(item2);
- if ((error = push_item(stack, item1)) ||
- (error = push_item(stack, item2))) {
+ if ((error = col_push_item(stack, item1)) ||
+ (error = col_push_item(stack, item2))) {
printf("Failed to pop or push items. Error %d\n", error);
- destroy_collection(stack);
+ col_destroy_collection(stack);
return error;
}
printf("\n\nPushed two items again in reverse order.\n\n");
- debug_collection(stack, COL_TRAVERSE_DEFAULT);
- destroy_collection(stack);
+ col_debug_collection(stack, COL_TRAVERSE_DEFAULT);
+ col_destroy_collection(stack);
TRACE_FLOW_NUMBER("stack_test. Returning", error);
printf("\n\nEND OF STACK TEST!!!.\n\n");
diff --git a/common/collection/collection_tools.c b/common/collection/collection_tools.c
index 2fec6c55..88ba4f09 100644
--- a/common/collection/collection_tools.c
+++ b/common/collection/collection_tools.c
@@ -30,18 +30,18 @@
#include "collection_tools.h"
/* Debug handle */
-int debug_handle(const char *property,
- int property_len,
- int type,
- void *data,
- int length,
- void *custom_data,
- int *dummy)
+int col_debug_handle(const char *property,
+ int property_len,
+ int type,
+ void *data,
+ int length,
+ void *custom_data,
+ int *dummy)
{
int i;
int nest_level;
- TRACE_FLOW_STRING("debug_handle", "Entry.");
+ TRACE_FLOW_STRING("col_debug_handle", "Entry.");
nest_level = *(int *)(custom_data);
@@ -146,32 +146,32 @@ int debug_handle(const char *property,
}
*(int *)(custom_data) = nest_level;
TRACE_INFO_NUMBER("Nest level at the end:", nest_level);
- TRACE_FLOW_STRING("debug_handle", "Success exit.");
+ TRACE_FLOW_STRING("col_debug_handle", "Success exit.");
return EOK;
}
/* Convenience function to debug an item */
-inline int debug_item(struct collection_item *item)
+inline int col_debug_item(struct collection_item *item)
{
int dummy = 0;
int nest_level = 0;
- return debug_handle(item->property,
- item->property_len,
- item->type,
- item->data,
- item->length,
- (void *)(&nest_level),
- &dummy);
+ return col_debug_handle(item->property,
+ item->property_len,
+ item->type,
+ item->data,
+ item->length,
+ (void *)(&nest_level),
+ &dummy);
}
/* Print collection for debugging purposes */
-int debug_collection(struct collection_item *handle, int flag)
+int col_debug_collection(struct collection_item *handle, int flag)
{
int error = EOK;
int nest_level = 0;
- TRACE_FLOW_STRING("debug_collection", "Entry.");
+ TRACE_FLOW_STRING("col_debug_collection", "Entry.");
printf("DEBUG COLLECTION %s\n", handle->property);
@@ -180,17 +180,18 @@ int debug_collection(struct collection_item *handle, int flag)
printf("Traverse flags %d\n", flag);
/* Traverse collection */
- error = traverse_collection(handle, flag,
- debug_handle, (void *)(&nest_level));
+ error = col_traverse_collection(handle, flag,
+ col_debug_handle,
+ (void *)(&nest_level));
if (error) printf("Error debuging collection %d\n", error);
- TRACE_FLOW_STRING("debug_collection", "Exit.");
+ TRACE_FLOW_STRING("col_debug_collection", "Exit.");
return error;
}
/* Return a static string based on type of the element */
-static inline const char *get_type(int type)
+static inline const char *col_get_type(int type)
{
switch (type) {
case COL_TYPE_STRING:
@@ -224,11 +225,11 @@ static inline const char *get_type(int type)
}
/* Calculate the potential size of the item */
-int get_data_len(int type, int length)
+int col_get_data_len(int type, int length)
{
int len = 0;
- TRACE_FLOW_STRING("util_get_item_len", "Entry point");
+ TRACE_FLOW_STRING("col_get_data_len", "Entry point");
switch (type) {
case COL_TYPE_INTEGER:
@@ -256,13 +257,13 @@ int get_data_len(int type, int length)
break;
}
- TRACE_FLOW_STRING("util_get_item_len","Exit point");
+ TRACE_FLOW_STRING("col_get_data_len","Exit point");
return len;
}
/* Copy data escaping characters */
-static int copy_esc(char *dest, char *source, char esc)
+static int col_copy_esc(char *dest, char *source, char esc)
{
int i = 0;
int j = 0;
@@ -289,11 +290,11 @@ static int copy_esc(char *dest, char *source, char esc)
}
/* Grow buffer to accomodate more space */
-int grow_buffer(struct serial_data *buf_data, int len)
+int col_grow_buffer(struct col_serial_data *buf_data, int len)
{
char *tmp;
- TRACE_FLOW_STRING("grow_buffer", "Entry point");
+ TRACE_FLOW_STRING("col_grow_buffer", "Entry point");
TRACE_INFO_NUMBER("Current length: ", buf_data->length);
TRACE_INFO_NUMBER("Increment length: ", len);
TRACE_INFO_NUMBER("Expected length: ", buf_data->length+len);
@@ -314,42 +315,42 @@ int grow_buffer(struct serial_data *buf_data, int len)
}
TRACE_INFO_NUMBER("Final size: ", buf_data->size);
- TRACE_FLOW_STRING("grow_buffer", "Success Exit.");
+ TRACE_FLOW_STRING("col_grow_buffer", "Success Exit.");
return EOK;
}
/* Specail function to add different formatting symbols to the output */
-int put_marker(struct serial_data *buf_data, const void *data, int len)
+int col_put_marker(struct col_serial_data *buf_data, const void *data, int len)
{
int error = EOK;
- TRACE_FLOW_STRING("put_marker", "Entry point");
+ TRACE_FLOW_STRING("col_put_marker", "Entry point");
TRACE_INFO_NUMBER("Marker length: ", len);
- error = grow_buffer(buf_data, len);
+ error = col_grow_buffer(buf_data, len);
if (error) {
- TRACE_ERROR_NUMBER("grow_buffer failed with: ", error);
+ TRACE_ERROR_NUMBER("col_grow_buffer failed with: ", error);
return error;
}
memcpy(buf_data->buffer + buf_data->length, data, len);
buf_data->length += len;
buf_data->buffer[buf_data->length] = '\0';
- TRACE_FLOW_STRING("put_marker","Success exit");
+ TRACE_FLOW_STRING("col_put_marker","Success exit");
return error;
}
/* Add item's data */
-int serialize(const char *property_in,
- int property_len_in,
- int type,
- void *data_in,
- int length_in,
- void *custom_data,
- int *dummy)
+int col_serialize(const char *property_in,
+ int property_len_in,
+ int type,
+ void *data_in,
+ int length_in,
+ void *custom_data,
+ int *dummy)
{
int len;
- struct serial_data *buf_data;
+ struct col_serial_data *buf_data;
const char *property;
const void *data;
int property_len;
@@ -357,12 +358,12 @@ int serialize(const char *property_in,
int error = EOK;
int i;
- TRACE_FLOW_STRING("serialize","Entry point");
+ TRACE_FLOW_STRING("col_serialize","Entry point");
*dummy = 0;
/* Check is there is buffer. If not allocate */
- buf_data = (struct serial_data *)custom_data;
+ buf_data = (struct col_serial_data *)custom_data;
if (buf_data == NULL) {
TRACE_ERROR_STRING("Error.", "Storage data is not passed in!");
return EINVAL;
@@ -388,7 +389,7 @@ int serialize(const char *property_in,
if (type == COL_TYPE_COLLECTION) {
TRACE_INFO_STRING("Serializing collection: ", property_in);
TRACE_INFO_STRING("First header. ", "");
- error = put_marker(buf_data, "(", 1);
+ error = col_put_marker(buf_data, "(", 1);
if (error != EOK) return error;
property = TEXT_COLLECTION;
property_len = TEXT_COLLEN;
@@ -400,7 +401,7 @@ int serialize(const char *property_in,
/* Check for subcollections */
else if (type == COL_TYPE_COLLECTIONREF) {
/* Skip */
- TRACE_FLOW_STRING("serialize", "skip reference return");
+ TRACE_FLOW_STRING("col_serialize", "skip reference return");
return EOK;
}
/* Check for the end of the collection */
@@ -412,10 +413,10 @@ int serialize(const char *property_in,
}
if (buf_data->nest_level > 0) {
buf_data->nest_level--;
- error = put_marker(buf_data, ")", 1);
+ error = col_put_marker(buf_data, ")", 1);
if (error != EOK) return error;
}
- TRACE_FLOW_STRING("serialize", "end collection item processed returning");
+ TRACE_FLOW_STRING("col_serialize", "end collection item processed returning");
return EOK;
}
else {
@@ -429,18 +430,18 @@ int serialize(const char *property_in,
TRACE_INFO_NUMBER("Property length: ", property_len);
/* Start with property and "=" */
- if ((error = put_marker(buf_data, property, property_len)) ||
- (error = put_marker(buf_data, "=", 1))) {
+ if ((error = col_put_marker(buf_data, property, property_len)) ||
+ (error = col_put_marker(buf_data, "=", 1))) {
TRACE_ERROR_NUMBER("put_marker returned error: ", error);
return error;
}
/* Get projected length of the item */
- len = get_data_len(type,length);
+ len = col_get_data_len(type,length);
TRACE_INFO_NUMBER("Expected data length: ",len);
TRACE_INFO_STRING("Buffer so far: ", buf_data->buffer);
/* Make sure we have enough space */
- if ((error = grow_buffer(buf_data, len))) {
+ if ((error = col_grow_buffer(buf_data, len))) {
TRACE_ERROR_NUMBER("grow_buffer returned error: ", error);
return error;
}
@@ -449,7 +450,7 @@ int serialize(const char *property_in,
switch (type) {
case COL_TYPE_STRING:
/* Escape double quotes */
- len = copy_esc(&buf_data->buffer[buf_data->length], (char *)(data), '"');
+ len = col_copy_esc(&buf_data->buffer[buf_data->length], (char *)(data), '"');
break;
case COL_TYPE_BINARY:
@@ -503,25 +504,25 @@ int serialize(const char *property_in,
buf_data->buffer[buf_data->length] = '\0';
/* Always put a comma at the end */
- error = put_marker(buf_data, ",", 1);
+ error = col_put_marker(buf_data, ",", 1);
if (error != EOK) {
TRACE_ERROR_NUMBER("put_marker returned error: ", error);
return error;
}
TRACE_INFO_STRING("Data: ", buf_data->buffer);
- TRACE_FLOW_STRING("serialize", "Exit point");
+ TRACE_FLOW_STRING("col_serialize", "Exit point");
return EOK;
}
/* Print the collection using default serialization */
-int print_collection(struct collection_item *handle)
+int col_print_collection(struct collection_item *handle)
{
- struct serial_data buf_data;
+ struct col_serial_data buf_data;
int error = EOK;
- TRACE_FLOW_STRING("print_collection", "Entry");
+ TRACE_FLOW_STRING("col_print_collection", "Entry");
printf("COLLECTION:\n");
@@ -531,9 +532,9 @@ int print_collection(struct collection_item *handle)
buf_data.nest_level = 0;
/* Traverse collection */
- error = traverse_collection(handle,
- COL_TRAVERSE_DEFAULT | COL_TRAVERSE_END ,
- serialize, (void *)(&buf_data));
+ error = col_traverse_collection(handle,
+ COL_TRAVERSE_DEFAULT | COL_TRAVERSE_END ,
+ col_serialize, (void *)(&buf_data));
if (error)
printf("Error traversing collection %d\n", error);
else
@@ -541,12 +542,12 @@ int print_collection(struct collection_item *handle)
free(buf_data.buffer);
- TRACE_FLOW_NUMBER("print_collection returning", error);
+ TRACE_FLOW_NUMBER("col_print_collection returning", error);
return error;
}
/* Print the collection using iterator */
-int print_collection2(struct collection_item *handle)
+int col_print_collection2(struct collection_item *handle)
{
struct collection_iterator *iterator = NULL;
int error = EOK;
@@ -555,7 +556,7 @@ int print_collection2(struct collection_item *handle)
int dummy = 0;
int line = 1;
- TRACE_FLOW_STRING("print_collection2", "Entry");
+ TRACE_FLOW_STRING("col_print_collection2", "Entry");
/* If we have something to print print it */
if (handle == NULL) {
@@ -564,8 +565,10 @@ int print_collection2(struct collection_item *handle)
}
/* Bind iterator */
- error = bind_iterator(&iterator, handle,
- COL_TRAVERSE_DEFAULT| COL_TRAVERSE_END| COL_TRAVERSE_SHOWSUB);
+ error = col_bind_iterator(&iterator, handle,
+ COL_TRAVERSE_DEFAULT |
+ COL_TRAVERSE_END |
+ COL_TRAVERSE_SHOWSUB);
if (error) {
TRACE_ERROR_NUMBER("Error (bind):", error);
return error;
@@ -573,10 +576,10 @@ int print_collection2(struct collection_item *handle)
do {
/* Loop through a collection */
- error = iterate_collection(iterator, &item);
+ error = col_iterate_collection(iterator, &item);
if (error) {
TRACE_ERROR_NUMBER("Error (iterate):", error);
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
return error;
}
@@ -585,41 +588,42 @@ int print_collection2(struct collection_item *handle)
if (item->type != COL_TYPE_END) printf("%05d", line);
- debug_handle(item->property,
- item->property_len,
- item->type,
- item->data,
- item->length,
- (void *)(&nest_level),
- &dummy);
+ col_debug_handle(item->property,
+ item->property_len,
+ item->type,
+ item->data,
+ item->length,
+ (void *)(&nest_level),
+ &dummy);
line++;
}
while(1);
/* Do not forget to unbind iterator - otherwise there will be a leak */
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
- TRACE_INFO_STRING("print_collection2", "Exit");
+ TRACE_INFO_STRING("col_print_collection2", "Exit");
return EOK;
}
/* Find and print one item using default serialization */
-int print_item(struct collection_item *handle, char *name)
+int col_print_item(struct collection_item *handle, char *name)
{
- struct serial_data buf_data;
+ struct col_serial_data buf_data;
int error = EOK;
- TRACE_FLOW_STRING("print_item", "Entry");
+ TRACE_FLOW_STRING("col_print_item", "Entry");
- printf("FIND ITEM:\n");
+ printf("PRINT ITEM:\n");
buf_data.buffer = NULL;
buf_data.length = 0;
buf_data.size = 0;
buf_data.nest_level = 0;
- error = get_item_and_do(handle, name, COL_TYPE_ANY,
- COL_TRAVERSE_DEFAULT, serialize, &buf_data);
+ error = col_get_item_and_do(handle, name, COL_TYPE_ANY,
+ COL_TRAVERSE_DEFAULT,
+ col_serialize, &buf_data);
if(error) printf("Error searching collection %d\n", error);
else {
if (buf_data.buffer != NULL) {
@@ -634,16 +638,16 @@ int print_item(struct collection_item *handle, char *name)
}
}
- TRACE_FLOW_NUMBER("print_item returning", error);
+ TRACE_FLOW_NUMBER("col_print_item returning", error);
return error;
}
/* Function to free the list of properties. */
-void free_property_list(char **str_list)
+void col_free_property_list(char **str_list)
{
int current = 0;
- TRACE_FLOW_STRING("free_property_list","Entry");
+ TRACE_FLOW_STRING("col_free_property_list","Entry");
if (str_list != NULL) {
while(str_list[current]) {
@@ -653,12 +657,12 @@ void free_property_list(char **str_list)
free(str_list);
}
- TRACE_FLOW_STRING("free_property_list","Exit");
+ TRACE_FLOW_STRING("col_free_property_list","Exit");
}
/* Convert collection to list of properties */
-char **collection_to_list(struct collection_item *handle, int *size, int *error)
+char **col_collection_to_list(struct collection_item *handle, int *size, int *error)
{
struct collection_iterator *iterator;
struct collection_item *item = NULL;
@@ -667,10 +671,10 @@ char **collection_to_list(struct collection_item *handle, int *size, int *error)
int err;
int current = 0;
- TRACE_FLOW_STRING("collection_to_list","Entry");
+ TRACE_FLOW_STRING("col_collection_to_list","Entry");
/* Get number of the subsections */
- err = get_collection_count(handle,&count);
+ err = col_get_collection_count(handle, &count);
if (err) {
TRACE_ERROR_NUMBER("Failed to get count of items from collection.", err);
if (error) *error = err;
@@ -689,7 +693,7 @@ char **collection_to_list(struct collection_item *handle, int *size, int *error)
/* Now iterate to fill in the sections */
/* Bind iterator */
- err = bind_iterator(&iterator, handle, COL_TRAVERSE_ONELEVEL);
+ err = col_bind_iterator(&iterator, handle, COL_TRAVERSE_ONELEVEL);
if (err) {
TRACE_ERROR_NUMBER("Failed to bind.", err);
if (error) *error = err;
@@ -699,43 +703,43 @@ char **collection_to_list(struct collection_item *handle, int *size, int *error)
while(1) {
/* Loop through a collection */
- err = iterate_collection(iterator, &item);
+ err = col_iterate_collection(iterator, &item);
if (err) {
TRACE_ERROR_NUMBER("Failed to iterate collection", err);
if (error) *error = err;
- free_property_list(list);
- unbind_iterator(iterator);
+ col_free_property_list(list);
+ col_unbind_iterator(iterator);
return NULL;
}
/* Are we done ? */
if (item == NULL) break;
- TRACE_INFO_STRING("Property:", get_item_property(item, NULL));
+ TRACE_INFO_STRING("Property:", col_get_item_property(item, NULL));
/* Skip head */
- if(get_item_type(item) == COL_TYPE_COLLECTION) continue;
+ if(col_get_item_type(item) == COL_TYPE_COLLECTION) continue;
/* Allocate memory for the new string */
errno = 0;
- list[current] = strdup(get_item_property(item, NULL));
+ list[current] = strdup(col_get_item_property(item, NULL));
if (list[current] == NULL) {
err = errno;
TRACE_ERROR_NUMBER("Failed to dup string.", err);
if (error) *error = ENOMEM;
- free_property_list(list);
+ col_free_property_list(list);
return NULL;
}
current++;
}
/* Do not forget to unbind iterator - otherwise there will be a leak */
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
if (size) *size = (int)(count - 1);
if (error) *error = EOK;
- TRACE_FLOW_STRING("collection_to_list returning", list == NULL ? "NULL" : list[0]);
+ TRACE_FLOW_STRING("col_collection_to_list returning", list == NULL ? "NULL" : list[0]);
return list;
}
diff --git a/common/collection/collection_tools.h b/common/collection/collection_tools.h
index a8d13f74..74453297 100644
--- a/common/collection/collection_tools.h
+++ b/common/collection/collection_tools.h
@@ -27,9 +27,9 @@
#include "collection.h"
#ifdef HAVE_TRACE
-#define DEBUG_COLLECTION(collection) debug_collection(collection,COL_TRAVERSE_DEFAULT);
+#define COL_DEBUG_COLLECTION(collection) col_debug_collection(collection,COL_TRAVERSE_DEFAULT);
#else
-#define DEBUG_COLLECTION(collection) ;
+#define COL_DEBUG_COLLECTION(collection) ;
#endif
#define COL_TYPE_NAME_STRING "string"
@@ -47,7 +47,7 @@
#define BLOCK_SIZE 1024
-struct serial_data {
+struct col_serial_data {
char *buffer;
int size;
int length;
@@ -56,52 +56,52 @@ struct serial_data {
/* Calculate the potential size of the item */
-int get_data_len(int type, int length);
+int col_get_data_len(int type, int length);
/* Grow buffer to accomodate more space */
-int grow_buffer(struct serial_data *buf_data, int len);
+int col_grow_buffer(struct col_serial_data *buf_data, int len);
/* Specail function to add different formatting symbols to the output */
-int put_marker(struct serial_data *buf_data, const void *data, int len);
+int col_put_marker(struct col_serial_data *buf_data, const void *data, int len);
/* Serialization of data user handler */
-int serialize(const char *property_in,
- int property_len_in,
- int type,
- void *data_in,
- int length_in,
- void *custom_data,
- int *dummy);
+int col_serialize(const char *property_in,
+ int property_len_in,
+ int type,
+ void *data_in,
+ int length_in,
+ void *custom_data,
+ int *dummy);
/* Debug handle */
-int debug_handle(const char *property,
- int property_len,
- int type,
- void *data,
- int length,
- void *custom_data,
- int *dummy);
+int col_debug_handle(const char *property,
+ int property_len,
+ int type,
+ void *data,
+ int length,
+ void *custom_data,
+ int *dummy);
/* Convenience function to debug an item */
-int debug_item(struct collection_item *item);
+int col_debug_item(struct collection_item *item);
/* Print collection for debugging purposes */
-int debug_collection(struct collection_item *handle,int flag);
+int col_debug_collection(struct collection_item *handle,int flag);
/* Print the collection using default serialization */
-int print_collection(struct collection_item *handle);
+int col_print_collection(struct collection_item *handle);
/* Print the collection using iterator */
-int print_collection2(struct collection_item *handle);
+int col_print_collection2(struct collection_item *handle);
/* Find and print one item using default serialization */
-int print_item(struct collection_item *handle, char *name);
+int col_print_item(struct collection_item *handle, char *name);
/* Convert collection to list of properties */
-char **collection_to_list(struct collection_item *handle, int *size, int *error);
+char **col_collection_to_list(struct collection_item *handle, int *size, int *error);
/* Function to free the list of properties. */
-void free_property_list(char **str_list);
+void col_free_property_list(char **str_list);
#endif
diff --git a/common/collection/collection_ut.c b/common/collection/collection_ut.c
index c1a4fcf8..f24d46a5 100644
--- a/common/collection/collection_ut.c
+++ b/common/collection/collection_ut.c
@@ -42,63 +42,63 @@ int ref_collection_test()
printf("\n\nREF TEST!!!.\n\n\n");
printf("Creating PEER collection.\n");
- if ((error = create_collection(&peer, "peer", 0)) ||
- (error = add_str_property(peer, NULL, "hostname", "peerhost.mytest.com", 0)) ||
+ if ((error = col_create_collection(&peer, "peer", 0)) ||
+ (error = col_add_str_property(peer, NULL, "hostname", "peerhost.mytest.com", 0)) ||
/* Expect trailing zero to be truncated */
- (error = add_str_property(peer, NULL, "IPv4", "10.10.10.10", 12)) ||
- (error = add_str_property(peer, NULL, "IPv6", "bla:bla:bla:bla:bla:bla", 0))) {
+ (error = col_add_str_property(peer, NULL, "IPv4", "10.10.10.10", 12)) ||
+ (error = col_add_str_property(peer, NULL, "IPv6", "bla:bla:bla:bla:bla:bla", 0))) {
printf("Failed to add property. Error %d\n", error);
- destroy_collection(peer);
+ col_destroy_collection(peer);
return error;
}
printf("Creating SOCKET collection.\n");
- if ((error = create_collection(&socket, "socket", 0)) ||
- (error = add_int_property(socket, NULL, "id", 1)) ||
- (error = add_long_property(socket, NULL, "packets", 100000000L)) ||
- (error = add_binary_property(socket, NULL, "stack", binary_dump, sizeof(binary_dump)))) {
- destroy_collection(peer);
- destroy_collection(socket);
+ if ((error = col_create_collection(&socket, "socket", 0)) ||
+ (error = col_add_int_property(socket, NULL, "id", 1)) ||
+ (error = col_add_long_property(socket, NULL, "packets", 100000000L)) ||
+ (error = col_add_binary_property(socket, NULL, "stack", binary_dump, sizeof(binary_dump)))) {
+ col_destroy_collection(peer);
+ col_destroy_collection(socket);
printf("Failed to add property. Error %d\n", error);
return error;
}
- debug_collection(socket, COL_TRAVERSE_DEFAULT);
- debug_collection(peer, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(socket, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(peer, COL_TRAVERSE_DEFAULT);
printf("Adding PEER collection to SOCKET collection as a reference named PEER\n");
/* Embed peer host into the socket2 as reference */
- error = add_collection_to_collection(socket, NULL, "peer", peer, COL_ADD_MODE_REFERENCE);
+ error = col_add_collection_to_collection(socket, NULL, "peer", peer, COL_ADD_MODE_REFERENCE);
if (error) {
- destroy_collection(peer);
- destroy_collection(socket);
+ col_destroy_collection(peer);
+ col_destroy_collection(socket);
printf("Failed to add collection to collection. Error %d\n", error);
return error;
}
- debug_collection(socket, COL_TRAVERSE_DEFAULT);
- debug_collection(peer, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(socket, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(peer, COL_TRAVERSE_DEFAULT);
printf("About to destroy PEER\n");
- destroy_collection(peer);
- debug_collection(socket, COL_TRAVERSE_DEFAULT);
+ col_destroy_collection(peer);
+ col_debug_collection(socket, COL_TRAVERSE_DEFAULT);
printf("About to extract PEER\n");
- error = get_collection_reference(socket, &peer, "peer");
+ error = col_get_collection_reference(socket, &peer, "peer");
if (error) {
- destroy_collection(socket);
+ col_destroy_collection(socket);
printf("Failed to extract collection. Error %d\n", error);
return error;
}
- debug_collection(socket, COL_TRAVERSE_DEFAULT);
- debug_collection(peer, COL_TRAVERSE_DEFAULT);
- destroy_collection(peer);
+ col_debug_collection(socket, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(peer, COL_TRAVERSE_DEFAULT);
+ col_destroy_collection(peer);
- debug_collection(socket, COL_TRAVERSE_DEFAULT);
- destroy_collection(socket);
+ col_debug_collection(socket, COL_TRAVERSE_DEFAULT);
+ col_destroy_collection(socket);
TRACE_FLOW_NUMBER("ref_collection_test. Returning", error);
printf("\n\nEND OF REF TEST!!!.\n\n\n");
@@ -115,50 +115,50 @@ int single_collection_test()
TRACE_FLOW_STRING("single_collection_test", "Entry.");
- if ((error = create_collection(&handle, "string_test", 0)) ||
- (error = add_str_property(handle, NULL, "property_1", "some data", 0)) ||
- (error = add_str_property(handle, NULL, "property_2", "some other data", 2)) ||
- (error = add_str_property(handle, NULL, "property_3", "more data", 7))) {
+ if ((error = col_create_collection(&handle, "string_test", 0)) ||
+ (error = col_add_str_property(handle, NULL, "property_1", "some data", 0)) ||
+ (error = col_add_str_property(handle, NULL, "property_2", "some other data", 2)) ||
+ (error = col_add_str_property(handle, NULL, "property_3", "more data", 7))) {
printf("Failed to add property. Error %d", error);
- destroy_collection(handle);
+ col_destroy_collection(handle);
return error;
}
- error = add_str_property(handle, NULL, "property 1", "some data", 0);
+ error = col_add_str_property(handle, NULL, "property 1", "some data", 0);
if (error) printf("Expected error adding bad property to collection %d\n", error);
else {
printf("Expected error but got success\n");
return -1;
}
- error = add_double_property(handle, NULL, "double", 0.253545);
+ error = col_add_double_property(handle, NULL, "double", 0.253545);
if (error) {
printf("Failed to add property. Error %d", error);
- destroy_collection(handle);
+ col_destroy_collection(handle);
return error;
}
- error = update_double_property(handle, "double", COL_TRAVERSE_DEFAULT, 1.999999);
+ error = col_update_double_property(handle, "double", COL_TRAVERSE_DEFAULT, 1.999999);
if (error) {
printf("Failed to add property. Error %d", error);
- destroy_collection(handle);
+ col_destroy_collection(handle);
return error;
}
printf("Created collection\n");
/* Traverse collection */
- error = debug_collection(handle, COL_TRAVERSE_DEFAULT);
+ error = col_debug_collection(handle, COL_TRAVERSE_DEFAULT);
if (error) {
printf("Error debugging collection %d\n", error);
return error;
}
- error = print_collection(handle);
+ error = col_print_collection(handle);
if (error) {
printf("Error printing collection %d\n", error);
return error;
}
- destroy_collection(handle);
+ col_destroy_collection(handle);
TRACE_FLOW_NUMBER("single_collection_test. Error: ", error);
return error;
@@ -177,47 +177,47 @@ int add_collection_test()
printf("\n\nADD TEST!!!.\n\n\n");
printf("Creating PEER collection.\n");
- if ((error = create_collection(&peer, "peer", 0)) ||
- (error = add_str_property(peer, NULL, "hostname", "peerhost.mytest.com", 0)) ||
+ if ((error = col_create_collection(&peer, "peer", 0)) ||
+ (error = col_add_str_property(peer, NULL, "hostname", "peerhost.mytest.com", 0)) ||
/* Expect trailing zero to be truncated */
- (error = add_str_property(peer, NULL, "IPv4", "10.10.10.10", 12)) ||
- (error = add_str_property(peer, NULL, "IPv6", "bla:bla:bla:bla:bla:bla", 0))) {
+ (error = col_add_str_property(peer, NULL, "IPv4", "10.10.10.10", 12)) ||
+ (error = col_add_str_property(peer, NULL, "IPv6", "bla:bla:bla:bla:bla:bla", 0))) {
printf("Failed to add property. Error %d", error);
- destroy_collection(peer);
+ col_destroy_collection(peer);
return error;
}
printf("Creating SOCKET collection.\n");
- if ((error = create_collection(&socket, "socket", 0)) ||
- (error = add_int_property(socket, NULL, "id", 1)) ||
- (error = add_long_property(socket, NULL, "packets", 100000000L)) ||
- (error = add_binary_property(socket, NULL, "stack", binary_dump, sizeof(binary_dump)))) {
- destroy_collection(peer);
- destroy_collection(socket);
+ if ((error = col_create_collection(&socket, "socket", 0)) ||
+ (error = col_add_int_property(socket, NULL, "id", 1)) ||
+ (error = col_add_long_property(socket, NULL, "packets", 100000000L)) ||
+ (error = col_add_binary_property(socket, NULL, "stack", binary_dump, sizeof(binary_dump)))) {
+ col_destroy_collection(peer);
+ col_destroy_collection(socket);
printf("Failed to add property. Error %d\n", error);
return error;
}
- debug_collection(socket, COL_TRAVERSE_DEFAULT);
- debug_collection(peer, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(socket, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(peer, COL_TRAVERSE_DEFAULT);
printf("Adding PEER collection to SOCKET collection as a reference named PEER\n");
/* Embed peer host into the socket2 as reference */
- error = add_collection_to_collection(socket, NULL, "peer", peer, COL_ADD_MODE_REFERENCE);
+ error = col_add_collection_to_collection(socket, NULL, "peer", peer, COL_ADD_MODE_REFERENCE);
if (error) {
- destroy_collection(peer);
- destroy_collection(socket);
+ col_destroy_collection(peer);
+ col_destroy_collection(socket);
printf("Failed to create collection. Error %d\n", error);
return error;
}
- debug_collection(socket, COL_TRAVERSE_DEFAULT);
- debug_collection(peer, COL_TRAVERSE_DEFAULT);
- destroy_collection(peer);
- debug_collection(socket, COL_TRAVERSE_DEFAULT);
- destroy_collection(socket);
+ col_debug_collection(socket, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(peer, COL_TRAVERSE_DEFAULT);
+ col_destroy_collection(peer);
+ col_debug_collection(socket, COL_TRAVERSE_DEFAULT);
+ col_destroy_collection(socket);
TRACE_FLOW_NUMBER("add_collection_test. Returning", error);
return error;
}
@@ -240,186 +240,186 @@ int mixed_collection_test()
printf("\n\nMIXED TEST!!!.\n\n\n");
printf("Creating PEER collection.\n");
- if ((error = create_collection(&peer, "peer", 0)) ||
- (error = add_str_property(peer, NULL, "hostname", "peerhost.mytest.com", 0)) ||
+ if ((error = col_create_collection(&peer, "peer", 0)) ||
+ (error = col_add_str_property(peer, NULL, "hostname", "peerhost.mytest.com", 0)) ||
/* Expect trailing zero to be truncated */
- (error = add_str_property(peer, NULL, "IPv4", "10.10.10.10", 12)) ||
- (error = add_str_property(peer, NULL, "IPv6", "bla:bla:bla:bla:bla:bla", 0))) {
+ (error = col_add_str_property(peer, NULL, "IPv4", "10.10.10.10", 12)) ||
+ (error = col_add_str_property(peer, NULL, "IPv6", "bla:bla:bla:bla:bla:bla", 0))) {
printf("Failed to add property. Error %d", error);
- destroy_collection(peer);
+ col_destroy_collection(peer);
return error;
}
- debug_collection(peer, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(peer, COL_TRAVERSE_DEFAULT);
printf("Creating HOST collection.\n");
- if ((error = create_collection(&host, "host", 0)) ||
- (error = add_str_property(host, NULL, "hostname", "myhost.mytest.com", 0)) ||
- (error = add_str_property(host, NULL, "IPv4", "20.20.20.20", 13)) ||
- (error = add_str_property(host, NULL, "IPv6", "bla:bla:bla:bla:bla:bla", 0)) ||
- (error = add_double_property(host, NULL, "double", 0.253545))) {
+ if ((error = col_create_collection(&host, "host", 0)) ||
+ (error = col_add_str_property(host, NULL, "hostname", "myhost.mytest.com", 0)) ||
+ (error = col_add_str_property(host, NULL, "IPv4", "20.20.20.20", 13)) ||
+ (error = col_add_str_property(host, NULL, "IPv6", "bla:bla:bla:bla:bla:bla", 0)) ||
+ (error = col_add_double_property(host, NULL, "double", 0.253545))) {
printf("Failed to add property. Error %d", error);
- destroy_collection(peer);
- destroy_collection(host);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
return error;
}
- debug_collection(host, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(host, COL_TRAVERSE_DEFAULT);
printf("Creating SOCKET1 collection.\n");
- if ((error = create_collection(&socket1, "socket1", 0)) ||
- (error = add_int_property(socket1, NULL, "id", 1)) ||
- (error = add_long_property(socket1, NULL, "packets", 100000000L)) ||
- (error = add_binary_property(socket1, NULL, "stack", binary_dump, sizeof(binary_dump)))) {
- destroy_collection(peer);
- destroy_collection(host);
- destroy_collection(socket1);
+ if ((error = col_create_collection(&socket1, "socket1", 0)) ||
+ (error = col_add_int_property(socket1, NULL, "id", 1)) ||
+ (error = col_add_long_property(socket1, NULL, "packets", 100000000L)) ||
+ (error = col_add_binary_property(socket1, NULL, "stack", binary_dump, sizeof(binary_dump)))) {
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
+ col_destroy_collection(socket1);
printf("Failed to add property. Error %d\n", error);
return error;
}
- debug_collection(socket1, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(socket1, COL_TRAVERSE_DEFAULT);
printf("Creating a copy of SOCKET1 collection named SOCKET2.\n");
- error = copy_collection(&socket2, socket1, "socket2");
+ error = col_copy_collection(&socket2, socket1, "socket2");
if (error) {
- destroy_collection(peer);
- destroy_collection(host);
- destroy_collection(socket1);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
+ col_destroy_collection(socket1);
printf("Failed to copy collection. Error %d\n", error);
return error;
}
- debug_collection(socket2, COL_TRAVERSE_DEFAULT);
- debug_collection(peer, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(socket2, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(peer, COL_TRAVERSE_DEFAULT);
printf("Adding PEER collection to SOCKET2 collection as a reference named PEER2\n");
/* Embed peer host into the socket2 as reference */
- error = add_collection_to_collection(socket2, NULL, "peer2", peer, COL_ADD_MODE_REFERENCE);
+ error = col_add_collection_to_collection(socket2, NULL, "peer2", peer, COL_ADD_MODE_REFERENCE);
if (error) {
- destroy_collection(peer);
- destroy_collection(host);
- destroy_collection(socket1);
- destroy_collection(socket2);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
+ col_destroy_collection(socket1);
+ col_destroy_collection(socket2);
printf("Failed to create collection. Error %d\n", error);
return error;
}
- debug_collection(socket2, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(socket2, COL_TRAVERSE_DEFAULT);
printf("Creating an EVENT collection.\n");
/* Construct event */
- error = create_collection(&event, "event", 0);
+ error = col_create_collection(&event, "event", 0);
if (error) {
- destroy_collection(peer);
- destroy_collection(host);
- destroy_collection(socket1);
- destroy_collection(socket2);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
+ col_destroy_collection(socket1);
+ col_destroy_collection(socket2);
printf("Failed to create collection. Error %d\n", error);
return error;
}
- debug_collection(event, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(event, COL_TRAVERSE_DEFAULT);
printf("Adding HOST to EVENT.\n");
/* Add host to event */
- error = add_collection_to_collection(event, NULL, NULL, host, COL_ADD_MODE_REFERENCE);
+ error = col_add_collection_to_collection(event, NULL, NULL, host, COL_ADD_MODE_REFERENCE);
if (error) {
- destroy_collection(peer);
- destroy_collection(host);
- destroy_collection(socket1);
- destroy_collection(socket2);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
+ col_destroy_collection(socket1);
+ col_destroy_collection(socket2);
printf("Failed to add collections. Error %d\n", error);
return error;
}
- debug_collection(event, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(event, COL_TRAVERSE_DEFAULT);
printf("Embed SOCKET1 into EVENT.\n");
/* Donate socket1 to event */
/* Socket1 should not be used after this */
- error = add_collection_to_collection(event, NULL, NULL, socket1, COL_ADD_MODE_EMBED);
+ error = col_add_collection_to_collection(event, NULL, NULL, socket1, COL_ADD_MODE_EMBED);
if (error) {
- destroy_collection(peer);
- destroy_collection(host);
- destroy_collection(socket1);
- destroy_collection(socket2);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
+ col_destroy_collection(socket1);
+ col_destroy_collection(socket2);
printf("Failed to add collections. Error %d\n", error);
return error;
}
printf("Traverse one level:\n");
- debug_collection(event, COL_TRAVERSE_ONELEVEL);
+ col_debug_collection(event, COL_TRAVERSE_ONELEVEL);
printf("Traverse ignore subcollections:\n");
- debug_collection(event, COL_TRAVERSE_IGNORE);
+ col_debug_collection(event, COL_TRAVERSE_IGNORE);
printf("Traverse normal:\n");
- debug_collection(event, COL_TRAVERSE_DEFAULT);
- debug_collection(socket1, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(event, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(socket1, COL_TRAVERSE_DEFAULT);
printf("SOCKET1 MUST NO BE USED AFTER THIS POINT!!!\n");
socket1 = (struct collection_item *)(NULL);
printf("Add collection PEER as PEER1 to subcollection SOCKET1 of the EVENT.\n");
- debug_collection(peer, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(peer, COL_TRAVERSE_DEFAULT);
- error = add_collection_to_collection(event, "socket1", "peer1", peer, COL_ADD_MODE_CLONE);
+ error = col_add_collection_to_collection(event, "socket1", "peer1", peer, COL_ADD_MODE_CLONE);
if (error) {
- destroy_collection(peer);
- destroy_collection(host);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
/* No socket1 any more :) */
- destroy_collection(socket2);
+ col_destroy_collection(socket2);
printf("Failed to add collections. Error %d\n", error);
return error;
}
- debug_collection(event, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(event, COL_TRAVERSE_DEFAULT);
printf("Add property named TIMEOUT to PEER collection.\n");
/* Add new property to the peer collection */
- error = add_int_property(peer, NULL, "timeout", 5);
+ error = col_add_int_property(peer, NULL, "timeout", 5);
if (error) {
- destroy_collection(peer);
- destroy_collection(host);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
/* No socket1 any more :) */
- destroy_collection(socket2);
+ col_destroy_collection(socket2);
printf("Failed to add property. Error %d\n", error);
return error;
}
- debug_collection(socket2, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(socket2, COL_TRAVERSE_DEFAULT);
printf("Add property named DELAY to PEER1 collection.\n");
- error = add_int_property(event, "peer1", "delay", 10);
+ error = col_add_int_property(event, "peer1", "delay", 10);
if (error) {
- destroy_collection(peer);
- destroy_collection(host);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
/* No socket1 any more :) */
- destroy_collection(socket2);
+ col_destroy_collection(socket2);
printf("Failed to add property. Error %d\n", error);
return error;
}
- debug_collection(event, COL_TRAVERSE_DEFAULT);
- debug_collection(host, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(event, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(host, COL_TRAVERSE_DEFAULT);
printf("Check if property PEER1.DELAY is in the EVENT collection.\n");
/* Check if the property in the collection */
found = 0;
- error = is_item_in_collection(event, "peer1.delay", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT, &found);
+ error = col_is_item_in_collection(event, "peer1.delay", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT, &found);
if (error) {
- destroy_collection(peer);
- destroy_collection(host);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
/* No socket1 any more :) */
- destroy_collection(socket2);
+ col_destroy_collection(socket2);
printf("Failed to check property. Error %d\n", error);
return error;
}
@@ -428,16 +428,16 @@ int mixed_collection_test()
else printf("Error property is not found!\n");
- print_item(event, "peer1.IPv6");
- print_item(event, "event.socket1.peer1.IPv6");
- print_item(event, "event.peer1.IPv6");
- print_item(event, "speer1.IPv6");
- print_item(event, "eer1.IPv6");
- print_item(event, ".peer1.IPv6");
- print_item(event, "t.peer1.IPv6");
+ col_print_item(event, "peer1.IPv6");
+ col_print_item(event, "event.socket1.peer1.IPv6");
+ col_print_item(event, "event.peer1.IPv6");
+ col_print_item(event, "speer1.IPv6");
+ col_print_item(event, "eer1.IPv6");
+ col_print_item(event, ".peer1.IPv6");
+ col_print_item(event, "t.peer1.IPv6");
/* Traverse collection */
- error = print_collection2(event);
+ error = col_print_collection2(event);
if (error) {
printf("Error printing collection %d\n", error);
return error;
@@ -445,12 +445,12 @@ int mixed_collection_test()
printf("Delete property PEER1.DELAY from the EVENT collection.\n");
- error = delete_property(event, "peer1.delay", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT);
+ error = col_delete_property(event, "peer1.delay", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT);
if (error) {
- destroy_collection(peer);
- destroy_collection(host);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
/* No socket1 any more :) */
- destroy_collection(socket2);
+ col_destroy_collection(socket2);
printf("Failed to delete property. Error %d\n", error);
return error;
}
@@ -458,14 +458,14 @@ int mixed_collection_test()
printf("Printing EVENT.\n");
/* Traverse collection */
- error = print_collection2(event);
+ error = col_print_collection2(event);
if (error) {
printf("Error printing collection %d\n", error);
return error;
}
printf("Debugging EVENT.\n");
- error = debug_collection(event, COL_TRAVERSE_DEFAULT);
+ error = col_debug_collection(event, COL_TRAVERSE_DEFAULT);
if (error) {
printf("Error printing collection %d\n", error);
return error;
@@ -474,34 +474,34 @@ int mixed_collection_test()
printf("Cleanup of the collections PEER, HOST and SOCKET2.\n");
/* Destroy a referenced collection */
- destroy_collection(peer);
- destroy_collection(host);
- destroy_collection(socket2);
+ col_destroy_collection(peer);
+ col_destroy_collection(host);
+ col_destroy_collection(socket2);
printf("Printing EVENT again.\n");
/* Traverse collection again - peer should still be there */
- error = print_collection(event);
+ error = col_print_collection(event);
if (error) {
- destroy_collection(event);
+ col_destroy_collection(event);
printf("Error printing collection %d\n", error);
return error;
}
printf("Debugging EVENT again.\n");
- error = debug_collection(event, COL_TRAVERSE_DEFAULT);
+ error = col_debug_collection(event, COL_TRAVERSE_DEFAULT);
if (error) {
- destroy_collection(event);
+ col_destroy_collection(event);
printf("Error printing collection %d\n", error);
return error;
}
printf("Attempt to add property to a referenced collection.\n");
- error = add_int_property(event, "host", "session", 500);
+ error = col_add_int_property(event, "host", "session", 500);
if (error) {
- destroy_collection(event);
+ col_destroy_collection(event);
printf("Error was NOT able to add property to a referenced collection %d.\n", error);
return error;
}
@@ -509,40 +509,40 @@ int mixed_collection_test()
printf("Attempt to delete non-existent property.\n");
/* Can't delete non exitent property */
- error = delete_property(event, "host.host", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT);
+ error = col_delete_property(event, "host.host", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT);
if (error == 0) {
- destroy_collection(event);
+ col_destroy_collection(event);
printf("Error was able to delete property that does not exist.\n");
return -1;
}
else printf("Expected error %d\n", error);
/* Set collection class */
- error = set_collection_class(event, 2);
+ error = col_set_collection_class(event, 2);
if (error != 0) {
- destroy_collection(event);
+ col_destroy_collection(event);
printf("Error was NOT able to set class.\n");
return error;
}
- error = get_collection_class(event, &class);
+ error = col_get_collection_class(event, &class);
if (error != 0) {
- destroy_collection(event);
+ col_destroy_collection(event);
printf("Error was NOT able to get class.\n");
return error;
}
else printf("Class = %d\n", class);
- if (is_of_class(event, 2)) printf("Class mathced!\n");
+ if (col_is_of_class(event, 2)) printf("Class mathced!\n");
else {
- destroy_collection(event);
+ col_destroy_collection(event);
printf("Error - bad class.\n");
return -1;
}
printf("Done. Cleaning...\n");
- destroy_collection(event);
+ col_destroy_collection(event);
printf("Exit.\n");
TRACE_FLOW_NUMBER("add_collection_test. Returning", EOK);
@@ -563,79 +563,79 @@ int iterator_test()
printf("\n\n==== ITERATOR TEST ====\n\n");
- if ((error = create_collection(&peer, "peer", 0)) ||
- (error = add_str_property(peer, NULL, "hostname", "peerhost.mytest.com", 0)) ||
+ if ((error = col_create_collection(&peer, "peer", 0)) ||
+ (error = col_add_str_property(peer, NULL, "hostname", "peerhost.mytest.com", 0)) ||
/* Expect trailing zero to be truncated */
- (error = add_str_property(peer, NULL, "IPv4", "10.10.10.10", 12)) ||
- (error = add_str_property(peer, NULL, "IPv6", "bla:bla:bla:bla:bla:bla", 0))) {
+ (error = col_add_str_property(peer, NULL, "IPv4", "10.10.10.10", 12)) ||
+ (error = col_add_str_property(peer, NULL, "IPv6", "bla:bla:bla:bla:bla:bla", 0))) {
printf("Failed to add property. Error %d", error);
- destroy_collection(peer);
+ col_destroy_collection(peer);
return error;
}
- if ((error = create_collection(&socket1, "socket", 0)) ||
- (error = add_int_property(socket1, NULL, "id", 1)) ||
- (error = add_long_property(socket1, NULL, "packets", 100000000L)) ||
- (error = add_binary_property(socket1, NULL, "stack", binary_dump, sizeof(binary_dump)))) {
- destroy_collection(peer);
- destroy_collection(socket1);
+ if ((error = col_create_collection(&socket1, "socket", 0)) ||
+ (error = col_add_int_property(socket1, NULL, "id", 1)) ||
+ (error = col_add_long_property(socket1, NULL, "packets", 100000000L)) ||
+ (error = col_add_binary_property(socket1, NULL, "stack", binary_dump, sizeof(binary_dump)))) {
+ col_destroy_collection(peer);
+ col_destroy_collection(socket1);
printf("Failed to add property. Error %d\n", error);
return error;
}
- if ((error = create_collection(&socket2, "socket", 0)) ||
- (error = add_int_property(socket2, NULL, "id", 2)) ||
- (error = add_long_property(socket2, NULL, "packets", 200000000L)) ||
- (error = add_binary_property(socket2, NULL, "queue", binary_dump, sizeof(binary_dump)))) {
- destroy_collection(peer);
- destroy_collection(socket1);
- destroy_collection(socket2);
+ if ((error = col_create_collection(&socket2, "socket", 0)) ||
+ (error = col_add_int_property(socket2, NULL, "id", 2)) ||
+ (error = col_add_long_property(socket2, NULL, "packets", 200000000L)) ||
+ (error = col_add_binary_property(socket2, NULL, "queue", binary_dump, sizeof(binary_dump)))) {
+ col_destroy_collection(peer);
+ col_destroy_collection(socket1);
+ col_destroy_collection(socket2);
printf("Failed to add property. Error %d\n", error);
return error;
}
- error = add_collection_to_collection(peer, NULL, "first", socket1, COL_ADD_MODE_EMBED);
+ error = col_add_collection_to_collection(peer, NULL, "first", socket1, COL_ADD_MODE_EMBED);
if (error) {
- destroy_collection(peer);
- destroy_collection(socket1);
- destroy_collection(socket2);
+ col_destroy_collection(peer);
+ col_destroy_collection(socket1);
+ col_destroy_collection(socket2);
printf("Failed to add collection to collection. Error %d\n", error);
return error;
}
- error = add_collection_to_collection(peer, NULL, "second", socket2, COL_ADD_MODE_EMBED);
+ error = col_add_collection_to_collection(peer, NULL, "second", socket2, COL_ADD_MODE_EMBED);
if (error) {
- destroy_collection(peer);
- destroy_collection(socket2);
+ col_destroy_collection(peer);
+ col_destroy_collection(socket2);
printf("Failed to add collection to collection. Error %d\n", error);
return error;
}
/* Bind iterator */
- error = bind_iterator(&iterator, peer, COL_TRAVERSE_DEFAULT);
+ error = col_bind_iterator(&iterator, peer, COL_TRAVERSE_DEFAULT);
if (error) {
printf("Error (bind): %d\n", error);
- destroy_collection(peer);
+ col_destroy_collection(peer);
return error;
}
printf("\n\nCollection:\n\n");
- debug_collection(peer, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(peer, COL_TRAVERSE_DEFAULT);
/* This should also work becuase iterator holds to collection */
- destroy_collection(peer);
+ col_destroy_collection(peer);
printf("\n\nIteration:\n\n");
do {
depth = 0;
- get_iterator_depth(iterator, &depth);
+ col_get_iterator_depth(iterator, &depth);
/* Loop through a collection */
- error = iterate_collection(iterator, &item);
+ error = col_iterate_collection(iterator, &item);
if (error) {
printf("Error (iterate): %d\n", error);
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
return error;
}
@@ -644,45 +644,45 @@ int iterator_test()
printf("%*s Property (%s), type = %d, data size = %d\n",
depth * 4, "",
- get_item_property(item, NULL),
- get_item_type(item),
- get_item_length(item));
+ col_get_item_property(item, NULL),
+ col_get_item_type(item),
+ col_get_item_length(item));
- if ((strcmp(get_item_property(item, NULL), "id")==0) &&
- (*((int *)(get_item_data(item))) == 1)) {
+ if ((strcmp(col_get_item_property(item, NULL), "id")==0) &&
+ (*((int *)(col_get_item_data(item))) == 1)) {
printf("\n\nFound property we need - go up!!!\n\n\n");
- error = iterate_up(iterator, 5);
+ error = col_iterate_up(iterator, 5);
if (!error) {
printf("We expected error but got seucces - bad.\n");
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
return -1;
}
/* This should work! */
- error = iterate_up(iterator, 1);
+ error = col_iterate_up(iterator, 1);
if (error) {
printf("We expected success but got error %d\n", error);
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
return error;
}
- if ((error = modify_str_item(item, "id2", "test", 0)) ||
- (error = debug_item(item)) ||
- (error = modify_str_item(item, NULL, "test", 2)) ||
- (error = debug_item(item)) ||
- (error = modify_binary_item(item, NULL, binary_dump, sizeof(binary_dump))) ||
- (error = debug_item(item)) ||
- (error = modify_bool_item(item, NULL, 1)) ||
- (error = debug_item(item)) ||
- (error = modify_int_item(item, "int", 1)) ||
- (error = debug_item(item)) ||
- (error = modify_long_item(item, "long", 1000000000L)) ||
- (error = debug_item(item)) ||
- (error = modify_ulong_item(item, "ulong", 4000000000UL)) ||
- (error = debug_item(item)) ||
- (error = modify_unsigned_item(item, "unsigned", 4000000000U)) ||
- (error = debug_item(item)) ||
- (error = modify_double_item(item, "double", -1.1)) ||
- (error = debug_item(item))) {
+ if ((error = col_modify_str_item(item, "id2", "test", 0)) ||
+ (error = col_debug_item(item)) ||
+ (error = col_modify_str_item(item, NULL, "test", 2)) ||
+ (error = col_debug_item(item)) ||
+ (error = col_modify_binary_item(item, NULL, binary_dump, sizeof(binary_dump))) ||
+ (error = col_debug_item(item)) ||
+ (error = col_modify_bool_item(item, NULL, 1)) ||
+ (error = col_debug_item(item)) ||
+ (error = col_modify_int_item(item, "int", 1)) ||
+ (error = col_debug_item(item)) ||
+ (error = col_modify_long_item(item, "long", 1000000000L)) ||
+ (error = col_debug_item(item)) ||
+ (error = col_modify_ulong_item(item, "ulong", 4000000000UL)) ||
+ (error = col_debug_item(item)) ||
+ (error = col_modify_unsigned_item(item, "unsigned", 4000000000U)) ||
+ (error = col_debug_item(item)) ||
+ (error = col_modify_double_item(item, "double", -1.1)) ||
+ (error = col_debug_item(item))) {
printf("Failed to change property.\n");
return error;
}
@@ -691,7 +691,7 @@ int iterator_test()
while(1);
/* Do not forget to unbind iterator - otherwise there will be a leak */
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
return EOK;
}
@@ -705,170 +705,170 @@ int insert_extract_test()
printf("\n\n==== INSERTION TEST ====\n\n");
- if ((error = create_collection(&col, "insertion", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_END,
- NULL, 0, COL_INSERT_NOCHECK,
- "property1", "value1", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_END,
- NULL, 0, COL_INSERT_NOCHECK,
- "property2", "value2", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_FRONT,
- NULL, 0, COL_INSERT_NOCHECK,
- "property0", "value0", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_BEFORE,
- "property0", 0, COL_INSERT_NOCHECK,
- "property_-1", "value_-1", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_BEFORE,
- "property1", 0, COL_INSERT_NOCHECK,
- "property0_5", "value0_5", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_BEFORE,
- "property2", 0, COL_INSERT_NOCHECK,
- "property1_5", "value1_5", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_AFTER,
- "property_-1", 0, COL_INSERT_NOCHECK,
- "property_-0_5", "value_-0_5", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_AFTER,
- "property1_5", 0, COL_INSERT_NOCHECK,
- "property1_6", "value1_6", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_INDEX,
- NULL, 10, COL_INSERT_NOCHECK,
- "property10", "value10", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_INDEX,
- NULL, 0, COL_INSERT_NOCHECK,
- "property_-2", "value_-2", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_INDEX,
- NULL, 1, COL_INSERT_NOCHECK,
- "property_-1_5", "value_-1_5", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_FIRSTDUP,
- NULL, 0, COL_INSERT_NOCHECK,
- "property0", "value0firstdup", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_LASTDUP,
- NULL, 0, COL_INSERT_NOCHECK,
- "property0", "value0lastdup", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_NDUP,
- NULL, 1, COL_INSERT_NOCHECK,
- "property0", "value0middledup", 0)) ||
- (error = insert_str_property(col, NULL, 0,
- NULL, 0, COL_INSERT_DUPOVER ,
- "property0", "value0firstdupupdate", 0)) ||
- (error = insert_str_property(col, NULL, 0,
- NULL, 0, COL_INSERT_DUPOVERT,
- "property1", "value1update", 0)) ||
- ((error = insert_str_property(col, NULL, 0,
- NULL, 0, COL_INSERT_DUPERROR,
- "property0", "does not matter", 0)) != EEXIST) ||
- (error = insert_str_property(col, NULL, COL_DSP_NDUP,
- NULL, 5, COL_INSERT_NOCHECK,
- "property10", "value10dup", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_LASTDUP,
- NULL, 0, COL_INSERT_NOCHECK,
- "property10", "value10lastdup", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_END,
- NULL, 0, COL_INSERT_DUPMOVET,
- "property_-2", "value-2moved_to_bottom", 0)) ||
- (error = insert_str_property(col, NULL, COL_DSP_FRONT,
- NULL, 0, COL_INSERT_DUPMOVE,
- "property1_6", "value_1_6_moved_moved_to_front", 0))) {
+ if ((error = col_create_collection(&col, "insertion", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_END,
+ NULL, 0, COL_INSERT_NOCHECK,
+ "property1", "value1", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_END,
+ NULL, 0, COL_INSERT_NOCHECK,
+ "property2", "value2", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_FRONT,
+ NULL, 0, COL_INSERT_NOCHECK,
+ "property0", "value0", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_BEFORE,
+ "property0", 0, COL_INSERT_NOCHECK,
+ "property_-1", "value_-1", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_BEFORE,
+ "property1", 0, COL_INSERT_NOCHECK,
+ "property0_5", "value0_5", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_BEFORE,
+ "property2", 0, COL_INSERT_NOCHECK,
+ "property1_5", "value1_5", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_AFTER,
+ "property_-1", 0, COL_INSERT_NOCHECK,
+ "property_-0_5", "value_-0_5", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_AFTER,
+ "property1_5", 0, COL_INSERT_NOCHECK,
+ "property1_6", "value1_6", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_INDEX,
+ NULL, 10, COL_INSERT_NOCHECK,
+ "property10", "value10", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_INDEX,
+ NULL, 0, COL_INSERT_NOCHECK,
+ "property_-2", "value_-2", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_INDEX,
+ NULL, 1, COL_INSERT_NOCHECK,
+ "property_-1_5", "value_-1_5", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_FIRSTDUP,
+ NULL, 0, COL_INSERT_NOCHECK,
+ "property0", "value0firstdup", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_LASTDUP,
+ NULL, 0, COL_INSERT_NOCHECK,
+ "property0", "value0lastdup", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_NDUP,
+ NULL, 1, COL_INSERT_NOCHECK,
+ "property0", "value0middledup", 0)) ||
+ (error = col_insert_str_property(col, NULL, 0,
+ NULL, 0, COL_INSERT_DUPOVER ,
+ "property0", "value0firstdupupdate", 0)) ||
+ (error = col_insert_str_property(col, NULL, 0,
+ NULL, 0, COL_INSERT_DUPOVERT,
+ "property1", "value1update", 0)) ||
+ ((error = col_insert_str_property(col, NULL, 0,
+ NULL, 0, COL_INSERT_DUPERROR,
+ "property0", "does not matter", 0)) != EEXIST) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_NDUP,
+ NULL, 5, COL_INSERT_NOCHECK,
+ "property10", "value10dup", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_LASTDUP,
+ NULL, 0, COL_INSERT_NOCHECK,
+ "property10", "value10lastdup", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_END,
+ NULL, 0, COL_INSERT_DUPMOVET,
+ "property_-2", "value-2moved_to_bottom", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_FRONT,
+ NULL, 0, COL_INSERT_DUPMOVE,
+ "property1_6", "value_1_6_moved_moved_to_front", 0))) {
printf("ERROR in the ITERATION TEST\n");
- debug_collection(col, COL_TRAVERSE_DEFAULT);
- destroy_collection(col);
+ col_debug_collection(col, COL_TRAVERSE_DEFAULT);
+ col_destroy_collection(col);
return error;
}
printf("\n\nCollection:\n\n");
- debug_collection(col, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(col, COL_TRAVERSE_DEFAULT);
printf("\n\n==== EXTRACTION TEST ====\n\n");
- if ((error = create_collection(&col2, "extraction", 0)) ||
+ if ((error = col_create_collection(&col2, "extraction", 0)) ||
- (error = extract_item(col, NULL, COL_DSP_FRONT,
- NULL, 0, 0, &item)) ||
+ (error = col_extract_item(col, NULL, COL_DSP_FRONT,
+ NULL, 0, 0, &item)) ||
- (error = insert_item(col2, NULL, item, COL_DSP_FRONT,
- NULL, 0, COL_INSERT_NOCHECK)) ||
+ (error = col_insert_item(col2, NULL, item, COL_DSP_FRONT,
+ NULL, 0, COL_INSERT_NOCHECK)) ||
- (debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
- (error = extract_item(col, NULL, COL_DSP_END,
- NULL, 0, 0, &item)) ||
+ (error = col_extract_item(col, NULL, COL_DSP_END,
+ NULL, 0, 0, &item)) ||
- (error = insert_item(col2, NULL, item, COL_DSP_END,
- NULL, 0, COL_INSERT_NOCHECK)) ||
+ (error = col_insert_item(col2, NULL, item, COL_DSP_END,
+ NULL, 0, COL_INSERT_NOCHECK)) ||
- (debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
- (error = insert_str_property(col, NULL, COL_DSP_INDEX,
- NULL, 100, COL_INSERT_NOCHECK,
- "property100", "value100", 0)) ||
+ (error = col_insert_str_property(col, NULL, COL_DSP_INDEX,
+ NULL, 100, COL_INSERT_NOCHECK,
+ "property100", "value100", 0)) ||
- (error = extract_item(col, NULL, COL_DSP_AFTER,
- "property10", 0, COL_TYPE_STRING, &item)) ||
+ (error = col_extract_item(col, NULL, COL_DSP_AFTER,
+ "property10", 0, COL_TYPE_STRING, &item)) ||
- (error = insert_item(col2, NULL, item, COL_DSP_END,
- NULL, 0, COL_INSERT_NOCHECK)) ||
+ (error = col_insert_item(col2, NULL, item, COL_DSP_END,
+ NULL, 0, COL_INSERT_NOCHECK)) ||
- (debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
- (error = extract_item(col, NULL, COL_DSP_BEFORE,
- "property0", 0, COL_TYPE_STRING, &item)) ||
+ (error = col_extract_item(col, NULL, COL_DSP_BEFORE,
+ "property0", 0, COL_TYPE_STRING, &item)) ||
- (error = insert_item(col2, NULL, item, COL_DSP_END,
- NULL, 0, COL_INSERT_NOCHECK)) ||
+ (error = col_insert_item(col2, NULL, item, COL_DSP_END,
+ NULL, 0, COL_INSERT_NOCHECK)) ||
- (debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
- (error = extract_item(col, NULL, COL_DSP_INDEX,
- NULL, 1, 0, &item)) ||
+ (error = col_extract_item(col, NULL, COL_DSP_INDEX,
+ NULL, 1, 0, &item)) ||
- (error = insert_item(col2, NULL, item, COL_DSP_END,
- NULL, 0, COL_INSERT_NOCHECK)) ||
+ (error = col_insert_item(col2, NULL, item, COL_DSP_END,
+ NULL, 0, COL_INSERT_NOCHECK)) ||
- (debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
- (error = extract_item(col, NULL, COL_DSP_NDUP,
- "property0", 1, 0, &item)) ||
+ (error = col_extract_item(col, NULL, COL_DSP_NDUP,
+ "property0", 1, 0, &item)) ||
- (error = insert_item(col2, NULL, item, COL_DSP_END,
- NULL, 0, COL_INSERT_NOCHECK)) ||
+ (error = col_insert_item(col2, NULL, item, COL_DSP_END,
+ NULL, 0, COL_INSERT_NOCHECK)) ||
- (debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
- (error = extract_item(col, NULL, COL_DSP_LASTDUP,
- "property0", 0, 0, &item)) ||
+ (error = col_extract_item(col, NULL, COL_DSP_LASTDUP,
+ "property0", 0, 0, &item)) ||
- (error = insert_item(col2, NULL, item, COL_DSP_END,
- NULL, 0, COL_INSERT_NOCHECK)) ||
+ (error = col_insert_item(col2, NULL, item, COL_DSP_END,
+ NULL, 0, COL_INSERT_NOCHECK)) ||
- (debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_debug_collection(col2, COL_TRAVERSE_DEFAULT)) ||
- (error = extract_item(col, NULL, COL_DSP_FIRSTDUP,
- "property0", 0, 0, &item)) ||
+ (error = col_extract_item(col, NULL, COL_DSP_FIRSTDUP,
+ "property0", 0, 0, &item)) ||
- (error = insert_item(col2, NULL, item, COL_DSP_END,
- NULL, 0, COL_INSERT_NOCHECK)) ||
+ (error = col_insert_item(col2, NULL, item, COL_DSP_END,
+ NULL, 0, COL_INSERT_NOCHECK)) ||
- (debug_collection(col2, COL_TRAVERSE_DEFAULT))) {
+ (error = col_debug_collection(col2, COL_TRAVERSE_DEFAULT))) {
printf("ERROR in the EXTRACTION TEST\n");
printf("Collection 1\n");
- debug_collection(col, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(col, COL_TRAVERSE_DEFAULT);
printf("Collection 2\n");
- debug_collection(col2, COL_TRAVERSE_DEFAULT);
- destroy_collection(col);
- destroy_collection(col2);
+ col_debug_collection(col2, COL_TRAVERSE_DEFAULT);
+ col_destroy_collection(col);
+ col_destroy_collection(col2);
return error;
}
printf("Collection 1\n");
- debug_collection(col, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(col, COL_TRAVERSE_DEFAULT);
printf("Collection 2\n");
- debug_collection(col2, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(col2, COL_TRAVERSE_DEFAULT);
- destroy_collection(col2);
- destroy_collection(col);
+ col_destroy_collection(col2);
+ col_destroy_collection(col);
return EOK;
@@ -882,29 +882,29 @@ int delete_test()
printf("\n\n==== DELETION TEST ====\n\n");
- if ((error = create_collection(&col, "test", 0)) ||
- (error = add_int_property(col, NULL, "tt", 1)) ||
- (error = debug_collection(col, COL_TRAVERSE_DEFAULT)) ||
- (error = add_int_property(col, NULL, "test", 1)) ||
- (error = debug_collection(col, COL_TRAVERSE_DEFAULT)) ||
- (error = delete_property(col, "test", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT)) ||
- (error = debug_collection(col, COL_TRAVERSE_DEFAULT)) ||
- (error = add_int_property(col, NULL, "test", 1)) ||
- (error = debug_collection(col, COL_TRAVERSE_DEFAULT)) ||
- (error = delete_property(col, "test", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT)) ||
- (error = debug_collection(col, COL_TRAVERSE_DEFAULT)) ||
- (error = add_int_property(col, NULL, "test", 1))) {
+ if ((error = col_create_collection(&col, "test", 0)) ||
+ (error = col_add_int_property(col, NULL, "tt", 1)) ||
+ (error = col_debug_collection(col, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_add_int_property(col, NULL, "test", 1)) ||
+ (error = col_debug_collection(col, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_delete_property(col, "test", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_debug_collection(col, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_add_int_property(col, NULL, "test", 1)) ||
+ (error = col_debug_collection(col, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_delete_property(col, "test", COL_TYPE_ANY, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_debug_collection(col, COL_TRAVERSE_DEFAULT)) ||
+ (error = col_add_int_property(col, NULL, "test", 1))) {
printf("Error in delete test %d\n", error);
- destroy_collection(col);
+ col_destroy_collection(col);
return error;
}
- debug_collection(col, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(col, COL_TRAVERSE_DEFAULT);
printf("\n\n==== DELETION TEST END ====\n\n");
- destroy_collection(col);
+ col_destroy_collection(col);
return error;
}
diff --git a/common/ini/ini_config.c b/common/ini/ini_config.c
index 8c54ad5c..1d318db9 100644
--- a/common/ini/ini_config.c
+++ b/common/ini/ini_config.c
@@ -160,19 +160,21 @@ static int add_or_update(struct collection_item *current_section,
TRACE_FLOW_STRING("add_or_update", "Entry");
- error = is_item_in_collection(current_section, key,
- COL_TYPE_ANY, COL_TRAVERSE_IGNORE, &found);
+ error = col_is_item_in_collection(current_section, key,
+ COL_TYPE_ANY,
+ COL_TRAVERSE_IGNORE,
+ &found);
if (found == COL_MATCH) {
TRACE_INFO_STRING("Updating...", "");
- error = update_property(current_section,
- key, type, value, length,
- COL_TRAVERSE_IGNORE);
+ error = col_update_property(current_section,
+ key, type, value, length,
+ COL_TRAVERSE_IGNORE);
}
else {
TRACE_INFO_STRING("Adding...", "");
- error = add_any_property(current_section, NULL,
- key, type, value, length);
+ error = col_add_any_property(current_section, NULL,
+ key, type, value, length);
}
TRACE_FLOW_NUMBER("add_or_update returning", error);
@@ -216,7 +218,7 @@ static int ini_to_collection(const char *filename,
/* Open the collection of errors */
if (error_list != NULL) {
*error_list = NULL;
- error = create_collection(error_list, filename, COL_CLASS_INI_PERROR);
+ error = col_create_collection(error_list, filename, COL_CLASS_INI_PERROR);
if (error) {
TRACE_ERROR_NUMBER("Failed to create error collection", error);
fclose(file);
@@ -237,13 +239,13 @@ static int ini_to_collection(const char *filename,
case RET_PAIR:
/* Add line to the collection of lines */
if (lines) {
- error = add_int_property(*lines, NULL, key, line);
+ error = col_add_int_property(*lines, NULL, key, line);
if (error) {
TRACE_ERROR_NUMBER("Failed to add line to line collection", error);
fclose(file);
- destroy_collection(current_section);
+ col_destroy_collection(current_section);
if (created) {
- destroy_collection(*error_list);
+ col_destroy_collection(*error_list);
*error_list = NULL;
}
return error;
@@ -253,22 +255,22 @@ static int ini_to_collection(const char *filename,
/* Do we have a section at the top of the file ? */
if (section_count == 0) {
/* Check if collection already exists */
- error = get_collection_reference(ini_config, &current_section,
- INI_DEFAULT_SECTION);
+ error = col_get_collection_reference(ini_config, &current_section,
+ INI_DEFAULT_SECTION);
if (error != EOK) {
/* Create default collection */
- if ((error = create_collection(&current_section,
- INI_DEFAULT_SECTION,
- COL_CLASS_INI_SECTION)) ||
- (error = add_collection_to_collection(ini_config,
- NULL,NULL,
- current_section,
- COL_ADD_MODE_REFERENCE))) {
+ if ((error = col_create_collection(&current_section,
+ INI_DEFAULT_SECTION,
+ COL_CLASS_INI_SECTION)) ||
+ (error = col_add_collection_to_collection(ini_config,
+ NULL,NULL,
+ current_section,
+ COL_ADD_MODE_REFERENCE))) {
TRACE_ERROR_NUMBER("Failed to create collection", error);
fclose(file);
- destroy_collection(current_section);
+ col_destroy_collection(current_section);
if (created) {
- destroy_collection(*error_list);
+ col_destroy_collection(*error_list);
*error_list = NULL;
}
return error;
@@ -283,9 +285,9 @@ static int ini_to_collection(const char *filename,
if (error != EOK) {
TRACE_ERROR_NUMBER("Failed to add pair to collection", error);
fclose(file);
- destroy_collection(current_section);
+ col_destroy_collection(current_section);
if (created) {
- destroy_collection(*error_list);
+ col_destroy_collection(*error_list);
*error_list = NULL;
}
return error;
@@ -298,13 +300,13 @@ static int ini_to_collection(const char *filename,
/* For easier search make line numbers for the sections negative.
* This would allow differentiating sections and attributes.
*/
- error = add_int_property(*lines, NULL, key, -1 * line);
+ error = col_add_int_property(*lines, NULL, key, -1 * line);
if (error) {
TRACE_ERROR_NUMBER("Failed to add line to line collection", error);
fclose(file);
- destroy_collection(current_section);
+ col_destroy_collection(current_section);
if (created) {
- destroy_collection(*error_list);
+ col_destroy_collection(*error_list);
*error_list = NULL;
}
return error;
@@ -312,23 +314,23 @@ static int ini_to_collection(const char *filename,
}
/* Read a new section */
- destroy_collection(current_section);
+ col_destroy_collection(current_section);
current_section = NULL;
- error = get_collection_reference(ini_config, &current_section, key);
+ error = col_get_collection_reference(ini_config, &current_section, key);
if (error != EOK) {
/* Create default collection */
- if ((error = create_collection(&current_section, key,
- COL_CLASS_INI_SECTION)) ||
- (error = add_collection_to_collection(ini_config,
- NULL, NULL,
- current_section,
- COL_ADD_MODE_REFERENCE))) {
+ if ((error = col_create_collection(&current_section, key,
+ COL_CLASS_INI_SECTION)) ||
+ (error = col_add_collection_to_collection(ini_config,
+ NULL, NULL,
+ current_section,
+ COL_ADD_MODE_REFERENCE))) {
TRACE_ERROR_NUMBER("Failed to add collection", error);
fclose(file);
- destroy_collection(current_section);
+ col_destroy_collection(current_section);
if (created) {
- destroy_collection(*error_list);
+ col_destroy_collection(*error_list);
*error_list = NULL;
}
return error;
@@ -348,14 +350,14 @@ static int ini_to_collection(const char *filename,
case RET_ERROR:
pe.line = line;
pe.error = ext_err;
- error = add_binary_property(*error_list, NULL,
- ERROR_TXT, &pe, sizeof(pe));
+ error = col_add_binary_property(*error_list, NULL,
+ ERROR_TXT, &pe, sizeof(pe));
if (error) {
TRACE_ERROR_NUMBER("Failed to add error to collection", error);
fclose(file);
- destroy_collection(current_section);
+ col_destroy_collection(current_section);
if (created) {
- destroy_collection(*error_list);
+ col_destroy_collection(*error_list);
*error_list = NULL;
}
return error;
@@ -363,7 +365,7 @@ static int ini_to_collection(const char *filename,
/* Exit if there was an error parsing file */
if (error_level != INI_STOP_ON_NONE) {
TRACE_ERROR_STRING("Invalid format of the file", "");
- destroy_collection(current_section);
+ col_destroy_collection(current_section);
fclose(file);
return EIO;
}
@@ -373,14 +375,14 @@ static int ini_to_collection(const char *filename,
default:
pe.line = line;
pe.error = ext_err;
- error = add_binary_property(*error_list, NULL,
- WARNING_TXT, &pe, sizeof(pe));
+ error = col_add_binary_property(*error_list, NULL,
+ WARNING_TXT, &pe, sizeof(pe));
if (error) {
TRACE_ERROR_NUMBER("Failed to add warning to collection", error);
fclose(file);
- destroy_collection(current_section);
+ col_destroy_collection(current_section);
if (created) {
- destroy_collection(*error_list);
+ col_destroy_collection(*error_list);
*error_list = NULL;
}
return error;
@@ -388,7 +390,7 @@ static int ini_to_collection(const char *filename,
/* Exit if we are told to exit on warnings */
if (error_level == INI_STOP_ON_ANY) {
TRACE_ERROR_STRING("Invalid format of the file", "");
- if (created) destroy_collection(current_section);
+ if (created) col_destroy_collection(current_section);
fclose(file);
return EIO;
}
@@ -401,11 +403,11 @@ static int ini_to_collection(const char *filename,
/* Close file */
fclose(file);
- DEBUG_COLLECTION(ini_config);
+ COL_DEBUG_COLLECTION(ini_config);
- destroy_collection(current_section);
+ col_destroy_collection(current_section);
- DEBUG_COLLECTION(ini_config);
+ COL_DEBUG_COLLECTION(ini_config);
TRACE_FLOW_STRING("ini_to_collection", "Success Exit");
@@ -457,9 +459,9 @@ int config_from_file_with_lines(const char *application,
/* Create collection if needed */
if (*ini_config == NULL) {
- error = create_collection(ini_config,
- application,
- COL_CLASS_INI_CONFIG);
+ error = col_create_collection(ini_config,
+ application,
+ COL_CLASS_INI_CONFIG);
if (error != EOK) {
TRACE_ERROR_NUMBER("Failed to create collection", error);
return error;
@@ -467,7 +469,7 @@ int config_from_file_with_lines(const char *application,
created = 1;
}
/* Is the collection of the right class? */
- else if (is_of_class(*ini_config, COL_CLASS_INI_CONFIG)) {
+ else if (col_is_of_class(*ini_config, COL_CLASS_INI_CONFIG)) {
TRACE_ERROR_NUMBER("Wrong collection type", EINVAL);
return EINVAL;
}
@@ -480,19 +482,19 @@ int config_from_file_with_lines(const char *application,
if (*lines) {
TRACE_ERROR_NUMBER("Collection of lines is not empty", EINVAL);
if (created) {
- destroy_collection(*ini_config);
+ col_destroy_collection(*ini_config);
*ini_config = NULL;
}
return EINVAL;
}
- error = create_collection(lines,
- application,
- COL_CLASS_INI_LINES);
+ error = col_create_collection(lines,
+ application,
+ COL_CLASS_INI_LINES);
if (error != EOK) {
TRACE_ERROR_NUMBER("Failed to create collection", error);
if (created) {
- destroy_collection(*ini_config);
+ col_destroy_collection(*ini_config);
*ini_config = NULL;
}
return error;
@@ -505,12 +507,12 @@ int config_from_file_with_lines(const char *application,
error_level, error_list, lines);
/* In case of error when we created collection - delete it */
if (error && created) {
- destroy_collection(*ini_config);
+ col_destroy_collection(*ini_config);
*ini_config = NULL;
}
/* Also create collection of lines if we created it */
if (error && created_lines) {
- destroy_collection(*lines);
+ col_destroy_collection(*lines);
*lines = NULL;
}
@@ -549,9 +551,9 @@ int config_for_app(const char *application,
pass_specific = &error_list_specific;
*error_set = NULL;
/* Construct the overarching error collection */
- error = create_collection(error_set,
- FILE_ERROR_SET,
- COL_CLASS_INI_PESET);
+ error = col_create_collection(error_set,
+ FILE_ERROR_SET,
+ COL_CLASS_INI_PESET);
if (error != EOK) {
TRACE_ERROR_NUMBER("Failed to create collection", error);
return error;
@@ -566,18 +568,18 @@ int config_for_app(const char *application,
/* Create collection if needed */
if (*ini_config == NULL) {
TRACE_INFO_STRING("New config collection. Allocate.", "");
- error = create_collection(ini_config,
- application,
- COL_CLASS_INI_CONFIG);
+ error = col_create_collection(ini_config,
+ application,
+ COL_CLASS_INI_CONFIG);
if (error != EOK) {
TRACE_ERROR_NUMBER("Failed to create collection", error);
- destroy_collection(*error_set);
+ col_destroy_collection(*error_set);
*error_set = NULL;
return error;
}
}
/* Is the collection of the right class? */
- else if (is_of_class(*ini_config, COL_CLASS_INI_CONFIG)) {
+ else if (col_is_of_class(*ini_config, COL_CLASS_INI_CONFIG)) {
TRACE_ERROR_NUMBER("Wrong collection type", EINVAL);
return EINVAL;
}
@@ -592,7 +594,7 @@ int config_for_app(const char *application,
TRACE_ERROR_NUMBER("Failed to read master file", error);
/* In case of error when we created collection - delete it */
if(error && created) {
- destroy_collection(*ini_config);
+ col_destroy_collection(*ini_config);
*ini_config = NULL;
}
/* We do not clear the error_set here */
@@ -601,15 +603,15 @@ int config_for_app(const char *application,
/* Add error results if any to the overarching error collection */
if ((pass_common != NULL) && (*pass_common != NULL)) {
TRACE_INFO_STRING("Process erros resulting from file:", config_file);
- error = add_collection_to_collection(*error_set, NULL, NULL,
- *pass_common,
- COL_ADD_MODE_EMBED);
+ error = col_add_collection_to_collection(*error_set, NULL, NULL,
+ *pass_common,
+ COL_ADD_MODE_EMBED);
if (error) {
if (created) {
- destroy_collection(*ini_config);
+ col_destroy_collection(*ini_config);
*ini_config = NULL;
}
- destroy_collection(*error_set);
+ col_destroy_collection(*error_set);
*error_set = NULL;
TRACE_ERROR_NUMBER("Failed to add error collection to another error collection", error);
return error;
@@ -625,10 +627,10 @@ int config_for_app(const char *application,
TRACE_ERROR_NUMBER("Failed to allocate memory for file name", error);
/* In case of error when we created collection - delete it */
if(error && created) {
- destroy_collection(*ini_config);
+ col_destroy_collection(*ini_config);
*ini_config = NULL;
}
- destroy_collection(*error_set);
+ col_destroy_collection(*error_set);
*error_set = NULL;
return error;
}
@@ -645,7 +647,7 @@ int config_for_app(const char *application,
TRACE_ERROR_NUMBER("Failed to read specific application file", error);
/* In case of error when we created collection - delete it */
if (error && created) {
- destroy_collection(*ini_config);
+ col_destroy_collection(*ini_config);
*ini_config = NULL;
}
/* We do not clear the error_set here */
@@ -655,15 +657,15 @@ int config_for_app(const char *application,
/* Add error results if any to the overarching error collection */
if ((pass_specific != NULL) && (*pass_specific != NULL)) {
TRACE_INFO_STRING("Process erros resulting from file:", file_name);
- error = add_collection_to_collection(*error_set, NULL, NULL,
- *pass_specific,
- COL_ADD_MODE_EMBED);
+ error = col_add_collection_to_collection(*error_set, NULL, NULL,
+ *pass_specific,
+ COL_ADD_MODE_EMBED);
if (error) {
if (created) {
- destroy_collection(*ini_config);
+ col_destroy_collection(*ini_config);
*ini_config = NULL;
}
- destroy_collection(*error_set);
+ col_destroy_collection(*error_set);
*error_set = NULL;
TRACE_ERROR_NUMBER("Failed to add error collection to another error collection", error);
return error;
@@ -861,14 +863,14 @@ static void print_error_list(FILE *file,
}
/* Make sure we go the right collection */
- if (!is_of_class(error_list, cclass)) {
+ if (!col_is_of_class(error_list, cclass)) {
TRACE_ERROR_STRING("Wrong collection class:", wrong_col_error);
fprintf(file,"%s\n", wrong_col_error);
return;
}
/* Bind iterator */
- error = bind_iterator(&iterator, error_list, COL_TRAVERSE_DEFAULT);
+ error = col_bind_iterator(&iterator, error_list, COL_TRAVERSE_DEFAULT);
if (error) {
TRACE_ERROR_STRING("Error (bind):", failed_to_process);
fprintf(file, "%s\n", failed_to_process);
@@ -877,11 +879,11 @@ static void print_error_list(FILE *file,
while(1) {
/* Loop through a collection */
- error = iterate_collection(iterator, &item);
+ error = col_iterate_collection(iterator, &item);
if (error) {
TRACE_ERROR_STRING("Error (iterate):", failed_to_process);
fprintf(file, "%s\n", failed_to_process);
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
return;
}
@@ -889,17 +891,17 @@ static void print_error_list(FILE *file,
if (item == NULL) break;
/* Process collection header */
- if (get_item_type(item) == COL_TYPE_COLLECTION) {
- get_collection_count(item, &count);
+ if (col_get_item_type(item) == COL_TYPE_COLLECTION) {
+ col_get_collection_count(item, &count);
if (count > 1)
- fprintf(file, error_header, get_item_property(item, NULL));
+ fprintf(file, error_header, col_get_item_property(item, NULL));
else break;
}
else {
/* Put error into provided format */
- pe = (struct parse_error *)(get_item_data(item));
+ pe = (struct parse_error *)(col_get_item_data(item));
fprintf(file, line_format,
- get_item_property(item, NULL), /* Error or warning */
+ col_get_item_property(item, NULL), /* Error or warning */
pe->error, /* Error */
pe->line, /* Line */
error_function(pe->error)); /* Error str */
@@ -908,7 +910,7 @@ static void print_error_list(FILE *file,
}
/* Do not forget to unbind iterator - otherwise there will be a leak */
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
TRACE_FLOW_STRING("print_error_list", "Exit");
}
@@ -975,14 +977,14 @@ void print_config_parsing_errors(FILE *file,
}
/* Make sure we go the right collection */
- if (!is_of_class(error_list, COL_CLASS_INI_PESET)) {
+ if (!col_is_of_class(error_list, COL_CLASS_INI_PESET)) {
TRACE_ERROR_STRING("Wrong collection class:", WRONG_COLLECTION);
fprintf(file, "%s\n", WRONG_COLLECTION);
return;
}
/* Bind iterator */
- error = bind_iterator(&iterator, error_list, COL_TRAVERSE_DEFAULT);
+ error = col_bind_iterator(&iterator, error_list, COL_TRAVERSE_DEFAULT);
if (error) {
TRACE_ERROR_STRING("Error (bind):", FAILED_TO_PROCCESS);
fprintf(file,"%s\n", FAILED_TO_PROCCESS);
@@ -991,11 +993,11 @@ void print_config_parsing_errors(FILE *file,
while(1) {
/* Loop through a collection */
- error = iterate_collection(iterator, &item);
+ error = col_iterate_collection(iterator, &item);
if (error) {
TRACE_ERROR_STRING("Error (iterate):", FAILED_TO_PROCCESS);
fprintf(file, "%s\n", FAILED_TO_PROCCESS);
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
return;
}
@@ -1003,21 +1005,21 @@ void print_config_parsing_errors(FILE *file,
if (item == NULL) break;
/* Print per file sets of errors */
- if (get_item_type(item) == COL_TYPE_COLLECTIONREF) {
+ if (col_get_item_type(item) == COL_TYPE_COLLECTIONREF) {
/* Extract a sub collection */
- error = get_reference_from_item(item, &file_errors);
+ error = col_get_reference_from_item(item, &file_errors);
if (error) {
TRACE_ERROR_STRING("Error (extract):", FAILED_TO_PROCCESS);
fprintf(file, "%s\n", FAILED_TO_PROCCESS);
return;
}
print_file_parsing_errors(file, file_errors);
- destroy_collection(file_errors);
+ col_destroy_collection(file_errors);
}
}
/* Do not forget to unbind iterator - otherwise there will be a leak */
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
TRACE_FLOW_STRING("print_config_parsing_errors", "Exit");
}
@@ -1043,7 +1045,7 @@ int get_config_item(const char *section,
}
/* Is the collection of a right type */
- if (!is_of_class(ini_config, COL_CLASS_INI_CONFIG)) {
+ if (!col_is_of_class(ini_config, COL_CLASS_INI_CONFIG)) {
TRACE_ERROR_NUMBER("Wrong collection type", EINVAL);
return EINVAL;
}
@@ -1057,7 +1059,7 @@ int get_config_item(const char *section,
TRACE_INFO_STRING("In Section:", section);
/* Get Subcollection */
- error = get_collection_reference(ini_config, &section_handle, to_find);
+ error = col_get_collection_reference(ini_config, &section_handle, to_find);
/* Check error */
if (error && (error != ENOENT)) {
TRACE_ERROR_NUMBER("Failed to get section", error);
@@ -1072,11 +1074,11 @@ int get_config_item(const char *section,
}
/* Get item */
- error = get_item(section_handle, name,
- COL_TYPE_STRING, COL_TRAVERSE_ONELEVEL, item);
+ error = col_get_item(section_handle, name,
+ COL_TYPE_STRING, COL_TRAVERSE_ONELEVEL, item);
/* Make sure we free the section we found */
- destroy_collection(section_handle);
+ col_destroy_collection(section_handle);
TRACE_FLOW_NUMBER("get_config_item returning", error);
return error;
@@ -1094,7 +1096,7 @@ long get_long_config_value(struct collection_item *item,
/* Do we have the item ? */
if ((item == NULL) ||
- (get_item_type(item) != COL_TYPE_STRING)) {
+ (col_get_item_type(item) != COL_TYPE_STRING)) {
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL);
if (error) *error = EINVAL;
return def;
@@ -1103,7 +1105,7 @@ long get_long_config_value(struct collection_item *item,
if (error) *error = EOK;
/* Try to parse the value */
- str = (const char *)get_item_data(item);
+ str = (const char *)col_get_item_data(item);
errno = 0;
val = strtol(str, &endptr, 10);
@@ -1161,7 +1163,7 @@ double get_double_config_value(struct collection_item *item,
/* Do we have the item ? */
if ((item == NULL) ||
- (get_item_type(item) != COL_TYPE_STRING)) {
+ (col_get_item_type(item) != COL_TYPE_STRING)) {
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL);
if (error) *error = EINVAL;
return def;
@@ -1170,7 +1172,7 @@ double get_double_config_value(struct collection_item *item,
if (error) *error = EOK;
/* Try to parse the value */
- str = (const char *)get_item_data(item);
+ str = (const char *)col_get_item_data(item);
errno = 0;
val = strtod(str, &endptr);
@@ -1204,7 +1206,7 @@ unsigned char get_bool_config_value(struct collection_item *item,
/* Do we have the item ? */
if ((item == NULL) ||
- (get_item_type(item) != COL_TYPE_STRING)) {
+ (col_get_item_type(item) != COL_TYPE_STRING)) {
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL);
if (error) *error = EINVAL;
return def;
@@ -1212,8 +1214,8 @@ unsigned char get_bool_config_value(struct collection_item *item,
if (error) *error = EOK;
- str = (const char *)get_item_data(item);
- len = get_item_length(item);
+ str = (const char *)col_get_item_data(item);
+ len = col_get_item_length(item);
/* Try to parse the value */
if ((strncasecmp(str, "true", len) == 0) ||
@@ -1242,14 +1244,14 @@ char *get_string_config_value(struct collection_item *item,
/* Do we have the item ? */
if ((item == NULL) ||
- (get_item_type(item) != COL_TYPE_STRING)) {
+ (col_get_item_type(item) != COL_TYPE_STRING)) {
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL);
if (error) *error = EINVAL;
return NULL;
}
errno = 0;
- str = strdup((const char *)get_item_data(item));
+ str = strdup((const char *)col_get_item_data(item));
if (str == NULL) {
TRACE_ERROR_NUMBER("Failed to allocate memory.", ENOMEM);
if (error) *error = ENOMEM;
@@ -1271,13 +1273,13 @@ const char *get_const_string_config_value(struct collection_item *item, int *err
/* Do we have the item ? */
if ((item == NULL) ||
- (get_item_type(item) != COL_TYPE_STRING)) {
+ (col_get_item_type(item) != COL_TYPE_STRING)) {
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL);
if (error) *error = EINVAL;
return NULL;
}
- str = (const char *)get_item_data(item);
+ str = (const char *)col_get_item_data(item);
if (error) *error = EOK;
@@ -1306,21 +1308,21 @@ char *get_bin_config_value(struct collection_item *item,
/* Do we have the item ? */
if ((item == NULL) ||
- (get_item_type(item) != COL_TYPE_STRING)) {
+ (col_get_item_type(item) != COL_TYPE_STRING)) {
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL);
if (error) *error = EINVAL;
return NULL;
}
/* Check the length */
- len = get_item_length(item)-1;
+ len = col_get_item_length(item)-1;
if ((len%2) != 0) {
TRACE_ERROR_STRING("Invalid length for binary data", "");
if (error) *error = EINVAL;
return NULL;
}
- str = (const char *)get_item_data(item);
+ str = (const char *)col_get_item_data(item);
/* Is the format correct ? */
if ((*str != '\'') ||
@@ -1402,7 +1404,7 @@ char **get_string_config_array(struct collection_item *item,
/* Do we have the item ? */
if ((item == NULL) ||
- (get_item_type(item) != COL_TYPE_STRING)) {
+ (col_get_item_type(item) != COL_TYPE_STRING)) {
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL);
if (error) *error = EINVAL;
return NULL;
@@ -1413,7 +1415,7 @@ char **get_string_config_array(struct collection_item *item,
lensep = strnlen(sep, 3);
/* Allocate memory for the copy of the string */
- copy = malloc(get_item_length(item));
+ copy = malloc(col_get_item_length(item));
if (copy == NULL) {
TRACE_ERROR_NUMBER("Failed to allocate memory.", ENOMEM);
if (error) *error = ENOMEM;
@@ -1543,7 +1545,7 @@ long *get_long_config_array(struct collection_item *item, int *size, int *error)
/* Do we have the item ? */
if ((item == NULL) ||
- (get_item_type(item) != COL_TYPE_STRING) ||
+ (col_get_item_type(item) != COL_TYPE_STRING) ||
(size == NULL)) {
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL);
if (error) *error = EINVAL;
@@ -1551,7 +1553,7 @@ long *get_long_config_array(struct collection_item *item, int *size, int *error)
}
/* Assume that we have maximum number of different numbers */
- array = (long *)malloc(sizeof(long) * get_item_length(item)/2);
+ array = (long *)malloc(sizeof(long) * col_get_item_length(item)/2);
if (array == NULL) {
TRACE_ERROR_NUMBER("Failed to allocate memory.", ENOMEM);
if (error) *error = ENOMEM;
@@ -1559,7 +1561,7 @@ long *get_long_config_array(struct collection_item *item, int *size, int *error)
}
/* Now parse the string */
- str = (const char *)get_item_data(item);
+ str = (const char *)col_get_item_data(item);
while (*str) {
errno = 0;
val = strtol(str, &endptr, 10);
@@ -1606,7 +1608,7 @@ double *get_double_config_array(struct collection_item *item, int *size, int *er
/* Do we have the item ? */
if ((item == NULL) ||
- (get_item_type(item) != COL_TYPE_STRING) ||
+ (col_get_item_type(item) != COL_TYPE_STRING) ||
(size == NULL)) {
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL);
if (error) *error = EINVAL;
@@ -1614,7 +1616,7 @@ double *get_double_config_array(struct collection_item *item, int *size, int *er
}
/* Assume that we have maximum number of different numbers */
- array = (double *)malloc(sizeof(double) * get_item_length(item)/2);
+ array = (double *)malloc(sizeof(double) * col_get_item_length(item)/2);
if (array == NULL) {
TRACE_ERROR_NUMBER("Failed to allocate memory.", ENOMEM);
if (error) *error = ENOMEM;
@@ -1629,7 +1631,7 @@ double *get_double_config_array(struct collection_item *item, int *size, int *er
loc = localeconv();
/* Now parse the string */
- str = (const char *)get_item_data(item);
+ str = (const char *)col_get_item_data(item);
while (*str) {
errno = 0;
TRACE_INFO_STRING("String to convert",str);
@@ -1682,7 +1684,7 @@ void free_section_list(char **section_list)
{
TRACE_FLOW_STRING("free_section_list","Entry");
- free_property_list(section_list);
+ col_free_property_list(section_list);
TRACE_FLOW_STRING("free_section_list","Exit");
}
@@ -1692,7 +1694,7 @@ void free_attribute_list(char **section_list)
{
TRACE_FLOW_STRING("free_section_list","Entry");
- free_property_list(section_list);
+ col_free_property_list(section_list);
TRACE_FLOW_STRING("free_section_list","Exit");
}
@@ -1708,14 +1710,14 @@ char **get_section_list(struct collection_item *ini_config, int *size, int *erro
TRACE_FLOW_STRING("get_section_list","Entry");
/* Do we have the item ? */
if ((ini_config == NULL) ||
- !is_of_class(ini_config, COL_CLASS_INI_CONFIG)) {
+ !col_is_of_class(ini_config, COL_CLASS_INI_CONFIG)) {
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL);
if (error) *error = EINVAL;
return NULL;
}
/* Pass it to the function from collection API */
- list = collection_to_list(ini_config, size, error);
+ list = col_collection_to_list(ini_config, size, error);
TRACE_FLOW_STRING("get_section_list returning", list == NULL ? "NULL" : list[0]);
return list;
@@ -1733,7 +1735,7 @@ char **get_attribute_list(struct collection_item *ini_config, const char *sectio
TRACE_FLOW_STRING("get_attribute_list","Entry");
/* Do we have the item ? */
if ((ini_config == NULL) ||
- !is_of_class(ini_config, COL_CLASS_INI_CONFIG) ||
+ !col_is_of_class(ini_config, COL_CLASS_INI_CONFIG) ||
(section == NULL)) {
TRACE_ERROR_NUMBER("Invalid argument.", EINVAL);
if (error) *error = EINVAL;
@@ -1741,7 +1743,7 @@ char **get_attribute_list(struct collection_item *ini_config, const char *sectio
}
/* Fetch section */
- err = get_collection_reference(ini_config, &subcollection, section);
+ err = col_get_collection_reference(ini_config, &subcollection, section);
/* Check error */
if (err && (subcollection == NULL)) {
TRACE_ERROR_NUMBER("Failed to get section", err);
@@ -1750,9 +1752,9 @@ char **get_attribute_list(struct collection_item *ini_config, const char *sectio
}
/* Pass it to the function from collection API */
- list = collection_to_list(subcollection, size, error);
+ list = col_collection_to_list(subcollection, size, error);
- destroy_collection(subcollection);
+ col_destroy_collection(subcollection);
TRACE_FLOW_STRING("get_attribute_list returning", list == NULL ? "NULL" : list[0]);
return list;
diff --git a/common/ini/ini_config_ut.c b/common/ini/ini_config_ut.c
index 9aefbe30..ce379211 100644
--- a/common/ini/ini_config_ut.c
+++ b/common/ini/ini_config_ut.c
@@ -41,9 +41,9 @@ int basic_test()
return error;
}
- debug_collection(ini_config,COL_TRAVERSE_DEFAULT);
- print_collection(ini_config);
- print_collection(error_set);
+ col_debug_collection(ini_config,COL_TRAVERSE_DEFAULT);
+ col_print_collection(ini_config);
+ col_print_collection(error_set);
printf("\n\n----------------------\n");
/* Output parsing errors (if any) */
@@ -51,8 +51,8 @@ int basic_test()
printf("----------------------\n\n\n");
- destroy_collection(ini_config);
- destroy_collection(error_set);
+ col_destroy_collection(ini_config);
+ col_destroy_collection(error_set);
return 0;
}
@@ -76,9 +76,9 @@ int single_file()
return error;
}
- debug_collection(ini_config, COL_TRAVERSE_DEFAULT);
- print_collection(ini_config);
- print_collection(error_set);
+ col_debug_collection(ini_config, COL_TRAVERSE_DEFAULT);
+ col_print_collection(ini_config);
+ col_print_collection(error_set);
printf("\n\n----------------------\n");
/* Output parsing errors (if any) */
@@ -86,8 +86,8 @@ int single_file()
printf("----------------------\n\n\n");
- destroy_collection(ini_config);
- destroy_collection(error_set);
+ col_destroy_collection(ini_config);
+ col_destroy_collection(error_set);
ini_config = NULL;
error_set = NULL;
@@ -102,8 +102,8 @@ int single_file()
return error;
}
- debug_collection(ini_config, COL_TRAVERSE_DEFAULT);
- debug_collection(lines, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(ini_config, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(lines, COL_TRAVERSE_DEFAULT);
printf("\n\n----------------------\n");
/* Output parsing errors (if any) */
@@ -111,9 +111,9 @@ int single_file()
printf("----------------------\n\n\n");
- destroy_collection(ini_config);
- destroy_collection(error_set);
- destroy_collection(lines);
+ col_destroy_collection(ini_config);
+ col_destroy_collection(error_set);
+ col_destroy_collection(lines);
return 0;
}
@@ -153,14 +153,14 @@ int negative_test()
}
count = 0;
- (void)get_collection_count(ini_config, &count);
+ (void)col_get_collection_count(ini_config, &count);
if (count > 1) {
printf("Expected empty collection but got contents with %d elements\n", count);
- print_collection(ini_config);
+ col_print_collection(ini_config);
return -1;
}
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return 0;
}
@@ -184,9 +184,9 @@ int real_test(const char *file)
}
printf("Debugging the config collection:\n");
- debug_collection(ini_config, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(ini_config, COL_TRAVERSE_DEFAULT);
printf("Debugging the error collection:\n");
- debug_collection(error_set, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(error_set, COL_TRAVERSE_DEFAULT);
printf("About to print parsing errors:\n");
printf("\n\n----------------------\n");
@@ -196,48 +196,48 @@ int real_test(const char *file)
printf("About to bind iterator to print the config file contents.\n");
/* Bind iterator */
- error = bind_iterator(&iterator, ini_config,
+ error = col_bind_iterator(&iterator, ini_config,
COL_TRAVERSE_DEFAULT|COL_TRAVERSE_END);
if (error) {
printf("Failed to bind iterator: %d\n",error);
- destroy_collection(ini_config);
- destroy_collection(error_set);
+ col_destroy_collection(ini_config);
+ col_destroy_collection(error_set);
return error;
}
printf("About to start iteration loop.\n");
do {
/* Loop through a collection */
- error = iterate_collection(iterator, &item);
+ error = col_iterate_collection(iterator, &item);
if (error) {
printf("Error iterating collection: %d", error);
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
return error;
}
/* Are we done ? */
if (item == (struct collection_item *)(NULL)) break;
- type = get_item_type(item);
+ type = col_get_item_type(item);
/* Start of the collection */
if (type == COL_TYPE_COLLECTION)
- printf("Contents of the configuration for application %s\n", get_item_property(item, NULL));
+ printf("Contents of the configuration for application %s\n", col_get_item_property(item, NULL));
/* End of section */
else if (type == COL_TYPE_END) printf("\n");
/* Section header ? */
- else if (type == COL_TYPE_COLLECTIONREF) printf("[%s]\n", get_item_property(item, NULL));
+ else if (type == COL_TYPE_COLLECTIONREF) printf("[%s]\n", col_get_item_property(item, NULL));
/* Anything else - we know they are all strings*/
- else printf("%s = %s\n", get_item_property(item, NULL), (char *)get_item_data(item));
+ else printf("%s = %s\n", col_get_item_property(item, NULL), (char *)col_get_item_data(item));
}
while(1);
/* Do not forget to unbind iterator - otherwise there will be a leak */
printf("About to clean up.\n");
- unbind_iterator(iterator);
+ col_unbind_iterator(iterator);
- destroy_collection(ini_config);
- destroy_collection(error_set);
+ col_destroy_collection(ini_config);
+ col_destroy_collection(error_set);
return 0;
}
@@ -277,10 +277,10 @@ int get_test()
}
printf("Debugging the config collection:\n");
- debug_collection(ini_config, COL_TRAVERSE_DEFAULT);
+ col_debug_collection(ini_config, COL_TRAVERSE_DEFAULT);
printf("Debugging the error collection:\n");
- debug_collection(error_set, COL_TRAVERSE_DEFAULT);
- destroy_collection(error_set);
+ col_debug_collection(error_set, COL_TRAVERSE_DEFAULT);
+ col_destroy_collection(error_set);
printf("Negtive test - trying to get non existing key-value pair.\n");
@@ -289,14 +289,14 @@ int get_test()
error = get_config_item("monitor1", "description1", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* Item should not be found */
if (item != (struct collection_item *)(NULL)) {
printf("Expected NULL but got something else!\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -305,14 +305,14 @@ int get_test()
error = get_config_item("monitor", "description1", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* Item should not be found */
if(item != (struct collection_item *)(NULL)) {
printf("Expected NULL but got something else!\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -323,18 +323,18 @@ int get_test()
error = get_config_item("monitor", "description", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* Item should be found */
if (item == (struct collection_item *)(NULL)) {
printf("Expected item but got something NULL!\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
- debug_item(item);
+ col_debug_item(item);
printf("Get item as string without duplication from NULL item.\n");
@@ -343,7 +343,7 @@ int get_test()
cstrn = get_const_string_config_value(NULL, NULL);
if (cstrn != NULL) {
printf("Expected error got success.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -354,7 +354,7 @@ int get_test()
cstr = get_const_string_config_value(item, &error);
if (error) {
printf("Expected success got error %d.\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
@@ -368,7 +368,7 @@ int get_test()
str = get_string_config_value(item, &error);
if (error) {
printf("Expected success got error %d.\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
@@ -383,18 +383,18 @@ int get_test()
error = get_config_item("monitor", "bad_number", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* Item should be found */
if (item == (struct collection_item *)(NULL)) {
printf("Expected item but got something NULL!\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
- debug_item(item);
+ col_debug_item(item);
/* Now try to get value in different ways */
@@ -405,7 +405,7 @@ int get_test()
printf("Expected error.\n");
if(number != 10) {
printf("It failed to set default value.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
}
@@ -418,14 +418,14 @@ int get_test()
if (error) {
/* We expected error in this case */
printf("Did not expect error.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
if (number != 5) {
/* We expected error in this case */
printf("We expected that the conversion will return 5.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -437,14 +437,14 @@ int get_test()
error = get_config_item("domains/LOCAL","enumerate", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* Item should be found */
if (item == (struct collection_item *)(NULL)) {
printf("Expected success but got NULL.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -455,14 +455,14 @@ int get_test()
number = get_int_config_value(item, 1, 100, &error);
if (error) {
printf("Did not expect error. Got %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* It is 3 in the file */
if (number != 3) {
printf("We expected that the conversion will return 3.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -475,14 +475,14 @@ int get_test()
number_long = get_long_config_value(item, 1, 100, &error);
if (error) {
printf("Did not expect error. Got %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* It is 3 in the file */
if (number_long != 3) {
printf("We expected that the conversion will return 3.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -495,14 +495,14 @@ int get_test()
number_unsigned = get_unsigned_config_value(item, 1, 100, &error);
if (error) {
printf("Did not expect error. Got %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* It is 3 in the file */
if(number_unsigned != 3) {
printf("We expected that the conversion will return 3.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -515,14 +515,14 @@ int get_test()
number_ulong = get_ulong_config_value(item, 1, 100, &error);
if (error) {
printf("Did not expect error. Got %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* It is 3 in the file */
if (number_ulong != 3) {
printf("We expected that the conversion will return 3.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -535,14 +535,14 @@ int get_test()
number_double = get_double_config_value(item, 1, 100., &error);
if (error) {
printf("Did not expect error. Got %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* It is 3 in the file */
if (number_double != 3.) {
printf("We expected that the conversion will return 3.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -555,7 +555,7 @@ int get_test()
logical = get_bool_config_value(item, 1, &error);
if (!error) {
printf("Expect error. Got success.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -566,14 +566,14 @@ int get_test()
error = get_config_item("domains/LOCAL","legacy", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n",error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* Item should be found */
if (item == (struct collection_item *)(NULL)) {
printf("Expected success but got NULL.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -583,7 +583,7 @@ int get_test()
logical = get_bool_config_value(item, 1, &error);
if (error) {
printf("Expect success got error %d.\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
@@ -600,24 +600,24 @@ int get_test()
error = get_config_item("domains/EXAMPLE.COM","binary_test", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* Item should be found */
if (item == (struct collection_item *)(NULL)) {
printf("Expected success but got NULL.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
- debug_item(item);
+ col_debug_item(item);
error = 0;
binary = get_bin_config_value(item, &length, &error);
if (error) {
printf("Expect success got error %d.\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
@@ -635,18 +635,18 @@ int get_test()
error = get_config_item("domains", "domainsorder", ini_config, &item);
if(error) {
printf("Expected success but got error! %d\n",error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* Item should be found */
if (item == (struct collection_item *)(NULL)) {
printf("Expected success but got NULL.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
- debug_item(item);
+ col_debug_item(item);
printf("Get str array without size.\n");
@@ -654,7 +654,7 @@ int get_test()
strarray = get_string_config_array(item, ",", NULL, &error);
if (error) {
printf("Expect success got error %d.\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
@@ -674,7 +674,7 @@ int get_test()
strarray = get_string_config_array(item, ",", &size, &error);
if (error) {
printf("Expect success got error %d.\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
@@ -689,25 +689,25 @@ int get_test()
error = get_config_item("domains/EXAMPLE.COM", "long_array", ini_config, &item);
if(error) {
printf("Expected success but got error! %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* Item should be found */
if (item == (struct collection_item *)(NULL)) {
printf("Expected success but got NULL.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
- debug_item(item);
+ col_debug_item(item);
error = 0;
size = 0; /* Here size is not optional!!! */
array = get_long_config_array(item, &size, &error);
if(error) {
printf("Expect success got error %d.\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
@@ -722,25 +722,25 @@ int get_test()
error = get_config_item("domains/EXAMPLE.COM", "double_array", ini_config, &item);
if (error) {
printf("Expected success but got error! %d\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
/* Item should be found */
if (item == (struct collection_item *)(NULL)) {
printf("Expected success but got NULL.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
- debug_item(item);
+ col_debug_item(item);
error = 0;
size = 0; /* Here size is not optional!!! */
darray = get_double_config_array(item, &size, &error);
if (error) {
printf("Expect success got error %d.\n", error);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return error;
}
@@ -755,7 +755,7 @@ int get_test()
prop_array = get_section_list(ini_config, NULL, NULL);
if (prop_array == NULL) {
printf("Expect success got error.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -772,7 +772,7 @@ int get_test()
prop_array = get_section_list(ini_config, &size, NULL);
if (prop_array == NULL) {
printf("Expect success got error.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
@@ -785,14 +785,14 @@ int get_test()
prop_array = get_attribute_list(ini_config, "domains/EXAMPLE.COM", &size, &error);
if (prop_array == NULL) {
printf("Expect success got error.\n");
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
return -1;
}
for (i=0;i<size;i++) printf("Attribute: [%s]\n", prop_array[i]);
free_attribute_list(prop_array);
- destroy_collection(ini_config);
+ col_destroy_collection(ini_config);
printf("Done with get test!\n");
return EOK;
}