summaryrefslogtreecommitdiff
path: root/libgps_core.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-06-08 14:17:15 -0400
committerEric S. Raymond <esr@thyrsus.com>2010-06-08 14:17:15 -0400
commitb7336b07a2b2e554d950c999b9e64b2823d07139 (patch)
tree8ef53c0fce5c1f0a2f3a382b784eac63a30db98d /libgps_core.c
parent423df1ff3a2201c5b0e9d90359464b2c9fa11575 (diff)
downloadgpsd-b7336b07a2b2e554d950c999b9e64b2823d07139.tar.gz
Introduce the gps_read() entry point and use it internally.
This is as per the roadmap. Clients can still use gps_poll(). All regression tests pass. Clients run correectly live.
Diffstat (limited to 'libgps_core.c')
-rw-r--r--libgps_core.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/libgps_core.c b/libgps_core.c
index 5e16b4ee..996b42f8 100644
--- a/libgps_core.c
+++ b/libgps_core.c
@@ -541,7 +541,7 @@ bool gps_waiting(struct gps_data_t * gpsdata)
}
/*@-compdef -usedef -uniondef@*/
-int gps_poll(/*@out@*/struct gps_data_t *gpsdata)
+int gps_read(/*@out@*/struct gps_data_t *gpsdata)
/* wait for and read data being streamed from the daemon */
{
char *eol;
@@ -614,10 +614,21 @@ int gps_poll(/*@out@*/struct gps_data_t *gpsdata)
priv->waiting -= response_length;
gpsdata->set |= PACKET_SET;
- return 0;
+ return status;
}
/*@+compdef -usedef +uniondef@*/
+int gps_poll(/*@out@*/struct gps_data_t *gpsdata)
+/* for backwards compatibility */
+{
+ int status = gps_read(gpsdata);
+
+ if (status > 0)
+ status = 0;
+
+ return status;
+}
+
int gps_send(struct gps_data_t *gpsdata, const char *fmt, ...)
/* send a command to the gpsd instance */
{
@@ -804,10 +815,10 @@ int main(int argc, char *argv[])
exit(1);
} else if (optind < argc) {
gps_set_raw_hook(collect, dumpline);
- strlcpy(buf, argv[optind], BUFSIZ);
- strlcat(buf, "\n", BUFSIZ);
- gps_send(collect, buf);
- gps_poll(collect);
+ (void)strlcpy(buf, argv[optind], BUFSIZ);
+ (void)strlcat(buf, "\n", BUFSIZ);
+ (void)gps_send(collect, buf);
+ (void)gps_read(collect);
libgps_dump_state(collect, time(NULL));
(void)gps_close(collect);
} else {
@@ -825,8 +836,8 @@ int main(int argc, char *argv[])
break;
}
collect->set = 0;
- gps_send(collect, buf);
- gps_poll(collect);
+ (void)gps_send(collect, buf);
+ (void)gps_read(collect);
libgps_dump_state(collect, time(NULL));
}
(void)gps_close(collect);