mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-11 10:40:27 +09:00
Fixed Windows build warnings.
This commit is contained in:
@@ -35,6 +35,7 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#define _WIN32_IE 0x0501 //SHGetSpecialFolderPath
|
#define _WIN32_IE 0x0501 //SHGetSpecialFolderPath
|
||||||
#include <winsock2.h> // Must be the first to include
|
#include <winsock2.h> // Must be the first to include
|
||||||
|
#include <ws2tcpip.h>
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <direct.h>
|
#include <direct.h>
|
||||||
#else
|
#else
|
||||||
@@ -503,7 +504,8 @@ int ssh_mkdir(const char *pathname, mode_t mode) {
|
|||||||
* @return The expanded directory, NULL on error.
|
* @return The expanded directory, NULL on error.
|
||||||
*/
|
*/
|
||||||
char *ssh_path_expand_tilde(const char *d) {
|
char *ssh_path_expand_tilde(const char *d) {
|
||||||
char *h, *r, *p;
|
char *h, *r;
|
||||||
|
const char *p;
|
||||||
size_t ld;
|
size_t ld;
|
||||||
size_t lh = 0;
|
size_t lh = 0;
|
||||||
|
|
||||||
@@ -515,6 +517,9 @@ char *ssh_path_expand_tilde(const char *d) {
|
|||||||
/* handle ~user/path */
|
/* handle ~user/path */
|
||||||
p = strchr(d, '/');
|
p = strchr(d, '/');
|
||||||
if (p != NULL && p > d) {
|
if (p != NULL && p > d) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
return strdup(d);
|
||||||
|
#else
|
||||||
struct passwd *pw;
|
struct passwd *pw;
|
||||||
size_t s = p - d;
|
size_t s = p - d;
|
||||||
char u[128];
|
char u[128];
|
||||||
@@ -530,6 +535,7 @@ char *ssh_path_expand_tilde(const char *d) {
|
|||||||
}
|
}
|
||||||
ld = strlen(p);
|
ld = strlen(p);
|
||||||
h = strdup(pw->pw_dir);
|
h = strdup(pw->pw_dir);
|
||||||
|
#endif
|
||||||
} else {
|
} else {
|
||||||
ld = strlen(d);
|
ld = strlen(d);
|
||||||
p = (char *) d;
|
p = (char *) d;
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
|
|||||||
|
|
||||||
#else /* HAVE_POLL */
|
#else /* HAVE_POLL */
|
||||||
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@@ -73,11 +72,13 @@ int ssh_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
|
|||||||
#define STRICT
|
#define STRICT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#else
|
#else
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
|
static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
|
||||||
@@ -150,9 +151,15 @@ static int bsd_poll(ssh_pollfd_t *fds, nfds_t nfds, int timeout) {
|
|||||||
char data[64] = {0};
|
char data[64] = {0};
|
||||||
|
|
||||||
/* support for POLLHUP */
|
/* support for POLLHUP */
|
||||||
|
#ifdef _WIN32
|
||||||
|
if ((recv(fds[i].fd, data, 64, MSG_PEEK) == -1) &&
|
||||||
|
(errno == WSAESHUTDOWN || errno == WSAECONNRESET ||
|
||||||
|
errno == WSAECONNABORTED || errno == WSAENETRESET)) {
|
||||||
|
#else
|
||||||
if ((recv(fds[i].fd, data, 64, MSG_PEEK) == -1) &&
|
if ((recv(fds[i].fd, data, 64, MSG_PEEK) == -1) &&
|
||||||
(errno == ESHUTDOWN || errno == ECONNRESET ||
|
(errno == ESHUTDOWN || errno == ECONNRESET ||
|
||||||
errno == ECONNABORTED || errno == ENETRESET)) {
|
errno == ECONNABORTED || errno == ENETRESET)) {
|
||||||
|
#endif
|
||||||
fds[i].revents |= POLLHUP;
|
fds[i].revents |= POLLHUP;
|
||||||
} else {
|
} else {
|
||||||
fds[i].revents |= fds[i].events & (POLLIN | POLLRDNORM);
|
fds[i].revents |= fds[i].events & (POLLIN | POLLRDNORM);
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
|
#include <ws2tcpip.h>
|
||||||
#else
|
#else
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user