summaryrefslogtreecommitdiff
path: root/gpxlogger.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-09-27 15:49:40 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-09-27 15:49:40 -0400
commite7ad4f5d8ccb1203b6590c763444755c58a1d759 (patch)
treeabe00dad0624148a28228fba247a54b9567384a4 /gpxlogger.c
parentc7d7030b8881be73bbbe1492ef4ddd6892d81a2f (diff)
downloadgpsd-e7ad4f5d8ccb1203b6590c763444755c58a1d759.tar.gz
Converge the library APIs for different transports more closely.
Diffstat (limited to 'gpxlogger.c')
-rw-r--r--gpxlogger.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/gpxlogger.c b/gpxlogger.c
index 18c128a8..f9e35bb5 100644
--- a/gpxlogger.c
+++ b/gpxlogger.c
@@ -126,7 +126,7 @@ static void print_fix(struct gps_data_t *gpsdata, double time)
(void)fflush(logfile);
}
-static void conditionally_log_fix(struct gps_data_t *gpsdata)
+static int conditionally_log_fix(struct gps_data_t *gpsdata, bool fix UNUSED)
{
static double int_time, old_int_time;
static double old_lat, old_lon;
@@ -134,14 +134,14 @@ static void conditionally_log_fix(struct gps_data_t *gpsdata)
int_time = gpsdata->fix.time;
if ((int_time == old_int_time) || gpsdata->fix.mode < MODE_2D)
- return;
+ return 0;
/* may not be worth logging if we've moved only a very short distance */
if (minmove>0 && !first && earth_distance(
gpsdata->fix.latitude,
gpsdata->fix.longitude,
old_lat, old_lon) < minmove)
- return;
+ return 0;
/*
* Make new track if the jump in time is above
@@ -170,6 +170,8 @@ static void conditionally_log_fix(struct gps_data_t *gpsdata)
old_lon = gpsdata->fix.longitude;
}
print_fix(gpsdata, int_time);
+
+ return 0;
}
static void quit_handler(int signum)
@@ -226,17 +228,8 @@ static int socket_mainloop(void)
(void)gps_stream(&gpsdata, flags, source.device);
print_gpx_header();
- for (;;) {
- if (!gps_waiting(&gpsdata, 5000000)) {
- (void)fprintf(stderr, "%s: error while waiting\n", progname);
- break;
- } else {
- (void)gps_read(&gpsdata);
- conditionally_log_fix(&gpsdata);
- }
- }
+ gps_sock_mainloop(&gpsdata, 5000000, conditionally_log_fix);
print_gpx_footer();
- (void)gps_close(&gpsdata);
return 0;
}
/*@+mustfreefresh +compdestroy@*/
@@ -267,7 +260,7 @@ static int shm_mainloop(void)
if (status == -1)
break;
if (status > 0)
- conditionally_log_fix(&gpsdata);
+ conditionally_log_fix(&gpsdata, true);
}
print_gpx_footer();
(void)gps_close(&gpsdata);