diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2013-10-08 10:34:41 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2013-10-08 10:34:41 -0400 |
commit | 615c05458b466c52979bdbcd150ced817f7aba2a (patch) | |
tree | b569f2f2a39160936688c8df8e268869f98e6ea7 /gpsd.c | |
parent | cf9a42c2c0441bd40357c75e95711f70280d8177 (diff) | |
download | gpsd-615c05458b466c52979bdbcd150ced817f7aba2a.tar.gz |
Refactoring step. All regression tests pass.
Diffstat (limited to 'gpsd.c')
-rw-r--r-- | gpsd.c | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -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, |