summaryrefslogtreecommitdiff
path: root/gpsd.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2013-10-08 10:34:41 -0400
committerEric S. Raymond <esr@thyrsus.com>2013-10-08 10:34:41 -0400
commit615c05458b466c52979bdbcd150ced817f7aba2a (patch)
treeb569f2f2a39160936688c8df8e268869f98e6ea7 /gpsd.c
parentcf9a42c2c0441bd40357c75e95711f70280d8177 (diff)
downloadgpsd-615c05458b466c52979bdbcd150ced817f7aba2a.tar.gz
Refactoring step. All regression tests pass.
Diffstat (limited to 'gpsd.c')
-rw-r--r--gpsd.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gpsd.c b/gpsd.c
index fbd6fb97..a8992a0d 100644
--- a/gpsd.c
+++ b/gpsd.c
@@ -1616,8 +1616,9 @@ static void all_reports(struct gps_device_t *device, gps_mask_t changed)
#endif /* SOCKET_EXPORT_ENABLE */
}
-static void consume_packets(struct gps_device_t *device)
-/* consume and report packets from a specified device */
+static void consume_packets(struct gps_device_t *device,
+ void (*handler)(struct gps_device_t *, gps_mask_t))
+/* consume and handle packets from a specified device */
{
gps_mask_t changed;
int fragments;
@@ -1722,8 +1723,8 @@ static void consume_packets(struct gps_device_t *device)
gps_maskdump(device->gpsdata.set));
- /* report on data contained in this packet */
- all_reports(device, changed);
+ /* handle data contained in this packet */
+ handler(device, changed);
}
}
@@ -2408,7 +2409,7 @@ int main(int argc, char *argv[])
if (device->gpsdata.gps_fd >= 0) {
if (FD_ISSET(device->gpsdata.gps_fd, &rfds))
/* get data from the device */
- consume_packets(device);
+ consume_packets(device, all_reports);
else if (device->reawake>0 && timestamp()>device->reawake) {
/* device may have had a zero-length read */
gpsd_report(context.debug, LOG_DATA,