diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-09-27 15:49:40 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-09-27 15:49:40 -0400 |
commit | e7ad4f5d8ccb1203b6590c763444755c58a1d759 (patch) | |
tree | abe00dad0624148a28228fba247a54b9567384a4 /libgps_core.c | |
parent | c7d7030b8881be73bbbe1492ef4ddd6892d81a2f (diff) | |
download | gpsd-e7ad4f5d8ccb1203b6590c763444755c58a1d759.tar.gz |
Converge the library APIs for different transports more closely.
Diffstat (limited to 'libgps_core.c')
-rw-r--r-- | libgps_core.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/libgps_core.c b/libgps_core.c index 6ea9f976..273b3fe2 100644 --- a/libgps_core.c +++ b/libgps_core.c @@ -173,6 +173,32 @@ int gps_stream(struct gps_data_t *gpsdata CONDITIONALLY_UNUSED, return status; } +int gps_mainloop(struct gps_data_t *gpsdata, int timeout, + int (*hook)(struct gps_data_t *gpsdata, bool)) +/* run a socket main loop with a specified handler */ +{ + int status; + + libgps_debug_trace((DEBUG_CALLS, "gps_mainloop() begins\n")); + + /*@ -usedef -compdef -uniondef @*/ +#ifdef SHM_EXPORT_ENABLE + if ((intptr_t)(gpsdata->gps_fd) == -1) { + status = gps_shm_mainloop(gpsdata, timeout, hook); + } +#endif /* SHM_EXPORT_ENABLE */ + +#ifdef SOCKET_EXPORT_ENABLE + if (status == -1) { + status = gps_sock_mainloop(gpsdata, timeout, hook); + } +#endif /* SOCKET_EXPORT_ENABLE */ + /*@ +usedef +compdef +uniondef @*/ + + libgps_debug_trace((DEBUG_CALLS, "gps_mainloop() -> %d\n")); + return status; +} + const char /*@observer@*/ *gps_data(const struct gps_data_t *gpsdata CONDITIONALLY_UNUSED) /* return the contents of the client data buffer */ { |