b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: b.a.t.m.a.n@lists.open-mesh.org
Cc: "Andrew Lunn" <andrew@lunn.ch>,
	"Steffen Möller" <steffen_moeller@gmx.de>,
	"Sven Eckelmann" <sven@narfation.org>
Subject: [PATCH] alfred-gpsd: Fix build against gpsd ABI 9.0
Date: Wed, 15 Jan 2020 21:01:58 +0100	[thread overview]
Message-ID: <20200115200158.2920-1-sven@narfation.org> (raw)

libgpsd 3.20 removed the timestamp_t type and the function
unix_to_iso8601(). The same release introduced the timespec_t based
function timespec_to_iso8601().

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 gpsd/alfred-gpsd.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/gpsd/alfred-gpsd.c b/gpsd/alfred-gpsd.c
index 884bdbf..47d6a64 100644
--- a/gpsd/alfred-gpsd.c
+++ b/gpsd/alfred-gpsd.c
@@ -8,6 +8,8 @@
 
 #include "alfred-gpsd.h"
 
+#include <time.h>
+
 static struct globals gpsd_globals;
 
 static int alfred_open_sock(struct globals *globals)
@@ -64,19 +66,31 @@ static int gpsd_publish_data(struct globals *globals)
 	return 0;
 }
 
+static void gpsd_now_to_iso8601(char *tbuf, size_t len)
+{
+#if GPSD_API_MAJOR_VERSION >= 9
+	timespec_t now;
+
+	clock_gettime(CLOCK_REALTIME, &now);
+	timespec_to_iso8601(now, tbuf, len);
+#else
+	timestamp_t now = timestamp();
+	unix_to_iso8601(now, tbuf, len);
+#endif
+}
+
 static void gpsd_get_location(struct globals *globals)
 {
 	if (globals->source == SOURCE_CMDLINE) {
 		char tbuf[JSON_DATE_MAX+1];
-		timestamp_t now = timestamp();
 
+		gpsd_now_to_iso8601(tbuf, sizeof(tbuf));
 		sprintf(globals->gpsd_data->tpv,
 			"{\"class\":\"TPV\",\"device\":\"command line\","
 			"\"time\":\"%s\","
 			"\"lat\":%f,\"lon\":%f,\"alt\":%f,"
 			"\"mode\":3}",
-			unix_to_iso8601(now, tbuf, sizeof(tbuf)),
-			globals->lat, globals->lon, globals->alt);
+			tbuf, globals->lat, globals->lon, globals->alt);
 		globals->gpsd_data->tpv_len =
 			htonl(strlen(globals->gpsd_data->tpv) + 1);
 	}
-- 
2.20.1


                 reply	other threads:[~2020-01-15 20:01 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200115200158.2920-1-sven@narfation.org \
    --to=sven@narfation.org \
    --cc=andrew@lunn.ch \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=steffen_moeller@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).