/* Copyright 1998 by the Massachusetts Institute of Technology.
*
- * $Id$
*
* Permission to use, copy, modify, and distribute this
* software and its documentation for any purpose and without
* without express or implied warranty.
*/
-#include "setup.h"
-#include <sys/types.h>
+#include "ares_setup.h"
#if !defined(WIN32) || defined(WATT32)
-#include <sys/time.h>
-#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
-#include <unistd.h>
#endif
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
+#ifdef HAVE_STRINGS_H
+#include <strings.h>
#endif
#include "ares.h"
#include "ares_dns.h"
#include "inet_ntop.h"
#include "inet_net_pton.h"
+#include "ares_getopt.h"
+#include "ares_ipv6.h"
+#include "ares_nowarn.h"
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
+#ifndef HAVE_STRDUP
+# include "ares_strdup.h"
+# define strdup(ptr) ares_strdup(ptr)
#endif
-#ifndef HAVE_STRUCT_IN6_ADDR
-struct in6_addr
-{
- unsigned char s6_addr[16];
-};
+#ifndef HAVE_STRCASECMP
+# include "ares_strcasecmp.h"
+# define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
#endif
-static void callback(void *arg, int status, struct hostent *host);
+#ifndef HAVE_STRNCASECMP
+# include "ares_strcasecmp.h"
+# define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
+#endif
+
+static void callback(void *arg, int status, int timeouts, struct hostent *host);
static void usage(void);
int main(int argc, char **argv)
fd_set read_fds, write_fds;
struct timeval *tvp, tv;
struct in_addr addr4;
- struct in6_addr addr6;
+ struct ares_in6_addr addr6;
#ifdef USE_WINSOCK
WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
WSAStartup(wVersionRequested, &wsaData);
#endif
- while ((c = getopt(argc,argv,"t:h")) != -1)
+ status = ares_library_init(ARES_LIB_INIT_ALL);
+ if (status != ARES_SUCCESS)
+ {
+ fprintf(stderr, "ares_library_init: %s\n", ares_strerror(status));
+ return 1;
+ }
+
+ while ((c = ares_getopt(argc,argv,"dt:h")) != -1)
{
switch (c)
{
+ case 'd':
+#ifdef WATT32
+ dbug_init();
+#endif
+ break;
case 't':
if (!strcasecmp(optarg,"a"))
addr_family = AF_INET;
}
/* Wait for all queries to complete. */
- while (1)
+ for (;;)
{
FD_ZERO(&read_fds);
FD_ZERO(&write_fds);
}
ares_destroy(channel);
+
+ ares_library_cleanup();
+
+#ifdef USE_WINSOCK
+ WSACleanup();
+#endif
+
return 0;
}
-static void callback(void *arg, int status, struct hostent *host)
+static void callback(void *arg, int status, int timeouts, struct hostent *host)
{
char **p;
+ (void)timeouts;
+
if (status != ARES_SUCCESS)
{
fprintf(stderr, "%s: %s\n", (char *) arg, ares_strerror(status));