summaryrefslogtreecommitdiff
path: root/gpspipe.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>2010-06-07 21:03:03 -0400
committerEric S. Raymond <esr@thyrsus.com>2010-06-07 21:03:03 -0400
commitc4bfad07e371bc40c06fca90f2d77124d5566ec2 (patch)
tree864e8cd57c840e6b4d5a91fb8f9ea00aa81ddc0a /gpspipe.c
parentef549333bb4f161cd97c3977a00d97cda906be02 (diff)
downloadgpsd-c4bfad07e371bc40c06fca90f2d77124d5566ec2.tar.gz
Use re-entrant open in the C examples.
In the next mahor API change the non-re-rentrant call will go away. All regression tests passm, code splints clean.
Diffstat (limited to 'gpspipe.c')
-rw-r--r--gpspipe.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/gpspipe.c b/gpspipe.c
index 1e0a5c54..ade902c8 100644
--- a/gpspipe.c
+++ b/gpspipe.c
@@ -47,7 +47,7 @@
#include "gpsdclient.h"
#include "revision.h"
-static struct gps_data_t *gpsdata;
+static struct gps_data_t gpsdata;
static void spinner(unsigned int, unsigned int);
/* NMEA-0183 standard baud rate */
@@ -295,8 +295,7 @@ int main(int argc, char **argv)
open_serial(serialport);
/*@ -nullpass -onlytrans @*/
- gpsdata = gps_open(source.server, source.port);
- if (gpsdata == NULL) {
+ if (gps_open_r(source.server, source.port, &gpsdata) != 0) {
(void)fprintf(stderr,
"gpspipe: could not connect to gpsd %s:%s, %s(%d)\n",
source.server, source.port, strerror(errno), errno);
@@ -306,7 +305,7 @@ int main(int argc, char **argv)
if (source.device != NULL)
flags |= WATCH_DEVICE;
- (void)gps_stream(gpsdata, flags, source.device);
+ (void)gps_stream(&gpsdata, flags, source.device);
if ((isatty(STDERR_FILENO) == 0) || daemon)
vflag = 0;
@@ -320,7 +319,7 @@ int main(int argc, char **argv)
spinner(vflag, l++);
/* reading directly from the socket avoids decode overhead */
- readbytes = (int)read(gpsdata->gps_fd, buf, sizeof(buf));
+ readbytes = (int)read(gpsdata.gps_fd, buf, sizeof(buf));
if (readbytes > 0) {
for (i = 0; i < readbytes; i++) {
char c = buf[i];