From b47c9e94e1ef26e3f99cb60c7042e2c9e795ef9d Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Thu, 18 Sep 2014 15:10:42 -0400 Subject: Make -D option of gpsdecode effective again. --- gpsdecode.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'gpsdecode.c') diff --git a/gpsdecode.c b/gpsdecode.c index 507d7ba4..22e342f5 100644 --- a/gpsdecode.c +++ b/gpsdecode.c @@ -21,6 +21,7 @@ static bool json = true; static bool split24 = false; static unsigned int ntypes = 0; static unsigned int typelist[32]; +struct gps_context_t context; /************************************************************************** * @@ -514,7 +515,6 @@ static void decode(FILE *fpin, FILE*fpout) /* sensor data on fpin to dump format on fpout */ { struct gps_device_t session; - struct gps_context_t context; struct policy_t policy; #if defined(SOCKET_EXPORT_ENABLE) || defined(AIVDM_ENABLE) char buf[GPS_JSON_RESPONSE_MAX * 4]; @@ -526,7 +526,6 @@ static void decode(FILE *fpin, FILE*fpout) policy.json = json; policy.scaled = scaled; - gps_context_init(&context, "gpsdecode"); gpsd_time_init(&context, time(NULL)); context.readonly = true; gpsd_init(&session, &context, NULL); @@ -590,11 +589,9 @@ static void encode(FILE *fpin, FILE *fpout) struct policy_t policy; struct gps_device_t session; int lineno = 0; - struct gps_context_t context; memset(&policy, '\0', sizeof(policy)); memset(&session, '\0', sizeof(session)); - memset(&context, '\0', sizeof(context)); session.context = &context; context.errout.debug = 0; context.errout.label = "gpsdecode"; @@ -634,6 +631,8 @@ int main(int argc, char **argv) enum { doencode, dodecode } mode = dodecode; + gps_context_init(&context, "gpsdecode"); + while ((c = getopt(argc, argv, "cdejpst:uvVD:")) != EOF) { switch (c) { case 'c': @@ -677,7 +676,7 @@ int main(int argc, char **argv) break; case 'D': - verbose = atoi(optarg); + context.errout.debug = verbose = atoi(optarg); #if defined(CLIENTDEBUG_ENABLE) && defined(SOCKET_EXPORT_ENABLE) json_enable_debug(verbose - 2, stderr); #endif -- cgit v1.2.1