diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-07-29 16:08:10 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-07-29 16:08:10 +0000 |
commit | 29200545c8a666de3ec69fa951f90e72a63b8236 (patch) | |
tree | f989a31ba14ef928f97029f6da5fdfd87c2da01d /libgps.c | |
parent | 42bbb63a1b66ee64e297d432689833d970a16ed8 (diff) | |
download | gpsd-29200545c8a666de3ec69fa951f90e72a63b8236.tar.gz |
Update client library to read current JSON - not yet tested.
Diffstat (limited to 'libgps.c')
-rw-r--r-- | libgps.c | 30 |
1 files changed, 15 insertions, 15 deletions
@@ -82,29 +82,29 @@ static void gps_unpack(char *buf, struct gps_data_t *gpsdata) char *ns, *sp, *tp; int i; - /* - * Get the decimal separator for the current application locale. - * This looks thread-unsafe, but it's not. The key is that - * character assignment is atomic. - */ - static char decimal_point = '\0'; - if (decimal_point == '\0') { - struct lconv *locale_data = localeconv(); - if (locale_data != NULL && locale_data->decimal_point[0] != '.') - decimal_point = locale_data->decimal_point[0]; - } - #ifdef GPSDNG_ENABLE /* detect and process a JSON response */ - if (buf[0] == '!' && (sp = strchr(buf, '='))!=NULL && sp[1] == '{') { - if (strncmp(buf, "!TPV=", 5) == 0) { + if (buf[0] == '{' && (sp = strchr(buf, '='))!= NULL) { + if (strstr(buf, "\"class\":\"TPV\"") == 0) { json_tpv_read(buf+5, gpsdata); - } else if (strncmp(buf, "!SKY=", 5) == 0) { + } else if (strstr(buf, "\"class\":\"SKY\"") == 0) { json_sky_read(buf+5, gpsdata); } } else #endif /* GPSDNG_ENABLE */ { + /* + * Get the decimal separator for the current application locale. + * This looks thread-unsafe, but it's not. The key is that + * character assignment is atomic. + */ + static char decimal_point = '\0'; + if (decimal_point == '\0') { + struct lconv *locale_data = localeconv(); + if (locale_data != NULL && locale_data->decimal_point[0] != '.') + decimal_point = locale_data->decimal_point[0]; + } + for (ns = buf; ns; ns = strstr(ns+1, "GPSD")) { if (/*@i1@*/strncmp(ns, "GPSD", 4) == 0) { bool eol = false; |