diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2010-03-30 04:48:33 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2010-03-30 04:48:33 -0400 |
commit | b6745e1d1878d305a71ef6eb6b78be47a2254f23 (patch) | |
tree | c13d064445aa958db91c2cc6d02f9f980f4d42eb /gpsd_json.c | |
parent | 72b545ecfa35b652d94f658eefda16d01c9d69f3 (diff) | |
download | gpsd-b6745e1d1878d305a71ef6eb6b78be47a2254f23.tar.gz |
Split out some functions from gpsd_json.c that are used by libgps.
Applications shouldn't need to carry around all that structure-dumping code,
Diffstat (limited to 'gpsd_json.c')
-rw-r--r-- | gpsd_json.c | 73 |
1 files changed, 2 insertions, 71 deletions
diff --git a/gpsd_json.c b/gpsd_json.c index b7e1fb06..343c2f39 100644 --- a/gpsd_json.c +++ b/gpsd_json.c @@ -4,8 +4,8 @@ NAME gpsd_json.c - move data between in-core and JSON structures DESCRIPTION - This module uses the generic JSON parser to get data from JSON -representations to gpsd core strctures, and vice_versa. + These are functions (used only by the daemon) to dump the contents +of various core data structures in JSON. PERMISSIONS Written by Eric S. Raymond, 2009 @@ -1344,73 +1344,4 @@ void aivdm_json_dump(const struct ais_t *ais, bool scaled, /*@out@*/char *buf, s #endif /* defined(AIVDM_ENABLE) */ -int json_device_read(const char *buf, - /*@out@*/struct devconfig_t *dev, - /*@null@*/const char **endptr) -{ - /*@ -fullinitblock @*/ - const struct json_attr_t json_attrs_device[] = { - {"class", t_check, .dflt.check = "DEVICE"}, - - {"path", t_string, .addr.string = dev->path, - .len = sizeof(dev->path)}, - {"activated", t_real, .addr.real = &dev->activated}, - {"flags", t_integer, .addr.integer = &dev->flags}, - {"driver", t_string, .addr.string = dev->driver, - .len = sizeof(dev->driver)}, - {"subtype", t_string, .addr.string = dev->subtype, - .len = sizeof(dev->subtype)}, - {"native", t_integer, .addr.integer = &dev->driver_mode, - .dflt.integer = DEVDEFAULT_NATIVE}, - {"bps", t_uinteger, .addr.uinteger = &dev->baudrate, - .dflt.uinteger = DEVDEFAULT_BPS}, - {"parity", t_character, .addr.character = &dev->parity, - .dflt.character = DEVDEFAULT_PARITY}, - {"stopbits", t_uinteger, .addr.uinteger = &dev->stopbits, - .dflt.uinteger = DEVDEFAULT_STOPBITS}, - {"cycle", t_real, .addr.real = &dev->cycle, - .dflt.real = NAN}, - {"mincycle", t_real, .addr.real = &dev->mincycle, - .dflt.real = NAN}, - {NULL}, - }; - /*@ +fullinitblock @*/ - int status; - - status = json_read_object(buf, json_attrs_device, endptr); - if (status != 0) - return status; - - return 0; -} - -int json_watch_read(const char *buf, - /*@out@*/struct policy_t *ccp, - /*@null@*/const char **endptr) -{ - /*@ -fullinitblock @*/ - struct json_attr_t chanconfig_attrs[] = { - {"class", t_check, .dflt.check = "WATCH"}, - - {"enable", t_boolean, .addr.boolean = &ccp->watcher, - .dflt.boolean = true}, - {"json", t_boolean, .addr.boolean = &ccp->json, - .nodefault = true}, - {"raw", t_integer, .addr.integer = &ccp->raw, - .nodefault = true}, - {"nmea", t_boolean, .addr.boolean = &ccp->nmea, - .nodefault = true}, - {"scaled", t_boolean, .addr.boolean = &ccp->scaled}, - {"timing", t_boolean, .addr.boolean = &ccp->timing}, - {"device", t_string, .addr.string = ccp->devpath, - .len = sizeof(ccp->devpath)}, - {NULL}, - }; - /*@ +fullinitblock @*/ - int status; - - status = json_read_object(buf, chanconfig_attrs, endptr); - return status; -} - /* gpsd_json.c ends here */ |