diff options
| author | Aris Adamantiadis <aris@0xbadc0de.be> | 2008-03-07 01:45:05 +0000 |
|---|---|---|
| committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2008-03-07 01:45:05 +0000 |
| commit | 29997022c812a5ac47c1c96cbea4d8cee339b532 (patch) | |
| tree | 9211b4ceac9dc49ddacfe011882af2db32ee2d9f /libssh/server.c | |
| parent | 5029fe9d74d0fbc93cc2756d8b48d1bb462e3f39 (diff) | |
| download | libssh-29997022c812a5ac47c1c96cbea4d8cee339b532.tar.gz libssh-29997022c812a5ac47c1c96cbea4d8cee339b532.tar.xz libssh-29997022c812a5ac47c1c96cbea4d8cee339b532.zip | |
first part of win32 patches
git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@141 7dcaeef0-15fb-0310-b436-a5af3365683c
Diffstat (limited to 'libssh/server.c')
| -rw-r--r-- | libssh/server.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/libssh/server.c b/libssh/server.c index 06d5879f..4f28c6a1 100644 --- a/libssh/server.c +++ b/libssh/server.c @@ -25,10 +25,22 @@ MA 02111-1307, USA. */ #include <fcntl.h> #include <unistd.h> #include <stdio.h> -#include <sys/types.h> +#ifdef _WIN32 +#include <winsock2.h> +#define SOCKOPT_TYPE_ARG4 char + +/* We need to provide hstrerror. Not we can't call the parameter h_errno because it's #defined */ +inline char* hstrerror(int h_errno_val) { + static char text[50]; + snprintf(text,sizeof(text),"gethostbyname error %d\n", h_errno_val); + return text; +} +#else #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> +#define SOCKOPT_TYPE_ARG4 int +#endif #include <errno.h> #include <string.h> #include <stdlib.h> @@ -36,10 +48,12 @@ MA 02111-1307, USA. */ #include "libssh/libssh.h" #include "libssh/server.h" #include "libssh/ssh2.h" -static int bind_socket(SSH_BIND *ssh_bind,char *hostname, int port) { + +// TODO: must use getaddrinfo +static socket_t bind_socket(SSH_BIND *ssh_bind,char *hostname, int port) { struct sockaddr_in myaddr; int opt = 1; - int s = socket(PF_INET, SOCK_STREAM, 0); + socket_t s = socket(PF_INET, SOCK_STREAM, 0); struct hostent *hp=NULL; #ifdef HAVE_GETHOSTBYNAME hp=gethostbyname(hostname); |
