diff options
author | Andreas Schneider <asn@cynapses.org> | 2010-06-24 09:16:58 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cynapses.org> | 2010-06-24 09:16:58 +0200 |
commit | fd45c1b36b4ccb9247af1cf69a07fda1152f6c72 (patch) | |
tree | a488072a24cc83976b1638eace9c7ca1576ffbd3 | |
parent | 508067158162df11cd07a2b264b12f07c6d78e46 (diff) | |
download | libssh-fd45c1b36b4ccb9247af1cf69a07fda1152f6c72.tar.gz libssh-fd45c1b36b4ccb9247af1cf69a07fda1152f6c72.tar.xz libssh-fd45c1b36b4ccb9247af1cf69a07fda1152f6c72.zip |
poll: Fixed building with poll-emulation on UNIX.
-rw-r--r-- | libssh/poll.c | 14 | ||||
-rw-r--r-- | libssh/socket.c | 3 |
2 files changed, 10 insertions, 7 deletions
diff --git a/libssh/poll.c b/libssh/poll.c index 59d37647..b565ed8c 100644 --- a/libssh/poll.c +++ b/libssh/poll.c @@ -71,27 +71,27 @@ int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) { #include <sys/types.h> +typedef int (*poll_fn)(ssh_pollfd_t *, nfds_t, int); +static poll_fn win_poll; + #ifdef _WIN32 #ifndef STRICT #define STRICT -#endif +#endif /* STRICT */ #include <time.h> #include <windows.h> #include <winsock2.h> #define WS2_LIBRARY "ws2_32.dll" -typedef int (*poll_fn)(ssh_pollfd_t *, nfds_t, int); - -static poll_fn win_poll; static HINSTANCE hlib; -#else +#else /* _WIN32 */ #include <sys/select.h> #include <sys/socket.h> #include <unistd.h> #include <sys/time.h> -#endif +#endif /* _WIN32 */ /* @@ -214,10 +214,12 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) { void ssh_poll_init(void) { poll_fn wsa_poll = NULL; +#ifdef _WIN32 hlib = LoadLibrary(WS2_LIBRARY); if (hlib != NULL) { wsa_poll = (poll_fn) GetProcAddress(hlib, "WSAPoll"); } +#endif /* _WIN32 */ if (wsa_poll == NULL) { win_poll = bsd_poll; diff --git a/libssh/socket.c b/libssh/socket.c index d074ed47..c88a149d 100644 --- a/libssh/socket.c +++ b/libssh/socket.c @@ -72,8 +72,9 @@ int ssh_socket_init(void) { return -1; } - ssh_poll_init(); #endif + ssh_poll_init(); + return 0; } /* |