/*++ Copyright (c) 1992 Microsoft Corporation Module Name: olddb.c Contents: old getxbyy emulations Abstract: This module contains support for the getprotobyY WinSock APIs. Author: David Treadwell (davidtr) 29-Jun-1992 Revision History: 02-Feb-1994 rfirth Modified for Chicago/Snowball MohsinA, 13-Mar-96. Winsock2 RnR re-routing. v11_App => wsock32: getxbyy() => ws2_32: ws2_getxbyy() => wsock32: GETXBYYSP_getxbyy() --*/ #include "winsockp.h" #include "nspmisc.h" #include #ifndef CHICAGO #define SOCKAPI WSAAPI #else // CHICAGO #include "imported.h" #endif // CHICAGO struct servent FAR * _pgetservebyport( IN const int port, IN const FAR char *name ); struct servent FAR * _pgetservebyname( IN const FAR char *name, IN const FAR char *proto ); CopyServentToBuffer ( IN char FAR * Buffer, IN int BufferLength, IN LPSERVENT Servent ); // // private prototypes // #ifdef CHICAGO HANDLE AsyncGetServByYCommon( IN HWND hWnd, IN unsigned int wMsg, IN char FAR * Name, IN char FAR * Protocol, IN int Port, IN char FAR * Buffer, IN int BufferLength ); extern HANDLE GenerateNextTaskHandle(VOID); #else #define FSTRCPY strcpy #define FSTRLEN strlen #endif // CHICAGO // // macros // #define h_addr_ptrs ACCESS_THREAD_DATA( h_addr_ptrs, GETHOST ) #define host ACCESS_THREAD_DATA( host, GETHOST ) #define host_aliases ACCESS_THREAD_DATA( host_aliases, GETHOST ) #define hostbuf ACCESS_THREAD_DATA( hostbuf, GETHOST ) #define host_addr ACCESS_THREAD_DATA( host_addr, GETHOST ) #define hostaddr ACCESS_THREAD_DATA( hostaddr, GETHOST ) #define host_addrs ACCESS_THREAD_DATA( host_addrs, GETHOST ) #define HOSTDB ACCESS_THREAD_DATA( HOSTDB, GETHOST ) #if defined(CHICAGO) #ifdef WIN32 #define _fmemcmp memcmp #define _gethtbyaddr(addr, len, type) GetHostentFromAddress(pThread, addr, len, type) #endif // // manifests // #if PACKETSZ > 1024 #define MAXPACKET PACKETSZ #else #define MAXPACKET 1024 #endif // // private types // typedef union { HEADER hdr; unsigned char buf[MAXPACKET]; } querybuf; typedef union { long al; char ac; } align; // // private prototypes // LPHOSTENT getanswer( IN LPSOCK_THREAD pThread, OUT querybuf * answer, OUT LPDWORD TimeToLive, IN int anslen, IN int iquery ); LPHOSTENT GetHostentByAttribute( IN LPSOCK_THREAD pThread, IN LPSTR Name, IN LPBYTE Address ); DWORD CopyHostentToBuffer( char FAR *Buffer, int BufferLength, PHOSTENT Hostent ); #endif // CHICAGO LPHOSTENT _pgethostbyaddr( const char FAR *addr, int len, int type ); int _pgethostname( char FAR * addr, int len ); // // data // extern GUID HostnameGuid; #if OLDXBYY INT APIENTRY __GetAddressByNameA ( IN DWORD dwNameSpace, IN LPGUID lpServiceType, IN LPTSTR lpServiceName, IN LPINT lpiProtocols, IN DWORD dwResolution, IN LPSERVICE_ASYNC_INFO lpServiceAsyncInfo OPTIONAL, IN OUT LPVOID lpCsaddrBuffer, IN OUT LPDWORD lpdwBufferLength, IN OUT LPTSTR lpAliasBuffer, IN OUT LPDWORD lpdwAliasBufferLength ); #endif // // functions // // ws2_32 RnR re-routing, MohsinA, 13-Mar-96. struct servent FAR * SOCKAPI getservbyname( const char FAR * name, const char FAR * proto ) { struct servent FAR * se; #ifndef CHICAGO #undef getservbyname extern struct servent * PASCAL getservbyname( const char * name, const char * proto ); WS_ENTER( "getservbyname", (PVOID)name, (PVOID)proto, NULL, NULL ); se = getservbyname( name, proto ); WS_EXIT( "getservbyname", (INT)se, (BOOLEAN)( se == NULL ) ); #else // CHICAGO WS_TRACE(NAME,">getservbyname(name=%s,proto=%x) => ws2", name, proto, 0 ); se = ( * ws2_getservbyname )( name, proto ); WS_TRACE(NAME,"getservbyport(port/netbyteorder=%x,proto=%x) => ws2", port, proto, 0 ); se = ( * ws2_getservbyport )( port, proto ); WS_TRACE(NAME,"WSAAsyncGetServByName(hWnd=%d,wMsg=%d,Name=%s,\n\t", hWnd, wMsg, Name )); DLL_PRINT(("Protocol=%s, Buffer[%d] @ %x) => ws2.\n", Protocol, BufferLength, Buffer )); } val = ( * ws2_WSAAsyncGetServByName )( hWnd, wMsg, Name, Protocol, Buffer, BufferLength ); IF_DEBUG( NAME ){ DLL_PRINT(("OpCode = WS_OPCODE_GET_SERV_BY_NAME; contextBlock->Overlay.AsyncGetServ.hWnd = hWnd; contextBlock->Overlay.AsyncGetServ.wMsg = wMsg; contextBlock->Overlay.AsyncGetServ.Filter = localName; contextBlock->Overlay.AsyncGetServ.Protocol = (PCHAR)Protocol;; contextBlock->Overlay.AsyncGetServ.Buffer = Buffer; contextBlock->Overlay.AsyncGetServ.BufferLength = BufferLength; // // Save the task handle so that we can return it to the caller. // After we post the context block, we're not allowed to access // it in any way. // taskHandle = contextBlock->TaskHandle; // // Queue the request to the async thread. // SockQueueRequestToAsyncThread( contextBlock ); IF_DEBUG(ASYNC_GETXBYY) { WS_PRINT(( "WSAAsyncGetServByAddr successfully posted request, " "handle = %lx\n", taskHandle )); } WS_ASSERT( sizeof(taskHandle) == sizeof(HANDLE) ); WS_EXIT( "GETXBYYSP_WSAAsyncGetServByName", (INT)taskHandle, FALSE ); return (HANDLE)taskHandle; #else // CHICAGO extern char * d_ascii( char * s, int n ); LPSOCK_THREAD pThread; HANDLE ret; if (!enterAPI(FALSE, TRUE, FALSE, &pThread)) { return NULL; } // // BUGBUG - what about parameter validation/UAEs? // WS_TRACE(NAME,"GETXBYYSP_WSAAsyncGetServByName(%s)",Name,0,0); ret = AsyncGetServByYCommon(hWnd, wMsg, (LPSTR)Name, (LPSTR)Protocol, 0, Buffer, BufferLength ); IF_DEBUG( NAME ){ DLL_PRINT(("GETXBYYSP_WSAAsyncGetServByName(%s)<%d\n Buffer=\n", Name,ret)); // Print the first 120 chars of buffer. DLL_PRINT(("%s\n", d_ascii(&Buffer[ 0],60))); DLL_PRINT(("%s\n", d_ascii(&Buffer[60],60))); } return ret; #endif // CHICAGO } // ws2_32 RnR re-routing, MohsinA, 13-Mar-96. HANDLE SOCKAPI WSAAsyncGetServByPort( IN HWND hWnd, IN unsigned int wMsg, IN int Port, IN const char FAR * Protocol, IN char FAR * Buffer, IN int BufferLength ) { HANDLE val; #ifndef CHICAGO #undef WSAAsyncGetServByPort extern HANDLE PASCAL WSAAsyncGetServByPort( HWND hWnd, unsigned int wMsg, int Port, const char FAR * Protocol, char FAR * Buffer, int BufferLength ); WS_ENTER( "WSAAsyncGetServByPort", (PVOID)hWnd, (PVOID)wMsg, (PVOID)Port, (PVOID)Protocol ); val = WSAAsyncGetServByPort( hWnd, wMsg, Port, Protocol, Buffer, BufferLength ); WS_EXIT( "WSAAsyncGetServByPort", (INT)val, (BOOLEAN)( val == NULL ) ); #else // CHICAGO IF_DEBUG( NAME ){ DLL_PRINT((">WSAAsyncGetServByPort(hWnd=%d,wMsg=%d,Port=%d,\n\t", hWnd, wMsg, Port )); DLL_PRINT(("Protocol=%s, Buffer[%d] @ %x) => ws2.\n", Protocol, BufferLength, Buffer )); } val = ( * ws2_WSAAsyncGetServByPort )( hWnd, wMsg, Port, Protocol, Buffer, BufferLength ); IF_DEBUG( NAME ){ DLL_PRINT(("OpCode = WS_OPCODE_GET_SERV_BY_PORT; contextBlock->Overlay.AsyncGetServ.hWnd = hWnd; contextBlock->Overlay.AsyncGetServ.wMsg = wMsg; contextBlock->Overlay.AsyncGetServ.Filter = (PVOID)Port; contextBlock->Overlay.AsyncGetServ.Protocol = (PCHAR)Protocol; contextBlock->Overlay.AsyncGetServ.Buffer = Buffer; contextBlock->Overlay.AsyncGetServ.BufferLength = BufferLength; // // Save the task handle so that we can return it to the caller. // After we post the context block, we're not allowed to access // it in any way. // taskHandle = contextBlock->TaskHandle; // // Queue the request to the async thread. // SockQueueRequestToAsyncThread( contextBlock ); IF_DEBUG(ASYNC_GETXBYY) { WS_PRINT(( "GETXBYYSP_WSAAsyncGetServByPort successfully posted request," "handle = %lx\n", taskHandle )); } WS_ASSERT( sizeof(taskHandle) == sizeof(HANDLE) ); WS_EXIT( "GETXBYYSP_WSAAsyncGetServByPort", (INT)taskHandle, FALSE ); return (HANDLE)taskHandle; #else // CHICAGO LPSOCK_THREAD pThread; if (!enterAPI(FALSE, TRUE, FALSE, &pThread)) { return NULL; } // // BUGBUG - what about parameter validation/UAEs? // return AsyncGetServByYCommon(hWnd, wMsg, NULL, (LPSTR)Protocol, Port, Buffer, BufferLength ); #endif // CHICAGO } #ifdef CHICAGO HANDLE AsyncGetServByYCommon( IN HWND hWnd, IN unsigned int wMsg, IN char FAR * Name, IN char FAR * Protocol, IN int Port, IN char FAR * Buffer, IN int BufferLength ) { LPSERVENT returnServ; UINT requiredBufferLength = 0; BOOL posted; LPARAM lParam; UINT error; HANDLE handle; // // Get the necessary information. // if (Name) { WS_TRACE(NAME,"AsyncGetServByYCommon(Name=%s,Protocol=%s)", Name,Protocol,0); returnServ = getservbyname(Name, Protocol); } else { WS_TRACE(NAME,"AsyncGetServByYCommon(Port=%s,Protocol=%s)", Port,Protocol,0); returnServ = getservbyport(Port, Protocol); } // // Copy the servent structure to the output buffer. // if (returnServ != NULL) { WS_TRACE(NAME,"AsyncGetServByYCommon, copying Buffer.",0,0,0); requiredBufferLength = CopyServentToBuffer(Buffer, BufferLength, returnServ ); if (requiredBufferLength > (UINT)BufferLength) { WS_TRACE(NAME,"AsyncGetServByYCommon, no Buffer %d>%d.", requiredBufferLength, BufferLength,0); error = WSAENOBUFS; } else { WS_TRACE(NAME,"AsyncGetServByYCommon, Buffer copied ok.", 0,0,0); error = NO_ERROR; } } else { error = WSAGetLastError(); WS_TRACE(NAME,"AsyncGetServByYCommon, failed with %d", error,0,0); } // // We return a handle and an async message even if we failed // handle = GenerateNextTaskHandle(); // // Build lParam for the message we'll post to the application. // The high 16 bits are the error code, the low 16 bits are // the minimum buffer size required for the operation. // lParam = WSAMAKEASYNCREPLY(requiredBufferLength, error); // // Post a message to the application indication that the data it // requested is available. // IF_DEBUG( NAME ){ DLL_PRINT(("AsyncGetServByYCommon: posting(%d,%d,%d,%8x).\n", hWnd, wMsg, handle, lParam )); } posted = PostMessage(hWnd, wMsg, (WPARAM)handle, lParam); // // !!! Need a mechanism to repost if the post failed! // if (!posted) { // BUGBUG - whatdowedo?whatdowedo WS_PRINT(("Error: AsyncGetServByYCommon:" " PostMessage(%04x, %04x, %04x, %08lx) failed\r\n", hWnd, wMsg, handle, lParam )); } return handle; } #endif #endif // WIN32 // // functions // // =================================================================== // MohsinA, 13-Mar-96. LPHOSTENT SOCKAPI gethostbyname( IN const char FAR * name ) { LPHOSTENT he; #ifndef CHICAGO #undef gethostbyname extern struct hostent * PASCAL gethostbyname( const char * name ); WS_ENTER( "getbyhostname", (PVOID)name, NULL, NULL, NULL ); he = gethostbyname( name ); WS_EXIT( "gethostbyname", (INT)he, (BOOLEAN)( he == NULL ) ); #else // CHICAGO WS_TRACE(NAME,">gethostbyname(name=%s) => ws2", name, 0, 0 ); he = ( * ws2_gethostbyname )( name ); WS_TRACE(NAME,"= WSAHOST_NOT_FOUND && err <= WSANO_DATA ) { SetLastError( err ); } else { SetLastError( WSANO_DATA ); } WS_EXIT( "gethostbyname", 0, TRUE ); return((struct hostent *) NULL); } // // Copy the CSADDR information to a hostent structure. // host.h_addr_list = h_addr_ptrs; host.h_length = sizeof (unsigned long); host.h_addrtype = AF_INET; host.h_aliases = host_aliases; // // Copy over the IP addresses for the host. // bp = hostbuf; csaddrInfo = (PCSADDR_INFO)buffer; for ( index = 0; index < count && (DWORD)bp - (DWORD)hostbuf < BUFSIZ; index++ ) { sockaddrIn = (PSOCKADDR_IN)csaddrInfo->RemoteAddr.lpSockaddr; host.h_addr_list[index] = bp; bp += 4; *((long *)host.h_addr_list[index]) = sockaddrIn->sin_addr.s_addr; csaddrInfo++; } // // Copy over the host name and alias information. If we got back // aliases, assume that the first one is the real host name. If // we didn't get aliases, use the passed-in host name. // s = aliasBuffer; if ( *s == '\0' ) { FSTRCPY( bp, name ); host.h_name = bp; host_aliases[0] = NULL; } else { FSTRCPY( bp, s ); host.h_name = bp; // // Copy over the aliases. // for ( i = 0, s += FSTRLEN( s ) + 1, bp += FSTRLEN( bp ) + 1; i < MAXALIASES && *s != '\0' && (DWORD)bp - (DWORD)hostbuf < BUFSIZ; i++, s += FSTRLEN( s ) + 1, bp += FSTRLEN( bp ) + 1 ) { FSTRCPY( bp, s ); host.h_aliases[i] = bp; } host_aliases[i] = NULL; } SockThreadProcessingGetXByY = FALSE; WS_EXIT( "gethostbyname", (INT)&host, FALSE ); return (&host); #else // WIN32 LPSOCK_THREAD pThread; LPHOSTENT lpHostent; WS_ENTER("gethostbyname", (PVOID)name, NULL, NULL, NULL); if (!SockEnterApi(TRUE, TRUE, TRUE)) { WS_EXIT("gethostbyname", 0, TRUE); return NULL; } // // if the name looks ok, try to resolve it // if (VerifyName((LPSTR)name)) { lpHostent = GetHostentByAttribute(pThread, (LPSTR)name, NULL); } else { // // the name was bad // WSASetLastError(WSANO_RECOVERY); lpHostent = NULL; } SockThreadProcessingGetXByY = FALSE; WS_EXIT("gethostbyname", (INT)lpHostent, lpHostent ? FALSE : TRUE); return lpHostent; #endif // defined(WIN32) } // ws2_32 RnR re-routing, MohsinA, 13-Mar-96. LPHOSTENT SOCKAPI gethostbyaddr( IN const char FAR * addr, IN int len, IN int type ) { LPHOSTENT he; #ifndef CHICAGO #undef gethostbyaddr extern struct hostent * PASCAL gethostbyaddr( const char * name, int len, int type ); WS_ENTER( "gethostbyaddr", (PVOID)addr, (PVOID)len, (PVOID)type, NULL ); he = gethostbyaddr( addr, len, type ); WS_EXIT( "gethostbyaddr", (INT)he, (BOOLEAN)( he == NULL ) ); #else // CHICAGO DWORD inaddr=0L; if( addr ) inaddr = *(DWORD*) addr; // else zero. WS_TRACE(NAME,">gethostbyaddr(inaddr=%lx,len=%d,type=%d) => ws2", inaddr, len,type ); he = ( * ws2_gethostbyaddr )( addr, len, type ); IF_DEBUG( NAME ){ if( he ){ DLL_PRINT(("h_name )); }else{ DLL_PRINT(("WSAAsyncGetHostByName(hWnd=%d,wMsg=%d,Name @ %x,\n\t", hWnd, wMsg, Name )); DLL_PRINT(("Buffer[%d] @ %x) => ws2.\n", BufferLength, Buffer)); } val = ( * ws2_WSAAsyncGetHostByName )( hWnd, wMsg, Name, Buffer, BufferLength ); IF_DEBUG( NAME ){ DLL_PRINT(("OpCode = WS_OPCODE_GET_HOST_BY_NAME; contextBlock->Overlay.AsyncGetHost.hWnd = hWnd; contextBlock->Overlay.AsyncGetHost.wMsg = wMsg; contextBlock->Overlay.AsyncGetHost.Filter = localName; contextBlock->Overlay.AsyncGetHost.Buffer = Buffer; contextBlock->Overlay.AsyncGetHost.BufferLength = BufferLength; // // Save the task handle so that we can return it to the caller. // After we post the context block, we're not allowed to access // it in any way. // taskHandle = contextBlock->TaskHandle; // // Queue the request to the async thread. // SockQueueRequestToAsyncThread( contextBlock ); IF_DEBUG(ASYNC_GETXBYY) { WS_PRINT(( "WSAAsyncGetHostByName successfully posted request, " "handle = %x\r\n", taskHandle )); } WS_ASSERT( sizeof(taskHandle) == sizeof(HANDLE) ); WS_EXIT( "WSAAsyncGetHostByName", (INT)taskHandle, FALSE ); return (HANDLE)taskHandle; } // WSAAsyncGetHostByName // ws2_32 RnR re-routing, MohsinA, 13-Mar-96. HANDLE SOCKAPI WSAAsyncGetHostByAddr( HWND hWnd, unsigned int wMsg, const char FAR * Address, int Length, int Type, char FAR * Buffer, int BufferLength ) { HANDLE val; #ifndef CHICAGO #undef WSAAsyncGetHostByAddr extern HANDLE PASCAL WSAAsyncGetHostByAddr( HWND hWnd, unsigned int wMsg, const char FAR * Address, int Length, int Type, char FAR * Buffer, int BufferLength ); WS_ENTER( "WSAAsyncGetHostByAddr", (PVOID)hWnd, (PVOID)wMsg, (PVOID)Address,(PVOID)Length ); val = WSAAsyncGetHostByAddr( hWnd, wMsg, Address, Length, Type, Buffer, BufferLength ); WS_EXIT( "WSAAsyncGetHostByAddr", (INT)val, (BOOLEAN)( val == NULL ) ); #else // CHICAGO IF_DEBUG( NAME ){ DLL_PRINT((">WSAAsyncGetHostByAddr(hWnd=%d,wMsg=%d,Address=%x,\n\t", hWnd, wMsg, Address )); DLL_PRINT(("Length=%d, Type=%d, Buffer[%d] @ %x) => ws2.\n", Length, Type, BufferLength, Buffer )); } val = ( * ws2_WSAAsyncGetHostByAddr )( hWnd, wMsg, Address, Length, Type, Buffer, BufferLength ); IF_DEBUG( NAME ){ DLL_PRINT(("OpCode = WS_OPCODE_GET_HOST_BY_ADDR; contextBlock->Overlay.AsyncGetHost.hWnd = hWnd; contextBlock->Overlay.AsyncGetHost.wMsg = wMsg; contextBlock->Overlay.AsyncGetHost.Filter = localAddress; contextBlock->Overlay.AsyncGetHost.Length = Length; contextBlock->Overlay.AsyncGetHost.Type = Type; contextBlock->Overlay.AsyncGetHost.Buffer = Buffer; contextBlock->Overlay.AsyncGetHost.BufferLength = BufferLength; // // Save the task handle so that we can return it to the caller. // After we post the context block, we're not allowed to access // it in any way. // taskHandle = contextBlock->TaskHandle; // // Queue the request to the async thread. // SockQueueRequestToAsyncThread( contextBlock ); IF_DEBUG(ASYNC_GETXBYY) { WS_PRINT(( "WSAAsyncGetHostByAddr successfully posted request, " "handle = %x\r\n", taskHandle )); } WS_ASSERT( sizeof(taskHandle) == sizeof(HANDLE) ); WS_EXIT( "WSAAsyncGetHostByAddr", (INT)taskHandle, FALSE ); return (HANDLE)taskHandle; } // WSAAsyncGetHostByAddr #if !defined(CHICAGO) || defined(WIN32) VOID SockProcessAsyncGetHost ( IN DWORD TaskHandle, IN DWORD OpCode, IN HWND hWnd, IN unsigned int wMsg, IN char FAR *Filter, IN int Length, IN int Type, IN char FAR *Buffer, IN int BufferLength ) { PHOSTENT returnHost; DWORD requiredBufferLength = 0; BOOL posted; LPARAM lParam; DWORD error; extern DWORD SockCancelledAsyncTaskHandle; extern DWORD SockCurrentAsyncThreadTaskHandle; WS_ASSERT( OpCode == WS_OPCODE_GET_HOST_BY_ADDR || OpCode == WS_OPCODE_GET_HOST_BY_NAME ); #if DBG WSASetLastError( NO_ERROR ); #endif // // Get the necessary information. // if ( OpCode == WS_OPCODE_GET_HOST_BY_ADDR ) { returnHost = gethostbyaddr( Filter, Length, Type ); } else { returnHost = gethostbyname( Filter ); } // // Free the filter space, it is no longer used. // FREE_HEAP( Filter ); // // Hold the lock that protects the async thread context block queue // while we do this. This prevents a race between this thread and // any thread invoking WSACancelAsyncRequest(). // SockAcquireGlobalLockExclusive( ); // // If this request was cancelled, just return. // if ( TaskHandle == SockCancelledAsyncTaskHandle ) { IF_DEBUG(ASYNC_GETXBYY) { WS_PRINT(( "SockProcessAsyncGetHost: task handle %lx cancelled\r\n", TaskHandle )); } SockReleaseGlobalLock( ); return; } // // Copy the hostent structure to the output buffer. // if ( returnHost != NULL ) { requiredBufferLength = CopyHostentToBuffer( Buffer, BufferLength, returnHost ); if ( requiredBufferLength > (DWORD)BufferLength ) { error = WSAENOBUFS; } else { error = NO_ERROR; } } else { error = WSAGetLastError( ); WS_ASSERT( error != NO_ERROR ); } SockReleaseGlobalLock( ); // // Build lParam for the message we'll post to the application. // The high 16 bits are the error code, the low 16 bits are // the minimum buffer size required for the operation. // lParam = WSAMAKEASYNCREPLY( requiredBufferLength, error ); // // Set the current async thread task handle to 0 so that if a cancel // request comes in after this point it is failed properly. // SockCurrentAsyncThreadTaskHandle = 0; // // Post a message to the application indication that the data it // requested is available. // WS_ASSERT( sizeof(TaskHandle) == sizeof(HANDLE) ); #ifdef CHICAGO #define SockPostRoutine PostMessage #endif posted = SockPostRoutine( hWnd, wMsg, (WPARAM)TaskHandle, lParam ); // // !!! Need a mechanism to repost if the post failed! // if ( !posted ) { WS_PRINT(( "SockProcessAsyncGetHost: PostMessage failed: %ld\r\n", WSAGetLastError( ) )); WS_ASSERT( FALSE ); } return; } // SockProcessAsyncGetHost #endif // WIN32 // RnR re-routing to ws2_32.dll, MohsinA, 13-Mar-96. int GETXBYYSP_gethostname( OUT char *name, IN int namelen ) { return(_pgethostname(name, namelen)); } int SOCKAPI gethostname( OUT char FAR * name, IN int namelen ) { int retval; #ifndef CHICAGO #undef gethostname extern int gethostname( char * name, int namelen ); WS_ENTER( "gethostname", name, (PVOID)namelen, NULL, NULL ); retval = gethostname( name, namelen ); WS_EXIT( "gethostname", retval, (BOOLEAN)( retval == SOCKET_ERROR ) ); #else // CHICAGO WS_TRACE(NAME,">gethostname(name @ %x, namelen=%d) => ws2", name, namelen, 0 ); retval = ( ws2_gethostname )( name, namelen ); WS_TRACE(NAME," (DWORD)BufferLength ) { error = WSAENOBUFS; } else { error = NO_ERROR; } } else { error = GetLastError( ); WS_ASSERT( error != NO_ERROR ); } // // Build lParam for the message we'll post to the application. // The high 16 bits are the error code, the low 16 bits are // the minimum buffer size required for the operation. // lParam = WSAMAKEASYNCREPLY( requiredBufferLength, error ); // // If this request was cancelled, just return. // if ( TaskHandle == SockCancelledAsyncTaskHandle ) { IF_DEBUG(ASYNC_GETXBYY) { WS_PRINT(( "SockProcessAsyncGetServ: task handle %lx cancelled\n", TaskHandle )); } return; } // // Set the current async thread task handle to 0 so that if a cancel // request comes in after this point it is failed properly. // SockCurrentAsyncThreadTaskHandle = 0; // // Post a message to the application indication that the data it // requested is available. // WS_ASSERT( sizeof(TaskHandle) == sizeof(HANDLE) ); posted = SockPostRoutine( hWnd, wMsg, (WPARAM)TaskHandle, lParam ); // // !!! Need a mechanism to repost if the post failed! // if ( !posted ) { WS_PRINT(( "SockProcessAsyncGetServ: PostMessage failed: %ld\n", GetLastError( ) )); WS_ASSERT( FALSE ); } return; } // SockProcessAsyncGetServ #endif // CHICAGO