{
/* Get the name */
UnicodeName = &Addrinfo->ai_canonname;
-
+
/* Check if it exists */
if (*UnicodeName)
{
{
/* Free the old one */
HeapFree(WsSockHeap, 0, *UnicodeName);
-
+
/* Set the new one */
*UnicodeName = (LPWSTR)AnsiName;
}
return FALSE;
WideCharToMultiByte(CP_ACP,
0,
- AddressString,
- -1,
- AnsiAddressString,
+ AddressString,
+ -1,
+ AnsiAddressString,
sizeof(AnsiAddressString),
NULL,
0);
*/
if (*cp) return FALSE;
+ if (pp >= parts + 4) return FALSE;
*pp++ = val;
/*
* Concoct the address according to
/* Check if we ran out of memory */
if (Next) return EAI_MEMORY;
-
+
/* Return success */
return 0;
}
/* Copy the canonical name */
strcpy(Alias, Hostent->h_name);
-
+
/* Return success */
return 0;
}
-
+
/* Find out what the error was */
switch (GetLastError())
{
/* Get the reverse name */
Dns_Ip4AddressToReverseName_W(ReverseBuffer, *Ip4Addr);
}
- /* FIXME: Not implemented for now
+ /* FIXME: Not implemented for now
else if ( */
/* By this point we have the Reverse Name, so prepare for lookup */
&LookupHandle);
if (ErrorCode == ERROR_SUCCESS)
{
- /* Lookup succesfull, now get the data */
+ /* Lookup successful, now get the data */
BufferLength = (NI_MAXHOST - 1) * sizeof(WCHAR) + sizeof(Restrictions);
ErrorCode = WSALookupServiceNextW(LookupHandle,
0,
/* Make a copy of the name */
strcpy(Name, NodeName);
-
+
/* Loop */
while (TRUE)
{
/* Exit if we have a result */
if (*pptResult) break;
- /* Don't loop continously if this is a DNS misconfiguration */
+ /* Don't loop continuously if this is a DNS misconfiguration */
if ((!strlen(Alias)) || (!strcmp(Name, Alias)) || (++AliasCount == 16))
{
/* Exit the loop with a failure */
Swap(Name, Alias, Scratch);
}
- /* Check if we suceeded and the canonical name is requested */
+ /* Check if we succeeded and the canonical name is requested */
if (!iError && bAI_CANONNAME)
{
/* Allocate memory for a copy */
(*pptResult)->ai_canonname = HeapAlloc(WsSockHeap, 0, 512);
-
+
/* Check if we had enough memory */
if (!(*pptResult)->ai_canonname)
{
else
{
/* Convert the alias to UNICODE */
- MultiByteToWideChar(CP_ACP,
- 0,
- Alias,
- -1,
- (*pptResult)->ai_canonname,
+ MultiByteToWideChar(CP_ACP,
+ 0,
+ Alias,
+ -1,
+ (*pptResult)->ai_canonname,
256);
}
}
SetLastError(EAI_FAIL);
return EAI_FAIL;
}
-
+
/* Save the flags and validate them */
iFlags = ptHints->ai_flags;
if ((iFlags & AI_CANONNAME) && !pszNodeName)
/* We need to convert it to ANSI */
WideCharToMultiByte(CP_ACP,
0,
- pszServiceName,
- -1,
- AnsiServiceName,
+ pszServiceName,
+ -1,
+ AnsiServiceName,
sizeof(AnsiServiceName),
NULL,
0);
/* Return the port from the servent */
if (ptService) wPort = wTcpPort = ptService->s_port;
}
-
+
/* If we got 0, then fail */
if (wPort == 0)
{
iSocketType = SOCK_STREAM;
if (!wTcpPort && wUdpPort)
iSocketType = SOCK_DGRAM;
- //bClone = (wTcpPort && wUdpPort);
+ //bClone = (wTcpPort && wUdpPort);
}
}
}
dwAddress = htonl((iFlags & AI_PASSIVE) ?
INADDR_ANY : INADDR_LOOPBACK);
}
-
+
/* Create the Addr Info */
*pptResult = NewAddrInfo(iSocketType, iProtocol, wPort, dwAddress);
/* If we didn't get one back, assume out of memory */
if (!(*pptResult)) iError = EAI_MEMORY;
-
+
/* Check if we have success and a nodename */
if (!iError && pszNodeName)
{
/* Set AI_NUMERICHOST since this is a numeric string */
(*pptResult)->ai_flags |= AI_NUMERICHOST;
-
+
/* Check if the canonical name was requested */
if (iFlags & AI_CANONNAME)
{
(*pptResult)->ai_canonname = HeapAlloc(WsSockHeap,
0,
wcslen(CanonicalName));
-
+
if (!(*pptResult)->ai_canonname)
{
/* No memory for the copy */
/* We need to convert it to ANSI */
WideCharToMultiByte(CP_ACP,
0,
- pszNodeName,
- -1,
- AnsiNodeName,
+ pszNodeName,
+ -1,
+ AnsiNodeName,
sizeof(AnsiNodeName),
NULL,
0);
{
/* Free the address info and return nothing */
FreeAddrInfoW(*pptResult);
- *pptResult = NULL;
+ *pptResult = NULL;
}
/* Return to caller */
/* Free it */
HeapFree(WsSockHeap, 0, NextInfo->ai_canonname);
}
-
+
/* Check if there is an address */
if (NextInfo->ai_addr)
{
{
INT ErrorCode;
LPWSTR UnicodeNodeName = NULL;
- LPWSTR UnicodeServName = NULL;
+ LPWSTR UnicodeServName = NULL;
DPRINT("getaddrinfo: %s, %s, %p, %p\n", nodename, servname, hints, res);
/* Check for WSAStartup */
/* Convert the node name */
if (nodename)
{
- UnicodeNodeName = UnicodeDupFromAnsi((LPSTR)nodename);
+ UnicodeNodeName = UnicodeDupFromAnsi(nodename);
if (!UnicodeNodeName)
{
/* Prepare to fail */
/* Convert the servname too, if we have one */
if (servname)
{
- UnicodeServName = UnicodeDupFromAnsi((LPSTR)servname);
+ UnicodeServName = UnicodeDupFromAnsi(servname);
if (!UnicodeServName)
{
/* Prepare to fail */
goto Quickie;
}
}
-
+
/* Now call the unicode function */
ErrorCode = GetAddrInfoW(UnicodeNodeName,
UnicodeServName,
(PADDRINFOW)hints,
(PADDRINFOW*)res);
- /* Convert it to ANSI if we suceeded */
+ /* Convert it to ANSI if we succeeded */
if (ErrorCode == ERROR_SUCCESS) ConvertAddrinfoFromUnicodeToAnsi((PADDRINFOW)*res);
Quickie:
/* Unsupported family */
SetLastError(EAI_FAMILY);
return EAI_FAMILY;
- }
+ }
- /* Check for valid socket adress length */
+ /* Check for valid socket address length */
if ((DWORD)SockaddrLength < AddressLength)
return WSAEFAULT;
/* Check if we have a node name */
if (pNodeBuffer)
- {
+ {
/* Check if only the numeric host is wanted */
if (!(Flags & NI_NUMERICHOST))
{
}
else
{
- /* We suceeded, no need to get the numeric address */
+ /* We succeeded, no need to get the numeric address */
goto SkipNumeric;
}
}
{
/* Setup the data for it */
ServiceString = ServiceBuffer;
- ServLength = sizeof(ServiceBuffer) - 1;
+ ServLength = sizeof(ServiceBuffer) / sizeof(WCHAR);
}
-
+
/* Now call the unicode function */
ErrorCode = GetNameInfoW(sa,
salen,