minor corrections by M.Taguchi
[reactos.git] / reactos / apps / tests / dnsquery / dnsquery.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 (DnsQuery ("www.reactos.com", DNS_TYPE_A, DNS_QUERY_STANDARD,
13 NULL, &QueryReply, NULL) == ERROR_SUCCESS);
14 AddrResponse = QueryReply;
15 while( AddrResponse ) {
16 if( AddrResponse->wType == DNS_TYPE_A ) {
17 Addr = ntohl( AddrResponse->Data.A.IpAddress );
18 printf( "www.reactos.com == %d.%d.%d.%d\n",
19 (int)(Addr >> 24) & 0xff,
20 (int)(Addr >> 16) & 0xff,
21 (int)(Addr >> 8) & 0xff,
22 (int)Addr & 0xff );
23 }
24 AddrResponse = AddrResponse->pNext;
25 }
26 DnsRecordListFree( QueryReply, DnsFreeRecordList );
27
28 return 0;
29 }