Adding rostests as part of the tree restructure
[reactos.git] / rosapps / tests / dnsapi / dnsapi.c
1 #include <windows.h>
2 #include <stdio.h>
3 #include <winerror.h>
4 #include <windns.h>
5 #include <winsock2.h>
6 #include <assert.h>
7
8 int main( int argc, char **argv ) {
9 PDNS_RECORD QueryReply, AddrResponse;
10 DWORD Addr;
11
12 assert (DnsValidateName( "||||", DnsNameDomain ) == DNS_ERROR_INVALID_NAME_CHAR);
13 assert (DnsValidateName( "a.b.c", DnsNameDomainLabel ) == DNS_ERROR_INVALID_NAME);
14 assert (DnsValidateName( "1234", DnsNameDomainLabel ) == ERROR_SUCCESS);
15 assert (DnsValidateName( "fubar", DnsNameDomain ) == ERROR_SUCCESS);
16 assert (DnsQuery ("www.reactos.com", DNS_TYPE_A, DNS_QUERY_STANDARD,
17 NULL, &QueryReply, NULL) == ERROR_SUCCESS);
18 AddrResponse = QueryReply;
19 while( AddrResponse ) {
20 if( AddrResponse->wType == DNS_TYPE_A ) {
21 Addr = ntohl( AddrResponse->Data.A.IpAddress );
22 printf( "www.reactos.com == %d.%d.%d.%d\n",
23 (int)(Addr >> 24) & 0xff,
24 (int)(Addr >> 16) & 0xff,
25 (int)(Addr >> 8) & 0xff,
26 (int)Addr & 0xff );
27 }
28 AddrResponse = AddrResponse->pNext;
29 }
30 DnsRecordListFree( QueryReply, DnsFreeRecordList );
31
32 return 0;
33 }