summaryrefslogtreecommitdiff
path: root/gpsd_json.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-08-19 18:27:10 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-08-19 18:27:10 +0000
commit6067882a3515163318590c70474969cd2a261571 (patch)
tree0bdbe0b4749da65a357e4a5e21517ca6c882cb2f /gpsd_json.c
parent8cae7779b40a304b418d9dc75d2f52266b5fbd00 (diff)
downloadgpsd-6067882a3515163318590c70474969cd2a261571.tar.gz
Ship device flags as integer rather than string list.
Diffstat (limited to 'gpsd_json.c')
-rw-r--r--gpsd_json.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/gpsd_json.c b/gpsd_json.c
index d938a8c7..9285cc31 100644
--- a/gpsd_json.c
+++ b/gpsd_json.c
@@ -164,18 +164,15 @@ void json_device_dump(struct gps_device_t *device,
(void)strlcat(reply, device->gpsdata.gps_device, replylen);
(void)strlcat(reply, "\",", replylen);
(void)snprintf(reply+strlen(reply), replylen-strlen(reply),
- "\"activated\":%2.2f", device->gpsdata.online);
+ "\"activated\":%2.2f,", device->gpsdata.online);
if (device->observed != 0) {
- (void)strlcat(reply, "\"type\":[", replylen);
+ int mask = 0;
for (cmp = classmap; cmp < classmap+NITEMS(classmap); cmp++)
- if ((device->observed & cmp->mask) != 0) {
- (void)strlcat(reply, "\"", replylen);
- (void)strlcat(reply, cmp->name, replylen);
- (void)strlcat(reply, "\",", replylen);
- }
- if (reply[strlen(reply)-1] == ',')
- reply[strlen(reply)-1] = '\0';
- (void)strlcat(reply, "],", replylen);
+ if ((device->observed & cmp->packetmask) != 0)
+ mask |= cmp->typemask;
+ if (flags != 0)
+ (void)snprintf(reply+strlen(reply), replylen-strlen(reply),
+ "\"flags\":%d,", mask);
}
if (device->device_type != NULL) {
(void)strlcat(reply, "\"driver\":\"", replylen);
@@ -185,10 +182,11 @@ void json_device_dump(struct gps_device_t *device,
(void)strlcat(reply, "\",", replylen);
}
if (device->subtype[0] != '\0') {
- (void)strlcat(reply, "\",\"subtype\":\"", replylen);
+ (void)strlcat(reply, "\"subtype\":\"", replylen);
(void)strlcat(reply,
device->subtype,
replylen);
+ (void)strlcat(reply, "\",", replylen);
}
if (reply[strlen(reply)-1] == ',')
reply[strlen(reply)-1] = '\0';