summaryrefslogtreecommitdiff
path: root/drivers.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-06-22 04:35:53 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-06-22 04:35:53 -0400
commit6d0f4732061cad5522fade68f35c95331b7aec1e (patch)
tree7dbd9b2f936671dc54d7d312a6b3ae2ba2ee05de /drivers.c
parentc62cf06bb2b9031a7d5072ee5a20eccbfbaf021d (diff)
downloadgpsd-6d0f4732061cad5522fade68f35c95331b7aec1e.tar.gz
Mark VERSION and WATCH with a remote attribute when passed from slaves.
Diffstat (limited to 'drivers.c')
-rw-r--r--drivers.c17
1 files changed, 16 insertions, 1 deletions
diff --git a/drivers.c b/drivers.c
index f737f2cc..fb7d8ef1 100644
--- a/drivers.c
+++ b/drivers.c
@@ -1229,11 +1229,26 @@ static void path_rewrite(struct gps_device_t *session, char *prefix)
static gps_mask_t json_pass_packet(struct gps_device_t *session UNUSED)
{
- /* FIX-ME: only tags the first of multiple devices on remote gpsd */
gpsd_report(LOG_IO, "<= GPS: %s\n", (char *)session->packet.outbuffer);
+
+ /* devices and paths need to be edited to */
if (strstr((char *)session->packet.outbuffer, "DEVICE") != NULL)
path_rewrite(session, "\"path\":\"");
path_rewrite(session, "\"device\":\"");
+
+ /* mark certain responses without a path or device attribute */
+ if (strstr((char *)session->packet.outbuffer, "VERSION") != NULL
+ || strstr((char *)session->packet.outbuffer, "WATCH") != NULL) {
+ session->packet.outbuffer[session->packet.outbuflen] = '\0';
+ (void)strlcat((char *)session->packet.outbuffer, ",\"remote\":\"",
+ sizeof(session->packet.outbuffer));
+ (void)strlcat((char *)session->packet.outbuffer,
+ session->gpsdata.dev.path,
+ sizeof(session->packet.outbuffer));
+ (void)strlcat((char *)session->packet.outbuffer, "\"}",
+ sizeof(session->packet.outbuffer));
+ }
+
gpsd_report (LOG_PROG,
"JSON, passing through %s\n",
(char *)session->packet.outbuffer);