diff options
-rw-r--r-- | cgps.c | 19 | ||||
-rw-r--r-- | gps.h | 2 | ||||
-rw-r--r-- | gpspipe.c | 9 | ||||
-rw-r--r-- | gpxlogger.c | 27 | ||||
-rw-r--r-- | lcdgps.c | 15 |
5 files changed, 34 insertions, 38 deletions
@@ -105,7 +105,7 @@ #include "gpsdclient.h" #include "revision.h" -static struct gps_data_t *gpsdata; +static struct gps_data_t gpsdata; static time_t status_timer; /* Time of last state change. */ static int state = 0; /* or MODE_NO_FIX=1, MODE_2D=2, MODE_3D=3 */ static float altfactor = METERS_TO_FEET; @@ -218,7 +218,7 @@ static void die(int sig) (void)endwin(); /* We're done talking to gpsd. */ - (void)gps_close(gpsdata); + (void)gps_close(&gpsdata); switch (sig) { case CGPS_QUIT: @@ -851,8 +851,7 @@ int main(int argc, char *argv[]) gpsd_source_spec(NULL, &source); /* Open the stream to gpsd. */ - /*@i@*/ gpsdata = gps_open(source.server, source.port); - if (!gpsdata) { + if (gps_open_r(source.server, source.port, &gpsdata) != 0) { (void)fprintf(stderr, "cgps: no gpsd running or network error: %d, %s\n", errno, gps_errstr(errno)); @@ -870,37 +869,37 @@ int main(int argc, char *argv[]) /* Here's where updates go now that things are established. */ #ifdef TRUENORTH if (compass_flag) { - gps_set_raw_hook(gpsdata, update_compass_panel); + gps_set_raw_hook(&gpsdata, update_compass_panel); } else #endif /* TRUENORTH */ { - gps_set_raw_hook(gpsdata, update_gps_panel); + gps_set_raw_hook(&gpsdata, update_gps_panel); } status_timer = time(NULL); - (void)gps_stream(gpsdata, WATCH_ENABLE, NULL); + (void)gps_stream(&gpsdata, WATCH_ENABLE, NULL); /* heart of the client */ for (;;) { /* watch to see when it has input */ FD_ZERO(&rfds); - FD_SET(gpsdata->gps_fd, &rfds); + FD_SET(gpsdata.gps_fd, &rfds); /* wait up to five seconds. */ timeout.tv_sec = 5; timeout.tv_usec = 0; /* check if we have new information */ - data = select(gpsdata->gps_fd + 1, &rfds, NULL, NULL, &timeout); + data = select(gpsdata.gps_fd + 1, &rfds, NULL, NULL, &timeout); if (data == -1) { fprintf(stderr, "cgps: socket error 3\n"); exit(2); } else if (data) { errno = 0; - if (gps_poll(gpsdata) != 0) { + if (gps_poll(&gpsdata) != 0) { fprintf(stderr, "cgps: socket error 4\n"); die(errno == 0 ? GPS_GONE : GPS_ERROR); } @@ -1098,7 +1098,7 @@ extern double wgs84_separation(double, double); #define WGS84F 298.257223563 /* flattening */ #define WGS84B 6356752.3142 /* polar radius */ -/* gps_open() errno return values */ +/* netlib_connectsock() errno return values */ #define NL_NOSERVICE -1 /* can't get service entry */ #define NL_NOHOST -2 /* can't get host entry */ #define NL_NOPROTO -3 /* can't get protocol entry */ @@ -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]; diff --git a/gpxlogger.c b/gpxlogger.c index 4eda2f6b..5e079749 100644 --- a/gpxlogger.c +++ b/gpxlogger.c @@ -299,44 +299,43 @@ static void process(struct gps_data_t *gpsdata, conditionally_log_fix(&gpsdata->fix); } -/*@-mustfreefresh@*/ +/*@-mustfreefresh -compdestroy@*/ static int socket_mainloop(void) { fd_set fds; - struct gps_data_t *gpsdata; + struct gps_data_t gpsdata; - gpsdata = gps_open(source.server, source.port); - if (!gpsdata) { - fprintf(stderr, - "%s: no gpsd running or network error: %d, %s\n", - progname, errno, gps_errstr(errno)); + if (gps_open_r(source.server, source.port, &gpsdata) != 0) { + (void)fprintf(stderr, + "%s: no gpsd running or network error: %d, %s\n", + progname, errno, gps_errstr(errno)); exit(1); } - gps_set_raw_hook(gpsdata, process); - (void)gps_stream(gpsdata, WATCH_ENABLE, NULL); + gps_set_raw_hook(&gpsdata, process); + (void)gps_stream(&gpsdata, WATCH_ENABLE, NULL); for (;;) { int data; struct timeval tv; FD_ZERO(&fds); - FD_SET(gpsdata->gps_fd, &fds); + FD_SET(gpsdata.gps_fd, &fds); tv.tv_usec = 250000; tv.tv_sec = 0; - data = select(gpsdata->gps_fd + 1, &fds, NULL, NULL, &tv); + data = select(gpsdata.gps_fd + 1, &fds, NULL, NULL, &tv); if (data == -1) { (void)fprintf(stderr, "%s\n", strerror(errno)); break; } else if (data) - (void)gps_poll(gpsdata); + (void)gps_poll(&gpsdata); } + (void)gps_close(&gpsdata); return 0; } - -/*@+mustfreefresh@*/ +/*@+mustfreefresh +compdestroy@*/ /************************************************************************** * @@ -94,7 +94,7 @@ ssize_t sockwriteline(int sockd,const void *vptr,size_t n); int send_lcd(char *buf); static struct fixsource_t source; -static struct gps_data_t *gpsdata; +static struct gps_data_t gpsdata; static float altfactor = METERS_TO_FEET; static float speedfactor = MPS_TO_MPH; static char *altunits = "ft"; @@ -471,8 +471,7 @@ int main(int argc, char *argv[]) daemonize(); /* Open the stream to gpsd. */ - /*@i@*/gpsdata = gps_open(source.server, source.port); - if (!gpsdata) { + if (gps_open_r(source.server, source.port, &gpsdata) != 0) { (void)fprintf( stderr, "cgps: no gpsd running or network error: %d, %s\n", errno, gps_errstr(errno)); @@ -520,21 +519,21 @@ int main(int argc, char *argv[]) reset_lcd(); /* Here's where updates go. */ - gps_set_raw_hook(gpsdata, update_lcd); - gps_stream(gpsdata, WATCH_ENABLE, NULL); + gps_set_raw_hook(&gpsdata, update_lcd); + gps_stream(&gpsdata, WATCH_ENABLE, NULL); for (;;) { /* heart of the client */ /* watch to see when it has input */ FD_ZERO(&rfds); - FD_SET(gpsdata->gps_fd, &rfds); + FD_SET(gpsdata.gps_fd, &rfds); /* wait up to five seconds. */ timeout.tv_sec = 5; timeout.tv_usec = 0; /* check if we have new information */ - data = select(gpsdata->gps_fd + 1, &rfds, NULL, NULL, &timeout); + data = select(gpsdata.gps_fd + 1, &rfds, NULL, NULL, &timeout); if (data == -1) { fprintf( stderr, "cgps: socket error\n"); @@ -542,7 +541,7 @@ int main(int argc, char *argv[]) } else if (data) { /* code that calls gps_poll(gpsdata) */ - (void)gps_poll(gpsdata); + (void)gps_poll(&gpsdata); } } |