From b9732abae7857c5873eec7fbd96924c2403e4a0f Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sun, 17 Nov 2013 07:49:50 -0500 Subject: Suppress path rewrites in one important special case. --- drivers.c | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'drivers.c') diff --git a/drivers.c b/drivers.c index b25fa7b3..f6b9ee04 100644 --- a/drivers.c +++ b/drivers.c @@ -1433,27 +1433,30 @@ static gps_mask_t json_pass_packet(struct gps_device_t *session) gpsd_report(session->context->debug, LOG_IO, "<= GPS: %s\n", (char *)session->packet.outbuffer); - /*@-nullpass@*/ /* required only because splint is buggy */ - /* devices and paths need to be edited */ - 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 (session->gpsdata.dev.path[0] != '\0') { - if (strstr((char *)session->packet.outbuffer, "VERSION") != NULL - || strstr((char *)session->packet.outbuffer, "WATCH") != NULL - || strstr((char *)session->packet.outbuffer, "DEVICES") != NULL) { - session->packet.outbuffer[session->packet.outbuflen-1] = '\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)); + if (strncmp(session->gpsdata.dev.path, "gpsd://localhost:", 17) != 0) + { + /*@-nullpass@*/ /* required only because splint is buggy */ + /* devices and paths need to be edited */ + 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 (session->gpsdata.dev.path[0] != '\0') { + if (strstr((char *)session->packet.outbuffer, "VERSION") != NULL + || strstr((char *)session->packet.outbuffer, "WATCH") != NULL + || strstr((char *)session->packet.outbuffer, "DEVICES") != NULL) { + session->packet.outbuffer[session->packet.outbuflen-1] = '\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)); + } + session->packet.outbuflen = strlen((char *)session->packet.outbuffer); } - session->packet.outbuflen = strlen((char *)session->packet.outbuffer); } gpsd_report(session->context->debug, LOG_PROG, "JSON, passing through %s\n", -- cgit v1.2.1