diff options
-rw-r--r-- | gpspipe.c | 14 | ||||
-rw-r--r-- | os_compat.h | 6 |
2 files changed, 19 insertions, 1 deletions
@@ -37,11 +37,21 @@ #include <string.h> #include <strings.h> #include <fcntl.h> +#ifdef HAVE_TERMIOS_H #include <termios.h> +#endif /* HAVE_TERMIOS_H */ #include <sys/time.h> #include <sys/types.h> #include <sys/stat.h> +#ifdef HAVE_SYS_SELECT_H #include <sys/select.h> +#endif /* HAVE_SYS_SELECT_H */ +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif /* HAVE_SYS_SOCKET_H */ +#ifdef HAVE_WINSOCK2_H +#include <winsock2.h> +#endif /* HAVE_WINSOCK2_H */ #include <unistd.h> #include "gpsd.h" @@ -74,6 +84,7 @@ static void open_serial(char *device) exit(EXIT_FAILURE); } +#ifdef HAVE_TERMIOS_H /* Save current serial port settings for later */ if (tcgetattr(fd_out, &oldtio) != 0) { (void)fprintf(stderr, "gpspipe: error reading serial port settings\n"); @@ -94,6 +105,7 @@ static void open_serial(char *device) (void)fprintf(stderr, "gpspipe: error configuring serial port\n"); exit(EXIT_FAILURE); } +#endif /* HAVE_TERMIOS_H */ } static void usage(void) @@ -319,7 +331,7 @@ int main(int argc, char **argv) /* reading directly from the socket avoids decode overhead */ errno = 0; - r = (int)read(gpsdata.gps_fd, buf, sizeof(buf)); + r = (int)recv(gpsdata.gps_fd, buf, sizeof(buf), 0); if (r > 0) { int i = 0; int j = 0; diff --git a/os_compat.h b/os_compat.h index 9321809f..2b4189f0 100644 --- a/os_compat.h +++ b/os_compat.h @@ -114,6 +114,12 @@ size_t strlcpy(char *dst, const char *src, size_t size); #define SIGQUIT 3 #endif +/* Provide missing open flags for non-POSIX builds */ + +#ifndef O_NOCTTY +#define O_NOCTTY 0400 +#endif + # ifdef __cplusplus } # endif |