diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-09-04 10:14:17 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-09-04 10:14:17 +0000 |
commit | 8ec5a4fe3400e4af5e8b49fb2f76160def1f015b (patch) | |
tree | b60562102617e938b8edea676249a6bca18776d1 /ais_json.c | |
parent | eff52aa6de15dc7702e9996496bb05a36f7ea75a (diff) | |
download | gpsd-8ec5a4fe3400e4af5e8b49fb2f76160def1f015b.tar.gz |
IS8601 dump format and some defaults were slightly wrong.
On the client side, interpreted message 4 and 5 timestamp fields.
Diffstat (limited to 'ais_json.c')
-rw-r--r-- | ais_json.c | 32 |
1 files changed, 26 insertions, 6 deletions
@@ -45,11 +45,35 @@ int json_ais_read(const char *buf, if (strstr(buf, "\"type\":1,")!=NULL || strstr(buf, "\"type\":2,")!=NULL || strstr(buf, "\"type\":3,")!=NULL) { status = json_read_object(buf, json_ais1, endptr); } else if (strstr(buf, "\"type\":4,") != NULL || strstr(buf, "\"type\":11,")!=NULL) { - // FIXME: Needs processing to handle timestamp field status = json_read_object(buf, json_ais4, endptr); - // FIXME: Needs processing to handle eta field + if (status == 0) { + ais->type4.year = AIS_YEAR_NOT_AVAILABLE; + ais->type4.month = AIS_MONTH_NOT_AVAILABLE; + ais->type4.day = AIS_DAY_NOT_AVAILABLE; + ais->type4.hour = AIS_HOUR_NOT_AVAILABLE; + ais->type4.minute = AIS_MINUTE_NOT_AVAILABLE; + ais->type4.second = AIS_SECOND_NOT_AVAILABLE; + (void)sscanf(timestamp, "%4u-%02u-%02uT%02u:%02u:%02uZ", + &ais->type4.year, + &ais->type4.month, + &ais->type4.day, + &ais->type4.hour, + &ais->type4.minute, + &ais->type4.second); + } } else if (strstr(buf, "\"type\":5,") != NULL) { status = json_read_object(buf, json_ais5, endptr); + if (status == 0) { + ais->type5.month = AIS_MONTH_NOT_AVAILABLE; + ais->type5.day = AIS_DAY_NOT_AVAILABLE; + ais->type5.hour = AIS_HOUR_NOT_AVAILABLE; + ais->type5.minute = AIS_MINUTE_NOT_AVAILABLE; + (void)sscanf(eta, "%02u-%02uT%02u:%02uZ", + &ais->type5.month, + &ais->type5.day, + &ais->type5.hour, + &ais->type5.minute); + } } else if (strstr(buf, "\"type\":6,") != NULL) { // FIXME: requires postprocessing of data field status = json_read_object(buf, json_ais6, endptr); @@ -86,10 +110,6 @@ int json_ais_read(const char *buf, } else if (strstr(buf, "\"type\":22,") != NULL) { status = json_read_object(buf, json_ais22, endptr); } else if (strstr(buf, "\"type\":24,") != NULL) { - /* - * Note: the parser doesn't check that attributes corresponding - * to union fields aren't stepping on each other. - */ status = json_read_object(buf, json_ais24, endptr); } else { return JSON_ERR_MISC; |