ReactOS 0.4.15-dev-8236-g99f0937
getnameinfo.c File Reference
#include "ws2_32.h"
Include dependency graph for getnameinfo.c:

Go to the source code of this file.

Functions

 START_TEST (getnameinfo)
 

Function Documentation

◆ START_TEST()

START_TEST ( getnameinfo  )

Definition at line 10 of file getnameinfo.c.

11{
12 WSADATA WsaData;
13 int Error, MinSize;
14 PCHAR NodeBuffer, ServiceBuffer;
15 CHAR TestBuf[NI_MAXHOST];
16 WCHAR TestBufW[NI_MAXHOST];
17 SOCKADDR_IN LocalAddr;
18
19 /* not yet initialized */
20 StartSeh()
21 Error = getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
24 StartSeh()
25 NodeBuffer = InvalidPointer;
26 ServiceBuffer = InvalidPointer;
27 Error = getnameinfo(NULL, 0, NodeBuffer, 0, ServiceBuffer, 0, 0);
29 ok_ptr(NodeBuffer, InvalidPointer);
30 ok_ptr(ServiceBuffer, InvalidPointer);
32
33 LocalAddr.sin_family = AF_INET;
34 LocalAddr.sin_port = 80;
35 LocalAddr.sin_addr.S_un.S_addr = ntohl(INADDR_LOOPBACK);
36 Error = getnameinfo((PSOCKADDR)&LocalAddr, sizeof(LocalAddr), TestBuf, sizeof(TestBuf), NULL, 0, 0);
38
39 Error = WSAStartup(MAKEWORD(2, 2), &WsaData);
40 ok_dec(Error, 0);
41
42 StartSeh()
43 Error = getnameinfo(NULL, 0, NULL, 0, NULL, 0, 0);
46 StartSeh()
47 NodeBuffer = InvalidPointer;
48 ServiceBuffer = InvalidPointer;
49 Error = getnameinfo(NULL, 0, NodeBuffer, 0, ServiceBuffer, 0, 0);
51 ok_ptr(NodeBuffer, InvalidPointer);
52 ok_ptr(ServiceBuffer, InvalidPointer);
54
55 /* initialize LocalAddress for tests */
56 Error = getnameinfo((PSOCKADDR)&LocalAddr, sizeof(LocalAddr), TestBuf, sizeof(TestBuf), NULL, 0, 0);
57 ok_dec(Error, 0);
59
60 /* test minimal size */
61 MinSize = sizeof(LocalAddr);
62 Error = getnameinfo((PSOCKADDR)&LocalAddr, MinSize, TestBuf, sizeof(TestBuf), NULL, 0, 0);
63 ok_dec(Error, 0);
65
66 Error = GetNameInfoA((PSOCKADDR)&LocalAddr, MinSize, TestBuf, sizeof(TestBuf), NULL, 0, 0);
67 ok_dec(Error, 0);
69
70 Error = GetNameInfoW((PSOCKADDR)&LocalAddr, MinSize, TestBufW, sizeof(TestBufW), NULL, 0, 0);
71 ok_dec(Error, 0);
73
74 MinSize--;
75 Error = getnameinfo((PSOCKADDR)&LocalAddr, MinSize, TestBuf, sizeof(TestBuf), NULL, 0, 0);
77
78 Error = GetNameInfoA((PSOCKADDR)&LocalAddr, MinSize, TestBuf, sizeof(TestBuf), NULL, 0, 0);
80
81 Error = GetNameInfoW((PSOCKADDR)&LocalAddr, MinSize, TestBufW, sizeof(TestBufW), NULL, 0, 0);
83
84 Error = WSACleanup();
85 ok_dec(Error, 0);
86
87 /* not initialized anymore */
88 Error = getnameinfo((PSOCKADDR)&LocalAddr, sizeof(LocalAddr), NodeBuffer, 0, ServiceBuffer, 0, 0);
90}
#define InvalidPointer
#define StartSeh()
Definition: _sntprintf.h:16
#define EndSeh(ExpectedStatus)
Definition: _sntprintf.h:17
INT WSAAPI GetNameInfoW(IN CONST SOCKADDR *pSockaddr, IN socklen_t SockaddrLength, OUT PWCHAR pNodeBuffer, IN DWORD NodeBufferSize, OUT PWCHAR pServiceBuffer, IN DWORD ServiceBufferSize, IN INT Flags)
Definition: addrinfo.c:873
#define ok_dec(expression, result)
Definition: atltest.h:101
#define ok_ptr(expression, result)
Definition: atltest.h:108
BOOL Error
Definition: chkdsk.c:66
#define NULL
Definition: types.h:112
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
#define AF_INET
Definition: tcpip.h:117
#define INADDR_LOOPBACK
Definition: inet.h:51
#define ntohl(x)
Definition: module.h:205
#define STATUS_SUCCESS
Definition: shellext.h:65
#define MAKEWORD(a, b)
Definition: typedefs.h:248
char * PCHAR
Definition: typedefs.h:51
#define WSANOTINITIALISED
Definition: winerror.h:1987
#define WSAEFAULT
Definition: winerror.h:1945
int PASCAL FAR WSAGetLastError(void)
Definition: dllmain.c:112
int PASCAL FAR WSACleanup(void)
Definition: startup.c:60
#define NI_MAXHOST
Definition: ws2def.h:359
#define GetNameInfoA
Definition: ws2tcpip.h:392
#define getnameinfo
Definition: wspiapi.h:45
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
__wchar_t WCHAR
Definition: xmlstorage.h:180
char CHAR
Definition: xmlstorage.h:175