From cfbaa54427ba9b8e9e1bf30f5a28a33e90d99d2f Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Mon, 14 Oct 2024 15:13:28 +0200 Subject: [PATCH] dbus: display D-Bus API versions implemented by the manager and gpiocli When passing -v/--version to gpiocli or gpio-manager, it's useful to also know the version of the GPIO D-Bus API the program implements. Define the version in the gpiodbus.h header and print it together with the library version. Signed-off-by: Bartosz Golaszewski --- dbus/client/gpiocli.c | 4 +++- dbus/lib/gpiodbus.h | 2 ++ dbus/manager/gpio-manager.c | 4 +++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/dbus/client/gpiocli.c b/dbus/client/gpiocli.c index fbd1bbe..e9ab380 100644 --- a/dbus/client/gpiocli.c +++ b/dbus/client/gpiocli.c @@ -2,6 +2,7 @@ // SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski #include +#include #include "common.h" @@ -115,7 +116,8 @@ static gchar *make_description(void) static void show_version_and_exit(void) { - g_print("gpiocli v%s\n", GPIOD_VERSION_STR); + g_print("gpiocli (libgpiod) v%s\nD-Bus API version: %d\n", + GPIOD_VERSION_STR, GPIODBUS_API_VERSION); exit(EXIT_SUCCESS); } diff --git a/dbus/lib/gpiodbus.h b/dbus/lib/gpiodbus.h index 69362f0..025c9c8 100644 --- a/dbus/lib/gpiodbus.h +++ b/dbus/lib/gpiodbus.h @@ -4,6 +4,8 @@ #ifndef __GPIODBUS_H__ #define __GPIODBUS_H__ +#define GPIODBUS_API_VERSION 1 + #include "generated-gpiodbus.h" #endif /* __GPIODBUS_H__ */ diff --git a/dbus/manager/gpio-manager.c b/dbus/manager/gpio-manager.c index e07641d..d34c7ea 100644 --- a/dbus/manager/gpio-manager.c +++ b/dbus/manager/gpio-manager.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "daemon.h" @@ -76,7 +77,8 @@ static void on_name_lost(GDBusConnection *con, static void print_version_and_exit(void) { - g_print("%s (libgpiod) v%s\n", g_get_prgname(), gpiodglib_api_version()); + g_print("%s (libgpiod) v%s\nD-Bus API version: %d\n", + g_get_prgname(), gpiodglib_api_version(), GPIODBUS_API_VERSION); exit(EXIT_SUCCESS); } -- 2.30.2