Commit c1c3691b authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

ws2_32: Move gethostname() to the Unix library.

parent 61b123fa
......@@ -913,6 +913,7 @@ struct WS_hostent * WINAPI WS_gethostbyname( const char *name )
{
struct WS_hostent *host = NULL;
char hostname[100];
int ret;
TRACE( "%s\n", debugstr_a(name) );
......@@ -922,9 +923,9 @@ struct WS_hostent * WINAPI WS_gethostbyname( const char *name )
return NULL;
}
if (gethostname( hostname, 100 ) == -1)
if ((ret = unix_funcs->gethostname( hostname, 100 )))
{
SetLastError( WSAENOBUFS );
SetLastError( ret );
return NULL;
}
......@@ -973,7 +974,7 @@ struct WS_hostent * WINAPI WS_gethostbyname( const char *name )
int WINAPI WS_gethostname( char *name, int namelen )
{
char buf[256];
int len;
int len, ret;
TRACE( "name %p, len %d\n", name, namelen );
......@@ -983,9 +984,9 @@ int WINAPI WS_gethostname( char *name, int namelen )
return -1;
}
if (gethostname( buf, sizeof(buf) ) != 0)
if ((ret = unix_funcs->gethostname( buf, sizeof(buf) )))
{
SetLastError( sock_get_error( errno ) );
SetLastError( ret );
return -1;
}
......@@ -1009,6 +1010,7 @@ int WINAPI WS_gethostname( char *name, int namelen )
int WINAPI GetHostNameW( WCHAR *name, int namelen )
{
char buf[256];
int ret;
TRACE( "name %p, len %d\n", name, namelen );
......@@ -1018,9 +1020,9 @@ int WINAPI GetHostNameW( WCHAR *name, int namelen )
return -1;
}
if (gethostname( buf, sizeof(buf) ))
if ((ret = unix_funcs->gethostname( buf, sizeof(buf) )))
{
SetLastError( sock_get_error( errno ) );
SetLastError( ret );
return -1;
}
......
......@@ -30,6 +30,7 @@
#include <errno.h>
#include <pthread.h>
#include <stdarg.h>
#include <unistd.h>
#include <sys/types.h>
#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
......@@ -789,11 +790,20 @@ static int CDECL unix_gethostbyname( const char *name, struct WS_hostent *const
#endif
static int CDECL unix_gethostname( char *name, int len )
{
if (!gethostname( name, len ))
return 0;
return errno_from_unix( errno );
}
static const struct unix_funcs funcs =
{
unix_getaddrinfo,
unix_gethostbyaddr,
unix_gethostbyname,
unix_gethostname,
};
NTSTATUS CDECL __wine_init_unix_lib( HMODULE module, DWORD reason, const void *ptr_in, void *ptr_out )
......
......@@ -203,6 +203,7 @@ struct unix_funcs
int (CDECL *gethostbyaddr)( const void *addr, int len, int family,
struct WS(hostent) *host, unsigned int *size );
int (CDECL *gethostbyname)( const char *name, struct WS(hostent) *host, unsigned int *size );
int (CDECL *gethostname)( char *name, int len );
};
extern const struct unix_funcs *unix_funcs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment