This is an automated email from the ASF dual-hosted git repository. pnoltes pushed a commit to branch feature/gh-509-remove-deprecated-utils in repository https://gitbox.apache.org/repos/asf/celix.git
commit 678dcc06d8a4454e94fab95c9b5dfa4e01247774 Author: Pepijn Noltes <[email protected]> AuthorDate: Sun Feb 8 12:09:41 2026 +0100 gh-509: Remove deprecated utils, celixbool, export and celix_utils_api header Also refactor code using the removed depecrated headers --- .../src/endpoint_discovery_poller.c | 7 ++- .../src/endpoint_discovery_server.c | 7 ++- .../discovery_configured/src/discovery_impl.c | 8 ++- .../discovery_etcd/src/discovery_impl.c | 9 ++-- .../discovery_etcd/src/etcd_watcher.c | 9 ++-- .../src/remote_service_admin_dfi.c | 3 +- .../remote_services/topology_manager/src/scope.c | 8 ++- .../topology_manager/src/topology_manager.c | 2 +- bundles/shell/shell/src/c_shell.c | 7 ++- libs/framework/include/celix_api.h | 13 ++--- .../include_deprecated/service_registration.h | 1 + libs/framework/src/bundle.c | 2 +- libs/framework/src/bundle_context.c | 3 +- libs/framework/src/framework.c | 9 ++-- libs/framework/src/module.c | 1 - libs/framework/src/service_reference.c | 2 +- libs/utils/benchmark/src/StringHashmapBenchmark.cc | 12 ++++- libs/utils/gtest/src/CelixUtilsTestSuite.cc | 58 ---------------------- libs/utils/include_deprecated/celix_utils_api.h | 35 ------------- libs/utils/include_deprecated/celixbool.h | 26 ---------- libs/utils/include_deprecated/exports.h | 49 ------------------ libs/utils/include_deprecated/utils.h | 57 --------------------- libs/utils/src/filter.c | 2 +- libs/utils/src/utils.c | 9 ++-- .../example_test/private/src/activator.c | 1 - .../example_test2/private/src/activator.c | 1 - .../private/src/configuration_admin_factory.c | 2 +- .../service/private/src/configuration_admin_impl.c | 2 +- .../service/private/src/configuration_impl.c | 2 +- .../service/private/src/configuration_store.c | 8 ++- .../service/private/src/managed_service_tracker.c | 14 ++++-- 31 files changed, 93 insertions(+), 276 deletions(-) diff --git a/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c b/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c index 72da36418..7d9ad9cb4 100644 --- a/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c +++ b/bundles/remote_services/discovery_common/src/endpoint_discovery_poller.c @@ -35,7 +35,6 @@ #include "bundle_context.h" #include "celix_log_helper.h" #include "celix_utils.h" -#include "utils.h" #include "endpoint_descriptor_reader.h" #include "discovery.h" @@ -95,7 +94,11 @@ celix_status_t endpointDiscoveryPoller_create(discovery_t *discovery, celix_bund (*poller)->poll_timeout = atoi(timeout); (*poller)->discovery = discovery; (*poller)->running = false; - (*poller)->entries = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL); + (*poller)->entries = hashMap_create( + (unsigned int (*)(const void*))celix_utils_stringHash, + NULL, + (int (*)(const void*, const void*))celix_utils_stringEquals, + NULL); const char* sep = ","; char *save_ptr = NULL; diff --git a/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c b/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c index 4d6043cce..5ef682f0c 100644 --- a/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c +++ b/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c @@ -27,7 +27,6 @@ #include "civetweb.h" #include "celix_errno.h" #include "celix_utils.h" -#include "utils.h" #include "celix_log_helper.h" #include "discovery.h" #include "endpoint_descriptor_writer.h" @@ -87,7 +86,11 @@ celix_status_t endpointDiscoveryServer_create(discovery_t *discovery, } (*server)->loghelper = &discovery->loghelper; - (*server)->entries = hashMap_create(&utils_stringHash, NULL, &utils_stringEquals, NULL); + (*server)->entries = hashMap_create( + (unsigned int (*)(const void*))celix_utils_stringHash, + NULL, + (int (*)(const void*, const void*))celix_utils_stringEquals, + NULL); if (!(*server)->entries) { return CELIX_ENOMEM; } diff --git a/bundles/remote_services/discovery_configured/src/discovery_impl.c b/bundles/remote_services/discovery_configured/src/discovery_impl.c index b0a013a48..0a86dc62b 100644 --- a/bundles/remote_services/discovery_configured/src/discovery_impl.c +++ b/bundles/remote_services/discovery_configured/src/discovery_impl.c @@ -31,7 +31,7 @@ #include "celix_threads.h" #include "bundle_context.h" -#include "utils.h" +#include "celix_utils.h" #include "celix_log_helper.h" #include "discovery.h" @@ -52,7 +52,11 @@ celix_status_t discovery_create(celix_bundle_context_t *context, discovery_t **d (*discovery)->stopped = false; (*discovery)->listenerReferences = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL); - (*discovery)->discoveredServices = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL); + (*discovery)->discoveredServices = hashMap_create( + (unsigned int (*)(const void*))celix_utils_stringHash, + NULL, + (int (*)(const void*, const void*))celix_utils_stringEquals, + NULL); celixThreadMutex_create(&(*discovery)->mutex, NULL); diff --git a/bundles/remote_services/discovery_etcd/src/discovery_impl.c b/bundles/remote_services/discovery_etcd/src/discovery_impl.c index 4503a8f8c..698e38ddb 100644 --- a/bundles/remote_services/discovery_etcd/src/discovery_impl.c +++ b/bundles/remote_services/discovery_etcd/src/discovery_impl.c @@ -27,7 +27,7 @@ #include "celix_threads.h" #include "bundle_context.h" -#include "utils.h" +#include "celix_utils.h" #include "celix_errno.h" #include "filter.h" #include "service_reference.h" @@ -56,7 +56,11 @@ celix_status_t discovery_create(celix_bundle_context_t *context, discovery_t** o discovery->listenerReferences = hashMap_create(serviceReference_hashCode, NULL, serviceReference_equals2, NULL); - discovery->discoveredServices = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL); + discovery->discoveredServices = hashMap_create( + (unsigned int (*)(const void*))celix_utils_stringHash, + NULL, + (int (*)(const void*, const void*))celix_utils_stringEquals, + NULL); celixThreadMutex_create(&discovery->mutex, NULL); @@ -175,4 +179,3 @@ celix_status_t discovery_stop(discovery_t *discovery) { } - diff --git a/bundles/remote_services/discovery_etcd/src/etcd_watcher.c b/bundles/remote_services/discovery_etcd/src/etcd_watcher.c index 131ec14e2..5377f8904 100644 --- a/bundles/remote_services/discovery_etcd/src/etcd_watcher.c +++ b/bundles/remote_services/discovery_etcd/src/etcd_watcher.c @@ -24,7 +24,7 @@ #include "celix_api.h" #include "celix_log_helper.h" -#include "utils.h" +#include "celix_utils.h" #include "discovery.h" #include "discovery_impl.h" @@ -293,7 +293,11 @@ celix_status_t etcdWatcher_create(discovery_t *discovery, celix_bundle_context_t { (*watcher)->discovery = discovery; (*watcher)->loghelper = &discovery->loghelper; - (*watcher)->entries = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL); + (*watcher)->entries = hashMap_create( + (unsigned int (*)(const void*))celix_utils_stringHash, + NULL, + (int (*)(const void*, const void*))celix_utils_stringEquals, + NULL); (*watcher)->ttl = DEFAULT_ETCD_TTL; } @@ -352,4 +356,3 @@ celix_status_t etcdWatcher_destroy(etcd_watcher_t *watcher) { return status; } - diff --git a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c index 2ec6b6454..5c02b5bbe 100644 --- a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c +++ b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c @@ -32,8 +32,8 @@ #include <jansson.h> #include "json_serializer.h" -#include "utils.h" #include "celix_utils.h" +#include "celix_threads.h" #include "celix_ref.h" #include "hash_map.h" @@ -1159,4 +1159,3 @@ static size_t remoteServiceAdmin_write(void *contents, size_t size, size_t nmemb fwrite(contents, size, nmemb, get->stream); return size * nmemb; } - diff --git a/bundles/remote_services/topology_manager/src/scope.c b/bundles/remote_services/topology_manager/src/scope.c index 3c4af2a98..c9b900a9e 100644 --- a/bundles/remote_services/topology_manager/src/scope.c +++ b/bundles/remote_services/topology_manager/src/scope.c @@ -23,7 +23,7 @@ #include "scope.h" #include "tm_scope.h" #include "topology_manager.h" -#include "utils.h" +#include "celix_utils.h" #include "filter.h" static bool import_equal(celix_array_list_entry_t src, celix_array_list_entry_t dest); @@ -198,7 +198,11 @@ celix_status_t scope_scopeCreate(void *handle, scope_pt *scope) { celixThreadMutex_create(&(*scope)->exportScopeLock, NULL); celixThreadMutex_create(&(*scope)->importScopeLock, NULL); - (*scope)->exportScopes = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL); + (*scope)->exportScopes = hashMap_create( + (unsigned int (*)(const void*))celix_utils_stringHash, + NULL, + (int (*)(const void*, const void*))celix_utils_stringEquals, + NULL); celix_array_list_create_options_t opts = CELIX_EMPTY_ARRAY_LIST_CREATE_OPTIONS; opts.equalsCallback = import_equal; (*scope)->importScopes = celix_arrayList_createWithOptions(&opts); diff --git a/bundles/remote_services/topology_manager/src/topology_manager.c b/bundles/remote_services/topology_manager/src/topology_manager.c index 799017b8a..b7b61ce82 100644 --- a/bundles/remote_services/topology_manager/src/topology_manager.c +++ b/bundles/remote_services/topology_manager/src/topology_manager.c @@ -43,7 +43,7 @@ #include "remote_constants.h" #include "filter.h" #include "listener_hook_service.h" -#include "utils.h" +#include "celix_utils.h" #include "service_reference.h" #include "service_registration.h" #include "celix_log_helper.h" diff --git a/bundles/shell/shell/src/c_shell.c b/bundles/shell/shell/src/c_shell.c index 364e5d893..3426ba0e7 100644 --- a/bundles/shell/shell/src/c_shell.c +++ b/bundles/shell/shell/src/c_shell.c @@ -26,7 +26,6 @@ #include "celix_utils.h" #include "celix_errno.h" #include "shell_private.h" -#include "utils.h" shell_t* shell_create(celix_bundle_context_t *ctx) { shell_t *shell = calloc(1, sizeof(*shell)); @@ -35,7 +34,11 @@ shell_t* shell_create(celix_bundle_context_t *ctx) { shell->logHelper = celix_logHelper_create(ctx, "celix_shell"); celixThreadRwlock_create(&shell->lock, NULL); - shell->commandServices = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL); + shell->commandServices = hashMap_create( + (unsigned int (*)(const void*))celix_utils_stringHash, + NULL, + (int (*)(const void*, const void*))celix_utils_stringEquals, + NULL); return shell; } diff --git a/libs/framework/include/celix_api.h b/libs/framework/include/celix_api.h index c4d5fcb86..a3e996c25 100644 --- a/libs/framework/include/celix_api.h +++ b/libs/framework/include/celix_api.h @@ -20,17 +20,14 @@ #ifndef CELIX_CELIX_API_H_ #define CELIX_CELIX_API_H_ -#include "celix_properties.h" -#include "celix_array_list.h" - -#include "celix_bundle.h" -#include "celix_bundle_context.h" -#include "celix_framework.h" - #include "celix_properties.h" #include "celix_array_list.h" #include "celix_constants.h" -#include "celix_utils_api.h" +#include "celix_errno.h" +#include "celix_threads.h" +#include "celix_utils.h" +#include "celix_version.h" +#include "celix_version_range.h" #include "celix_bundle.h" #include "celix_bundle_context.h" diff --git a/libs/framework/include_deprecated/service_registration.h b/libs/framework/include_deprecated/service_registration.h index cf648c05b..07b85558a 100644 --- a/libs/framework/include_deprecated/service_registration.h +++ b/libs/framework/include_deprecated/service_registration.h @@ -22,6 +22,7 @@ #include <stdbool.h> +#include "celix_errno.h" #include "celix_types.h" #include "celix_properties_type.h" #include "celix_framework_export.h" diff --git a/libs/framework/src/bundle.c b/libs/framework/src/bundle.c index 96ab4270b..70ce40933 100644 --- a/libs/framework/src/bundle.c +++ b/libs/framework/src/bundle.c @@ -23,10 +23,10 @@ #include "celix_properties.h" #include "celix_properties_type.h" #include "framework_private.h" -#include "utils.h" #include "celix_file_utils.h" #include "bundle_context_private.h" #include "service_tracker_private.h" +#include "celix_utils.h" #include <stdlib.h> #include <string.h> diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c index 0cd0d621e..f35010586 100644 --- a/libs/framework/src/bundle_context.c +++ b/libs/framework/src/bundle_context.c @@ -20,7 +20,6 @@ #include <stdlib.h> #include <stdio.h> #include <string.h> -#include <utils.h> #include <assert.h> #include <unistd.h> #include <stdarg.h> @@ -1779,4 +1778,4 @@ void celix_bundleContext_vlog(const celix_bundle_context_t *ctx, celix_log_level void celix_bundleContext_logTssErrors(const celix_bundle_context_t *ctx, celix_log_level_e level) { celix_framework_logTssErrors(ctx->framework->logger, level); -} \ No newline at end of file +} diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c index 74bd4741b..c6557025d 100644 --- a/libs/framework/src/framework.c +++ b/libs/framework/src/framework.c @@ -47,7 +47,7 @@ #include "framework_private.h" #include "service_reference_private.h" #include "service_registration_private.h" -#include "utils.h" +#include "celix_utils.h" #include "celix_bundle_archive.h" struct celix_bundle_activator { @@ -243,7 +243,11 @@ celix_status_t framework_create(framework_pt *out, celix_properties_t* config) { celixThreadCondition_init(&framework->dispatcher.cond, NULL); framework->dispatcher.active = true; framework->currentBundleId = CELIX_FRAMEWORK_BUNDLE_ID; - framework->installRequestMap = hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals); + framework->installRequestMap = hashMap_create( + (unsigned int (*)(const void*))celix_utils_stringHash, + (unsigned int (*)(const void*))celix_utils_stringHash, + (int (*)(const void*, const void*))celix_utils_stringEquals, + (int (*)(const void*, const void*))celix_utils_stringEquals); framework->installedBundles.entries = celix_arrayList_create(); framework->configurationMap = config; //note form now on celix_framework_getConfigProperty* can be used framework->bundleListeners = celix_arrayList_create(); @@ -2717,4 +2721,3 @@ void celix_framework_waitForStop(celix_framework_t *framework) { celixThreadMutex_unlock(&framework->shutdown.mutex); } - diff --git a/libs/framework/src/module.c b/libs/framework/src/module.c index 08f0a4211..2243d93a6 100644 --- a/libs/framework/src/module.c +++ b/libs/framework/src/module.c @@ -30,7 +30,6 @@ #include "celix_module.h" #include "celix_utils.h" #include "framework_private.h" -#include "utils.h" #include "celix_bundle_private.h" #ifdef __linux__ diff --git a/libs/framework/src/service_reference.c b/libs/framework/src/service_reference.c index 9a8b52a7d..7dd155bec 100644 --- a/libs/framework/src/service_reference.c +++ b/libs/framework/src/service_reference.c @@ -20,7 +20,7 @@ #include <stdio.h> #include <stdlib.h> #include <stdint.h> -#include <utils.h> +#include <celix_utils.h> #include <assert.h> #include "service_reference.h" diff --git a/libs/utils/benchmark/src/StringHashmapBenchmark.cc b/libs/utils/benchmark/src/StringHashmapBenchmark.cc index 7ecfb81e0..4b261be19 100644 --- a/libs/utils/benchmark/src/StringHashmapBenchmark.cc +++ b/libs/utils/benchmark/src/StringHashmapBenchmark.cc @@ -28,12 +28,20 @@ #include "celix_string_hash_map.h" #include "celix_hash_map_internal.h" #include "celix_properties_internal.h" -#include "utils.h" +#include "celix_utils.h" class StringHashmapBenchmark { public: explicit StringHashmapBenchmark(int64_t _nrOfEntries) : testVectorsMap{createRandomMap(_nrOfEntries)} { - deprecatedHashMap = hashMap_create(utils_stringHash, nullptr, utils_stringEquals, nullptr); + deprecatedHashMap = hashMap_create( + reinterpret_cast<unsigned int (*)(const void*)>(celix_utils_stringHash), + nullptr, + [](const void* keyA, const void* keyB) -> int + { + auto equal = celix_utils_stringEquals(static_cast<const char*>(keyA), static_cast<const char*>(keyB)); + return equal ? 1 : 0; + }, + nullptr); celix_string_hash_map_create_options_t opts{}; opts.storeKeysWeakly = true; //ensure that the celix hash map does not copy strings (we don't want to measure that). celixHashMap = celix_stringHashMap_createWithOptions(&opts); diff --git a/libs/utils/gtest/src/CelixUtilsTestSuite.cc b/libs/utils/gtest/src/CelixUtilsTestSuite.cc index 95e143d41..833f09075 100644 --- a/libs/utils/gtest/src/CelixUtilsTestSuite.cc +++ b/libs/utils/gtest/src/CelixUtilsTestSuite.cc @@ -21,7 +21,6 @@ #include "celix_stdlib_cleanup.h" #include "celix_utils.h" -#include "utils.h" class UtilsTestSuite : public ::testing::Test { public: @@ -183,10 +182,6 @@ TEST_F(UtilsTestSuite, StringHashTest) { hash = celix_utils_stringHash(nullptr); EXPECT_EQ(0, hash); - - //test deprecated api - hash = utils_stringHash("abc"); - EXPECT_EQ(193485963, hash); } TEST_F(UtilsTestSuite, StringEqualsTest) { @@ -199,38 +194,6 @@ TEST_F(UtilsTestSuite, StringEqualsTest) { EXPECT_TRUE(celix_utils_stringEquals("", "")); EXPECT_FALSE(celix_utils_stringEquals("", nullptr)); - //test deprecated api - EXPECT_TRUE(utils_stringEquals("abc", "abc")); -} - -TEST_F(UtilsTestSuite, IsNumericTest) { - //test deprecated api - - // Check numeric string - bool result; - celix_status_t status = utils_isNumeric("42", &result); - EXPECT_EQ(CELIX_SUCCESS, status); - EXPECT_TRUE(result); - - // Check non numeric string - status = utils_isNumeric("42b", &result); - EXPECT_EQ(CELIX_SUCCESS, status); - EXPECT_FALSE(result); -} - -TEST_F(UtilsTestSuite, ThreadEqualSelfTest) { - celix_thread thread = celixThread_self(); - bool equal; - - celix_status_t status = thread_equalsSelf(thread, &equal); - EXPECT_EQ(CELIX_SUCCESS, status); - EXPECT_TRUE(equal); - - - thread.thread = (pthread_t) 0x42; - status = thread_equalsSelf(thread, &equal); - EXPECT_EQ(CELIX_SUCCESS, status); - EXPECT_FALSE(equal); } TEST_F(UtilsTestSuite, StringTrimTest) { @@ -265,27 +228,6 @@ TEST_F(UtilsTestSuite, StringTrimTest) { free(trimmed); } -TEST_F(UtilsTestSuite, StringNBdupTest){ - // test deprecated api - - // Compare with equal strings - const char * org = "abc"; - char * cmp = nullptr; - - cmp = string_ndup(org, 3); - EXPECT_STREQ(org, cmp); - free(cmp); - - org = "abc123def456ghi789jkl012mno345pqr678stu901vwx234yz"; - cmp = string_ndup(org, 50); - EXPECT_STREQ(org, cmp); - free(cmp); - - cmp = string_ndup(org, 25); - EXPECT_EQ(25, strlen(cmp)); - free(cmp); -} - TEST_F(UtilsTestSuite, WriteOrCreateStringTest) { //Buffer big enough, write to stack buffer char buffer[16]; diff --git a/libs/utils/include_deprecated/celix_utils_api.h b/libs/utils/include_deprecated/celix_utils_api.h deleted file mode 100644 index 68b02ca90..000000000 --- a/libs/utils/include_deprecated/celix_utils_api.h +++ /dev/null @@ -1,35 +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. - */ - -#ifndef CELIX_CELIX_UTILS_API_H_ -#define CELIX_CELIX_UTILS_API_H_ - -#include <stdbool.h> - -#include "celix_errno.h" -#include "celix_threads.h" -#include "celix_array_list.h" -#include "hash_map.h" -#include "celix_properties.h" -#include "utils.h" -#include "celix_utils.h" -#include "celix_version.h" -#include "celix_version_range.h" - -#endif //CELIX_CELIX_UTILS_API_H_ diff --git a/libs/utils/include_deprecated/celixbool.h b/libs/utils/include_deprecated/celixbool.h deleted file mode 100644 index 97647099d..000000000 --- a/libs/utils/include_deprecated/celixbool.h +++ /dev/null @@ -1,26 +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. - */ - -#ifndef CELIXBOOL_H_ -#define CELIXBOOL_H_ - -#warning celixbool.h is deprecated, use <stdbool.h> instead. -#include <stdbool.h> - -#endif /* CELIXBOOL_H_ */ diff --git a/libs/utils/include_deprecated/exports.h b/libs/utils/include_deprecated/exports.h deleted file mode 100644 index 1061c3de7..000000000 --- a/libs/utils/include_deprecated/exports.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. - */ -/** - * exports.h - * - * \date Jun 16, 2011 - * \author <a href="mailto:[email protected]">Apache Celix Project Team</a> - * \copyright Apache License, Version 2.0 - */ - -#ifndef EXPORTS_H_ -#define EXPORTS_H_ - -/* Cmake will define utils_EXPORTS on Windows when it -configures to build a shared library. If you are going to use -another build system on windows or create the visual studio -projects by hand you need to define utils_EXPORTS when -building a DLL on windows. - -We are using the Visual Studio Compiler and building Shared libraries -*/ - -#if defined (_WIN32) - #if defined(celix_utils_EXPORTS) - #define UTILS_EXPORT __declspec(dllexport) - #else - #define UTILS_EXPORT __declspec(dllimport) - #endif /* celix_utils_EXPORTS */ -#else /* defined (_WIN32) */ - #define UTILS_EXPORT __attribute__((visibility("default"))) -#endif - -#endif /* EXPORTS_H_ */ diff --git a/libs/utils/include_deprecated/utils.h b/libs/utils/include_deprecated/utils.h deleted file mode 100644 index c4c092a0c..000000000 --- a/libs/utils/include_deprecated/utils.h +++ /dev/null @@ -1,57 +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") CELIX_UTILS_DEPRECATED_ATTR; you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -#ifndef UTILS_H_ -#define UTILS_H_ - -#include <ctype.h> -#include <stdbool.h> - -#include "celix_errno.h" -#include "celix_utils_export.h" -#include "celix_threads.h" -#include "celix_utils.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define CELIX_UTILS_DEPRECATED_ATTR __attribute__((deprecated("functions in utils.h are deprecated use functions in celix_utils.h instead"))) - -CELIX_UTILS_DEPRECATED_EXPORT unsigned int utils_stringHash(const void *string) CELIX_UTILS_DEPRECATED_ATTR; - -CELIX_UTILS_DEPRECATED_EXPORT int utils_stringEquals(const void *string, const void *toCompare) CELIX_UTILS_DEPRECATED_ATTR; - -CELIX_UTILS_DEPRECATED_EXPORT char *string_ndup(const char *s, size_t n) CELIX_UTILS_DEPRECATED_ATTR; - -CELIX_UTILS_DEPRECATED_EXPORT char *utils_stringTrim(char *string) CELIX_UTILS_DEPRECATED_ATTR; - -CELIX_UTILS_DEPRECATED_EXPORT bool utils_isStringEmptyOrNull(const char *const str) CELIX_UTILS_DEPRECATED_ATTR; - -CELIX_UTILS_DEPRECATED_EXPORT int -utils_compareServiceIdsAndRanking(long servId, long servRank, long otherServId, long otherServRank) CELIX_UTILS_DEPRECATED_ATTR; - -CELIX_UTILS_DEPRECATED_EXPORT celix_status_t thread_equalsSelf(celix_thread_t thread, bool *equals) CELIX_UTILS_DEPRECATED_ATTR; - -CELIX_UTILS_DEPRECATED_EXPORT celix_status_t utils_isNumeric(const char *number, bool *ret) CELIX_UTILS_DEPRECATED_ATTR; - -#ifdef __cplusplus -} -#endif -#endif /* UTILS_H_ */ diff --git a/libs/utils/src/filter.c b/libs/utils/src/filter.c index c732bb40c..40904df81 100644 --- a/libs/utils/src/filter.c +++ b/libs/utils/src/filter.c @@ -22,7 +22,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <utils.h> +#include <celix_utils.h> #include "celix_convert_utils.h" #include "celix_err.h" diff --git a/libs/utils/src/utils.c b/libs/utils/src/utils.c index dac59f37b..e2d6dd183 100644 --- a/libs/utils/src/utils.c +++ b/libs/utils/src/utils.c @@ -18,13 +18,16 @@ */ -#include <stdlib.h> -#include <string.h> #include <assert.h> +#include <ctype.h> +#include <errno.h> #include <stdarg.h> +#include <stdlib.h> +#include <string.h> -#include "utils.h" #include "celix_utils.h" +#include "celix_errno.h" +#include "celix_threads.h" #include "celix_utils_private_constants.h" #ifdef __APPLE__ diff --git a/misc/experimental/bundles/config_admin/config_admin_tst/example_test/private/src/activator.c b/misc/experimental/bundles/config_admin/config_admin_tst/example_test/private/src/activator.c index 94c53900a..b2e774b88 100644 --- a/misc/experimental/bundles/config_admin/config_admin_tst/example_test/private/src/activator.c +++ b/misc/experimental/bundles/config_admin/config_admin_tst/example_test/private/src/activator.c @@ -34,7 +34,6 @@ #include "bundle_context.h" #include "celix_constants.h" #include "properties.h" -#include "utils.h" /* celix.utils */ #include "hash_map.h" /* celix.configadmin */ diff --git a/misc/experimental/bundles/config_admin/config_admin_tst/example_test2/private/src/activator.c b/misc/experimental/bundles/config_admin/config_admin_tst/example_test2/private/src/activator.c index b5c6b1931..1adeb4713 100644 --- a/misc/experimental/bundles/config_admin/config_admin_tst/example_test2/private/src/activator.c +++ b/misc/experimental/bundles/config_admin/config_admin_tst/example_test2/private/src/activator.c @@ -35,7 +35,6 @@ #include "bundle_context.h" #include "celix_constants.h" #include "properties.h" -#include "utils.h" /* celix.utils */ #include "hash_map.h" /* celix.configadmin */ diff --git a/misc/experimental/bundles/config_admin/service/private/src/configuration_admin_factory.c b/misc/experimental/bundles/config_admin/service/private/src/configuration_admin_factory.c index 63102d83a..58b449559 100644 --- a/misc/experimental/bundles/config_admin/service/private/src/configuration_admin_factory.c +++ b/misc/experimental/bundles/config_admin/service/private/src/configuration_admin_factory.c @@ -24,7 +24,7 @@ * \copyright Apache License, Version 2.0 */ -#include <celixbool.h> +#include <stdbool.h> #include <stddef.h> #include <stdlib.h> #include <stdio.h> diff --git a/misc/experimental/bundles/config_admin/service/private/src/configuration_admin_impl.c b/misc/experimental/bundles/config_admin/service/private/src/configuration_admin_impl.c index 9ed5b8f48..1feeccd02 100644 --- a/misc/experimental/bundles/config_admin/service/private/src/configuration_admin_impl.c +++ b/misc/experimental/bundles/config_admin/service/private/src/configuration_admin_impl.c @@ -33,7 +33,7 @@ #include "configuration_admin_impl.h" /* celix.framework.public */ -#include "utils.h" +#include "celix_utils.h" /* celix.framework_patch*/ #include "framework_patch.h" /* celix.config_admin.private*/ diff --git a/misc/experimental/bundles/config_admin/service/private/src/configuration_impl.c b/misc/experimental/bundles/config_admin/service/private/src/configuration_impl.c index 49aa9bdf1..4d21f71a5 100644 --- a/misc/experimental/bundles/config_admin/service/private/src/configuration_impl.c +++ b/misc/experimental/bundles/config_admin/service/private/src/configuration_impl.c @@ -38,7 +38,7 @@ /* celix.framework */ #include "bundle.h" #include "celix_constants.h" -#include "utils.h" +#include "celix_utils.h" /* celix.framework_patch*/ #include "framework_patch.h" /* celix.config_admin.public*/ diff --git a/misc/experimental/bundles/config_admin/service/private/src/configuration_store.c b/misc/experimental/bundles/config_admin/service/private/src/configuration_store.c index 31af82612..4adc7e348 100644 --- a/misc/experimental/bundles/config_admin/service/private/src/configuration_store.c +++ b/misc/experimental/bundles/config_admin/service/private/src/configuration_store.c @@ -42,7 +42,7 @@ #include "hash_map.h" /* celix.framework */ #include "properties.h" -#include "utils.h" +#include "celix_utils.h" /* celix.config_admin.private*/ #include "configuration_admin_factory.h" #include "configuration.h" @@ -88,7 +88,11 @@ celix_status_t configurationStore_create(bundle_context_pt context, configuratio (*store)->configurationAdminFactory = factory; - (*store)->configurations = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL); + (*store)->configurations = hashMap_create( + (unsigned int (*)(const void*))celix_utils_stringHash, + NULL, + (int (*)(const void*, const void*))celix_utils_stringEquals, + NULL); // (*store)->createdPidCount = 0; if (configurationStore_createCache((*store)) != CELIX_SUCCESS) { diff --git a/misc/experimental/bundles/config_admin/service/private/src/managed_service_tracker.c b/misc/experimental/bundles/config_admin/service/private/src/managed_service_tracker.c index ef77fc111..8dd763151 100644 --- a/misc/experimental/bundles/config_admin/service/private/src/managed_service_tracker.c +++ b/misc/experimental/bundles/config_admin/service/private/src/managed_service_tracker.c @@ -38,7 +38,7 @@ /* celix.framework */ #include "celix_constants.h" #include "properties.h" -#include "utils.h" +#include "celix_utils.h" #include "service_reference.h" #include "service_registration.h" /* celix.framework.Patch*/ @@ -137,8 +137,16 @@ celix_status_t managedServiceTracker_createHandle(bundle_context_pt context, con this->configurationStore = store; this->updatedThreadPool = updatedThreadPool; - this->managedServices = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL); - this->managedServicesReferences = hashMap_create(utils_stringHash, NULL, utils_stringEquals, NULL); + this->managedServices = hashMap_create( + (unsigned int (*)(const void*))celix_utils_stringHash, + NULL, + (int (*)(const void*, const void*))celix_utils_stringEquals, + NULL); + this->managedServicesReferences = hashMap_create( + (unsigned int (*)(const void*))celix_utils_stringHash, + NULL, + (int (*)(const void*, const void*))celix_utils_stringEquals, + NULL); celix_status_t mutexStatus = celixThreadMutex_create(&this->managedServicesReferencesMutex, NULL); if (mutexStatus != CELIX_SUCCESS) {
