dbus: display D-Bus API versions implemented by the manager and gpiocli
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 14 Oct 2024 13:13:28 +0000 (15:13 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 14 Oct 2024 13:13:28 +0000 (15:13 +0200)
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 <bartosz.golaszewski@linaro.org>
dbus/client/gpiocli.c
dbus/lib/gpiodbus.h
dbus/manager/gpio-manager.c

index fbd1bbe067fe07f07d86b49f38de0f39bbe2d910..e9ab38096c255d6c24880094d5e8abddfc1c196b 100644 (file)
@@ -2,6 +2,7 @@
 // SPDX-FileCopyrightText: 2022-2023 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
 
 #include <glib/gstdio.h>
+#include <gpiodbus.h>
 
 #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);
 }
index 69362f006aa9964e21ba265cb3dd76f68d8f8279..025c9c8586818051719078ba9d240f6d8b39e016 100644 (file)
@@ -4,6 +4,8 @@
 #ifndef __GPIODBUS_H__
 #define __GPIODBUS_H__
 
+#define GPIODBUS_API_VERSION 1
+
 #include "generated-gpiodbus.h"
 
 #endif /* __GPIODBUS_H__ */
index e07641d3068120b1c8e1da1f842cbbf04a127fe5..d34c7ea96c2165a6da0e2375c565594a9b9f2696 100644 (file)
@@ -5,6 +5,7 @@
 #include <glib.h>
 #include <glib-unix.h>
 #include <gpiod-glib.h>
+#include <gpiodbus.h>
 #include <stdlib.h>
 
 #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);
 }