/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS WinSock 2 DLL
- * FILE: misc/ns.c
+ * FILE: dll/win32/ws2_32/misc/ns.c
* PURPOSE: Namespace APIs
* PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
* REVISIONS:
#include "ws2_32.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <winnls.h>
+
#ifndef BUFSIZ
#define BUFSIZ 1024
#endif/*BUFSIZ*/
p = NtCurrentTeb()->WinSockData;
- if( !p )
+ if (!p || !WSAINITIALIZED)
{
WSASetLastError( WSANOTINITIALISED );
return NULL;
DWORD ReadSize = 0;
PWINSOCK_THREAD_BLOCK p = NtCurrentTeb()->WinSockData;
- if( !p )
+ if (!p || !WSAINITIALIZED)
{
WSASetLastError( WSANOTINITIALISED );
return NULL;
DWORD ReadSize = 0, ValidData = 0;
PWINSOCK_THREAD_BLOCK p = NtCurrentTeb()->WinSockData;
- if( !p )
+ if( !p || !WSAINITIALIZED)
{
WSASetLastError( WSANOTINITIALISED );
return NULL;
struct addrinfo *ret = NULL, *ai;
ULONG addr;
USHORT port;
+ PCHAR pc;
struct servent *se;
char *proto;
LPPROTOENT pent;
struct sockaddr_in *sin;
INT error;
- if (res == NULL)
+ if (!WSAINITIALIZED)
{
- error = WSAEINVAL;
+ error = WSANOTINITIALISED;
goto End;
}
+
+ *res = NULL;
+
if (nodename == NULL && servname == NULL)
{
error = WSAHOST_NOT_FOUND;
goto End;
}
- if (!WSAINITIALIZED)
- {
- error = WSANOTINITIALISED;
- goto End;
- }
-
if (servname)
{
/* converting port number */
- port = strtoul(servname, NULL, 10);
+ port = strtoul(servname, &pc, 10);
/* service name was specified? */
- if (port == 0)
+ if (*pc != ANSI_NULL)
{
/* protocol was specified? */
if (hints && hints->ai_protocol)