summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers.c16
-rw-r--r--gpsd.h-tail1
-rw-r--r--gpsdecode.c2
-rw-r--r--timebase.c23
4 files changed, 27 insertions, 15 deletions
diff --git a/drivers.c b/drivers.c
index 2db8bc39..99ac5dc7 100644
--- a/drivers.c
+++ b/drivers.c
@@ -30,21 +30,7 @@ gps_mask_t generic_parse_input(struct gps_device_t *session)
const struct gps_type_t **dp;
if (session->packet.type == COMMENT_PACKET) {
- unsigned char *cp;
- int year;
- /*
- * Interpret "Date: dd mmm yyyy", setting the session context
- * century from the year. We do this so the behavior of the
- * regression tests won't depend on what century the daemon
- * started up in.
- */
- if (strstr((char *)session->packet.outbuffer, "Date:") != NULL) {
- cp = session->packet.outbuffer + strlen((char *)session->packet.outbuffer) - 1;
- while (isspace(*cp))
- --cp;
- year = atoi((char *)cp - 4);
- session->context->century = year - (year % 100);
- }
+ gpsd_set_century(session);
return 0;
#ifdef NMEA_ENABLE
} else if (session->packet.type == NMEA_PACKET) {
diff --git a/gpsd.h-tail b/gpsd.h-tail
index 89b5c4ff..9223b73e 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -661,6 +661,7 @@ extern void gpsd_assert_sync(struct gps_device_t *);
extern void gpsd_close(struct gps_device_t *);
extern void gpsd_time_init(struct gps_context_t *, time_t);
+extern void gpsd_set_century(struct gps_device_t *);
extern timestamp_t gpsd_gpstime_resolve(/*@in@ */ struct gps_device_t *,
const unsigned short, const double);
extern timestamp_t gpsd_utc_resolve(/*@in@*/struct gps_device_t *);
diff --git a/gpsdecode.c b/gpsdecode.c
index ca1f3600..529f180a 100644
--- a/gpsdecode.c
+++ b/gpsdecode.c
@@ -411,6 +411,8 @@ static void decode(FILE *fpin, FILE*fpout)
if (changed == ERROR_SET || changed == NODATA_IS)
break;
+ if (session.packet.type == COMMENT_PACKET)
+ gpsd_set_century(&session);
if (verbose >= 1 && TEXTUAL_PACKET_TYPE(session.packet.type))
(void)fputs((char *)session.packet.outbuffer, fpout);
if ((changed & (REPORT_IS|SUBFRAME_SET|AIS_SET|RTCM2_SET|RTCM3_SET|PASSTHROUGH_IS)) == 0)
diff --git a/timebase.c b/timebase.c
index 7ab2079d..b69191b2 100644
--- a/timebase.c
+++ b/timebase.c
@@ -77,6 +77,10 @@ BSD terms apply: see the file COPYING in the distribution root for details.
*****************************************************************************/
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+
#include "gpsd.h"
#include "timebase.h"
@@ -116,6 +120,25 @@ void gpsd_time_init(struct gps_context_t *context, time_t starttime)
}
}
+void gpsd_set_century(struct gps_device_t *session)
+/*
+ * Interpret "Date: dd mmm yyyy", setting the session context
+ * century from the year. We do this so the behavior of the
+ * regression tests won't depend on what century the daemon
+ * started up in.
+ */
+{
+ unsigned char *cp;
+ int year;
+ if (strstr((char *)session->packet.outbuffer, "Date:") != NULL) {
+ cp = session->packet.outbuffer + strlen((char *)session->packet.outbuffer) - 1;
+ while (isspace(*cp))
+ --cp;
+ year = atoi((char *)cp - 4);
+ session->context->century = year - (year % 100);
+ }
+}
+
#ifdef NMEA_ENABLE
timestamp_t gpsd_utc_resolve(/*@in@*/struct gps_device_t *session)
/* resolve a UTC date, checking for rollovers */