summaryrefslogtreecommitdiff
path: root/libgps_sock.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2011-09-27 14:50:59 -0400
committerEric S. Raymond <esr@thyrsus.com>2011-09-27 14:50:59 -0400
commitc7d7030b8881be73bbbe1492ef4ddd6892d81a2f (patch)
treee9e3575c6e1a4a57859c085edf7e2ee2b1bc113a /libgps_sock.c
parentd0c9777345d50ac189f88914f3980b2fc8161035 (diff)
downloadgpsd-c7d7030b8881be73bbbe1492ef4ddd6892d81a2f.tar.gz
More refactoring.
gpxlogger currently works with socket and DBUS methods but fails with a segfault in the shm code.
Diffstat (limited to 'libgps_sock.c')
-rw-r--r--libgps_sock.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/libgps_sock.c b/libgps_sock.c
index 5a5b425c..ae4d45c3 100644
--- a/libgps_sock.c
+++ b/libgps_sock.c
@@ -565,6 +565,22 @@ int gps_sock_stream(struct gps_data_t *gpsdata, unsigned int flags,
}
}
+int gps_sock_mainloop(struct gps_data_t *gpsdata, int timeout,
+ void (*hook)(struct gps_data_t *gpsdata))
+/* run a socket main loop with a specified handler */
+{
+ for (;;) {
+ if (!gps_waiting(gpsdata, timeout)) {
+ return -1;
+ } else {
+ (void)gps_read(gpsdata);
+ (*hook)(gpsdata);
+ }
+ }
+ (void)gps_close(gpsdata);
+ return 0;
+}
+
#endif /* SOCKET_EXPORT_ENABLE */
/* end */