summaryrefslogtreecommitdiff
path: root/libgps_json.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2009-11-18 19:58:38 +0000
committerEric S. Raymond <esr@thyrsus.com>2009-11-18 19:58:38 +0000
commit32d58dffbe4e421690e39b704208ccdefe7584a5 (patch)
tree3d5ac9052e9a061c4602ae89ceba89471f736324 /libgps_json.c
parent5cb985a6603505f5fc5268ee4ac9a51a49b52a0a (diff)
downloadgpsd-32d58dffbe4e421690e39b704208ccdefe7584a5.tar.gz
Keep validity flags for the client-side union in a valid state.
Ensure that when libgps updates any member of the union, the validity flags for others are cleared.
Diffstat (limited to 'libgps_json.c')
-rw-r--r--libgps_json.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libgps_json.c b/libgps_json.c
index e9069b68..cee37026 100644
--- a/libgps_json.c
+++ b/libgps_json.c
@@ -221,6 +221,7 @@ static int json_devicelist_read(const char *buf,
}
gpsdata->devices.time = timestamp();
+ gpsdata->set =~ UNION_SET;
gpsdata->set |= DEVICELIST_SET;
return 0;
}
@@ -248,6 +249,7 @@ static int json_version_read(const char *buf,
if (status != 0)
return status;
+ gpsdata->set =~ UNION_SET;
gpsdata->set |= VERSION_SET;
return 0;
}
@@ -271,6 +273,7 @@ static int json_error_read(const char *buf,
if (status != 0)
return status;
+ gpsdata->set =~ UNION_SET;
gpsdata->set |= ERR_SET;
return 0;
}
@@ -292,8 +295,10 @@ int libgps_json_unpack(const char *buf, struct gps_data_t *gpsdata)
return status;
} else if (strstr(buf, "\"class\":\"WATCH\"") != 0) {
status = json_watch_read(buf, &gpsdata->policy, NULL);
- if (status == 0)
+ if (status == 0) {
+ gpsdata->set =~ UNION_SET;
gpsdata->set |= POLICY_SET;
+ }
return status;
} else if (strstr(buf, "\"class\":\"VERSION\"") != 0) {
return json_version_read(buf, gpsdata, NULL);
@@ -302,8 +307,10 @@ int libgps_json_unpack(const char *buf, struct gps_data_t *gpsdata)
status = json_rtcm2_read(buf,
gpsdata->dev.path, sizeof(gpsdata->dev.path),
&gpsdata->rtcm2, NULL);
- if (status == 0)
+ if (status == 0) {
+ gpsdata->set =~ UNION_SET;
gpsdata->set |= RTCM2_SET;
+ }
return status;
#endif /* RTCM104V2_ENABLE */
#ifdef AIVDM_ENABLE
@@ -311,8 +318,10 @@ int libgps_json_unpack(const char *buf, struct gps_data_t *gpsdata)
status = json_ais_read(buf,
gpsdata->dev.path, sizeof(gpsdata->dev.path),
&gpsdata->ais, NULL);
- if (status == 0)
+ if (status == 0) {
+ gpsdata->set =~ UNION_SET;
gpsdata->set |= AIS_SET;
+ }
return status;
#endif /* AIVDM_ENABLE */
} else if (strstr(buf, "\"class\":\"ERROR\"") != 0) {