mirror of
https://github.com/reactos/reactos.git
synced 2024-09-14 23:01:53 +00:00
dnsapi test application.
svn path=/trunk/; revision=7108
This commit is contained in:
parent
78aaee0a8b
commit
92d507d00a
6
reactos/apps/tests/dnsapi/.cvsignore
Normal file
6
reactos/apps/tests/dnsapi/.cvsignore
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
*.o
|
||||||
|
*.d
|
||||||
|
*.exe
|
||||||
|
*.coff
|
||||||
|
*.sym
|
||||||
|
*.map
|
33
reactos/apps/tests/dnsapi/dnsapi.c
Normal file
33
reactos/apps/tests/dnsapi/dnsapi.c
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#include <windows.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <WinError.h>
|
||||||
|
#include <WinDNS.h>
|
||||||
|
#include <winsock2.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
int main( int argc, char **argv ) {
|
||||||
|
PDNS_RECORD QueryReply, AddrResponse;
|
||||||
|
DWORD Addr;
|
||||||
|
|
||||||
|
assert (DnsValidateName( "||||", DnsNameDomain ) == DNS_ERROR_INVALID_NAME_CHAR);
|
||||||
|
assert (DnsValidateName( "a.b.c", DnsNameDomainLabel ) == DNS_ERROR_INVALID_NAME);
|
||||||
|
assert (DnsValidateName( "1234", DnsNameDomainLabel ) == ERROR_SUCCESS);
|
||||||
|
assert (DnsValidateName( "fubar", DnsNameDomain ) == ERROR_SUCCESS);
|
||||||
|
assert (DnsQuery ("www.reactos.com", DNS_TYPE_A, DNS_QUERY_STANDARD,
|
||||||
|
NULL, &QueryReply, NULL) == ERROR_SUCCESS);
|
||||||
|
AddrResponse = QueryReply;
|
||||||
|
while( AddrResponse ) {
|
||||||
|
if( AddrResponse->wType == DNS_TYPE_A ) {
|
||||||
|
Addr = ntohl( AddrResponse->Data.A.IpAddress );
|
||||||
|
printf( "www.reactos.com == %d.%d.%d.%d\n",
|
||||||
|
(int)(Addr >> 24) & 0xff,
|
||||||
|
(int)(Addr >> 16) & 0xff,
|
||||||
|
(int)(Addr >> 8) & 0xff,
|
||||||
|
(int)Addr & 0xff );
|
||||||
|
}
|
||||||
|
AddrResponse = AddrResponse->pNext;
|
||||||
|
}
|
||||||
|
DnsRecordListFree( QueryReply, DnsFreeRecordList );
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
22
reactos/apps/tests/dnsapi/makefile
Normal file
22
reactos/apps/tests/dnsapi/makefile
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
PATH_TO_TOP = ../../..
|
||||||
|
|
||||||
|
TARGET_NORC = yes
|
||||||
|
|
||||||
|
TARGET_TYPE = program
|
||||||
|
|
||||||
|
TARGET_APPTYPE = console
|
||||||
|
|
||||||
|
TARGET_NAME = dnsapi
|
||||||
|
|
||||||
|
TARGET_SDKLIBS = dnsapi.a ws2_32.a kernel32.a
|
||||||
|
|
||||||
|
TARGET_OBJECTS = $(TARGET_NAME).o
|
||||||
|
|
||||||
|
TARGET_CFLAGS = -Wall -Werror -g
|
||||||
|
|
||||||
|
include $(PATH_TO_TOP)/rules.mak
|
||||||
|
|
||||||
|
include $(TOOLS_PATH)/helper.mk
|
||||||
|
|
||||||
|
# EOF
|
Loading…
Reference in a new issue