From f23c9be5200c83ce3a0d40d606974220686a83d7 Mon Sep 17 00:00:00 2001 From: Alexander Bushnev Date: Tue, 10 Sep 2024 17:46:30 +0200 Subject: [PATCH] Remove legacy z_config_peer/z_config_client methods --- CMakeLists.txt | 3 -- docs/api.rst | 2 -- include/zenoh-pico/api/primitives.h | 23 -------------- src/api/api.c | 16 ---------- tests/z_api_config_test.c | 49 ----------------------------- 5 files changed, 93 deletions(-) delete mode 100644 tests/z_api_config_test.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 877eb404d..8d13bc1bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -414,7 +414,6 @@ if(UNIX OR MSVC) add_executable(z_bytes_test ${PROJECT_SOURCE_DIR}/tests/z_bytes_test.c) add_executable(z_api_bytes_test ${PROJECT_SOURCE_DIR}/tests/z_api_bytes_test.c) add_executable(z_api_encoding_test ${PROJECT_SOURCE_DIR}/tests/z_api_encoding_test.c) - add_executable(z_api_config_test ${PROJECT_SOURCE_DIR}/tests/z_api_config_test.c) add_executable(z_refcount_test ${PROJECT_SOURCE_DIR}/tests/z_refcount_test.c) target_link_libraries(z_data_struct_test ${Libname}) @@ -433,7 +432,6 @@ if(UNIX OR MSVC) target_link_libraries(z_bytes_test ${Libname}) target_link_libraries(z_api_bytes_test ${Libname}) target_link_libraries(z_api_encoding_test ${Libname}) - target_link_libraries(z_api_config_test ${Libname}) target_link_libraries(z_refcount_test ${Libname}) configure_file(${PROJECT_SOURCE_DIR}/tests/modularity.py ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/modularity.py COPYONLY) @@ -456,7 +454,6 @@ if(UNIX OR MSVC) add_test(z_bytes_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/z_bytes_test) add_test(z_api_bytes_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/z_api_bytes_test) add_test(z_api_encoding_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/z_api_encoding_test) - add_test(z_api_config_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/z_api_config_test) add_test(z_refcount_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/z_refcount_test) endif() diff --git a/docs/api.rst b/docs/api.rst index 08c7ff423..35323dae5 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -304,8 +304,6 @@ Primitives .. autocfunction:: primitives.h::z_keyexpr_join .. autocfunction:: primitives.h::z_config_new .. autocfunction:: primitives.h::z_config_default -.. autocfunction:: primitives.h::z_config_client -.. autocfunction:: primitives.h::z_config_peer .. autocfunction:: primitives.h::zp_config_get .. autocfunction:: primitives.h::zp_config_insert .. autocfunction:: primitives.h::z_encoding_from_str diff --git a/include/zenoh-pico/api/primitives.h b/include/zenoh-pico/api/primitives.h index 05c56ad31..926cb977b 100644 --- a/include/zenoh-pico/api/primitives.h +++ b/include/zenoh-pico/api/primitives.h @@ -309,29 +309,6 @@ int8_t z_config_default(z_owned_config_t *config); */ void z_config_clone(z_owned_config_t *config, const z_loaned_config_t *src); -/** - * Builds a new, zenoh-allocated, client configuration. - * - * Parameters: - * config: Pointer to uninitialized :c:type:`z_owned_config_t`. - * locator: Zenoh router locator string, if null multicast scouting will be performed. - * - * Return: - * `0`` in case of success, or a ``negative value`` otherwise. - */ -int8_t z_config_client(z_owned_config_t *config, const char *locator); -/** - * Builds a new, zenoh-allocated, peer configuration. - * - * Parameters: - * config: Pointer to uninitialized :c:type:`z_owned_config_t`. - * locator: Multicast address for peer-to-peer communication. - * - * Return: - * `0`` in case of success, or a ``negative value`` otherwise. - */ -int8_t z_config_peer(z_owned_config_t *config, const char *locator); - /** * Gets the property with the given integer key from the configuration. * diff --git a/src/api/api.c b/src/api/api.c index e54c85d79..a9d358982 100644 --- a/src/api/api.c +++ b/src/api/api.c @@ -190,22 +190,6 @@ int8_t z_config_default(z_owned_config_t *config) { return _z_config_default(&co void z_config_clone(z_owned_config_t *config, const z_loaned_config_t *src) { config->_val = _z_config_clone(src); } -int8_t z_config_client(z_owned_config_t *config, const char *locator) { - return _z_config_client(&config->_val, locator); -} - -int8_t z_config_peer(z_owned_config_t *config, const char *locator) { - if (locator == NULL) { - return _Z_ERR_INVALID; - } - _Z_RETURN_IF_ERR(z_config_default(config)); - _Z_CLEAN_RETURN_IF_ERR(zp_config_insert(&config->_val, Z_CONFIG_MODE_KEY, Z_CONFIG_MODE_PEER), - z_config_drop(z_config_move(config))); - _Z_CLEAN_RETURN_IF_ERR(zp_config_insert(&config->_val, Z_CONFIG_CONNECT_KEY, locator), - z_config_drop(z_config_move(config))); - return _Z_RES_OK; -} - const char *zp_config_get(const z_loaned_config_t *config, uint8_t key) { return _z_config_get(config, key); } int8_t zp_config_insert(z_loaned_config_t *config, uint8_t key, const char *value) { diff --git a/tests/z_api_config_test.c b/tests/z_api_config_test.c deleted file mode 100644 index 534edd317..000000000 --- a/tests/z_api_config_test.c +++ /dev/null @@ -1,49 +0,0 @@ -// -// Copyright (c) 2024 ZettaScale Technology -// -// This program and the accompanying materials are made available under the -// terms of the Eclipse Public License 2.0 which is available at -// http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 -// which is available at https://www.apache.org/licenses/LICENSE-2.0. -// -// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 -// -// Contributors: -// ZettaScale Zenoh Team, - -#include -#include -#include - -#include "zenoh-pico/api/primitives.h" -#include "zenoh-pico/api/types.h" - -#undef NDEBUG -#include - -void config_client(void) { - const char *locator = "tcp/127.0.0.1"; - z_owned_config_t config; - assert(0 == z_config_client(&config, locator)); - assert(z_internal_config_check(&config)); - assert(strcmp(zp_config_get(z_config_loan(&config), Z_CONFIG_MODE_KEY), Z_CONFIG_MODE_CLIENT) == 0); - assert(strcmp(zp_config_get(z_config_loan(&config), Z_CONFIG_CONNECT_KEY), locator) == 0); - z_config_drop(z_config_move(&config)); -} - -void config_peer(void) { - const char *locator = "udp/228.0.0.4:7447#iface=en0"; - z_owned_config_t config; - assert(0 == z_config_peer(&config, locator)); - assert(z_internal_config_check(&config)); - assert(strcmp(zp_config_get(z_config_loan(&config), Z_CONFIG_MODE_KEY), Z_CONFIG_MODE_PEER) == 0); - assert(strcmp(zp_config_get(z_config_loan(&config), Z_CONFIG_CONNECT_KEY), locator) == 0); - z_config_drop(z_config_move(&config)); - assert(0 != z_config_peer(&config, NULL)); - assert(!z_internal_config_check(&config)); -} - -int main(void) { - config_client(); - config_peer(); -}