Commit in reactos/lib/ws2_32 on MAIN
makefile+45-441.18 -> 1.19
include/ws2_32.h+81.9 -> 1.10
misc/dllmain.c+111.18 -> 1.19
    /event.c+61.6 -> 1.7
    /ns.c+1216-9891.9 -> 1.10
    /stubs.c+1-11.14 -> 1.15
+1287-1034
6 modified files
Added gethostbyname implementation written by Adam Kelly (insulanus).
- Mostly complete, does not support multiple returned a records or hosts file
  though
- Relies on dnsapi
- Stores hostent struct in teb->Hostent

reactos/lib/ws2_32
makefile 1.18 -> 1.19
diff -u -r1.18 -r1.19
--- makefile	17 Nov 2004 05:17:21 -0000	1.18
+++ makefile	25 Nov 2004 23:32:53 -0000	1.19
@@ -1,44 +1,45 @@
-# $Id: makefile,v 1.18 2004/11/17 05:17:21 arty Exp $
-
-PATH_TO_TOP = ../..
-
-TARGET_REGTESTS = yes
-
-TARGET_TYPE = dynlink
-
-TARGET_NAME = ws2_32
-
-TARGET_PCH = include/ws2_32.h
-
-TARGET_BASE = $(TARGET_BASE_LIB_W2_32)
-
-TARGET_CFLAGS = \
- -I./include \
- -Wall \
- -Werror \
- -fno-builtin \
- -DUNICODE \
- -DLE \
- -D__USE_W32API
-
-# require os code to explicitly request A/W version of structs/functions
-TARGET_CFLAGS += -D_DISABLE_TIDENTS
-
-TARGET_LFLAGS = -nostartfiles -nostdlib
-
-TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a
-
-TARGET_OBJECTS = \
-  misc/bsd.o misc/catalog.o misc/dllmain.o \
-  misc/event.o misc/handle.o misc/ns.o \
-  misc/sndrcv.o misc/stubs.o misc/upcall.o
-
-DEP_OBJECTS = $(TARGET_OBJECTS)
-
-include $(PATH_TO_TOP)/rules.mak
-
-include $(TOOLS_PATH)/helper.mk
-
-include $(TOOLS_PATH)/depend.mk
-
-# EOF
+# $Id: makefile,v 1.19 2004/11/25 23:32:53 arty Exp $
+
+PATH_TO_TOP = ../..
+
+TARGET_REGTESTS = yes
+
+TARGET_TYPE = dynlink
+
+TARGET_NAME = ws2_32
+
+TARGET_PCH = include/ws2_32.h
+
+TARGET_BASE = $(TARGET_BASE_LIB_W2_32)
+
+TARGET_CFLAGS = \
+ -I./include \
+ -Wall \
+ -Werror \
+ -fno-builtin \
+ -DUNICODE \
+ -DLE \
+ -D__USE_W32API \
+ -D_WIN32_WINNT=0x0500
+
+# require os code to explicitly request A/W version of structs/functions
+TARGET_CFLAGS += -D_DISABLE_TIDENTS
+
+TARGET_LFLAGS = -nostartfiles -nostdlib
+
+TARGET_SDKLIBS = ntdll.a kernel32.a advapi32.a dnsapi.a
+
+TARGET_OBJECTS = \
+  misc/bsd.o misc/catalog.o misc/dllmain.o \
+  misc/event.o misc/handle.o misc/ns.o \
+  misc/sndrcv.o misc/stubs.o misc/upcall.o
+
+DEP_OBJECTS = $(TARGET_OBJECTS)
+
+include $(PATH_TO_TOP)/rules.mak
+
+include $(TOOLS_PATH)/helper.mk
+
+include $(TOOLS_PATH)/depend.mk
+
+# EOF

reactos/lib/ws2_32/include
ws2_32.h 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- ws2_32.h	15 Jul 2004 02:03:06 -0000	1.9
+++ ws2_32.h	25 Nov 2004 23:32:54 -0000	1.10
@@ -7,6 +7,7 @@
 #ifndef __WS2_32_H
 #define __WS2_32_H
 
+#include <roscfg.h>
 #include <ddk/ntddk.h>
 #include <ddk/ntifs.h>
 #include <ntos.h>
@@ -17,6 +18,7 @@
 #include <windows.h>
 #undef assert
 #include <debug.h>
+#include <WinDNS.h> // DNS_A_DATA
 
 /* Exported by ntdll.dll, but where is the prototype? */
 unsigned long strtoul(const char *nptr, char **endptr, int base);
@@ -51,6 +53,7 @@
     Getservbyname;          /* Buffer used by getservbyname */
     PWINSOCK_GETSERVBYPORT_CACHE
     Getservbyport;          /* Buffer used by getservbyname */
+    struct hostent* Hostent;
 } WINSOCK_THREAD_BLOCK, *PWINSOCK_THREAD_BLOCK;
 
 
@@ -60,6 +63,11 @@
 
 #define WSASETINITIALIZED (Initialized = TRUE)
 
+/* ws2_32 internal Functions */
+void check_hostent(struct hostent **he);
+void populate_hostent(struct hostent *he, char* name, DNS_A_DATA addr);
+void free_hostent(struct hostent *he);
+void free_servent(struct servent* s);
 
 #ifdef LE
 

reactos/lib/ws2_32/misc
dllmain.c 1.18 -> 1.19
diff -u -r1.18 -r1.19
--- dllmain.c	17 Nov 2004 05:17:22 -0000	1.18
+++ dllmain.c	25 Nov 2004 23:32:54 -0000	1.19
@@ -663,6 +663,16 @@
     return FALSE;
 }
 
+void free_winsock_thread_block(PWINSOCK_THREAD_BLOCK p) {
+  if(p) {
+    if(p->Hostent) { free_hostent(p->Hostent); p->Hostent = 0; }
+    if(p->Getservbyname){}
+    if(p->Getservbyport) {}
+
+
+  }
+}
+
 BOOL
 STDCALL
 DllMain(HANDLE hInstDll,
@@ -708,6 +718,7 @@
       return FALSE;
     }
 
+    p->Hostent = NULL;
     p->LastErrorValue = NO_ERROR;
     p->Getservbyname  = NULL;
     p->Getservbyport  = NULL;

reactos/lib/ws2_32/misc
event.c 1.6 -> 1.7
diff -u -r1.6 -r1.7
--- event.c	7 Aug 2003 04:03:24 -0000	1.6
+++ event.c	25 Nov 2004 23:32:54 -0000	1.7
@@ -157,6 +157,10 @@
   INT Status;
   INT Errno;
 
+  WS_DbgPrint(MID_TRACE,("Called (Socket %x, hEventObject %x, "
+			 "lpNetworkEvents %x)\n",
+			 s, hEventObject, lpNetworkEvents));
+
   if (!lpNetworkEvents) {
     WSASetLastError(WSAEINVAL);
     return SOCKET_ERROR;
@@ -180,6 +184,8 @@
   if (Status == SOCKET_ERROR)
     WSASetLastError(Errno);
 
+  WS_DbgPrint(MID_TRACE,("Leaving %x\n", Status));
+
   return Status;
 }
 

reactos/lib/ws2_32/misc
ns.c 1.9 -> 1.10
diff -u -r1.9 -r1.10
--- ns.c	15 Jul 2004 02:03:07 -0000	1.9
+++ ns.c	25 Nov 2004 23:32:54 -0000	1.10
@@ -1,989 +1,1216 @@
-/*
- * COPYRIGHT:   See COPYING in the top level directory
- * PROJECT:     ReactOS WinSock 2 DLL
- * FILE:        misc/ns.c
- * PURPOSE:     Namespace APIs
- * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
- * REVISIONS:
- *   CSH 01/09-2000 Created
- */
-#include <ctype.h>
-#include <ws2_32.h>
-
-#ifndef BUFSIZ
-#define BUFSIZ 1024
-#endif/*BUFSIZ*/
-
-/* Name resolution APIs */
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAAddressToStringA(
-    IN      LPSOCKADDR lpsaAddress,
-    IN      DWORD dwAddressLength,
-    IN      LPWSAPROTOCOL_INFOA lpProtocolInfo,
-    OUT     LPSTR lpszAddressString,
-    IN OUT  LPDWORD lpdwAddressStringLength)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAAddressToStringW(
-    IN      LPSOCKADDR lpsaAddress,
-    IN      DWORD dwAddressLength,
-    IN      LPWSAPROTOCOL_INFOW lpProtocolInfo,
-    OUT     LPWSTR lpszAddressString,
-    IN OUT  LPDWORD lpdwAddressStringLength)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAEnumNameSpaceProvidersA(
-    IN OUT  LPDWORD lpdwBufferLength,
-    OUT     LPWSANAMESPACE_INFOA lpnspBuffer)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAEnumNameSpaceProvidersW(
-    IN OUT  LPDWORD lpdwBufferLength,
-    OUT     LPWSANAMESPACE_INFOW lpnspBuffer)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAGetServiceClassInfoA(
-    IN      LPGUID lpProviderId,
-    IN      LPGUID lpServiceClassId,
-    IN OUT  LPDWORD lpdwBufferLength,
-    OUT     LPWSASERVICECLASSINFOA lpServiceClassInfo)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAGetServiceClassInfoW(
-    IN      LPGUID lpProviderId,
-    IN      LPGUID lpServiceClassId,
-    IN OUT  LPDWORD lpdwBufferLength,
-    OUT     LPWSASERVICECLASSINFOW lpServiceClassInfo)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAGetServiceClassNameByClassIdA(
-    IN      LPGUID lpServiceClassId,
-    OUT     LPSTR lpszServiceClassName,
-    IN OUT  LPDWORD lpdwBufferLength)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAGetServiceClassNameByClassIdW(
-    IN      LPGUID lpServiceClassId,
-    OUT     LPWSTR lpszServiceClassName,
-    IN OUT  LPDWORD lpdwBufferLength)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAInstallServiceClassA(
-    IN  LPWSASERVICECLASSINFOA lpServiceClassInfo)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAInstallServiceClassW(
-    IN  LPWSASERVICECLASSINFOW lpServiceClassInfo)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSALookupServiceBeginA(
-    IN  LPWSAQUERYSETA lpqsRestrictions,
-    IN  DWORD dwControlFlags,
-    OUT LPHANDLE lphLookup)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSALookupServiceBeginW(
-    IN  LPWSAQUERYSETW lpqsRestrictions,
-    IN  DWORD dwControlFlags,
-    OUT LPHANDLE lphLookup)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSALookupServiceEnd(
-    IN  HANDLE hLookup)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSALookupServiceNextA(
-    IN      HANDLE hLookup,
-    IN      DWORD dwControlFlags,
-    IN OUT  LPDWORD lpdwBufferLength,
-    OUT     LPWSAQUERYSETA lpqsResults)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSALookupServiceNextW(
-    IN      HANDLE hLookup,
-    IN      DWORD dwControlFlags,
-    IN OUT  LPDWORD lpdwBufferLength,
-    OUT     LPWSAQUERYSETW lpqsResults)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSARemoveServiceClass(
-    IN  LPGUID lpServiceClassId)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSASetServiceA(
-    IN  LPWSAQUERYSETA lpqsRegInfo,
-    IN  WSAESETSERVICEOP essOperation,
-    IN  DWORD dwControlFlags)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSASetServiceW(
-    IN  LPWSAQUERYSETW lpqsRegInfo,
-    IN  WSAESETSERVICEOP essOperation,
-    IN  DWORD dwControlFlags)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAStringToAddressA(
-    IN      LPSTR AddressString,
-    IN      INT AddressFamily,
-    IN      LPWSAPROTOCOL_INFOA lpProtocolInfo,
-    OUT     LPSOCKADDR lpAddress,
-    IN OUT  LPINT lpAddressLength)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-WSAStringToAddressW(
-    IN      LPWSTR AddressString,
-    IN      INT AddressFamily,
-    IN      LPWSAPROTOCOL_INFOW lpProtocolInfo,
-    OUT     LPSOCKADDR lpAddress,
-    IN OUT  LPINT lpAddressLength)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/* WinSock 1.1 compatible name resolution APIs */
-
-/*
- * @unimplemented
- */
-LPHOSTENT
-EXPORT
-gethostbyaddr(
-    IN  CONST CHAR FAR* addr,
-    IN  INT len,
-    IN  INT type)
-{
-    UNIMPLEMENTED
-
-    return (LPHOSTENT)NULL;
-}
-
-/*
- * @unimplemented
- */
-LPHOSTENT
-EXPORT
-gethostbyname(
-    IN  CONST CHAR FAR* name)
-{
-    UNIMPLEMENTED
-
-    return (LPHOSTENT)NULL;
-}
-
-
-/*
- * @unimplemented
- */
-INT
-EXPORT
-gethostname(
-    OUT CHAR FAR* name,
-    IN  INT namelen)
-{
-    UNIMPLEMENTED
-
-    return 0;
-}
-
-
-/*
- * XXX arty -- Partial implementation pending a better one.  This one will
- * do for normal purposes.
- *
- * Return the address of a static LPPROTOENT corresponding to the named
- * protocol.  These structs aren't very interesting, so I'm not too ashamed
- * to have this function work on builtins for now.
- *
- * @unimplemented
- */
-LPPROTOENT
-EXPORT
-getprotobyname(
-    IN  CONST CHAR FAR* name)
-{
-    static CHAR *udp_aliases = 0;
-    static PROTOENT udp = { "udp", &udp_aliases, 17 };
-    static CHAR *tcp_aliases = 0;
-    static PROTOENT tcp = { "tcp", &tcp_aliases, 6 };
-    if( !_stricmp( name, "udp" ) ) {
-	return &udp;
-    } else if( !_stricmp( name, "tcp" ) ) {
-	return &tcp;
-    }
-    
-    return 0;
-}
-
-/*
- * @unimplemented
- */
-LPPROTOENT
-EXPORT
-getprotobynumber(
-    IN  INT number)
-{
-    UNIMPLEMENTED
-
-    return (LPPROTOENT)NULL;
-}
-
-#define SKIPWS(ptr,act) \
-{while(*ptr && isspace(*ptr)) ptr++; if(!*ptr) act;}
-#define SKIPANDMARKSTR(ptr,act) \
-{while(*ptr && !isspace(*ptr)) ptr++; \
- if(!*ptr) {act;} else { *ptr = 0; ptr++; }}
- 
-
-static BOOL DecodeServEntFromString( IN  PCHAR ServiceString,
-				     OUT PCHAR *ServiceName,
-				     OUT PCHAR *PortNumberStr,
-				     OUT PCHAR *ProtocolStr,
-				     IN  PCHAR *Aliases,
-				     IN  DWORD MaxAlias ) {
-    UINT NAliases = 0;
-
-    WS_DbgPrint(MAX_TRACE, ("Parsing service ent [%s]\n", ServiceString));
-
-    SKIPWS(ServiceString, return FALSE);
-    *ServiceName = ServiceString;
-    SKIPANDMARKSTR(ServiceString, return FALSE);
-    SKIPWS(ServiceString, return FALSE);
-    *PortNumberStr = ServiceString;
-    SKIPANDMARKSTR(ServiceString, ;);
-
-    while( *ServiceString && NAliases < MaxAlias - 1 ) {
-	SKIPWS(ServiceString, break);
-	if( *ServiceString ) {
-	    SKIPANDMARKSTR(ServiceString, ;);
-	    if( strlen(ServiceString) ) {
-		WS_DbgPrint(MAX_TRACE, ("Alias: %s\n", ServiceString));
-		*Aliases++ = ServiceString;
-		NAliases++;
-	    }
-	}
-    }
-    *Aliases = NULL;
-
-    *ProtocolStr = strchr(*PortNumberStr,'/');
-    if( !*ProtocolStr ) return FALSE;
-    **ProtocolStr = 0; (*ProtocolStr)++;
-
-    WS_DbgPrint(MAX_TRACE, ("Parsing done: %s %s %s %d\n",
-			    *ServiceName, *ProtocolStr, *PortNumberStr,
-			    NAliases));
-
-    return TRUE;
-}
-
-#define ADJ_PTR(p,b1,b2) p = (p - b1) + b2
-
-/*
- * @implemented
- */
-LPSERVENT
-EXPORT
-getservbyname(
-
-    IN  CONST CHAR FAR* name, 
-    IN  CONST CHAR FAR* proto)
-{
-    BOOL  Found = FALSE;
-    HANDLE ServicesFile;
-    CHAR ServiceDBData[BUFSIZ] = { 0 };
-    PCHAR SystemDirectory = ServiceDBData; /* Reuse this stack space */
-    PCHAR ServicesFileLocation = "\\drivers\\etc\\services";
-    PCHAR ThisLine = 0, NextLine = 0, ServiceName = 0, PortNumberStr = 0, 
-	ProtocolStr = 0, Comment = 0;
-    PCHAR Aliases[WS2_INTERNAL_MAX_ALIAS] = { 0 };
-    UINT i,SizeNeeded = 0, 
-	SystemDirSize = sizeof(ServiceDBData) - 1;
-    DWORD ReadSize = 0, ValidData = 0;
-    PWINSOCK_THREAD_BLOCK p = NtCurrentTeb()->WinSockData;
-    
-    if( !p ) {
-	WSASetLastError( WSANOTINITIALISED );
-	return NULL;
-    }
-
-    if( !name ) {
-	WSASetLastError( WSANO_RECOVERY );
-	return NULL;
-    }
-    
-    if( !GetSystemDirectoryA( SystemDirectory, SystemDirSize ) ) {
-	WSASetLastError( WSANO_RECOVERY );
-	WS_DbgPrint(MIN_TRACE, ("Could not get windows system directory.\n"));
-	return NULL; /* Can't get system directory */
-    }
-    
-    strncat( SystemDirectory, ServicesFileLocation, SystemDirSize );
-
-    ServicesFile = CreateFileA( SystemDirectory,
-				GENERIC_READ,
-				FILE_SHARE_READ,
-				NULL,
-				OPEN_EXISTING,
-				FILE_ATTRIBUTE_NORMAL | 
-				FILE_FLAG_SEQUENTIAL_SCAN,
-				NULL );
-
-    if( ServicesFile == INVALID_HANDLE_VALUE ) {
-	WSASetLastError( WSANO_RECOVERY );
-	return NULL;
-    }
-
-    /* Scan the services file ... 
-     *
-     * We will read up to BUFSIZ bytes per pass, until the buffer does not
-     * contain a full line, then we will try to read more.
-     *
-     * We fall from the loop if the buffer does not have a line terminator.
-     */
-
-    /* Initial Read */
-    while( !Found &&
-	   ReadFile( ServicesFile, ServiceDBData + ValidData,
-		     sizeof( ServiceDBData ) - ValidData,
-		     &ReadSize, NULL ) ) {
-	ValidData += ReadSize;
-	ReadSize = 0;
-	NextLine = ThisLine = ServiceDBData;
-
-	/* Find the beginning of the next line */
-	while( NextLine < ServiceDBData + ValidData &&
-	       *NextLine != '\r' && *NextLine != '\n' ) NextLine++;
-	
-	/* Zero and skip, so we can treat what we have as a string */
-	if( NextLine >= ServiceDBData + ValidData ) 
-	    break;
-
-	*NextLine = 0; NextLine++;
-
-	Comment = strchr( ThisLine, '#' );
-	if( Comment ) *Comment = 0; /* Terminate at comment start */
-
-	if( DecodeServEntFromString( ThisLine, 
-				     &ServiceName, 
-				     &PortNumberStr,
-				     &ProtocolStr,
-				     Aliases,
-				     WS2_INTERNAL_MAX_ALIAS ) &&
-	    !strcmp( ServiceName, name ) &&
-	    (proto ? !strcmp( ProtocolStr, proto ) : TRUE) ) {
-
-	    WS_DbgPrint(MAX_TRACE,("Found the service entry.\n"));
-	    Found = TRUE;
-	    SizeNeeded = sizeof(WINSOCK_GETSERVBYNAME_CACHE) + 
-		(NextLine - ThisLine);
-	    break;
-	}
-
-	/* Get rid of everything we read so far */
-	while( NextLine <= ServiceDBData + ValidData &&
-	       isspace( *NextLine ) ) NextLine++;
-
-	WS_DbgPrint(MAX_TRACE,("About to move %d chars\n", 
-			       ServiceDBData + ValidData - NextLine));
-
-	memmove( ServiceDBData, NextLine, 
-		 ServiceDBData + ValidData - NextLine );
-	ValidData -= NextLine - ServiceDBData;
-	WS_DbgPrint(MAX_TRACE,("Valid bytes: %d\n", ValidData));
-    }
-
-    /* This we'll do no matter what */
-    CloseHandle( ServicesFile );
-    
-    if( !Found ) {
-	WS_DbgPrint(MAX_TRACE,("Not found\n"));
-	WSASetLastError( WSANO_DATA );
-	return NULL;
-    }
-    
-    if( !p->Getservbyname || p->Getservbyname->Size < SizeNeeded ) {
-	/* Free previous getservbyname buffer, allocate bigger */
-	if( p->Getservbyname ) 
-	    HeapFree(GlobalHeap, 0, p->Getservbyname);
-	p->Getservbyname = HeapAlloc(GlobalHeap, 0, SizeNeeded);
-	if( !p->Getservbyname ) {
-	    WS_DbgPrint(MIN_TRACE,("Couldn't allocate %d bytes\n", 
-				   SizeNeeded));
-	    WSASetLastError( WSATRY_AGAIN );
-	    return NULL;
-	}
-	p->Getservbyname->Size = SizeNeeded;
-    }
-
-    /* Copy the data */
-    memmove( p->Getservbyname->Data, 
-	     ThisLine,
-	     NextLine - ThisLine );
-
-    ADJ_PTR(ServiceName,ThisLine,p->Getservbyname->Data);
-    ADJ_PTR(ProtocolStr,ThisLine,p->Getservbyname->Data);
-    WS_DbgPrint(MAX_TRACE,
-		("ServiceName: %s, Protocol: %s\n", ServiceName, ProtocolStr));
-		
-    for( i = 0; Aliases[i]; i++ ) {
-	ADJ_PTR(Aliases[i],ThisLine,p->Getservbyname->Data);
-	WS_DbgPrint(MAX_TRACE,("Aliase %d: %s\n", i, Aliases[i]));
-    }
-
-    memcpy(p->Getservbyname,Aliases,sizeof(Aliases));
-
-    /* Create the struct proper */
-    p->Getservbyname->ServerEntry.s_name = ServiceName;
-    p->Getservbyname->ServerEntry.s_aliases = p->Getservbyname->Aliases;
-    p->Getservbyname->ServerEntry.s_port = htons(atoi(PortNumberStr));
-    p->Getservbyname->ServerEntry.s_proto = ProtocolStr;
-
-    return &p->Getservbyname->ServerEntry;
-}
-
-
-/*
- * @implemented
- */
-LPSERVENT
-EXPORT
-getservbyport(
-    IN  INT port, 
-    IN  CONST CHAR FAR* proto)
-{
-    BOOL  Found = FALSE;
-    HANDLE ServicesFile;
-    CHAR ServiceDBData[BUFSIZ] = { 0 };
-    PCHAR SystemDirectory = ServiceDBData; /* Reuse this stack space */
-    PCHAR ServicesFileLocation = "\\drivers\\etc\\services";
-    PCHAR ThisLine = 0, NextLine = 0, ServiceName = 0, PortNumberStr = 0, 
-	ProtocolStr = 0, Comment = 0;
-    PCHAR Aliases[WS2_INTERNAL_MAX_ALIAS] = { 0 };
-    UINT i,SizeNeeded = 0, 
-	SystemDirSize = sizeof(ServiceDBData) - 1;
-    DWORD ReadSize = 0, ValidData = 0;
-    PWINSOCK_THREAD_BLOCK p = NtCurrentTeb()->WinSockData;
-    
-    if( !p ) {
-	WSASetLastError( WSANOTINITIALISED );
-	return NULL;
-    }
-
-    if ( !port ) {
-        WSASetLastError( WSANO_RECOVERY );
-        return NULL;
-    }
- 
-    if( !GetSystemDirectoryA( SystemDirectory, SystemDirSize ) ) {
-	WSASetLastError( WSANO_RECOVERY );
-	WS_DbgPrint(MIN_TRACE, ("Could not get windows system directory.\n"));
-	return NULL; /* Can't get system directory */
-    }
-    
-    strncat( SystemDirectory, ServicesFileLocation, SystemDirSize );
-
-    ServicesFile = CreateFileA( SystemDirectory,
-				GENERIC_READ,
-				FILE_SHARE_READ,
-				NULL,
-				OPEN_EXISTING,
-				FILE_ATTRIBUTE_NORMAL | 
-				FILE_FLAG_SEQUENTIAL_SCAN,
-				NULL );
-
-    if( ServicesFile == INVALID_HANDLE_VALUE ) {
-	WSASetLastError( WSANO_RECOVERY );
-	return NULL;
-    }
-
-    /* Scan the services file ... 
-     *
-     * We will read up to BUFSIZ bytes per pass, until the buffer does not
-     * contain a full line, then we will try to read more.
-     *
-     * We fall from the loop if the buffer does not have a line terminator.
-     */
-
-    /* Initial Read */
-    while( !Found &&
-	   ReadFile( ServicesFile, ServiceDBData + ValidData,
-		     sizeof( ServiceDBData ) - ValidData,
-		     &ReadSize, NULL ) ) {
-	ValidData += ReadSize;
-	ReadSize = 0;
-	NextLine = ThisLine = ServiceDBData;
-
-	/* Find the beginning of the next line */
-	while( NextLine < ServiceDBData + ValidData &&
-	       *NextLine != '\r' && *NextLine != '\n' ) NextLine++;
-	
-	/* Zero and skip, so we can treat what we have as a string */
-	if( NextLine >= ServiceDBData + ValidData ) 
-	    break;
-
-	*NextLine = 0; NextLine++;
-
-	Comment = strchr( ThisLine, '#' );
-	if( Comment ) *Comment = 0; /* Terminate at comment start */
-
-	if( DecodeServEntFromString( ThisLine, 
-				     &ServiceName, 
-				     &PortNumberStr,
-				     &ProtocolStr,
-				     Aliases,
-				     WS2_INTERNAL_MAX_ALIAS ) &&
-	    (htons(atoi( PortNumberStr )) == port ) &&
-	    (proto ? !strcmp( ProtocolStr, proto ) : TRUE) ) {
-
-            WS_DbgPrint(MAX_TRACE,("Found the port entry.\n"));
-
-	    Found = TRUE;
-	    SizeNeeded = sizeof(WINSOCK_GETSERVBYPORT_CACHE) + 
-		(NextLine - ThisLine);
-	    break;
-	}
-
-	/* Get rid of everything we read so far */
-	while( NextLine <= ServiceDBData + ValidData &&
-	       isspace( *NextLine ) ) NextLine++;
-
-	WS_DbgPrint(MAX_TRACE,("About to move %d chars\n", 
-			       ServiceDBData + ValidData - NextLine));
-
-	memmove( ServiceDBData, NextLine, 
-		 ServiceDBData + ValidData - NextLine );
-	ValidData -= NextLine - ServiceDBData;
-	WS_DbgPrint(MAX_TRACE,("Valid bytes: %d\n", ValidData));
-    }
-
-    /* This we'll do no matter what */
-    CloseHandle( ServicesFile );
-    
-    if( !Found ) {
-	WS_DbgPrint(MAX_TRACE,("Not found\n"));
-	WSASetLastError( WSANO_DATA );
-	return NULL;
-    }
-    
-    if( !p->Getservbyport || p->Getservbyport->Size < SizeNeeded ) {
-	/* Free previous getservbyport buffer, allocate bigger */
-	if( p->Getservbyport ) 
-	    HeapFree(GlobalHeap, 0, p->Getservbyport);
-	p->Getservbyport = HeapAlloc(GlobalHeap, 0, SizeNeeded);
-	if( !p->Getservbyport ) {
-	    WS_DbgPrint(MIN_TRACE,("Couldn't allocate %d bytes\n", 
-				   SizeNeeded));
-	    WSASetLastError( WSATRY_AGAIN );
-	    return NULL;
-	}
-        p->Getservbyport->Size = SizeNeeded;
-    }
-    /* Copy the data */
-    memmove( p->Getservbyport->Data, 
-	     ThisLine,
-	     NextLine - ThisLine );
-
-    ADJ_PTR(PortNumberStr,ThisLine,p->Getservbyport->Data);
-    ADJ_PTR(ProtocolStr,ThisLine,p->Getservbyport->Data);
-    WS_DbgPrint(MAX_TRACE,
-		("Port Number: %s, Protocol: %s\n", PortNumberStr, ProtocolStr));
-		
-    for( i = 0; Aliases[i]; i++ ) {
-	ADJ_PTR(Aliases[i],ThisLine,p->Getservbyport->Data);
-	WS_DbgPrint(MAX_TRACE,("Aliases %d: %s\n", i, Aliases[i]));
-    }
-
-    memcpy(p->Getservbyport,Aliases,sizeof(Aliases));
-
-    /* Create the struct proper */
-    p->Getservbyport->ServerEntry.s_name = ServiceName;
-    p->Getservbyport->ServerEntry.s_aliases = p->Getservbyport->Aliases;
-    p->Getservbyport->ServerEntry.s_port = port;
-    p->Getservbyport->ServerEntry.s_proto = ProtocolStr;
-
-    WS_DbgPrint(MID_TRACE,("s_name: %s\n", ServiceName));
-
-    return &p->Getservbyport->ServerEntry;
-
-}
-
-
-/*
- * @implemented
- */
-ULONG
-EXPORT
-inet_addr(
-    IN  CONST CHAR FAR* cp)
-/*
- * FUNCTION: Converts a string containing an IPv4 address to an unsigned long
- * ARGUMENTS:
- *     cp = Pointer to string with address to convert
- * RETURNS:
- *     Binary representation of IPv4 address, or INADDR_NONE
- */
-{
-    UINT i;
-    PCHAR p;
-    ULONG u = 0;
-
-    p = (PCHAR)cp;
-
-    if (strlen(p) == 0)
-        return INADDR_NONE;
-
-    if (strcmp(p, " ") == 0)
-        return 0;
-
-    for (i = 0; i <= 3; i++) {
-        u += (strtoul(p, &p, 0) << (i * 8));
-
-        if (strlen(p) == 0)
-            return u;
-
-        if (p[0] != '.')
-            return INADDR_NONE;
-
-        p++;
-    }
-
-    return u;
-}
-
-
-/*
- * @implemented
- */
-CHAR FAR*
-EXPORT
-inet_ntoa(
-    IN  IN_ADDR in)
-{
-    CHAR b[10];
-    PCHAR p;
-
-    p = ((PWINSOCK_THREAD_BLOCK)NtCurrentTeb()->WinSockData)->Intoa;
-    _itoa(in.S_un.S_addr & 0xFF, b, 10);
-    strcpy(p, b);
-    _itoa((in.S_un.S_addr >> 8) & 0xFF, b, 10);
-    strcat(p, ".");
-    strcat(p, b);
-    _itoa((in.S_un.S_addr >> 16) & 0xFF, b, 10);
-    strcat(p, ".");
-    strcat(p, b);
-    _itoa((in.S_un.S_addr >> 24) & 0xFF, b, 10);
-    strcat(p, ".");
-    strcat(p, b);
-    return (CHAR FAR*)p;
-}
-
-
-/*
- * @unimplemented
- */
-HANDLE
-EXPORT
-WSAAsyncGetHostByAddr(
-    IN  HWND hWnd,
-    IN  UINT wMsg,
-    IN  CONST CHAR FAR* addr, 
-    IN  INT len,
-    IN  INT type, 
-    OUT CHAR FAR* buf, 
-    IN  INT buflen)
-{
-    UNIMPLEMENTED
-
-    return (HANDLE)0;
-}
-
-
-/*
- * @unimplemented
- */
-HANDLE
-EXPORT
-WSAAsyncGetHostByName(
-    IN  HWND hWnd, 
-    IN  UINT wMsg,  
-    IN  CONST CHAR FAR* name, 
-    OUT CHAR FAR* buf, 
-    IN  INT buflen)
-{
-    UNIMPLEMENTED
-
-    return (HANDLE)0;
-}
-
-
-/*
- * @unimplemented
- */
-HANDLE
-EXPORT
-WSAAsyncGetProtoByName(
-    IN  HWND hWnd,
-    IN  UINT wMsg,
-    IN  CONST CHAR FAR* name,
-    OUT CHAR FAR* buf,
-    IN  INT buflen)
-{
-    UNIMPLEMENTED
-
-    return (HANDLE)0;
-}
-
-
-/*
- * @unimplemented
- */
-HANDLE
-EXPORT
-WSAAsyncGetProtoByNumber(
-    IN  HWND hWnd,
-    IN  UINT wMsg,
-    IN  INT number,
-    OUT CHAR FAR* buf,
-    IN  INT buflen)
-{
-    UNIMPLEMENTED
-
-    return (HANDLE)0;
-}
-
-
-/*
- * @unimplemented
- */
-HANDLE
-EXPORT
-WSAAsyncGetServByName(
-    IN  HWND hWnd,
-    IN  UINT wMsg,
-    IN  CONST CHAR FAR* name,
-    IN  CONST CHAR FAR* proto,
-    OUT CHAR FAR* buf,
-    IN  INT buflen)
-{
-    UNIMPLEMENTED
-
-    return (HANDLE)0;
-}
-
-
-/*
- * @unimplemented
- */
-HANDLE
-EXPORT
-WSAAsyncGetServByPort(
-    IN  HWND hWnd,
-    IN  UINT wMsg,
-    IN  INT port,
-    IN  CONST CHAR FAR* proto,
-    OUT CHAR FAR* buf,
-    IN  INT buflen)
-{
-    UNIMPLEMENTED
-
-    return (HANDLE)0;
-}
-
-/* EOF */
+/*
+ * COPYRIGHT:   See COPYING in the top level directory
+ * PROJECT:     ReactOS WinSock 2 DLL
+ * FILE:        misc/ns.c
+ * PURPOSE:     Namespace APIs
+ * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
+ * REVISIONS:
[truncated at 1000 lines; 1209 more skipped]

reactos/lib/ws2_32/misc
stubs.c 1.14 -> 1.15
diff -u -r1.14 -r1.15
--- stubs.c	17 Nov 2004 05:17:22 -0000	1.14
+++ stubs.c	25 Nov 2004 23:32:54 -0000	1.15
@@ -147,7 +147,7 @@
  * @implemented
  */
 INT
-EXPORT
+EXPORT __stdcall
 setsockopt(
     IN  SOCKET s,
     IN  INT level,
CVSspam 0.2.8