diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-11-17 07:49:50 -0500 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-11-17 07:49:50 -0500 |
commit | b9732abae7857c5873eec7fbd96924c2403e4a0f (patch) | |
tree | 8a923d730c937ddeea5af3d222bcec1c484de0af /drivers.c | |
parent | 881be972b47712a69a8b433652fe407717c09331 (diff) | |
download | gpsd-b9732abae7857c5873eec7fbd96924c2403e4a0f.tar.gz |
Suppress path rewrites in one important special case.
Diffstat (limited to 'drivers.c')
-rw-r--r-- | drivers.c | 43 |
1 files changed, 23 insertions, 20 deletions
@@ -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", |