Blob Blame Raw
From a1e2d1c3a88723e41efaf44a10f6374e6dfdd8df Mon Sep 17 00:00:00 2001
From: wb2osz <wb2osz@comcast.net>
Date: Sun, 17 Feb 2019 21:04:49 -0500
Subject: [PATCH] Issue 196 - Compatibility with GPSD API 7.

---
 dwgpsd.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/dwgpsd.c b/dwgpsd.c
index 5709497..ff37c68 100644
--- a/dwgpsd.c
+++ b/dwgpsd.c
@@ -57,7 +57,10 @@
 // Debian bug report:  direwolf (1.2-1) FTBFS with libgps22 as part of the gpsd transition (#803605):
 // dwgps.c claims to only support GPSD_API_MAJOR_VERSION 5, but also builds successfully with
 // GPSD_API_MAJOR_VERSION 6 provided by libgps22 when the attached patch is applied.
-#if GPSD_API_MAJOR_VERSION < 5 || GPSD_API_MAJOR_VERSION > 6
+
+// Also compatible with API 7 with conditional compilation later.
+
+#if GPSD_API_MAJOR_VERSION < 5 || GPSD_API_MAJOR_VERSION > 7
 #error libgps API version might be incompatible.
 #endif
 
@@ -257,7 +260,19 @@ static void * read_gpsd_thread (void *arg)
 	    /* Fall thru to read which should get error and bail out. */
 	  }
 
+// https://github.com/wb2osz/direwolf/issues/196
+// https://bugzilla.redhat.com/show_bug.cgi?id=1674812
+
+// gps_read has two new parameters in API version 7.
+// It looks like this could be used to obtain the JSON message from the daemon.
+// Specify NULL, instead of message buffer space, if this is not desired.
+// Why couldn't they add a new function instead of introducing incompatibility?
+
+#if GPSD_API_MAJOR_VERSION >= 7
+	  if (gps_read (&gpsdata, NULL, 0) == -1) {
+#else
 	  if (gps_read (&gpsdata) == -1) {
+#endif
 	    text_color_set(DW_COLOR_ERROR);
 
 	    dw_printf ("------------------------------------------\n");
-- 
2.20.1