summaryrefslogtreecommitdiff
path: root/gpsdecode.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-02-28 21:27:28 -0500
committerEric S. Raymond <esr@thyrsus.com>2011-02-28 21:27:28 -0500
commit421ad6171b3b9b7164dcc0b2fd92f0374af105ba (patch)
tree229ef387f5c2b6cc027625090ef544a28e93ce61 /gpsdecode.c
parentd2df1e6c25ea8c58d125575104edf4b724c2284c (diff)
downloadgpsd-421ad6171b3b9b7164dcc0b2fd92f0374af105ba.tar.gz
Simplify the encoding side of gpsdecode.
All regression tests pass.
Diffstat (limited to 'gpsdecode.c')
-rw-r--r--gpsdecode.c26
1 files changed, 9 insertions, 17 deletions
diff --git a/gpsdecode.c b/gpsdecode.c
index 11322d07..6ea84946 100644
--- a/gpsdecode.c
+++ b/gpsdecode.c
@@ -414,13 +414,16 @@ static void decode(FILE *fpin, FILE *fpout)
/*@ -compdestroy @*/
static void encode(FILE * fpin, FILE * fpout)
-/* dump format on fpin to RTCM-104 on fpout */
+/* JSON format on fpin to JSON on fpout - idempotency test */
{
char inbuf[BUFSIZ];
+ struct policy_t policy;
struct gps_data_t gpsdata;
int lineno = 0;
- memset(&gpsdata, '\0', sizeof(gpsdata)); /* avoid segfault due to garbage in thread-hook slots */
+ memset(&policy, '\0', sizeof(policy));
+ policy.json = json;
+
while (fgets(inbuf, (int)sizeof(inbuf), fpin) != NULL) {
int status;
@@ -434,21 +437,10 @@ static void encode(FILE * fpin, FILE * fpout)
status, json_error_string(status), lineno);
exit(1);
}
-#ifdef RTCM104V2_ENABLE
- if ((gpsdata.set & RTCM2_SET) != 0) {
- /* this works */
- char outbuf[BUFSIZ];
- json_rtcm2_dump(&gpsdata.rtcm2, NULL, outbuf, sizeof(outbuf));
- (void)fputs(outbuf, fpout);
- }
-#endif
-#ifdef AIVDM_ENABLE
- if ((gpsdata.set & AIS_SET) != 0) {
- char outbuf[BUFSIZ];
- json_aivdm_dump(&gpsdata.ais, NULL, false, outbuf, sizeof(outbuf));
- (void)fputs(outbuf, fpout);
- }
-#endif /* AIVDM_ENABLE */
+ json_data_report(gpsdata.set,
+ &gpsdata, &policy,
+ inbuf, sizeof(inbuf));
+ (void)fputs(inbuf, fpout);
}
}