You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2016/12/20 20:07:48 UTC
[3/3] celix git commit: CELIX-390: Refactors celix utils. Ensures
that celix_utils is build before celix framework and does not have the celix
framework as include path.
CELIX-390: Refactors celix utils. Ensures that celix_utils is build before celix framework and does not have the celix framework as include path.
Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/147e8bfe
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/147e8bfe
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/147e8bfe
Branch: refs/heads/develop
Commit: 147e8bfeda0a8eee55470ed50705e98cdc9f3b09
Parents: 950788f
Author: Pepijn Noltes <pe...@gmail.com>
Authored: Tue Dec 20 21:11:55 2016 +0100
Committer: Pepijn Noltes <pe...@gmail.com>
Committed: Tue Dec 20 21:11:55 2016 +0100
----------------------------------------------------------------------
CMakeLists.txt | 20 +-
cmake/CMakeCelix.cmake | 3 -
dependency_manager/CMakeLists.txt | 2 +-
framework/CMakeLists.txt | 34 +--
framework/private/resources-test/properties.txt | 20 --
framework/private/src/properties.c | 306 -------------------
framework/private/src/utils.c | 142 ---------
framework/private/test/properties_test.cpp | 124 --------
framework/private/test/utils_test.cpp | 300 ------------------
framework/public/include/celix_errno.h | 112 -------
framework/public/include/celixbool.h | 61 ----
framework/public/include/properties.h | 54 ----
framework/public/include/utils.h | 49 ---
utils/CMakeLists.txt | 45 ++-
utils/private/resources-test/properties.txt | 20 ++
utils/private/src/properties.c | 306 +++++++++++++++++++
utils/private/src/utils.c | 142 +++++++++
utils/private/test/properties_test.cpp | 124 ++++++++
utils/private/test/utils_test.cpp | 300 ++++++++++++++++++
utils/public/include/celix_errno.h | 112 +++++++
utils/public/include/celixbool.h | 61 ++++
utils/public/include/properties.h | 54 ++++
utils/public/include/utils.h | 49 +++
23 files changed, 1203 insertions(+), 1237 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4dafbb3..57cf8a5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -72,13 +72,19 @@ include(UseDoxygen)
# Default bundle version
set(DEFAULT_VERSION 1.0.0)
-## New sub project must use a buildoption to be able to enable/disable the project using the CMake Editor
-## Sub projects depending on another sub project automatically enable these dependencies
-## For this to work, the order off "add_subdirectory" has to be correct (ie backwards)
+#utils, dfi and etcdlib are standalone
+#(e.g. no dependency on celix framework
+add_subdirectory(utils)
+add_subdirectory(dfi)
+add_subdirectory(etcdlib)
+
+add_subdirectory(framework)
+
+include_directories(framework/public/include)
+add_subdirectory(launcher)
add_subdirectory(config_admin)
add_subdirectory(device_access)
add_subdirectory(deployment_admin)
-add_subdirectory(etcdlib)
add_subdirectory(remote_services)
add_subdirectory(remote_shell)
add_subdirectory(shell_bonjour)
@@ -90,12 +96,6 @@ add_subdirectory(log_service)
#add_subdirectory(event_admin)# event_admin is unstable
add_subdirectory(dependency_manager)
add_subdirectory(dependency_manager_cxx)
-#add_subdirectory(scr) scr still needs APR
-
-add_subdirectory(launcher)
-add_subdirectory(framework)
-add_subdirectory(utils)
-add_subdirectory(dfi)
#Example as last, because some example will check if underlining options are enabled
add_subdirectory(examples)
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/cmake/CMakeCelix.cmake
----------------------------------------------------------------------
diff --git a/cmake/CMakeCelix.cmake b/cmake/CMakeCelix.cmake
index 0cda030..5a67385 100644
--- a/cmake/CMakeCelix.cmake
+++ b/cmake/CMakeCelix.cmake
@@ -22,9 +22,6 @@ if (ANDROID)
add_definitions( -DANDROID )
endif ()
-include_directories("framework/public/include")
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
include(cmake_celix/Dependencies)
include(cmake_celix/Packaging)
include(cmake_celix/PackagingLegacy)
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/dependency_manager/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/dependency_manager/CMakeLists.txt b/dependency_manager/CMakeLists.txt
index 446c294..ba65cf6 100644
--- a/dependency_manager/CMakeLists.txt
+++ b/dependency_manager/CMakeLists.txt
@@ -67,7 +67,7 @@ if (DEPENDENCY_MANAGER)
include_directories("public/include")
include_directories("private/include")
- include_directories("../shell/public/include")
+ include_directories("${PROJECT_SOURCE_DIR}/shell/public/include")
include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
target_link_libraries(dependency_manager_static celix_framework)
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/framework/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/framework/CMakeLists.txt b/framework/CMakeLists.txt
index 06f0c9f..2ded2fb 100644
--- a/framework/CMakeLists.txt
+++ b/framework/CMakeLists.txt
@@ -54,17 +54,17 @@ if (FRAMEWORK)
private/src/attribute.c private/src/bundle.c private/src/bundle_archive.c private/src/bundle_cache.c
private/src/bundle_context.c private/src/bundle_revision.c private/src/capability.c private/src/celix_errorcodes.c
private/src/filter.c private/src/framework.c private/src/manifest.c private/src/ioapi.c
- private/src/manifest_parser.c private/src/miniunz.c private/src/module.c private/src/properties.c
+ private/src/manifest_parser.c private/src/miniunz.c private/src/module.c
private/src/requirement.c private/src/resolver.c private/src/service_reference.c private/src/service_registration.c
private/src/service_registry.c private/src/service_tracker.c private/src/service_tracker_customizer.c
- private/src/unzip.c private/src/utils.c private/src/wire.c
+ private/src/unzip.c private/src/wire.c
private/src/celix_log.c private/src/celix_launcher.c
private/include/attribute.h public/include/framework_exports.h
- public/include/framework.h public/include/properties.h public/include/bundle_context.h public/include/bundle.h
+ public/include/bundle_context.h public/include/bundle.h
public/include/bundle_activator.h public/include/service_registration.h public/include/service_reference.h
- public/include/bundle_archive.h public/include/utils.h public/include/module.h public/include/service_tracker.h
+ public/include/bundle_archive.h public/include/module.h public/include/service_tracker.h
public/include/service_tracker_customizer.h public/include/requirement.h
${IO}
@@ -155,7 +155,6 @@ if (FRAMEWORK)
private/mock/bundle_revision_mock.c
private/mock/resolver_mock.c
private/mock/version_mock.c
- private/src/utils.c
private/src/bundle.c
private/src/celix_errorcodes.c
private/mock/celix_log_mock.c)
@@ -165,7 +164,6 @@ if (FRAMEWORK)
private/test/capability_test.cpp
private/mock/attribute_mock.c
private/mock/version_mock.c
- private/src/utils.c
private/src/capability.c
private/src/celix_errorcodes.c
private/mock/celix_log_mock.c)
@@ -178,8 +176,6 @@ if (FRAMEWORK)
add_executable(filter_test
private/test/filter_test.cpp
- private/src/utils.c
- private/src/properties.c
private/src/filter.c
private/src/celix_errorcodes.c
private/mock/celix_log_mock.c)
@@ -200,8 +196,6 @@ if (FRAMEWORK)
private/mock/bundle_revision_mock.c
private/mock/bundle_cache_mock.c
private/mock/manifest_mock.c
- private/src/utils.c
- private/src/properties.c
private/src/celix_errorcodes.c
private/mock/celix_log_mock.c
private/src/framework.c)
@@ -215,7 +209,6 @@ if (FRAMEWORK)
private/src/attribute.c
private/src/capability.c
private/src/requirement.c
- private/src/utils.c
private/src/manifest_parser.c
private/src/celix_errorcodes.c
private/mock/celix_log_mock.c)
@@ -224,7 +217,6 @@ if (FRAMEWORK)
add_executable(manifest_test
private/test/manifest_test.cpp
private/mock/properties_mock.c
- private/src/utils.c
private/src/manifest.c
private/src/celix_errorcodes.c
private/mock/celix_log_mock.c)
@@ -242,19 +234,12 @@ if (FRAMEWORK)
# private/src/module.c)
# target_link_libraries(module_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
- add_executable(properties_test
- private/test/properties_test.cpp
- private/src/utils.c
- private/src/properties.c)
- target_link_libraries(properties_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
-
add_executable(requirement_test
private/test/requirement_test.cpp
private/mock/attribute_mock.c
private/mock/capability_mock.c
private/mock/version_range_mock.c
private/src/requirement.c
- private/src/utils.c
private/src/celix_errorcodes.c
private/mock/celix_log_mock.c)
target_link_libraries(requirement_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
@@ -279,7 +264,6 @@ if (FRAMEWORK)
private/mock/service_registration_mock.c
private/mock/service_registry_mock.c
private/src/service_reference.c
- private/src/utils.c
private/src/celix_errorcodes.c
private/mock/celix_log_mock.c)
target_link_libraries(service_reference_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
@@ -287,8 +271,6 @@ if (FRAMEWORK)
add_executable(service_registration_test
private/test/service_registration_test.cpp
private/mock/service_registry_mock.c
- private/src/properties.c
- private/src/utils.c
private/src/service_registration.c
private/src/celix_errorcodes.c
private/mock/celix_log_mock.c)
@@ -327,9 +309,6 @@ if (FRAMEWORK)
# private/mock/celix_log_mock.c)
# target_link_libraries(service_tracker_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
- add_executable(utils_test
- private/test/utils_test.cpp private/src/utils.c)
- target_link_libraries(utils_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
add_executable(wire_test
private/mock/requirement_mock.c
@@ -343,7 +322,6 @@ if (FRAMEWORK)
configure_file(private/resources-test/manifest_sections.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest_sections.txt COPYONLY)
configure_file(private/resources-test/manifest.txt ${CMAKE_BINARY_DIR}/framework/resources-test/manifest.txt COPYONLY)
- configure_file(private/resources-test/properties.txt ${CMAKE_BINARY_DIR}/framework/resources-test/properties.txt COPYONLY)
#set_target_properties(wire_test PROPERTIES COMPILE_FLAGS "-include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorMallocMacros.h -include ${CPPUTEST_INCLUDE_DIR}/CppUTest/MemoryLeakDetectorNewMacros.h")
@@ -360,7 +338,6 @@ if (FRAMEWORK)
add_test(NAME manifest_parser_test COMMAND manifest_parser_test)
add_test(NAME manifest_test COMMAND manifest_test)
# add_test(NAME module_test COMMAND module_test)
- add_test(NAME properties_test COMMAND properties_test)
add_test(NAME requirement_test COMMAND requirement_test)
# add_test(NAME resolver_test COMMAND resolver_test)
add_test(NAME service_reference_test COMMAND service_reference_test)
@@ -368,7 +345,6 @@ if (FRAMEWORK)
add_test(NAME service_registry_test COMMAND service_registry_test)
add_test(NAME service_tracker_customizer_test COMMAND service_tracker_customizer_test)
# add_test(NAME service_tracker_test COMMAND service_tracker_test)
- add_test(NAME utils_test COMMAND utils_test)
add_test(NAME wire_test COMMAND wire_test)
SETUP_TARGET_FOR_COVERAGE(attribute_test attribute_test ${CMAKE_BINARY_DIR}/coverage/attribute_test/attribute_test)
@@ -384,7 +360,6 @@ if (FRAMEWORK)
SETUP_TARGET_FOR_COVERAGE(manifest_parser_test manifest_parser_test ${CMAKE_BINARY_DIR}/coverage/manifest_parser_test/manifest_parser_test)
SETUP_TARGET_FOR_COVERAGE(manifest_test manifest_test ${CMAKE_BINARY_DIR}/coverage/manifest_test/manifest_test)
# SETUP_TARGET_FOR_COVERAGE(module_test module_test ${CMAKE_BINARY_DIR}/coverage/module_test/module_test)
- SETUP_TARGET_FOR_COVERAGE(properties_test properties_test ${CMAKE_BINARY_DIR}/coverage/properties_test/properties_test)
SETUP_TARGET_FOR_COVERAGE(requirement_test requirement_test ${CMAKE_BINARY_DIR}/coverage/requirement_test/requirement_test)
# SETUP_TARGET_FOR_COVERAGE(resolver_test resolver_test ${CMAKE_BINARY_DIR}/coverage/resolver_test/resolver_test)
SETUP_TARGET_FOR_COVERAGE(service_reference_test service_reference_test ${CMAKE_BINARY_DIR}/coverage/service_reference_test/service_reference_test)
@@ -392,7 +367,6 @@ if (FRAMEWORK)
SETUP_TARGET_FOR_COVERAGE(service_registry_test service_registry_test ${CMAKE_BINARY_DIR}/coverage/service_registry_test/service_registry_test)
SETUP_TARGET_FOR_COVERAGE(service_tracker_customizer_test service_tracker_customizer_test ${CMAKE_BINARY_DIR}/coverage/service_tracker_customizer_test/service_tracker_customizer_test)
# SETUP_TARGET_FOR_COVERAGE(service_tracker_test service_tracker_test ${CMAKE_BINARY_DIR}/coverage/service_tracker_test/service_tracker_test)
- SETUP_TARGET_FOR_COVERAGE(utils_test utils_test ${CMAKE_BINARY_DIR}/coverage/utils_test/utils_test)
SETUP_TARGET_FOR_COVERAGE(wire_test wire_test ${CMAKE_BINARY_DIR}/coverage/wire_test/wire_test)
endif (ENABLE_TESTING AND FRAMEWORK_TESTS)
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/framework/private/resources-test/properties.txt
----------------------------------------------------------------------
diff --git a/framework/private/resources-test/properties.txt b/framework/private/resources-test/properties.txt
deleted file mode 100644
index 30f3c79..0000000
--- a/framework/private/resources-test/properties.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-a=b
-b=c
- // == \\ # 5 \0 \=
- #line to check possible special characters
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/framework/private/src/properties.c
----------------------------------------------------------------------
diff --git a/framework/private/src/properties.c b/framework/private/src/properties.c
deleted file mode 100644
index cd3b1f1..0000000
--- a/framework/private/src/properties.c
+++ /dev/null
@@ -1,306 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * properties.c
- *
- * \date Apr 27, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include "celixbool.h"
-#include "properties.h"
-#include "utils.h"
-
-#define MALLOC_BLOCK_SIZE 5
-
-static void parseLine(const char* line, properties_pt props);
-
-properties_pt properties_create(void) {
- return hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
-}
-
-void properties_destroy(properties_pt properties) {
- hash_map_iterator_pt iter = hashMapIterator_create(properties);
- while (hashMapIterator_hasNext(iter)) {
- hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
- free(hashMapEntry_getKey(entry));
- free(hashMapEntry_getValue(entry));
- }
- hashMapIterator_destroy(iter);
- hashMap_destroy(properties, false, false);
-}
-
-properties_pt properties_load(const char* filename) {
- FILE *file = fopen(filename, "r");
- if(file==NULL){
- return NULL;
- }
- properties_pt props = properties_loadWithStream(file);
- fclose(file);
- return props;
-}
-
-FRAMEWORK_EXPORT properties_pt properties_loadWithStream(FILE *file) {
- properties_pt props = NULL;
-
-
- if (file != NULL ) {
- char *saveptr;
- char *filebuffer = NULL;
- char *line = NULL;
- size_t file_size = 0;
-
- props = properties_create();
- fseek(file, 0, SEEK_END);
- file_size = ftell(file);
- fseek(file, 0, SEEK_SET);
-
- if(file_size > 0){
- filebuffer = calloc(file_size + 1, sizeof(char));
- if(filebuffer) {
- size_t rs = fread(filebuffer, sizeof(char), file_size, file);
- if(rs != file_size){
- fprintf(stderr,"fread read only %lu bytes out of %lu\n",rs,file_size);
- }
- filebuffer[file_size]='\0';
- line = strtok_r(filebuffer, "\n", &saveptr);
- while ( line != NULL ) {
- parseLine(line, props);
- line = strtok_r(NULL, "\n", &saveptr);
- }
- free(filebuffer);
- }
- }
- }
-
- return props;
-}
-
-
-/**
- * Header is ignored for now, cannot handle comments yet
- */
-void properties_store(properties_pt properties, const char* filename, const char* header) {
- FILE *file = fopen ( filename, "w+" );
- char *str;
-
- if (file != NULL) {
- if (hashMap_size(properties) > 0) {
- hash_map_iterator_pt iterator = hashMapIterator_create(properties);
- while (hashMapIterator_hasNext(iterator)) {
- hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
- str = hashMapEntry_getKey(entry);
- for (int i = 0; i < strlen(str); i += 1) {
- if (str[i] == '#' || str[i] == '!' || str[i] == '=' || str[i] == ':') {
- fputc('\\', file);
- }
- fputc(str[i], file);
- }
-
- fputc('=', file);
-
- str = hashMapEntry_getValue(entry);
- for (int i = 0; i < strlen(str); i += 1) {
- if (str[i] == '#' || str[i] == '!' || str[i] == '=' || str[i] == ':') {
- fputc('\\', file);
- }
- fputc(str[i], file);
- }
-
- fputc('\n', file);
-
- }
- hashMapIterator_destroy(iterator);
- }
- fclose(file);
- } else {
- perror("File is null");
- }
-}
-
-celix_status_t properties_copy(properties_pt properties, properties_pt *out) {
- celix_status_t status = CELIX_SUCCESS;
- properties_pt copy = properties_create();
-
- if (copy != NULL) {
- hash_map_iterator_pt iter = hashMapIterator_create(properties);
- while (hashMapIterator_hasNext(iter)) {
- hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
- char *key = hashMapEntry_getKey(entry);
- char *value = hashMapEntry_getValue(entry);
- properties_set(copy, key, value);
- }
- hashMapIterator_destroy(iter);
- } else {
- status = CELIX_ENOMEM;
- }
-
- if (status == CELIX_SUCCESS) {
- *out = copy;
- }
-
- return status;
-}
-
-const char* properties_get(properties_pt properties, const char* key) {
- return hashMap_get(properties, (void*)key);
-}
-
-const char* properties_getWithDefault(properties_pt properties, const char* key, const char* defaultValue) {
- const char* value = properties_get(properties, key);
- return value == NULL ? defaultValue : value;
-}
-
-void properties_set(properties_pt properties, const char* key, const char* value) {
- hash_map_entry_pt entry = hashMap_getEntry(properties, key);
- char* oldValue = NULL;
- if (entry != NULL) {
- char* oldKey = hashMapEntry_getKey(entry);
- oldValue = hashMapEntry_getValue(entry);
- hashMap_put(properties, oldKey, strndup(value, 1024*10));
- } else {
- hashMap_put(properties, strndup(key, 1024*10), strndup(value, 1024*10));
- }
- free(oldValue);
-}
-
-static void updateBuffers(char **key, char ** value, char **output, int outputPos, int *key_len, int *value_len) {
- if (*output == *key) {
- if (outputPos == (*key_len) - 1) {
- (*key_len) += MALLOC_BLOCK_SIZE;
- *key = realloc(*key, *key_len);
- *output = *key;
- }
- }
- else {
- if (outputPos == (*value_len) - 1) {
- (*value_len) += MALLOC_BLOCK_SIZE;
- *value = realloc(*value, *value_len);
- *output = *value;
- }
- }
-}
-
-static void parseLine(const char* line, properties_pt props) {
- int linePos = 0;
- bool precedingCharIsBackslash = false;
- bool isComment = false;
- int outputPos = 0;
- char *output = NULL;
- int key_len = MALLOC_BLOCK_SIZE;
- int value_len = MALLOC_BLOCK_SIZE;
- linePos = 0;
- precedingCharIsBackslash = false;
- isComment = false;
- output = NULL;
- outputPos = 0;
-
- //Ignore empty lines
- if (line[0] == '\n' && line[1] == '\0') {
- return;
- }
-
- char *key = calloc(1, key_len);
- char *value = calloc(1, value_len);
- key[0] = '\0';
- value[0] = '\0';
-
- while (line[linePos] != '\0') {
- if (line[linePos] == ' ' || line[linePos] == '\t') {
- if (output == NULL) {
- //ignore
- linePos += 1;
- continue;
- }
- else {
- output[outputPos++] = line[linePos];
- updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
- }
- }
- else {
- if (output == NULL) {
- output = key;
- }
- }
- if (line[linePos] == '=' || line[linePos] == ':' || line[linePos] == '#' || line[linePos] == '!') {
- if (precedingCharIsBackslash) {
- //escaped special character
- output[outputPos++] = line[linePos];
- updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
- precedingCharIsBackslash = false;
- }
- else {
- if (line[linePos] == '#' || line[linePos] == '!') {
- if (outputPos == 0) {
- isComment = true;
- break;
- }
- else {
- output[outputPos++] = line[linePos];
- updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
- }
- }
- else { // = or :
- if (output == value) { //already have a seperator
- output[outputPos++] = line[linePos];
- updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
- }
- else {
- output[outputPos++] = '\0';
- updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
- output = value;
- outputPos = 0;
- }
- }
- }
- }
- else if (line[linePos] == '\\') {
- if (precedingCharIsBackslash) { //double backslash -> backslash
- output[outputPos++] = '\\';
- updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
- }
- precedingCharIsBackslash = true;
- }
- else { //normal character
- precedingCharIsBackslash = false;
- output[outputPos++] = line[linePos];
- updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
- }
- linePos += 1;
- }
- if (output != NULL) {
- output[outputPos] = '\0';
- }
-
- if (!isComment) {
- //printf("putting 'key'/'value' '%s'/'%s' in properties\n", utils_stringTrim(key), utils_stringTrim(value));
- properties_set(props, utils_stringTrim(key), utils_stringTrim(value));
- }
- if(key) {
- free(key);
- }
- if(value) {
- free(value);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/framework/private/src/utils.c
----------------------------------------------------------------------
diff --git a/framework/private/src/utils.c b/framework/private/src/utils.c
deleted file mode 100644
index 9fc5335..0000000
--- a/framework/private/src/utils.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * utils.c
- *
- * \date Jul 27, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <string.h>
-
-#include "utils.h"
-
-unsigned int utils_stringHash(const void* strPtr) {
- const char* string = strPtr;
- unsigned int hash = 5381;
- unsigned int i = 0;
- unsigned int len = strlen(string);
-
- for(i=0; i < len; i++)
- { hash = (hash << 5) + (*string) + hash; }
-
- return hash;
-}
-
-int utils_stringEquals(const void* string, const void* toCompare) {
- return strcmp((const char*)string, (const char*)toCompare) == 0;
-}
-
-char * string_ndup(const char *s, size_t n) {
- size_t len = strlen(s);
- char *ret;
-
- if (len <= n) {
- return strdup(s);
- }
-
- ret = malloc(n + 1);
- strncpy(ret, s, n);
- ret[n] = '\0';
- return ret;
-}
-
-char * utils_stringTrim(char * string) {
- char* copy = string;
-
- char *end;
- // Trim leading space
- while (isspace(*copy)) {
- copy++;
- }
-
- // Trim trailing space
- end = copy + strlen(copy) - 1;
- while(end > copy && isspace(*end)) {
- *(end) = '\0';
- end--;
- }
-
- if (copy != string) {
- //beginning whitespaces -> move char in copy to to begin string
- //This to ensure free still works on the same pointer.
- char* nstring = string;
- while(*copy != '\0') {
- *(nstring++) = *(copy++);
- }
- (*nstring) = '\0';
- }
-
- return string;
-}
-
-bool utils_isStringEmptyOrNull(const char * const str) {
- bool empty = true;
- if (str != NULL) {
- int i;
- for (i = 0; i < strnlen(str, 1024 * 1024); i += 1) {
- if (!isspace(str[i])) {
- empty = false;
- break;
- }
- }
- }
-
- return empty;
-}
-
-celix_status_t thread_equalsSelf(celix_thread_t thread, bool *equals) {
- celix_status_t status = CELIX_SUCCESS;
-
- celix_thread_t self = celixThread_self();
- if (status == CELIX_SUCCESS) {
- *equals = celixThread_equals(self, thread);
- }
-
- return status;
-}
-
-celix_status_t utils_isNumeric(const char *number, bool *ret) {
- celix_status_t status = CELIX_SUCCESS;
- *ret = true;
- while(*number) {
- if(!isdigit(*number) && *number != '.') {
- *ret = false;
- break;
- }
- number++;
- }
- return status;
-}
-
-
-FRAMEWORK_EXPORT int utils_compareServiceIdsAndRanking(unsigned long servId, long servRank, unsigned long otherServId, long otherServRank) {
- int result;
-
- if (servId == otherServId) {
- result = 0;
- } else if (servRank != otherServRank) {
- result = servRank < otherServRank ? -1 : 1;
- } else { //equal service rank, compare service ids
- result = servId < otherServId ? 1 : -1;
- }
-
- return result;
-}
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/framework/private/test/properties_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/properties_test.cpp b/framework/private/test/properties_test.cpp
deleted file mode 100644
index 3124fe7..0000000
--- a/framework/private/test/properties_test.cpp
+++ /dev/null
@@ -1,124 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * properties_test.cpp
- *
- * \date Feb 11, 2013
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "CppUTest/TestHarness.h"
-#include "CppUTest/TestHarness_c.h"
-#include "CppUTest/CommandLineTestRunner.h"
-#include "CppUTestExt/MockSupport.h"
-
-extern "C" {
-#include "properties.h"
-}
-
-int main(int argc, char** argv) {
- return RUN_ALL_TESTS(argc, argv);
-}
-
-TEST_GROUP(properties) {
- properties_pt properties;
-
- void setup(void) {
- }
-
- void teardown() {
- mock().checkExpectations();
- mock().clear();
- }
-};
-
-TEST(properties, create) {
- properties = properties_create();
- CHECK(properties);
-
- properties_destroy(properties);
-}
-
-TEST(properties, load) {
- char propertiesFile[] = "resources-test/properties.txt";
- properties = properties_load(propertiesFile);
- LONGS_EQUAL(3, hashMap_size(properties));
-
- const char keyA[] = "a";
- const char *valueA = properties_get(properties, keyA);
- STRCMP_EQUAL("b", valueA);
- const char keyB[] = "b";
- STRCMP_EQUAL("c", properties_get(properties, keyB));
-
- properties_destroy(properties);
-}
-
-TEST(properties, store) {
- char propertiesFile[] = "resources-test/properties_out.txt";
- properties = properties_create();
- char keyA[] = "x";
- char keyB[] = "y";
- char valueA[] = "1";
- char valueB[] = "2";
- properties_set(properties, keyA, valueA);
- properties_set(properties, keyB, valueB);
- properties_store(properties, propertiesFile, NULL);
-
- properties_destroy(properties);
-}
-
-TEST(properties, copy) {
- properties_pt copy;
- char propertiesFile[] = "resources-test/properties.txt";
- properties = properties_load(propertiesFile);
- LONGS_EQUAL(3, hashMap_size(properties));
-
- properties_copy(properties, ©);
-
- char keyA[] = "a";
- const char *valueA = properties_get(copy, keyA);
- STRCMP_EQUAL("b", valueA);
- const char keyB[] = "b";
- STRCMP_EQUAL("c", properties_get(copy, keyB));
-
- properties_destroy(properties);
- properties_destroy(copy);
-}
-
-TEST(properties, getSet) {
- properties = properties_create();
- char keyA[] = "x";
- char keyB[] = "y";
- char keyC[] = "z";
- char valueA[] = "1";
- char valueB[] = "2";
- char valueC[] = "3";
- properties_set(properties, keyA, valueA);
- properties_set(properties, keyB, valueB);
-
- STRCMP_EQUAL(valueA, properties_get(properties, keyA));
- STRCMP_EQUAL(valueB, properties_get(properties, keyB));
- STRCMP_EQUAL(valueC, properties_getWithDefault(properties, keyC, valueC));
-
- properties_destroy(properties);
-}
-
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/framework/private/test/utils_test.cpp
----------------------------------------------------------------------
diff --git a/framework/private/test/utils_test.cpp b/framework/private/test/utils_test.cpp
deleted file mode 100644
index 22b04b7..0000000
--- a/framework/private/test/utils_test.cpp
+++ /dev/null
@@ -1,300 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * utils_test.cpp
- *
- * \date Feb 6, 2013
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-#include "string.h"
-#include <stdlib.h>
-#include <string.h>
-
-#include "CppUTest/TestHarness.h"
-#include "CppUTest/TestHarness_c.h"
-#include "CppUTest/CommandLineTestRunner.h"
-
-extern "C"
-{
-#include "utils.h"
-}
-
-int main(int argc, char** argv) {
- return RUN_ALL_TESTS(argc, argv);
-}
-
-TEST_GROUP(utils) {
-
- void setup(void) {
- }
-
- void teardown() {
- }
-};
-
-static char* my_strdup(const char* s){
- if(s==NULL){
- return NULL;
- }
-
- size_t len = strlen(s);
-
- char *d = (char*) calloc (len + 1,sizeof(char));
-
- if (d == NULL){
- return NULL;
- }
-
- strncpy (d,s,len);
- return d;
-}
-
-TEST(utils, stringHash) {
- char * toHash = my_strdup("abc");
- unsigned int hash;
- hash = utils_stringHash((void *) toHash);
- LONGS_EQUAL(193485928, hash);
-
- free(toHash);
- toHash = my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
- hash = utils_stringHash((void *) toHash);
- LONGS_EQUAL(3704717399, hash);
-
- free(toHash);
- toHash = my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
- hash = utils_stringHash((void *) toHash);
- LONGS_EQUAL(3862509969, hash);
- free(toHash);
-}
-
-TEST(utils, stringEquals) {
- // Compare with equal strings
- char * org = my_strdup("abc");
- char * cmp = my_strdup("abc");
-
- int result = utils_stringEquals((void *) org, (void *) cmp);
- CHECK(result);
-
- // Compare with no equal strings
- free(cmp);
- cmp = my_strdup("abcd");
-
- result = utils_stringEquals((void *) org, (void *) cmp);
- CHECK_FALSE(result);
-
- // Compare with numeric strings
- free(org);
- free(cmp);
- org = my_strdup("123");
- cmp = my_strdup("123");
-
- result = utils_stringEquals((void *) org, (void *) cmp);
- CHECK(result);
-
- // Compare with long strings
- free(org);
- free(cmp);
- org = my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
- cmp = my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
- "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
-
- result = utils_stringEquals((void *) org, (void *) cmp);
- CHECK(result);
-
- free(org);
- free(cmp);
-}
-
-TEST(utils, string_ndup){
- // Compare with equal strings
- const char * org = "abc";
- char * cmp = NULL;
-
- cmp = string_ndup(org, 3);
- STRCMP_EQUAL(org, cmp);
- free(cmp);
-
- org = "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz";
- cmp = string_ndup(org, 50);
- STRCMP_EQUAL(org, cmp);
- free(cmp);
-
- cmp = string_ndup(org, 25);
- LONGS_EQUAL(25, strlen(cmp));
- free(cmp);
-}
-
-TEST(utils, stringTrim) {
- // Multiple whitespaces, before, after and in between
- char * toTrim = my_strdup(" a b c ");
- char * result = utils_stringTrim(toTrim);
-
- STRCMP_EQUAL("a b c", result);
-
- // No whitespaces
- free(toTrim);
- toTrim = my_strdup("abc");
- result = utils_stringTrim(toTrim);
-
- STRCMP_EQUAL("abc", result);
-
- // Only whitespace before
- free(toTrim);
- toTrim = my_strdup(" abc");
- result = utils_stringTrim(toTrim);
-
- STRCMP_EQUAL("abc", result);
-
- // Only whitespace after
- free(toTrim);
- toTrim = my_strdup("abc ");
- result = utils_stringTrim(toTrim);
-
- STRCMP_EQUAL("abc", result);
-
- // Whitespace other then space (tab, cr..).
- free(toTrim);
- toTrim = my_strdup("\tabc \n asdf \n");
- result = utils_stringTrim(toTrim);
-
- STRCMP_EQUAL("abc \n asdf", result);
-
- free(toTrim);
-}
-
-TEST(utils, thread_equalsSelf){
- celix_thread thread = celixThread_self();
- bool get;
-
- LONGS_EQUAL(CELIX_SUCCESS, thread_equalsSelf(thread, &get));
- CHECK(get);
-
- thread.thread = (pthread_t) 0x42;
- LONGS_EQUAL(CELIX_SUCCESS, thread_equalsSelf(thread, &get));
- CHECK_FALSE(get);
-}
-
-TEST(utils, isNumeric) {
- // Check numeric string
- char * toCheck = my_strdup("42");
-
- bool result;
- celix_status_t status = utils_isNumeric(toCheck, &result);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- CHECK_C(result);
-
- // Check non numeric string
- free(toCheck);
- toCheck = my_strdup("42b");
- status = utils_isNumeric(toCheck, &result);
- LONGS_EQUAL(CELIX_SUCCESS, status);
- CHECK_C(!result);
-
- free(toCheck);
-}
-
-TEST(utils, compareServiceIdsAndRanking){
- int ret;
- //service 1 is higher ranked and has a irrelevant ID
- ret = utils_compareServiceIdsAndRanking(2,2,1,1);
- LONGS_EQUAL(1, ret);
-
- //service 1 is equally ranked and has a lower ID
- ret = utils_compareServiceIdsAndRanking(1,1,2,1);
- LONGS_EQUAL(1, ret);
-
- //service 1 is equally ranked and has a higher ID
- ret = utils_compareServiceIdsAndRanking(2,1,1,1);
- LONGS_EQUAL(-1, ret);
-
- //service 1 is lower ranked and has a irrelevant ID
- ret = utils_compareServiceIdsAndRanking(1,1,2,2);
- LONGS_EQUAL(-1, ret);
-
- //service 1 is equal in ID and irrelevantly ranked
- ret = utils_compareServiceIdsAndRanking(1,1,1,1);
- LONGS_EQUAL(0, ret);
-
-
-}
-
-
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/framework/public/include/celix_errno.h
----------------------------------------------------------------------
diff --git a/framework/public/include/celix_errno.h b/framework/public/include/celix_errno.h
deleted file mode 100644
index 54a7689..0000000
--- a/framework/public/include/celix_errno.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * celix_errno.h
- *
- * \date Feb 15, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-/*!
- \file
- \brief Error codes
- \defgroup framework Celix Framework
- */
-#ifndef CELIX_ERRNO_H_
-#define CELIX_ERRNO_H_
-
-#include <stddef.h>
-#include <errno.h>
-
-#include "framework_exports.h"
-
-/*!
- * Helper macro which check the current status and executes the provided expression if the
- * status is still CELIX_SUCCESS (0)
- */
-#define CELIX_DO_IF(status, expr) ((status) == CELIX_SUCCESS) ? (expr) : (status)
-
-/*!
- * \defgroup celix_errno Error Codes
- * \ingroup framework
- * \{
- */
-
-struct celix_status {
- int code;
- char *error;
-};
-
-/*!
- * Status type returned by all functions in Celix
- */
-typedef int celix_status_t;
-
-/*!
- * Return a readable string for the given error code.
- *
- */
-FRAMEWORK_EXPORT char *celix_strerror(celix_status_t errorcode, char *buffer, size_t bufferSize);
-
-/*!
- * Error code indicating successful execution of the function.
- */
-#define CELIX_SUCCESS 0
-
-/*!
- * Starting point for Celix errors.
- */
-#define CELIX_START_ERROR 70000
-
-/*!
- * The range for Celix errors.
- */
-#define CELIX_ERRSPACE_SIZE 1000
-
-/*!
- * The start error number user application can use.
- */
-#define CELIX_START_USERERR (CELIX_START_ERROR + CELIX_ERRSPACE_SIZE)
-
-/*!
- * Exception indicating a problem with a bundle
- */
-#define CELIX_BUNDLE_EXCEPTION (CELIX_START_ERROR + 1)
-/*!
- * Invalid bundle context is used
- */
-#define CELIX_INVALID_BUNDLE_CONTEXT (CELIX_START_ERROR + 2)
-/*!
- * Argument is not correct
- */
-#define CELIX_ILLEGAL_ARGUMENT (CELIX_START_ERROR + 3)
-#define CELIX_INVALID_SYNTAX (CELIX_START_ERROR + 4)
-#define CELIX_FRAMEWORK_SHUTDOWN (CELIX_START_ERROR + 5)
-#define CELIX_ILLEGAL_STATE (CELIX_START_ERROR + 6)
-#define CELIX_FRAMEWORK_EXCEPTION (CELIX_START_ERROR + 7)
-#define CELIX_FILE_IO_EXCEPTION (CELIX_START_ERROR + 8)
-#define CELIX_SERVICE_EXCEPTION (CELIX_START_ERROR + 9)
-
-#define CELIX_ENOMEM ENOMEM
-
-/**
- * \}
- */
-
-#endif /* CELIX_ERRNO_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/framework/public/include/celixbool.h
----------------------------------------------------------------------
diff --git a/framework/public/include/celixbool.h b/framework/public/include/celixbool.h
deleted file mode 100644
index 526392b..0000000
--- a/framework/public/include/celixbool.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * celixbool.h
- *
- * \date Jun 16, 2011
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef CELIXBOOL_H_
-#define CELIXBOOL_H_
-
-
-#if defined(__STDC__)
-# define C89
-# if defined(__STDC_VERSION__)
-# define C90
-# if (__STDC_VERSION__ >= 199409L)
-# define C94
-# endif
-# if (__STDC_VERSION__ >= 199901L)
-# define C99
-# endif
-# endif
-#endif
-
-
-#if __STDC_VERSION__ < 199901L && __GNUC__ < 3
-// #ifndef C99
-
-typedef int _Bool;
-
-#define bool _Bool
-#define false 0
-#define true 1
-
-
-#else
-
-#include <stdbool.h>
-
-#endif
-
-#endif /* CELIXBOOL_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/framework/public/include/properties.h
----------------------------------------------------------------------
diff --git a/framework/public/include/properties.h b/framework/public/include/properties.h
deleted file mode 100644
index 9a12a2a..0000000
--- a/framework/public/include/properties.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * properties.h
- *
- * \date Apr 27, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef PROPERTIES_H_
-#define PROPERTIES_H_
-
-#include <stdio.h>
-
-#include "hash_map.h"
-#include "framework_exports.h"
-#include "celix_errno.h"
-
-typedef hash_map_pt properties_pt;
-
-FRAMEWORK_EXPORT properties_pt properties_create(void);
-FRAMEWORK_EXPORT void properties_destroy(properties_pt properties);
-FRAMEWORK_EXPORT properties_pt properties_load(const char* filename);
-FRAMEWORK_EXPORT properties_pt properties_loadWithStream(FILE *stream);
-FRAMEWORK_EXPORT void properties_store(properties_pt properties, const char* file, const char* header);
-
-FRAMEWORK_EXPORT const char* properties_get(properties_pt properties, const char* key);
-FRAMEWORK_EXPORT const char* properties_getWithDefault(properties_pt properties, const char* key, const char* defaultValue);
-FRAMEWORK_EXPORT void properties_set(properties_pt properties, const char* key, const char* value);
-
-FRAMEWORK_EXPORT celix_status_t properties_copy(properties_pt properties, properties_pt *copy);
-
-#define PROPERTIES_FOR_EACH(props, key) \
- for(hash_map_iterator_t iter = hashMapIterator_construct(props); \
- hashMapIterator_hasNext(&iter), (key) = (const char*)hashMapIterator_nextKey(&iter);)
-
-#endif /* PROPERTIES_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/framework/public/include/utils.h
----------------------------------------------------------------------
diff --git a/framework/public/include/utils.h b/framework/public/include/utils.h
deleted file mode 100644
index 108bbdd..0000000
--- a/framework/public/include/utils.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- *Licensed to the Apache Software Foundation (ASF) under one
- *or more contributor license agreements. See the NOTICE file
- *distributed with this work for additional information
- *regarding copyright ownership. The ASF licenses this file
- *to you under the Apache License, Version 2.0 (the
- *"License"); you may not use this file except in compliance
- *with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- *Unless required by applicable law or agreed to in writing,
- *software distributed under the License is distributed on an
- *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- *specific language governing permissions and limitations
- *under the License.
- */
-/*
- * utils.h
- *
- * \date Jul 27, 2010
- * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
- * \copyright Apache License, Version 2.0
- */
-
-#ifndef UTILS_H_
-#define UTILS_H_
-
-#include <ctype.h>
-
-#include "celix_errno.h"
-#include "celixbool.h"
-#include "framework_exports.h"
-#include "celix_threads.h"
-
-FRAMEWORK_EXPORT unsigned int utils_stringHash(const void* string);
-FRAMEWORK_EXPORT int utils_stringEquals(const void* string, const void* toCompare);
-FRAMEWORK_EXPORT char * string_ndup(const char *s, size_t n);
-FRAMEWORK_EXPORT char * utils_stringTrim(char * string);
-FRAMEWORK_EXPORT bool utils_isStringEmptyOrNull(const char * const str);
-
-FRAMEWORK_EXPORT int utils_compareServiceIdsAndRanking(unsigned long servId, long servRank, unsigned long otherServId, long otherServRank);
-
-FRAMEWORK_EXPORT celix_status_t thread_equalsSelf(celix_thread_t thread, bool *equals);
-
-FRAMEWORK_EXPORT celix_status_t utils_isNumeric(const char *number, bool *ret);
-
-#endif /* UTILS_H_ */
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/utils/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
index 3c20b90..9132f45 100644
--- a/utils/CMakeLists.txt
+++ b/utils/CMakeLists.txt
@@ -19,41 +19,24 @@ celix_subproject(UTILS "Option to build the utilities library" ON)
if (UTILS)
cmake_minimum_required(VERSION 2.6)
+if (ANDROID)
add_definitions(-DUSE_FILE32API)
- #aux_source_directory("private/src" SRC)
+endif ()
+
include_directories("private/include")
include_directories("public/include")
add_library(celix_utils SHARED
private/src/array_list.c
- public/include/array_list.h
- private/include/array_list_private.h
-
private/src/hash_map.c
- public/include/hash_map.h
- private/include/hash_map_private.h
-
private/src/linked_list.c
private/src/linked_list_iterator.c
- public/include/linked_list.h
- public/include/linked_list_iterator.h
- private/include/linked_list_private.h
-
- public/include/exports.h
-
private/src/celix_threads.c
- public/include/celix_threads.h
-
private/src/version.c
- private/include/version_private.h
- public/include/version.h
-
private/src/version_range.c
- private/include/version_range_private.h
- public/include/version_range.h
-
private/src/thpool.c
- public/include/thpool.h
- )
+ private/src/properties.c
+ private/src/utils.c
+ )
set_target_properties(celix_utils PROPERTIES "SOVERSION" 2)
@@ -79,8 +62,8 @@ if (UTILS)
include_directories(${CUNIT_INCLUDE_DIRS})
include_directories(${CPPUTEST_INCLUDE_DIR})
- include_directories("${PROJECT_SOURCE_DIR}/utils/public/include")
- include_directories("${PROJECT_SOURCE_DIR}/utils/private/include")
+ include_directories(public/include)
+ include_directories(utils/private/include)
add_executable(hash_map_test private/test/hash_map_test.cpp)
target_link_libraries(hash_map_test celix_utils ${CPPUTEST_LIBRARY} pthread)
@@ -96,17 +79,29 @@ if (UTILS)
add_executable(thread_pool_test private/test/thread_pool_test.cpp)
target_link_libraries(thread_pool_test celix_utils ${CPPUTEST_LIBRARY} pthread)
+ add_executable(properties_test private/test/properties_test.cpp)
+ target_link_libraries(properties_test ${CPPUTEST_LIBRARY} ${CPPUTEST_EXT_LIBRARY} celix_utils pthread)
+
+ add_executable(utils_test private/test/utils_test.cpp)
+ target_link_libraries(utils_test ${CPPUTEST_LIBRARY} celix_utils pthread)
+
+ configure_file(private/resources-test/properties.txt ${CMAKE_BINARY_DIR}/utils/resources-test/properties.txt COPYONLY)
+
add_test(NAME run_array_list_test COMMAND array_list_test)
add_test(NAME run_hash_map_test COMMAND hash_map_test)
add_test(NAME run_celix_threads_test COMMAND celix_threads_test)
add_test(NAME run_thread_pool_test COMMAND thread_pool_test)
add_test(NAME run_linked_list_test COMMAND linked_list_test)
+ add_test(NAME run_properties_test COMMAND properties_test)
+ add_test(NAME run_utils_test COMMAND utils_test)
SETUP_TARGET_FOR_COVERAGE(array_list_test array_list_test ${CMAKE_BINARY_DIR}/coverage/array_list_test/array_list_test)
SETUP_TARGET_FOR_COVERAGE(hash_map hash_map_test ${CMAKE_BINARY_DIR}/coverage/hash_map_test/hash_map_test)
SETUP_TARGET_FOR_COVERAGE(celix_threads_test celix_threads_test ${CMAKE_BINARY_DIR}/coverage/celix_threads_test/celix_threads_test)
SETUP_TARGET_FOR_COVERAGE(thread_pool_test thread_pool_test ${CMAKE_BINARY_DIR}/coverage/thread_pool_test/thread_pool_test)
SETUP_TARGET_FOR_COVERAGE(linked_list_test linked_list_test ${CMAKE_BINARY_DIR}/coverage/linked_list_test/linked_list_test)
+ SETUP_TARGET_FOR_COVERAGE(properties_test properties_test ${CMAKE_BINARY_DIR}/coverage/properties_test/properties_test)
+ SETUP_TARGET_FOR_COVERAGE(utils_test utils_test ${CMAKE_BINARY_DIR}/coverage/utils_test/utils_test)
endif(ENABLE_TESTING AND UTILS-TESTS)
endif (UTILS)
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/utils/private/resources-test/properties.txt
----------------------------------------------------------------------
diff --git a/utils/private/resources-test/properties.txt b/utils/private/resources-test/properties.txt
new file mode 100644
index 0000000..30f3c79
--- /dev/null
+++ b/utils/private/resources-test/properties.txt
@@ -0,0 +1,20 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+a=b
+b=c
+ // == \\ # 5 \0 \=
+ #line to check possible special characters
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/utils/private/src/properties.c
----------------------------------------------------------------------
diff --git a/utils/private/src/properties.c b/utils/private/src/properties.c
new file mode 100644
index 0000000..c162711
--- /dev/null
+++ b/utils/private/src/properties.c
@@ -0,0 +1,306 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * properties.c
+ *
+ * \date Apr 27, 2010
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include "celixbool.h"
+#include "properties.h"
+#include "utils.h"
+
+#define MALLOC_BLOCK_SIZE 5
+
+static void parseLine(const char* line, properties_pt props);
+
+properties_pt properties_create(void) {
+ return hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
+}
+
+void properties_destroy(properties_pt properties) {
+ hash_map_iterator_pt iter = hashMapIterator_create(properties);
+ while (hashMapIterator_hasNext(iter)) {
+ hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+ free(hashMapEntry_getKey(entry));
+ free(hashMapEntry_getValue(entry));
+ }
+ hashMapIterator_destroy(iter);
+ hashMap_destroy(properties, false, false);
+}
+
+properties_pt properties_load(const char* filename) {
+ FILE *file = fopen(filename, "r");
+ if(file==NULL){
+ return NULL;
+ }
+ properties_pt props = properties_loadWithStream(file);
+ fclose(file);
+ return props;
+}
+
+properties_pt properties_loadWithStream(FILE *file) {
+ properties_pt props = NULL;
+
+
+ if (file != NULL ) {
+ char *saveptr;
+ char *filebuffer = NULL;
+ char *line = NULL;
+ size_t file_size = 0;
+
+ props = properties_create();
+ fseek(file, 0, SEEK_END);
+ file_size = ftell(file);
+ fseek(file, 0, SEEK_SET);
+
+ if(file_size > 0){
+ filebuffer = calloc(file_size + 1, sizeof(char));
+ if(filebuffer) {
+ size_t rs = fread(filebuffer, sizeof(char), file_size, file);
+ if(rs != file_size){
+ fprintf(stderr,"fread read only %lu bytes out of %lu\n",rs,file_size);
+ }
+ filebuffer[file_size]='\0';
+ line = strtok_r(filebuffer, "\n", &saveptr);
+ while ( line != NULL ) {
+ parseLine(line, props);
+ line = strtok_r(NULL, "\n", &saveptr);
+ }
+ free(filebuffer);
+ }
+ }
+ }
+
+ return props;
+}
+
+
+/**
+ * Header is ignored for now, cannot handle comments yet
+ */
+void properties_store(properties_pt properties, const char* filename, const char* header) {
+ FILE *file = fopen ( filename, "w+" );
+ char *str;
+
+ if (file != NULL) {
+ if (hashMap_size(properties) > 0) {
+ hash_map_iterator_pt iterator = hashMapIterator_create(properties);
+ while (hashMapIterator_hasNext(iterator)) {
+ hash_map_entry_pt entry = hashMapIterator_nextEntry(iterator);
+ str = hashMapEntry_getKey(entry);
+ for (int i = 0; i < strlen(str); i += 1) {
+ if (str[i] == '#' || str[i] == '!' || str[i] == '=' || str[i] == ':') {
+ fputc('\\', file);
+ }
+ fputc(str[i], file);
+ }
+
+ fputc('=', file);
+
+ str = hashMapEntry_getValue(entry);
+ for (int i = 0; i < strlen(str); i += 1) {
+ if (str[i] == '#' || str[i] == '!' || str[i] == '=' || str[i] == ':') {
+ fputc('\\', file);
+ }
+ fputc(str[i], file);
+ }
+
+ fputc('\n', file);
+
+ }
+ hashMapIterator_destroy(iterator);
+ }
+ fclose(file);
+ } else {
+ perror("File is null");
+ }
+}
+
+celix_status_t properties_copy(properties_pt properties, properties_pt *out) {
+ celix_status_t status = CELIX_SUCCESS;
+ properties_pt copy = properties_create();
+
+ if (copy != NULL) {
+ hash_map_iterator_pt iter = hashMapIterator_create(properties);
+ while (hashMapIterator_hasNext(iter)) {
+ hash_map_entry_pt entry = hashMapIterator_nextEntry(iter);
+ char *key = hashMapEntry_getKey(entry);
+ char *value = hashMapEntry_getValue(entry);
+ properties_set(copy, key, value);
+ }
+ hashMapIterator_destroy(iter);
+ } else {
+ status = CELIX_ENOMEM;
+ }
+
+ if (status == CELIX_SUCCESS) {
+ *out = copy;
+ }
+
+ return status;
+}
+
+const char* properties_get(properties_pt properties, const char* key) {
+ return hashMap_get(properties, (void*)key);
+}
+
+const char* properties_getWithDefault(properties_pt properties, const char* key, const char* defaultValue) {
+ const char* value = properties_get(properties, key);
+ return value == NULL ? defaultValue : value;
+}
+
+void properties_set(properties_pt properties, const char* key, const char* value) {
+ hash_map_entry_pt entry = hashMap_getEntry(properties, key);
+ char* oldValue = NULL;
+ if (entry != NULL) {
+ char* oldKey = hashMapEntry_getKey(entry);
+ oldValue = hashMapEntry_getValue(entry);
+ hashMap_put(properties, oldKey, strndup(value, 1024*10));
+ } else {
+ hashMap_put(properties, strndup(key, 1024*10), strndup(value, 1024*10));
+ }
+ free(oldValue);
+}
+
+static void updateBuffers(char **key, char ** value, char **output, int outputPos, int *key_len, int *value_len) {
+ if (*output == *key) {
+ if (outputPos == (*key_len) - 1) {
+ (*key_len) += MALLOC_BLOCK_SIZE;
+ *key = realloc(*key, *key_len);
+ *output = *key;
+ }
+ }
+ else {
+ if (outputPos == (*value_len) - 1) {
+ (*value_len) += MALLOC_BLOCK_SIZE;
+ *value = realloc(*value, *value_len);
+ *output = *value;
+ }
+ }
+}
+
+static void parseLine(const char* line, properties_pt props) {
+ int linePos = 0;
+ bool precedingCharIsBackslash = false;
+ bool isComment = false;
+ int outputPos = 0;
+ char *output = NULL;
+ int key_len = MALLOC_BLOCK_SIZE;
+ int value_len = MALLOC_BLOCK_SIZE;
+ linePos = 0;
+ precedingCharIsBackslash = false;
+ isComment = false;
+ output = NULL;
+ outputPos = 0;
+
+ //Ignore empty lines
+ if (line[0] == '\n' && line[1] == '\0') {
+ return;
+ }
+
+ char *key = calloc(1, key_len);
+ char *value = calloc(1, value_len);
+ key[0] = '\0';
+ value[0] = '\0';
+
+ while (line[linePos] != '\0') {
+ if (line[linePos] == ' ' || line[linePos] == '\t') {
+ if (output == NULL) {
+ //ignore
+ linePos += 1;
+ continue;
+ }
+ else {
+ output[outputPos++] = line[linePos];
+ updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+ }
+ }
+ else {
+ if (output == NULL) {
+ output = key;
+ }
+ }
+ if (line[linePos] == '=' || line[linePos] == ':' || line[linePos] == '#' || line[linePos] == '!') {
+ if (precedingCharIsBackslash) {
+ //escaped special character
+ output[outputPos++] = line[linePos];
+ updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+ precedingCharIsBackslash = false;
+ }
+ else {
+ if (line[linePos] == '#' || line[linePos] == '!') {
+ if (outputPos == 0) {
+ isComment = true;
+ break;
+ }
+ else {
+ output[outputPos++] = line[linePos];
+ updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+ }
+ }
+ else { // = or :
+ if (output == value) { //already have a seperator
+ output[outputPos++] = line[linePos];
+ updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+ }
+ else {
+ output[outputPos++] = '\0';
+ updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+ output = value;
+ outputPos = 0;
+ }
+ }
+ }
+ }
+ else if (line[linePos] == '\\') {
+ if (precedingCharIsBackslash) { //double backslash -> backslash
+ output[outputPos++] = '\\';
+ updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+ }
+ precedingCharIsBackslash = true;
+ }
+ else { //normal character
+ precedingCharIsBackslash = false;
+ output[outputPos++] = line[linePos];
+ updateBuffers(&key, &value, &output, outputPos, &key_len, &value_len);
+ }
+ linePos += 1;
+ }
+ if (output != NULL) {
+ output[outputPos] = '\0';
+ }
+
+ if (!isComment) {
+ //printf("putting 'key'/'value' '%s'/'%s' in properties\n", utils_stringTrim(key), utils_stringTrim(value));
+ properties_set(props, utils_stringTrim(key), utils_stringTrim(value));
+ }
+ if(key) {
+ free(key);
+ }
+ if(value) {
+ free(value);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/utils/private/src/utils.c
----------------------------------------------------------------------
diff --git a/utils/private/src/utils.c b/utils/private/src/utils.c
new file mode 100644
index 0000000..a9ffd2c
--- /dev/null
+++ b/utils/private/src/utils.c
@@ -0,0 +1,142 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * utils.c
+ *
+ * \date Jul 27, 2010
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <string.h>
+
+#include "utils.h"
+
+unsigned int utils_stringHash(const void* strPtr) {
+ const char* string = strPtr;
+ unsigned int hash = 5381;
+ unsigned int i = 0;
+ unsigned int len = strlen(string);
+
+ for(i=0; i < len; i++)
+ { hash = (hash << 5) + (*string) + hash; }
+
+ return hash;
+}
+
+int utils_stringEquals(const void* string, const void* toCompare) {
+ return strcmp((const char*)string, (const char*)toCompare) == 0;
+}
+
+char * string_ndup(const char *s, size_t n) {
+ size_t len = strlen(s);
+ char *ret;
+
+ if (len <= n) {
+ return strdup(s);
+ }
+
+ ret = malloc(n + 1);
+ strncpy(ret, s, n);
+ ret[n] = '\0';
+ return ret;
+}
+
+char * utils_stringTrim(char * string) {
+ char* copy = string;
+
+ char *end;
+ // Trim leading space
+ while (isspace(*copy)) {
+ copy++;
+ }
+
+ // Trim trailing space
+ end = copy + strlen(copy) - 1;
+ while(end > copy && isspace(*end)) {
+ *(end) = '\0';
+ end--;
+ }
+
+ if (copy != string) {
+ //beginning whitespaces -> move char in copy to to begin string
+ //This to ensure free still works on the same pointer.
+ char* nstring = string;
+ while(*copy != '\0') {
+ *(nstring++) = *(copy++);
+ }
+ (*nstring) = '\0';
+ }
+
+ return string;
+}
+
+bool utils_isStringEmptyOrNull(const char * const str) {
+ bool empty = true;
+ if (str != NULL) {
+ int i;
+ for (i = 0; i < strnlen(str, 1024 * 1024); i += 1) {
+ if (!isspace(str[i])) {
+ empty = false;
+ break;
+ }
+ }
+ }
+
+ return empty;
+}
+
+celix_status_t thread_equalsSelf(celix_thread_t thread, bool *equals) {
+ celix_status_t status = CELIX_SUCCESS;
+
+ celix_thread_t self = celixThread_self();
+ if (status == CELIX_SUCCESS) {
+ *equals = celixThread_equals(self, thread);
+ }
+
+ return status;
+}
+
+celix_status_t utils_isNumeric(const char *number, bool *ret) {
+ celix_status_t status = CELIX_SUCCESS;
+ *ret = true;
+ while(*number) {
+ if(!isdigit(*number) && *number != '.') {
+ *ret = false;
+ break;
+ }
+ number++;
+ }
+ return status;
+}
+
+
+int utils_compareServiceIdsAndRanking(unsigned long servId, long servRank, unsigned long otherServId, long otherServRank) {
+ int result;
+
+ if (servId == otherServId) {
+ result = 0;
+ } else if (servRank != otherServRank) {
+ result = servRank < otherServRank ? -1 : 1;
+ } else { //equal service rank, compare service ids
+ result = servId < otherServId ? 1 : -1;
+ }
+
+ return result;
+}
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/utils/private/test/properties_test.cpp
----------------------------------------------------------------------
diff --git a/utils/private/test/properties_test.cpp b/utils/private/test/properties_test.cpp
new file mode 100644
index 0000000..3124fe7
--- /dev/null
+++ b/utils/private/test/properties_test.cpp
@@ -0,0 +1,124 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * properties_test.cpp
+ *
+ * \date Feb 11, 2013
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "CppUTest/TestHarness.h"
+#include "CppUTest/TestHarness_c.h"
+#include "CppUTest/CommandLineTestRunner.h"
+#include "CppUTestExt/MockSupport.h"
+
+extern "C" {
+#include "properties.h"
+}
+
+int main(int argc, char** argv) {
+ return RUN_ALL_TESTS(argc, argv);
+}
+
+TEST_GROUP(properties) {
+ properties_pt properties;
+
+ void setup(void) {
+ }
+
+ void teardown() {
+ mock().checkExpectations();
+ mock().clear();
+ }
+};
+
+TEST(properties, create) {
+ properties = properties_create();
+ CHECK(properties);
+
+ properties_destroy(properties);
+}
+
+TEST(properties, load) {
+ char propertiesFile[] = "resources-test/properties.txt";
+ properties = properties_load(propertiesFile);
+ LONGS_EQUAL(3, hashMap_size(properties));
+
+ const char keyA[] = "a";
+ const char *valueA = properties_get(properties, keyA);
+ STRCMP_EQUAL("b", valueA);
+ const char keyB[] = "b";
+ STRCMP_EQUAL("c", properties_get(properties, keyB));
+
+ properties_destroy(properties);
+}
+
+TEST(properties, store) {
+ char propertiesFile[] = "resources-test/properties_out.txt";
+ properties = properties_create();
+ char keyA[] = "x";
+ char keyB[] = "y";
+ char valueA[] = "1";
+ char valueB[] = "2";
+ properties_set(properties, keyA, valueA);
+ properties_set(properties, keyB, valueB);
+ properties_store(properties, propertiesFile, NULL);
+
+ properties_destroy(properties);
+}
+
+TEST(properties, copy) {
+ properties_pt copy;
+ char propertiesFile[] = "resources-test/properties.txt";
+ properties = properties_load(propertiesFile);
+ LONGS_EQUAL(3, hashMap_size(properties));
+
+ properties_copy(properties, ©);
+
+ char keyA[] = "a";
+ const char *valueA = properties_get(copy, keyA);
+ STRCMP_EQUAL("b", valueA);
+ const char keyB[] = "b";
+ STRCMP_EQUAL("c", properties_get(copy, keyB));
+
+ properties_destroy(properties);
+ properties_destroy(copy);
+}
+
+TEST(properties, getSet) {
+ properties = properties_create();
+ char keyA[] = "x";
+ char keyB[] = "y";
+ char keyC[] = "z";
+ char valueA[] = "1";
+ char valueB[] = "2";
+ char valueC[] = "3";
+ properties_set(properties, keyA, valueA);
+ properties_set(properties, keyB, valueB);
+
+ STRCMP_EQUAL(valueA, properties_get(properties, keyA));
+ STRCMP_EQUAL(valueB, properties_get(properties, keyB));
+ STRCMP_EQUAL(valueC, properties_getWithDefault(properties, keyC, valueC));
+
+ properties_destroy(properties);
+}
+
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/utils/private/test/utils_test.cpp
----------------------------------------------------------------------
diff --git a/utils/private/test/utils_test.cpp b/utils/private/test/utils_test.cpp
new file mode 100644
index 0000000..22b04b7
--- /dev/null
+++ b/utils/private/test/utils_test.cpp
@@ -0,0 +1,300 @@
+/**
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * utils_test.cpp
+ *
+ * \date Feb 6, 2013
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+#include "string.h"
+#include <stdlib.h>
+#include <string.h>
+
+#include "CppUTest/TestHarness.h"
+#include "CppUTest/TestHarness_c.h"
+#include "CppUTest/CommandLineTestRunner.h"
+
+extern "C"
+{
+#include "utils.h"
+}
+
+int main(int argc, char** argv) {
+ return RUN_ALL_TESTS(argc, argv);
+}
+
+TEST_GROUP(utils) {
+
+ void setup(void) {
+ }
+
+ void teardown() {
+ }
+};
+
+static char* my_strdup(const char* s){
+ if(s==NULL){
+ return NULL;
+ }
+
+ size_t len = strlen(s);
+
+ char *d = (char*) calloc (len + 1,sizeof(char));
+
+ if (d == NULL){
+ return NULL;
+ }
+
+ strncpy (d,s,len);
+ return d;
+}
+
+TEST(utils, stringHash) {
+ char * toHash = my_strdup("abc");
+ unsigned int hash;
+ hash = utils_stringHash((void *) toHash);
+ LONGS_EQUAL(193485928, hash);
+
+ free(toHash);
+ toHash = my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
+ hash = utils_stringHash((void *) toHash);
+ LONGS_EQUAL(3704717399, hash);
+
+ free(toHash);
+ toHash = my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
+ hash = utils_stringHash((void *) toHash);
+ LONGS_EQUAL(3862509969, hash);
+ free(toHash);
+}
+
+TEST(utils, stringEquals) {
+ // Compare with equal strings
+ char * org = my_strdup("abc");
+ char * cmp = my_strdup("abc");
+
+ int result = utils_stringEquals((void *) org, (void *) cmp);
+ CHECK(result);
+
+ // Compare with no equal strings
+ free(cmp);
+ cmp = my_strdup("abcd");
+
+ result = utils_stringEquals((void *) org, (void *) cmp);
+ CHECK_FALSE(result);
+
+ // Compare with numeric strings
+ free(org);
+ free(cmp);
+ org = my_strdup("123");
+ cmp = my_strdup("123");
+
+ result = utils_stringEquals((void *) org, (void *) cmp);
+ CHECK(result);
+
+ // Compare with long strings
+ free(org);
+ free(cmp);
+ org = my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
+ cmp = my_strdup("abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"
+ "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz");
+
+ result = utils_stringEquals((void *) org, (void *) cmp);
+ CHECK(result);
+
+ free(org);
+ free(cmp);
+}
+
+TEST(utils, string_ndup){
+ // Compare with equal strings
+ const char * org = "abc";
+ char * cmp = NULL;
+
+ cmp = string_ndup(org, 3);
+ STRCMP_EQUAL(org, cmp);
+ free(cmp);
+
+ org = "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz";
+ cmp = string_ndup(org, 50);
+ STRCMP_EQUAL(org, cmp);
+ free(cmp);
+
+ cmp = string_ndup(org, 25);
+ LONGS_EQUAL(25, strlen(cmp));
+ free(cmp);
+}
+
+TEST(utils, stringTrim) {
+ // Multiple whitespaces, before, after and in between
+ char * toTrim = my_strdup(" a b c ");
+ char * result = utils_stringTrim(toTrim);
+
+ STRCMP_EQUAL("a b c", result);
+
+ // No whitespaces
+ free(toTrim);
+ toTrim = my_strdup("abc");
+ result = utils_stringTrim(toTrim);
+
+ STRCMP_EQUAL("abc", result);
+
+ // Only whitespace before
+ free(toTrim);
+ toTrim = my_strdup(" abc");
+ result = utils_stringTrim(toTrim);
+
+ STRCMP_EQUAL("abc", result);
+
+ // Only whitespace after
+ free(toTrim);
+ toTrim = my_strdup("abc ");
+ result = utils_stringTrim(toTrim);
+
+ STRCMP_EQUAL("abc", result);
+
+ // Whitespace other then space (tab, cr..).
+ free(toTrim);
+ toTrim = my_strdup("\tabc \n asdf \n");
+ result = utils_stringTrim(toTrim);
+
+ STRCMP_EQUAL("abc \n asdf", result);
+
+ free(toTrim);
+}
+
+TEST(utils, thread_equalsSelf){
+ celix_thread thread = celixThread_self();
+ bool get;
+
+ LONGS_EQUAL(CELIX_SUCCESS, thread_equalsSelf(thread, &get));
+ CHECK(get);
+
+ thread.thread = (pthread_t) 0x42;
+ LONGS_EQUAL(CELIX_SUCCESS, thread_equalsSelf(thread, &get));
+ CHECK_FALSE(get);
+}
+
+TEST(utils, isNumeric) {
+ // Check numeric string
+ char * toCheck = my_strdup("42");
+
+ bool result;
+ celix_status_t status = utils_isNumeric(toCheck, &result);
+ LONGS_EQUAL(CELIX_SUCCESS, status);
+ CHECK_C(result);
+
+ // Check non numeric string
+ free(toCheck);
+ toCheck = my_strdup("42b");
+ status = utils_isNumeric(toCheck, &result);
+ LONGS_EQUAL(CELIX_SUCCESS, status);
+ CHECK_C(!result);
+
+ free(toCheck);
+}
+
+TEST(utils, compareServiceIdsAndRanking){
+ int ret;
+ //service 1 is higher ranked and has a irrelevant ID
+ ret = utils_compareServiceIdsAndRanking(2,2,1,1);
+ LONGS_EQUAL(1, ret);
+
+ //service 1 is equally ranked and has a lower ID
+ ret = utils_compareServiceIdsAndRanking(1,1,2,1);
+ LONGS_EQUAL(1, ret);
+
+ //service 1 is equally ranked and has a higher ID
+ ret = utils_compareServiceIdsAndRanking(2,1,1,1);
+ LONGS_EQUAL(-1, ret);
+
+ //service 1 is lower ranked and has a irrelevant ID
+ ret = utils_compareServiceIdsAndRanking(1,1,2,2);
+ LONGS_EQUAL(-1, ret);
+
+ //service 1 is equal in ID and irrelevantly ranked
+ ret = utils_compareServiceIdsAndRanking(1,1,1,1);
+ LONGS_EQUAL(0, ret);
+
+
+}
+
+
http://git-wip-us.apache.org/repos/asf/celix/blob/147e8bfe/utils/public/include/celix_errno.h
----------------------------------------------------------------------
diff --git a/utils/public/include/celix_errno.h b/utils/public/include/celix_errno.h
new file mode 100644
index 0000000..5637b4b
--- /dev/null
+++ b/utils/public/include/celix_errno.h
@@ -0,0 +1,112 @@
+/*
+ *Licensed to the Apache Software Foundation (ASF) under one
+ *or more contributor license agreements. See the NOTICE file
+ *distributed with this work for additional information
+ *regarding copyright ownership. The ASF licenses this file
+ *to you under the Apache License, Version 2.0 (the
+ *"License"); you may not use this file except in compliance
+ *with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *Unless required by applicable law or agreed to in writing,
+ *software distributed under the License is distributed on an
+ *"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ *specific language governing permissions and limitations
+ *under the License.
+ */
+/*
+ * celix_errno.h
+ *
+ * \date Feb 15, 2011
+ * \author <a href="mailto:dev@celix.apache.org">Apache Celix Project Team</a>
+ * \copyright Apache License, Version 2.0
+ */
+/*!
+ \file
+ \brief Error codes
+ \defgroup framework Celix Framework
+ */
+#ifndef CELIX_ERRNO_H_
+#define CELIX_ERRNO_H_
+
+#include <stddef.h>
+#include <errno.h>
+
+#include "exports.h"
+
+/*!
+ * Helper macro which check the current status and executes the provided expression if the
+ * status is still CELIX_SUCCESS (0)
+ */
+#define CELIX_DO_IF(status, expr) ((status) == CELIX_SUCCESS) ? (expr) : (status)
+
+/*!
+ * \defgroup celix_errno Error Codes
+ * \ingroup framework
+ * \{
+ */
+
+struct celix_status {
+ int code;
+ char *error;
+};
+
+/*!
+ * Status type returned by all functions in Celix
+ */
+typedef int celix_status_t;
+
+/*!
+ * Return a readable string for the given error code.
+ *
+ */
+UTILS_EXPORT char *celix_strerror(celix_status_t errorcode, char *buffer, size_t bufferSize);
+
+/*!
+ * Error code indicating successful execution of the function.
+ */
+#define CELIX_SUCCESS 0
+
+/*!
+ * Starting point for Celix errors.
+ */
+#define CELIX_START_ERROR 70000
+
+/*!
+ * The range for Celix errors.
+ */
+#define CELIX_ERRSPACE_SIZE 1000
+
+/*!
+ * The start error number user application can use.
+ */
+#define CELIX_START_USERERR (CELIX_START_ERROR + CELIX_ERRSPACE_SIZE)
+
+/*!
+ * Exception indicating a problem with a bundle
+ */
+#define CELIX_BUNDLE_EXCEPTION (CELIX_START_ERROR + 1)
+/*!
+ * Invalid bundle context is used
+ */
+#define CELIX_INVALID_BUNDLE_CONTEXT (CELIX_START_ERROR + 2)
+/*!
+ * Argument is not correct
+ */
+#define CELIX_ILLEGAL_ARGUMENT (CELIX_START_ERROR + 3)
+#define CELIX_INVALID_SYNTAX (CELIX_START_ERROR + 4)
+#define CELIX_FRAMEWORK_SHUTDOWN (CELIX_START_ERROR + 5)
+#define CELIX_ILLEGAL_STATE (CELIX_START_ERROR + 6)
+#define CELIX_FRAMEWORK_EXCEPTION (CELIX_START_ERROR + 7)
+#define CELIX_FILE_IO_EXCEPTION (CELIX_START_ERROR + 8)
+#define CELIX_SERVICE_EXCEPTION (CELIX_START_ERROR + 9)
+
+#define CELIX_ENOMEM ENOMEM
+
+/**
+ * \}
+ */
+
+#endif /* CELIX_ERRNO_H_ */