From cd6b50e73265e8b1a687ac035b0312237f3ff51d Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 31 Jul 2002 23:20:47 +0000 Subject: [PATCH] Moved the #ifdefs for the getnetby* etc. functions directly into the winsock implementation to avoid having to redefine the data structures in port.h. --- dlls/winsock/async.c | 8 ++++++ dlls/winsock/socket.c | 7 +++++- dlls/wsock32/protocol.c | 4 +++ include/wine/port.h | 42 ------------------------------- library/port.c | 55 ----------------------------------------- 5 files changed, 18 insertions(+), 98 deletions(-) diff --git a/dlls/winsock/async.c b/dlls/winsock/async.c index c773605394c..29629e739d5 100644 --- a/dlls/winsock/async.c +++ b/dlls/winsock/async.c @@ -423,6 +423,7 @@ static DWORD WINAPI _async_queryfun(LPVOID arg) { } break; case AQ_GETPROTO: { +#if defined(HAVE_GETPROTOBYNAME) && defined(HAVE_GETPROTOBYNUMBER) struct protoent *pe; char *copy_protoent = targetptr; EnterCriticalSection( &csWSgetXXXbyYYY ); @@ -445,6 +446,9 @@ static DWORD WINAPI _async_queryfun(LPVOID arg) { fail = WSANO_DATA; } LeaveCriticalSection( &csWSgetXXXbyYYY ); +#else + fail = WSANO_DATA; +#endif } break; case AQ_GETSERV: { @@ -453,7 +457,11 @@ static DWORD WINAPI _async_queryfun(LPVOID arg) { EnterCriticalSection( &csWSgetXXXbyYYY ); se = (aq->flags & AQ_NAME)? getservbyname(aq->serv_name,aq->serv_proto) : +#ifdef HAVE_GETSERVBYPORT getservbyport(aq->serv_port,aq->serv_proto); +#else + NULL; +#endif if (se) { size = WS_copy_se(copy_servent,(char*)aq->sbuf,aq->sbuflen,se,aq->flags); if (size < 0) { diff --git a/dlls/winsock/socket.c b/dlls/winsock/socket.c index db1b95fa0dc..bdb6c6e3c16 100644 --- a/dlls/winsock/socket.c +++ b/dlls/winsock/socket.c @@ -2996,7 +2996,7 @@ struct WS_hostent* WINAPI WS_gethostbyname(const char* name) static WIN_protoent* __ws_getprotobyname(const char *name, int dup_flag) { WIN_protoent* retval = NULL; - +#ifdef HAVE_GETPROTOBYNAME struct protoent* proto; EnterCriticalSection( &csWSgetXXXbyYYY ); if( (proto = getprotobyname(name)) != NULL ) @@ -3011,6 +3011,7 @@ static WIN_protoent* __ws_getprotobyname(const char *name, int dup_flag) SetLastError(WSANO_DATA); } LeaveCriticalSection( &csWSgetXXXbyYYY ); +#endif return retval; } @@ -3040,6 +3041,7 @@ struct WS_protoent* WINAPI WS_getprotobyname(const char* name) static WIN_protoent* __ws_getprotobynumber(int number, int dup_flag) { WIN_protoent* retval = NULL; +#ifdef HAVE_GETPROTOBYNUMBER struct protoent* proto; EnterCriticalSection( &csWSgetXXXbyYYY ); if( (proto = getprotobynumber(number)) != NULL ) @@ -3054,6 +3056,7 @@ static WIN_protoent* __ws_getprotobynumber(int number, int dup_flag) SetLastError(WSANO_DATA); } LeaveCriticalSection( &csWSgetXXXbyYYY ); +#endif return retval; } @@ -3134,6 +3137,7 @@ struct WS_servent* WINAPI WS_getservbyname(const char *name, const char *proto) static WIN_servent* __ws_getservbyport(int port, const char* proto, int dup_flag) { WIN_servent* retval = NULL; +#ifdef HAVE_GETSERVBYPORT struct servent* serv; if (!proto || wsi_strtolo( proto, NULL )) { EnterCriticalSection( &csWSgetXXXbyYYY ); @@ -3151,6 +3155,7 @@ static WIN_servent* __ws_getservbyport(int port, const char* proto, int dup_flag LeaveCriticalSection( &csWSgetXXXbyYYY ); } else SetLastError(WSAENOBUFS); +#endif return retval; } diff --git a/dlls/wsock32/protocol.c b/dlls/wsock32/protocol.c index c0749e33a64..450d2fddc7f 100644 --- a/dlls/wsock32/protocol.c +++ b/dlls/wsock32/protocol.c @@ -303,5 +303,9 @@ UINT WINAPI WSOCK32_inet_network(const char *cp) */ struct netent * WINAPI WSOCK32_getnetbyname(const char *name) { +#ifdef HAVE_GETNETBYNAME return getnetbyname(name); +#else + return NULL; +#endif } diff --git a/include/wine/port.h b/include/wine/port.h index ca4728b00d1..8baa5bfdc53 100644 --- a/include/wine/port.h +++ b/include/wine/port.h @@ -61,23 +61,6 @@ typedef unsigned int size_t; typedef int ssize_t; #endif -#if !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME) -struct netent { - char *n_name; - char **n_aliases; - int n_addrtype; - unsigned long n_net; -}; -#endif /* !defined(HAVE_GETNETBYADDR) && !defined(HAVE_GETNETBYNAME) */ - -#if !defined(HAVE_GETPROTOBYNAME) && !defined(HAVE_GETPROTOBYNUMBER) -struct protoent { - char *p_name; - char **p_aliases; - int p_proto; -}; -#endif /* !defined(HAVE_GETPROTOBYNAME) && !defined(HAVE_GETPROTOBYNUMBER) */ - #ifndef HAVE_STATFS # ifdef __BEOS__ # define STATFS_HAS_BFREE @@ -186,30 +169,10 @@ struct statfs; int clone(int (*fn)(void *arg), void *stack, int flags, void *arg); #endif /* !defined(HAVE_CLONE) && defined(linux) */ -#ifndef HAVE_GETNETBYADDR -struct netent *getnetbyaddr(unsigned long net, int type); -#endif /* defined(HAVE_GETNETBYNAME) */ - -#ifndef HAVE_GETNETBYNAME -struct netent *getnetbyname(const char *name); -#endif /* defined(HAVE_GETNETBYNAME) */ - #ifndef HAVE_GETPAGESIZE size_t getpagesize(void); #endif /* HAVE_GETPAGESIZE */ -#ifndef HAVE_GETPROTOBYNAME -struct protoent *getprotobyname(const char *name); -#endif /* !defined(HAVE_GETPROTOBYNAME) */ - -#ifndef HAVE_GETPROTOBYNUMBER -struct protoent *getprotobynumber(int proto); -#endif /* !defined(HAVE_GETPROTOBYNUMBER) */ - -#ifndef HAVE_GETSERVBYPORT -struct servent *getservbyport(int port, const char *proto); -#endif /* !defined(HAVE_GETSERVBYPORT) */ - #ifndef HAVE_GETSOCKOPT int getsockopt(int socket, int level, int option_name, void *option_value, size_t *option_len); #endif /* !defined(HAVE_GETSOCKOPT) */ @@ -325,12 +288,7 @@ extern long interlocked_xchg_add( long *dest, long incr ); #define __WINE_NOT_PORTABLE(func) func##_is_not_portable func##_is_not_portable #define clone __WINE_NOT_PORTABLE(clone) -#define getnetbyaddr __WINE_NOT_PORTABLE(getnetbyaddr) -#define getnetbyname __WINE_NOT_PORTABLE(getnetbyname) #define getpagesize __WINE_NOT_PORTABLE(getpagesize) -#define getprotobyname __WINE_NOT_PORTABLE(getprotobyname) -#define getprotobynumber __WINE_NOT_PORTABLE(getprotobynumber) -#define getservbyport __WINE_NOT_PORTABLE(getservbyport) #define getsockopt __WINE_NOT_PORTABLE(getsockopt) #define inet_network __WINE_NOT_PORTABLE(inet_network) #define lstat __WINE_NOT_PORTABLE(lstat) diff --git a/library/port.c b/library/port.c index eb93423efea..c63322a5933 100644 --- a/library/port.c +++ b/library/port.c @@ -215,61 +215,6 @@ int strncasecmp( const char *str1, const char *str2, size_t n ) } #endif /* HAVE_STRNCASECMP */ -/*********************************************************************** - * getnetbyaddr - */ -#ifndef HAVE_GETNETBYADDR -struct netent *getnetbyaddr(unsigned long net, int type) -{ - errno = ENOSYS; - return NULL; -} -#endif /* defined(HAVE_GETNETBYNAME) */ - -/*********************************************************************** - * getnetbyname - */ -#ifndef HAVE_GETNETBYNAME -struct netent *getnetbyname(const char *name) -{ - errno = ENOSYS; - return NULL; -} -#endif /* defined(HAVE_GETNETBYNAME) */ - -/*********************************************************************** - * getprotobyname - */ -#ifndef HAVE_GETPROTOBYNAME -struct protoent *getprotobyname(const char *name) -{ - errno = ENOSYS; - return NULL; -} -#endif /* !defined(HAVE_GETPROTOBYNAME) */ - -/*********************************************************************** - * getprotobynumber - */ -#ifndef HAVE_GETPROTOBYNUMBER -struct protoent *getprotobynumber(int proto) -{ - errno = ENOSYS; - return NULL; -} -#endif /* !defined(HAVE_GETPROTOBYNUMBER) */ - -/*********************************************************************** - * getservbyport - */ -#ifndef HAVE_GETSERVBYPORT -struct servent *getservbyport(int port, const char *proto) -{ - errno = ENOSYS; - return NULL; -} -#endif /* !defined(HAVE_GETSERVBYPORT) */ - /*********************************************************************** * getsockopt */