Skip to content

Commit e856d3e

Browse files
committed
port to libnetconf2 v3
This is really just a change of logging, nothing else. Unfortunately, the new logging still affects a global state, it was really just a change of the function signature, and the logger callback might well be invoked with a NULL session. This means that mapping from the nc_session* to a libnetconf::client::Session is not possible, so I though that simply providing an opaque pointer is not a bad solution. Change-Id: Iaa10855f4173fdd5e3046efa1827e4931cd05acb Depends-on: https://gerrit.cesnet.cz/c/CzechLight/libyang-cpp/+/7049
1 parent b1fd592 commit e856d3e

6 files changed

Lines changed: 18 additions & 12 deletions

File tree

.zuul.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
pre-run: ci/pre.yaml
66
required-projects:
77
- name: github/CESNET/libyang
8-
override-checkout: cesnet/2024-03--v2-latest
8+
override-checkout: devel
99
- name: github/CESNET/libnetconf2
10-
override-checkout: cesnet/wip-libnetconf-v2
10+
override-checkout: devel
1111
- name: github/onqtam/doctest
1212
override-checkout: v2.4.8
1313
- name: github/rollbear/trompeloeil
@@ -17,9 +17,9 @@
1717
pre-run: ci/pre.yaml
1818
required-projects: &projects
1919
- name: github/CESNET/libyang
20-
override-checkout: cesnet/2024-03--v2-latest
20+
override-checkout: devel
2121
- name: github/CESNET/libnetconf2
22-
override-checkout: cesnet/wip-libnetconf-v2
22+
override-checkout: devel
2323
- name: github/onqtam/doctest
2424
override-checkout: v2.4.11
2525
- name: github/rollbear/trompeloeil

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ option(WITH_DOCS "Create and install internal documentation (needs Doxygen)" ${D
2727
option(BUILD_SHARED_LIBS "By default, shared libs are enabled. Turn off for a static build." ON)
2828

2929
find_package(PkgConfig)
30-
pkg_check_modules(LIBYANG_CPP REQUIRED libyang-cpp>=1.1.0 IMPORTED_TARGET)
31-
pkg_check_modules(LIBNETCONF2 REQUIRED libnetconf2>=2.1.40 libnetconf2<3 IMPORTED_TARGET)
32-
set(LIBNETCONF2_CPP_PKG_VERSION "1.0.0")
30+
pkg_check_modules(LIBYANG_CPP REQUIRED libyang-cpp>=2 IMPORTED_TARGET)
31+
pkg_check_modules(LIBNETCONF2 REQUIRED libnetconf2>=3.0.17 IMPORTED_TARGET)
32+
set(LIBNETCONF2_CPP_PKG_VERSION "2")
3333

3434
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include)
3535

ci/pre.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,9 @@
33
- name: install libssh-debuginfo
44
command: 'dnf debuginfo-install -y libssh'
55
become: true
6+
7+
- name: install curl
8+
package:
9+
name: libcurl-devel
10+
state: present
11+
become: true

include/libnetconf2-cpp/netconf-client.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ReportedError : public std::runtime_error {
2424
~ReportedError() override;
2525
};
2626

27-
using LogCb = std::function<void(LogLevel, const char*)>;
27+
using LogCb = std::function<void(const nc_session*, LogLevel, const char*)>;
2828

2929
void setLogLevel(LogLevel level);
3030
void setLogCallback(const LogCb& callback);

src/netconf-client.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ namespace impl {
2424

2525
static client::LogCb logCallback;
2626

27-
static void logViaCallback(NC_VERB_LEVEL level, const char* message)
27+
static void logViaCallback(const nc_session* session, NC_VERB_LEVEL level, const char* message)
2828
{
29-
logCallback(libnetconf::utils::toLogLevel(level), message);
29+
logCallback(session, libnetconf::utils::toLogLevel(level), message);
3030
}
3131

3232

@@ -165,7 +165,7 @@ void setLogLevel(LogLevel level)
165165
void setLogCallback(const client::LogCb& callback)
166166
{
167167
impl::logCallback = callback;
168-
nc_set_print_clb(callback ? impl::logViaCallback : NULL);
168+
nc_set_print_clb_session(callback ? impl::logViaCallback : NULL);
169169
}
170170

171171
libyang::Context Session::libyangContext()

tests/client.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ TEST_CASE("client")
9191
}
9292
}
9393
)";
94-
logCb = [&logBuf, &logMtx](const auto, const auto msg) {
94+
logCb = [&logBuf, &logMtx](const auto, const auto, const auto msg) {
9595
std::unique_lock lck{logMtx};
9696
logBuf += "\n";
9797
logBuf += msg;

0 commit comments

Comments
 (0)