Browse Source

Reduce contrib/libs/c-ares import footprint

thegeorg 1 year ago
parent
commit
816268d291

+ 0 - 35
contrib/libs/c-ares/acountry/ya.make

@@ -1,35 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-WITHOUT_LICENSE_TEXTS()
-
-PEERDIR(
-    contrib/libs/c-ares
-)
-
-ADDINCL(
-    GLOBAL contrib/libs/c-ares
-    GLOBAL contrib/libs/c-ares/include
-    GLOBAL contrib/libs/c-ares/src/lib
-    contrib/libs/c-ares/src/tools
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
-    -DHAVE_CONFIG_H=1
-)
-
-SRCDIR(contrib/libs/c-ares/src)
-
-SRCS(
-    lib/ares_nowarn.c
-    lib/ares_strcasecmp.c
-    tools/acountry.c
-    tools/ares_getopt.c
-)
-
-END()

+ 0 - 35
contrib/libs/c-ares/adig/ya.make

@@ -1,35 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-WITHOUT_LICENSE_TEXTS()
-
-PEERDIR(
-    contrib/libs/c-ares
-)
-
-ADDINCL(
-    GLOBAL contrib/libs/c-ares
-    GLOBAL contrib/libs/c-ares/include
-    GLOBAL contrib/libs/c-ares/src/lib
-    contrib/libs/c-ares/src/tools
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
-    -DHAVE_CONFIG_H=1
-)
-
-SRCDIR(contrib/libs/c-ares/src)
-
-SRCS(
-    lib/ares_nowarn.c
-    lib/ares_strcasecmp.c
-    tools/adig.c
-    tools/ares_getopt.c
-)
-
-END()

+ 0 - 35
contrib/libs/c-ares/ahost/ya.make

@@ -1,35 +0,0 @@
-# Generated by devtools/yamaker.
-
-PROGRAM()
-
-WITHOUT_LICENSE_TEXTS()
-
-PEERDIR(
-    contrib/libs/c-ares
-)
-
-ADDINCL(
-    GLOBAL contrib/libs/c-ares
-    GLOBAL contrib/libs/c-ares/include
-    GLOBAL contrib/libs/c-ares/src/lib
-    contrib/libs/c-ares/src/tools
-)
-
-NO_COMPILER_WARNINGS()
-
-NO_RUNTIME()
-
-CFLAGS(
-    -DHAVE_CONFIG_H=1
-)
-
-SRCDIR(contrib/libs/c-ares/src)
-
-SRCS(
-    lib/ares_nowarn.c
-    lib/ares_strcasecmp.c
-    tools/ahost.c
-    tools/ares_getopt.c
-)
-
-END()

+ 1 - 1
contrib/libs/c-ares/src/lib/bitncmp.c

@@ -40,7 +40,7 @@ int ares__bitncmp(const void *l, const void *r, int n)
 
   b = n / 8;
   x = memcmp(l, r, b);
-  if (x || (n & 7) == 0)
+  if (x || (n % 8) == 0)
     return (x);
 
   lb = ((const unsigned char *)l)[b];

+ 0 - 655
contrib/libs/c-ares/src/tools/acountry.c

@@ -1,655 +0,0 @@
-/*
- *
- * IP-address/hostname to country converter.
- *
- * Problem; you want to know where IP a.b.c.d is located.
- *
- * Use ares_gethostbyname ("d.c.b.a.zz.countries.nerd.dk")
- * and get the CNAME (host->h_name). Result will be:
- *   CNAME = zz<CC>.countries.nerd.dk with address 127.0.x.y (ver 1) or
- *   CNAME = <a.b.c.d>.zz.countries.nerd.dk with address 127.0.x.y (ver 2)
- *
- * The 2 letter country code is in <CC> and the ISO-3166 country
- * number is in x.y (number = x*256 + y). Version 2 of the protocol is missing
- * the <CC> number.
- *
- * Ref: http://countries.nerd.dk/more.html
- *
- * Written by G. Vanem <gvanem@yahoo.no> 2006, 2007
- *
- * NB! This program may not be big-endian aware.
- *
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting
- * documentation, and that the name of M.I.T. not be used in
- * advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.
- * M.I.T. makes no representations about the suitability of
- * this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- */
-
-#include "ares_setup.h"
-
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-#if defined(WIN32) && !defined(WATT32)
-  #include <winsock.h>
-#else
-  #include <arpa/inet.h>
-  #include <netinet/in.h>
-  #include <netdb.h>
-#endif
-
-#include "ares.h"
-#include "ares_getopt.h"
-#include "ares_nowarn.h"
-
-#ifndef HAVE_STRDUP
-#  include "ares_strdup.h"
-#  define strdup(ptr) ares_strdup(ptr)
-#endif
-
-#ifndef HAVE_STRCASECMP
-#  include "ares_strcasecmp.h"
-#  define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
-#endif
-
-#ifndef HAVE_STRNCASECMP
-#  include "ares_strcasecmp.h"
-#  define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
-#endif
-
-#ifndef INADDR_NONE
-#define INADDR_NONE 0xffffffff
-#endif
-
-/* By using a double cast, we can get rid of the bogus warning of
- * warning: cast from 'const struct sockaddr *' to 'const struct sockaddr_in6 *' increases required alignment from 1 to 4 [-Wcast-align]
- */
-#define CARES_INADDR_CAST(type, var) ((type)((void *)var))
-
-static const char *usage      = "acountry [-?hdv] {host|addr} ...\n";
-static const char  nerd_fmt[] = "%u.%u.%u.%u.zz.countries.nerd.dk";
-static const char *nerd_ver1  = nerd_fmt + 14;  /* .countries.nerd.dk */
-static const char *nerd_ver2  = nerd_fmt + 11;  /* .zz.countries.nerd.dk */
-static int         verbose    = 0;
-
-#define TRACE(fmt) do {               \
-                     if (verbose > 0) \
-                       printf fmt ;   \
-                   } WHILE_FALSE
-
-static void wait_ares(ares_channel channel);
-static void callback(void *arg, int status, int timeouts, struct hostent *host);
-static void callback2(void *arg, int status, int timeouts, struct hostent *host);
-static void find_country_from_cname(const char *cname, struct in_addr addr);
-static void print_help_info_acountry(void);
-
-static void Abort(const char *fmt, ...)
-{
-  va_list args;
-  va_start(args, fmt);
-  vfprintf(stderr, fmt, args);
-  va_end(args);
-  exit(1);
-}
-
-int main(int argc, char **argv)
-{
-  ares_channel channel;
-  int    ch, status;
-
-#if defined(WIN32) && !defined(WATT32)
-  WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
-  WSADATA wsaData;
-  WSAStartup(wVersionRequested, &wsaData);
-#endif
-
-  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 ((ch = ares_getopt(argc, argv, "dvh?")) != -1)
-    switch (ch)
-      {
-      case 'd':
-#ifdef WATT32
-        dbug_init();
-#endif
-        break;
-      case 'v':
-        verbose++;
-        break;
-      case 'h':
-        print_help_info_acountry();
-        break;
-      case '?':
-        print_help_info_acountry();
-        break;
-      default:
-        Abort(usage);
-      }
-
-  argc -= optind;
-  argv += optind;
-  if (argc < 1)
-     Abort(usage);
-
-  status = ares_init(&channel);
-  if (status != ARES_SUCCESS)
-    {
-      fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
-      return 1;
-    }
-
-  /* Initiate the queries, one per command-line argument. */
-  for ( ; *argv; argv++)
-    {
-      struct in_addr addr;
-      char *buf;
-
-      /* If this fails, assume '*argv' is a host-name that
-       * must be resolved first
-       */
-      if (ares_inet_pton(AF_INET, *argv, &addr) != 1)
-        {
-          ares_gethostbyname(channel, *argv, AF_INET, callback2, &addr);
-          wait_ares(channel);
-          if (addr.s_addr == INADDR_NONE)
-            {
-              printf("Failed to lookup %s\n", *argv);
-              continue;
-            }
-        }
-
-      buf = malloc(100);
-      sprintf(buf, nerd_fmt,
-              (unsigned int)(addr.s_addr >> 24),
-              (unsigned int)((addr.s_addr >> 16) & 255),
-              (unsigned int)((addr.s_addr >> 8) & 255),
-              (unsigned int)(addr.s_addr & 255));
-      TRACE(("Looking up %s...", buf));
-      fflush(stdout);
-      ares_gethostbyname(channel, buf, AF_INET, callback, buf);
-    }
-
-  wait_ares(channel);
-  ares_destroy(channel);
-
-  ares_library_cleanup();
-
-#if defined(WIN32) && !defined(WATT32)
-  WSACleanup();
-#endif
-
-  return 0;
-}
-
-/*
- * Wait for the queries to complete.
- */
-static void wait_ares(ares_channel channel)
-{
-  for (;;)
-    {
-      struct timeval *tvp, tv;
-      fd_set read_fds, write_fds;
-      int nfds;
-
-      FD_ZERO(&read_fds);
-      FD_ZERO(&write_fds);
-      nfds = ares_fds(channel, &read_fds, &write_fds);
-      if (nfds == 0)
-        break;
-      tvp = ares_timeout(channel, NULL, &tv);
-      nfds = select(nfds, &read_fds, &write_fds, NULL, tvp);
-      if (nfds < 0)
-        continue;
-      ares_process(channel, &read_fds, &write_fds);
-    }
-}
-
-/*
- * This is the callback used when we have the IP-address of interest.
- * Extract the CNAME and figure out the country-code from it.
- */
-static void callback(void *arg, int status, int timeouts, struct hostent *host)
-{
-  const char *name = (const char*)arg;
-  const char *cname;
-  char buf[20];
-
-  (void)timeouts;
-
-  if (!host || status != ARES_SUCCESS)
-    {
-      printf("Failed to lookup %s: %s\n", name, ares_strerror(status));
-      free(arg);
-      return;
-    }
-
-  TRACE(("\nFound address %s, name %s\n",
-         ares_inet_ntop(AF_INET,(const char*)host->h_addr,buf,sizeof(buf)),
-         host->h_name));
-
-  cname = host->h_name;  /* CNAME gets put here */
-  if (!cname)
-    printf("Failed to get CNAME for %s\n", name);
-  else
-    find_country_from_cname(cname, *(CARES_INADDR_CAST(struct in_addr *, host->h_addr)));
-  free(arg);
-}
-
-/*
- * This is the callback used to obtain the IP-address of the host of interest.
- */
-static void callback2(void *arg, int status, int timeouts, struct hostent *host)
-{
-  struct in_addr *addr = (struct in_addr*) arg;
-
-  (void)timeouts;
-  if (!host || status != ARES_SUCCESS)
-    memset(addr, INADDR_NONE, sizeof(*addr));
-  else
-    memcpy(addr, host->h_addr, sizeof(*addr));
-}
-
-struct search_list {
-       int         country_number; /* ISO-3166 country number */
-       char        short_name[3];  /* A2 short country code */
-       const char *long_name;      /* normal country name */
-     };
-
-static const struct search_list *list_lookup(int number, const struct search_list *list, int num)
-{
-  while (num > 0 && list->long_name)
-    {
-      if (list->country_number == number)
-        return (list);
-      num--;
-      list++;
-    }
-  return (NULL);
-}
-
-/*
- * Ref: https://en.wikipedia.org/wiki/ISO_3166-1
- */
-static const struct search_list country_list[] = {
-       {   4, "af", "Afghanistan"                          },
-       { 248, "ax", "Åland Island"                         },
-       {   8, "al", "Albania"                              },
-       {  12, "dz", "Algeria"                              },
-       {  16, "as", "American Samoa"                       },
-       {  20, "ad", "Andorra"                              },
-       {  24, "ao", "Angola"                               },
-       { 660, "ai", "Anguilla"                             },
-       {  10, "aq", "Antarctica"                           },
-       {  28, "ag", "Antigua & Barbuda"                    },
-       {  32, "ar", "Argentina"                            },
-       {  51, "am", "Armenia"                              },
-       { 533, "aw", "Aruba"                                },
-       {  36, "au", "Australia"                            },
-       {  40, "at", "Austria"                              },
-       {  31, "az", "Azerbaijan"                           },
-       {  44, "bs", "Bahamas"                              },
-       {  48, "bh", "Bahrain"                              },
-       {  50, "bd", "Bangladesh"                           },
-       {  52, "bb", "Barbados"                             },
-       { 112, "by", "Belarus"                              },
-       {  56, "be", "Belgium"                              },
-       {  84, "bz", "Belize"                               },
-       { 204, "bj", "Benin"                                },
-       {  60, "bm", "Bermuda"                              },
-       {  64, "bt", "Bhutan"                               },
-       {  68, "bo", "Bolivia"                              },
-       { 535, "bq", "Bonaire, Sint Eustatius and Saba"     }, /* Formerly 'Bonaire' / 'Netherlands Antilles' */
-       {  70, "ba", "Bosnia & Herzegovina"                 },
-       {  72, "bw", "Botswana"                             },
-       {  74, "bv", "Bouvet Island"                        },
-       {  76, "br", "Brazil"                               },
-       {  86, "io", "British Indian Ocean Territory"       },
-       {  96, "bn", "Brunei Darussalam"                    },
-       { 100, "bg", "Bulgaria"                             },
-       { 854, "bf", "Burkina Faso"                         },
-       { 108, "bi", "Burundi"                              },
-       { 116, "kh", "Cambodia"                             },
-       { 120, "cm", "Cameroon"                             },
-       { 124, "ca", "Canada"                               },
-       { 132, "cv", "Cape Verde"                           },
-       { 136, "ky", "Cayman Islands"                       },
-       { 140, "cf", "Central African Republic"             },
-       { 148, "td", "Chad"                                 },
-       { 152, "cl", "Chile"                                },
-       { 156, "cn", "China"                                },
-       { 162, "cx", "Christmas Island"                     },
-       { 166, "cc", "Cocos Islands"                        },
-       { 170, "co", "Colombia"                             },
-       { 174, "km", "Comoros"                              },
-       { 178, "cg", "Congo"                                },
-       { 180, "cd", "Congo"                                },
-       { 184, "ck", "Cook Islands"                         },
-       { 188, "cr", "Costa Rica"                           },
-       { 384, "ci", "Cote d'Ivoire"                        },
-       { 191, "hr", "Croatia"                              },
-       { 192, "cu", "Cuba"                                 },
-       { 531, "cw", "Curaçao"                              },
-       { 196, "cy", "Cyprus"                               },
-       { 203, "cz", "Czech Republic"                       },
-       { 208, "dk", "Denmark"                              },
-       { 262, "dj", "Djibouti"                             },
-       { 212, "dm", "Dominica"                             },
-       { 214, "do", "Dominican Republic"                   },
-       { 218, "ec", "Ecuador"                              },
-       { 818, "eg", "Egypt"                                },
-       { 222, "sv", "El Salvador"                          },
-       { 226, "gq", "Equatorial Guinea"                    },
-       { 232, "er", "Eritrea"                              },
-       { 233, "ee", "Estonia"                              },
-       { 748, "sz", "Eswatini"                             }, /* Formerly Swaziland */
-       { 231, "et", "Ethiopia"                             },
-     { 65281, "eu", "European Union"                       }, /* 127.0.255.1 */
-       { 238, "fk", "Falkland Islands"                     },
-       { 234, "fo", "Faroe Islands"                        },
-       { 242, "fj", "Fiji"                                 },
-       { 246, "fi", "Finland"                              },
-       { 250, "fr", "France"                               },
-       { 249, "fx", "France, Metropolitan"                 },
-       { 254, "gf", "French Guiana"                        },
-       { 258, "pf", "French Polynesia"                     },
-       { 260, "tf", "French Southern Territories"          },
-       { 266, "ga", "Gabon"                                },
-       { 270, "gm", "Gambia"                               },
-       { 268, "ge", "Georgia"                              },
-       { 276, "de", "Germany"                              },
-       { 288, "gh", "Ghana"                                },
-       { 292, "gi", "Gibraltar"                            },
-       { 300, "gr", "Greece"                               },
-       { 304, "gl", "Greenland"                            },
-       { 308, "gd", "Grenada"                              },
-       { 312, "gp", "Guadeloupe"                           },
-       { 316, "gu", "Guam"                                 },
-       { 320, "gt", "Guatemala"                            },
-       { 831, "gg", "Guernsey"                             },
-       { 324, "gn", "Guinea"                               },
-       { 624, "gw", "Guinea-Bissau"                        },
-       { 328, "gy", "Guyana"                               },
-       { 332, "ht", "Haiti"                                },
-       { 334, "hm", "Heard & Mc Donald Islands"            },
-       { 336, "va", "Holy See"                             }, /* Vatican City */
-       { 340, "hn", "Honduras"                             },
-       { 344, "hk", "Hong kong"                            },
-       { 348, "hu", "Hungary"                              },
-       { 352, "is", "Iceland"                              },
-       { 356, "in", "India"                                },
-       { 360, "id", "Indonesia"                            },
-       { 364, "ir", "Iran"                                 },
-       { 368, "iq", "Iraq"                                 },
-       { 372, "ie", "Ireland"                              },
-       { 833, "im", "Isle of Man"                          },
-       { 376, "il", "Israel"                               },
-       { 380, "it", "Italy"                                },
-       { 388, "jm", "Jamaica"                              },
-       { 392, "jp", "Japan"                                },
-       { 832, "je", "Jersey"                               },
-       { 400, "jo", "Jordan"                               },
-       { 398, "kz", "Kazakhstan"                           },
-       { 404, "ke", "Kenya"                                },
-       { 296, "ki", "Kiribati"                             },
-       { 408, "kp", "Korea (north)"                        },
-       { 410, "kr", "Korea (south)"                        },
-       {   0, "xk", "Kosovo"                               }, /* https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 */
-       { 414, "kw", "Kuwait"                               },
-       { 417, "kg", "Kyrgyzstan"                           },
-       { 418, "la", "Laos"                                 },
-       { 428, "lv", "Latvia"                               },
-       { 422, "lb", "Lebanon"                              },
-       { 426, "ls", "Lesotho"                              },
-       { 430, "lr", "Liberia"                              },
-       { 434, "ly", "Libya"                                },
-       { 438, "li", "Liechtenstein"                        },
-       { 440, "lt", "Lithuania"                            },
-       { 442, "lu", "Luxembourg"                           },
-       { 446, "mo", "Macao"                                },
-       { 450, "mg", "Madagascar"                           },
-       { 454, "mw", "Malawi"                               },
-       { 458, "my", "Malaysia"                             },
-       { 462, "mv", "Maldives"                             },
-       { 466, "ml", "Mali"                                 },
-       { 470, "mt", "Malta"                                },
-       { 584, "mh", "Marshall Islands"                     },
-       { 474, "mq", "Martinique"                           },
-       { 478, "mr", "Mauritania"                           },
-       { 480, "mu", "Mauritius"                            },
-       { 175, "yt", "Mayotte"                              },
-       { 484, "mx", "Mexico"                               },
-       { 583, "fm", "Micronesia"                           },
-       { 498, "md", "Moldova"                              },
-       { 492, "mc", "Monaco"                               },
-       { 496, "mn", "Mongolia"                             },
-       { 499, "me", "Montenegro"                           },  
-       { 500, "ms", "Montserrat"                           },
-       { 504, "ma", "Morocco"                              },
-       { 508, "mz", "Mozambique"                           },
-       { 104, "mm", "Myanmar"                              },
-       { 516, "na", "Namibia"                              },
-       { 520, "nr", "Nauru"                                },
-       { 524, "np", "Nepal"                                },
-       { 528, "nl", "Netherlands"                          },
-       { 540, "nc", "New Caledonia"                        },
-       { 554, "nz", "New Zealand"                          },
-       { 558, "ni", "Nicaragua"                            },
-       { 562, "ne", "Niger"                                },
-       { 566, "ng", "Nigeria"                              },
-       { 570, "nu", "Niue"                                 },
-       { 574, "nf", "Norfolk Island"                       },
-       { 807, "mk", "North Macedonia"                      }, /* 'Macedonia' until February 2019 */
-       { 580, "mp", "Northern Mariana Islands"             },
-       { 578, "no", "Norway"                               },
-       { 512, "om", "Oman"                                 },
-       { 586, "pk", "Pakistan"                             },
-       { 585, "pw", "Palau"                                },
-       { 275, "ps", "Palestinian Territory"                },
-       { 591, "pa", "Panama"                               },
-       { 598, "pg", "Papua New Guinea"                     },
-       { 600, "py", "Paraguay"                             },
-       { 604, "pe", "Peru"                                 },
-       { 608, "ph", "Philippines"                          },
-       { 612, "pn", "Pitcairn"                             },
-       { 616, "pl", "Poland"                               },
-       { 620, "pt", "Portugal"                             },
-       { 630, "pr", "Puerto Rico"                          },
-       { 634, "qa", "Qatar"                                },
-       { 638, "re", "Reunion"                              },
-       { 642, "ro", "Romania"                              },
-       { 643, "ru", "Russian Federation"                   },
-       { 646, "rw", "Rwanda"                               },
-       { 0,   "bl", "Saint Barthélemy"                     }, /* https://en.wikipedia.org/wiki/ISO_3166-2:BL */
-       { 659, "kn", "Saint Kitts & Nevis"                  },
-       { 662, "lc", "Saint Lucia"                          },
-       { 663, "mf", "Saint Martin"                         },
-       { 670, "vc", "Saint Vincent"                        },
-       { 882, "ws", "Samoa"                                },
-       { 674, "sm", "San Marino"                           },
-       { 678, "st", "Sao Tome & Principe"                  },
-       { 682, "sa", "Saudi Arabia"                         },
-       { 686, "sn", "Senegal"                              },
-       { 688, "rs", "Serbia"                               },
-       { 690, "sc", "Seychelles"                           },
-       { 694, "sl", "Sierra Leone"                         },
-       { 702, "sg", "Singapore"                            },
-       { 534, "sx", "Sint Maarten"                         },
-       { 703, "sk", "Slovakia"                             },
-       { 705, "si", "Slovenia"                             },
-       {  90, "sb", "Solomon Islands"                      },
-       { 706, "so", "Somalia"                              },
-       { 710, "za", "South Africa"                         },
-       { 239, "gs", "South Georgia & South Sandwich Is."   },
-       { 728, "ss", "South Sudan"                          },
-       { 724, "es", "Spain"                                },
-       { 144, "lk", "Sri Lanka"                            },
-       { 654, "sh", "St. Helena"                           },
-       { 666, "pm", "St. Pierre & Miquelon"                },
-       { 736, "sd", "Sudan"                                },
-       { 740, "sr", "Suriname"                             },
-       { 744, "sj", "Svalbard & Jan Mayen Islands"         },
-       { 752, "se", "Sweden"                               },
-       { 756, "ch", "Switzerland"                          },
-       { 760, "sy", "Syrian Arab Republic"                 },
-       { 158, "tw", "Taiwan"                               },
-       { 762, "tj", "Tajikistan"                           },
-       { 834, "tz", "Tanzania"                             },
-       { 764, "th", "Thailand"                             },
-       { 626, "tl", "Timor-Leste"                          },
-       { 768, "tg", "Togo"                                 },
-       { 772, "tk", "Tokelau"                              },
-       { 776, "to", "Tonga"                                },
-       { 780, "tt", "Trinidad & Tobago"                    },
-       { 788, "tn", "Tunisia"                              },
-       { 792, "tr", "Turkey"                               },
-       { 795, "tm", "Turkmenistan"                         },
-       { 796, "tc", "Turks & Caicos Islands"               },
-       { 798, "tv", "Tuvalu"                               },
-       { 800, "ug", "Uganda"                               },
-       { 804, "ua", "Ukraine"                              },
-       { 784, "ae", "United Arab Emirates"                 },
-       { 826, "gb", "United Kingdom"                       },
-       { 840, "us", "United States"                        },
-       { 581, "um", "United States Minor Outlying Islands" },
-       { 858, "uy", "Uruguay"                              },
-       { 860, "uz", "Uzbekistan"                           },
-       { 548, "vu", "Vanuatu"                              },
-       { 862, "ve", "Venezuela"                            },
-       { 704, "vn", "Vietnam"                              },
-       {  92, "vg", "Virgin Islands (British)"             },
-       { 850, "vi", "Virgin Islands (US)"                  },
-       { 876, "wf", "Wallis & Futuna Islands"              },
-       { 732, "eh", "Western Sahara"                       },
-       { 887, "ye", "Yemen"                                },
-       { 894, "zm", "Zambia"                               },
-       { 716, "zw", "Zimbabwe"                             }
-     };
-
-/*
- * Check if start of 'str' is simply an IPv4 address.
- */
-#define BYTE_OK(x) ((x) >= 0 && (x) <= 255)
-
-static int is_addr(char *str, char **end)
-{
-  int a0, a1, a2, a3, num, rc = 0, length = 0;
-
-  num = sscanf(str,"%3d.%3d.%3d.%3d%n",&a0,&a1,&a2,&a3,&length);
-  if( (num == 4) &&
-      BYTE_OK(a0) && BYTE_OK(a1) && BYTE_OK(a2) && BYTE_OK(a3) &&
-      length >= (3+4))
-    {
-      rc = 1;
-      *end = str + length;
-    }
-  return rc;
-}
-
-/*
- * Find the country-code and name from the CNAME. E.g.:
- *   version 1: CNAME = zzno.countries.nerd.dk with address 127.0.2.66
- *              yields ccode_A" = "no" and cnumber 578 (2.66).
- *   version 2: CNAME = <a.b.c.d>.zz.countries.nerd.dk with address 127.0.2.66
- *              yields cnumber 578 (2.66). ccode_A is "";
- */
-static void find_country_from_cname(const char *cname, struct in_addr addr)
-{
-  const struct search_list *country;
-  char  ccode_A2[3], *ccopy, *dot_4;
-  int   cnumber, z0, z1, ver_1, ver_2;
-  unsigned long ip;
-
-  ip = ntohl(addr.s_addr);
-  z0 = TOLOWER(cname[0]);
-  z1 = TOLOWER(cname[1]);
-  ccopy = strdup(cname);
-  dot_4 = NULL;
-
-  ver_1 = (z0 == 'z' && z1 == 'z' && !strcasecmp(cname+4,nerd_ver1));
-  ver_2 = (is_addr(ccopy,&dot_4) && !strcasecmp(dot_4,nerd_ver2));
-
-  if (ver_1)
-    {
-      const char *dot = strchr(cname, '.');
-      if (dot != cname+4)
-        {
-          printf("Unexpected CNAME %s (ver_1)\n", cname);
-          free(ccopy);
-          return;
-        }
-    }
-  else if (ver_2)
-    {
-      z0 = TOLOWER(dot_4[1]);
-      z1 = TOLOWER(dot_4[2]);
-      if (z0 != 'z' && z1 != 'z')
-        {
-          printf("Unexpected CNAME %s (ver_2)\n", cname);
-          free(ccopy);
-          return;
-        }
-    }
-  else
-    {
-      printf("Unexpected CNAME %s (ver?)\n", cname);
-      free(ccopy);
-      return;
-    }
-
-  if (ver_1)
-    {
-      ccode_A2[0] = (char)TOLOWER(cname[2]);
-      ccode_A2[1] = (char)TOLOWER(cname[3]);
-      ccode_A2[2] = '\0';
-    }
-  else
-    ccode_A2[0] = '\0';
-
-  cnumber = ip & 0xFFFF;
-
-  TRACE(("Found country-code `%s', number %d\n",
-         ver_1 ? ccode_A2 : "<n/a>", cnumber));
-
-  country = list_lookup(cnumber, country_list,
-                        sizeof(country_list) / sizeof(country_list[0]));
-  if (!country)
-    printf("Name for country-number %d not found.\n", cnumber);
-  else
-    {
-      if (ver_1)
-        {
-          if ((country->short_name[0] != ccode_A2[0]) ||
-              (country->short_name[1] != ccode_A2[1]) ||
-              (country->short_name[2] != ccode_A2[2]))
-            printf("short-name mismatch; %s vs %s\n",
-                   country->short_name, ccode_A2);
-        }
-      printf("%s (%s), number %d.\n",
-             country->long_name, country->short_name, cnumber);
-    }
-  free(ccopy);
-}
-
-/* Information from the man page. Formatting taken from man -h */
-static void print_help_info_acountry(void) {
-    printf("acountry, version %s\n\n", ARES_VERSION_STR);
-    printf("usage: acountry [-hdv] host|addr ...\n\n"
-    "  h : Display this help and exit.\n"
-    "  d : Print some extra debugging output.\n"
-    "  v : Be more verbose. Print extra information.\n\n");
-    exit(0);
-}

+ 0 - 988
contrib/libs/c-ares/src/tools/adig.c

@@ -1,988 +0,0 @@
-/* Copyright 1998 by the Massachusetts Institute of Technology.
- *
- *
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting
- * documentation, and that the name of M.I.T. not be used in
- * advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.
- * M.I.T. makes no representations about the suitability of
- * this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- */
-
-#include "ares_setup.h"
-
-#ifdef HAVE_NETINET_IN_H
-#  include <netinet/in.h>
-#endif
-#ifdef HAVE_ARPA_INET_H
-#  include <arpa/inet.h>
-#endif
-#ifdef HAVE_NETDB_H
-#  include <netdb.h>
-#endif
-
-#include "ares_nameser.h"
-
-#ifdef HAVE_STRINGS_H
-#  include <strings.h>
-#endif
-
-#include "ares.h"
-#include "ares_dns.h"
-#include "ares_getopt.h"
-#include "ares_nowarn.h"
-
-#ifndef HAVE_STRDUP
-#  include "ares_strdup.h"
-#  define strdup(ptr) ares_strdup(ptr)
-#endif
-
-#ifndef HAVE_STRCASECMP
-#  include "ares_strcasecmp.h"
-#  define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
-#endif
-
-#ifndef HAVE_STRNCASECMP
-#  include "ares_strcasecmp.h"
-#  define strncasecmp(p1,p2,n) ares_strncasecmp(p1,p2,n)
-#endif
-
-#ifdef WATT32
-#undef WIN32  /* Redefined in MingW headers */
-#endif
-
-
-struct nv {
-  const char *name;
-  int value;
-};
-
-static const struct nv flags[] = {
-  { "usevc",            ARES_FLAG_USEVC },
-  { "primary",          ARES_FLAG_PRIMARY },
-  { "igntc",            ARES_FLAG_IGNTC },
-  { "norecurse",        ARES_FLAG_NORECURSE },
-  { "stayopen",         ARES_FLAG_STAYOPEN },
-  { "noaliases",        ARES_FLAG_NOALIASES }
-};
-static const int nflags = sizeof(flags) / sizeof(flags[0]);
-
-static const struct nv classes[] = {
-  { "IN",       C_IN },
-  { "CHAOS",    C_CHAOS },
-  { "HS",       C_HS },
-  { "ANY",      C_ANY }
-};
-static const int nclasses = sizeof(classes) / sizeof(classes[0]);
-
-static const struct nv types[] = {
-  { "A",        T_A },
-  { "NS",       T_NS },
-  { "MD",       T_MD },
-  { "MF",       T_MF },
-  { "CNAME",    T_CNAME },
-  { "SOA",      T_SOA },
-  { "MB",       T_MB },
-  { "MG",       T_MG },
-  { "MR",       T_MR },
-  { "NULL",     T_NULL },
-  { "WKS",      T_WKS },
-  { "PTR",      T_PTR },
-  { "HINFO",    T_HINFO },
-  { "MINFO",    T_MINFO },
-  { "MX",       T_MX },
-  { "TXT",      T_TXT },
-  { "RP",       T_RP },
-  { "AFSDB",    T_AFSDB },
-  { "X25",      T_X25 },
-  { "ISDN",     T_ISDN },
-  { "RT",       T_RT },
-  { "NSAP",     T_NSAP },
-  { "NSAP_PTR", T_NSAP_PTR },
-  { "SIG",      T_SIG },
-  { "KEY",      T_KEY },
-  { "PX",       T_PX },
-  { "GPOS",     T_GPOS },
-  { "AAAA",     T_AAAA },
-  { "LOC",      T_LOC },
-  { "SRV",      T_SRV },
-  { "AXFR",     T_AXFR },
-  { "MAILB",    T_MAILB },
-  { "MAILA",    T_MAILA },
-  { "NAPTR",    T_NAPTR },
-  { "DS",       T_DS },
-  { "SSHFP",    T_SSHFP },
-  { "RRSIG",    T_RRSIG },
-  { "NSEC",     T_NSEC },
-  { "DNSKEY",   T_DNSKEY },
-  { "CAA",      T_CAA },
-  { "URI",      T_URI },
-  { "ANY",      T_ANY }
-};
-static const int ntypes = sizeof(types) / sizeof(types[0]);
-
-static const char *opcodes[] = {
-  "QUERY", "IQUERY", "STATUS", "(reserved)", "NOTIFY",
-  "(unknown)", "(unknown)", "(unknown)", "(unknown)",
-  "UPDATEA", "UPDATED", "UPDATEDA", "UPDATEM", "UPDATEMA",
-  "ZONEINIT", "ZONEREF"
-};
-
-static const char *rcodes[] = {
-  "NOERROR", "FORMERR", "SERVFAIL", "NXDOMAIN", "NOTIMP", "REFUSED",
-  "(unknown)", "(unknown)", "(unknown)", "(unknown)", "(unknown)",
-  "(unknown)", "(unknown)", "(unknown)", "(unknown)", "NOCHANGE"
-};
-
-static void callback(void *arg, int status, int timeouts,
-                     unsigned char *abuf, int alen);
-static const unsigned char *display_question(const unsigned char *aptr,
-                                             const unsigned char *abuf,
-                                             int alen);
-static const unsigned char *display_rr(const unsigned char *aptr,
-                                       const unsigned char *abuf, int alen);
-static int convert_query (char **name, int use_bitstring);
-static const char *type_name(int type);
-static const char *class_name(int dnsclass);
-static void usage(void);
-static void destroy_addr_list(struct ares_addr_node *head);
-static void append_addr_list(struct ares_addr_node **head,
-                             struct ares_addr_node *node);
-static void print_help_info_adig(void);
-
-int main(int argc, char **argv)
-{
-  ares_channel channel;
-  int c, i, optmask = ARES_OPT_FLAGS, dnsclass = C_IN, type = T_A;
-  int status, nfds, count;
-  int use_ptr_helper = 0;
-  struct ares_options options;
-  struct hostent *hostent;
-  fd_set read_fds, write_fds;
-  struct timeval *tvp, tv;
-  struct ares_addr_node *srvr, *servers = NULL;
-
-#ifdef USE_WINSOCK
-  WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
-  WSADATA wsaData;
-  WSAStartup(wVersionRequested, &wsaData);
-#endif
-
-  status = ares_library_init(ARES_LIB_INIT_ALL);
-  if (status != ARES_SUCCESS)
-    {
-      fprintf(stderr, "ares_library_init: %s\n", ares_strerror(status));
-      return 1;
-    }
-
-  options.flags = ARES_FLAG_NOCHECKRESP;
-  options.servers = NULL;
-  options.nservers = 0;
-  while ((c = ares_getopt(argc, argv, "dh?f:s:c:t:T:U:x")) != -1)
-    {
-      switch (c)
-        {
-        case 'd':
-#ifdef WATT32
-          dbug_init();
-#endif
-          break;
-        case 'h':
-          print_help_info_adig();
-          break;
-        case '?':
-          print_help_info_adig();
-          break;
-        case 'f':
-          /* Add a flag. */
-          for (i = 0; i < nflags; i++)
-            {
-              if (strcmp(flags[i].name, optarg) == 0)
-                break;
-            }
-          if (i < nflags)
-            options.flags |= flags[i].value;
-          else
-            usage();
-          break;
-
-        case 's':
-          /* User-specified name servers override default ones. */
-          srvr = malloc(sizeof(struct ares_addr_node));
-          if (!srvr)
-            {
-              fprintf(stderr, "Out of memory!\n");
-              destroy_addr_list(servers);
-              return 1;
-            }
-          append_addr_list(&servers, srvr);
-          if (ares_inet_pton(AF_INET, optarg, &srvr->addr.addr4) > 0)
-            srvr->family = AF_INET;
-          else if (ares_inet_pton(AF_INET6, optarg, &srvr->addr.addr6) > 0)
-            srvr->family = AF_INET6;
-          else
-            {
-              hostent = gethostbyname(optarg);
-              if (!hostent)
-                {
-                  fprintf(stderr, "adig: server %s not found.\n", optarg);
-                  destroy_addr_list(servers);
-                  return 1;
-                }
-              switch (hostent->h_addrtype)
-                {
-                  case AF_INET:
-                    srvr->family = AF_INET;
-                    memcpy(&srvr->addr.addr4, hostent->h_addr,
-                           sizeof(srvr->addr.addr4));
-                    break;
-                  case AF_INET6:
-                    srvr->family = AF_INET6;
-                    memcpy(&srvr->addr.addr6, hostent->h_addr,
-                           sizeof(srvr->addr.addr6));
-                    break;
-                  default:
-                    fprintf(stderr,
-                      "adig: server %s unsupported address family.\n", optarg);
-                    destroy_addr_list(servers);
-                    return 1;
-                }
-            }
-          /* Notice that calling ares_init_options() without servers in the
-           * options struct and with ARES_OPT_SERVERS set simultaneously in
-           * the options mask, results in an initialization with no servers.
-           * When alternative name servers have been specified these are set
-           * later calling ares_set_servers() overriding any existing server
-           * configuration. To prevent initial configuration with default
-           * servers that will be discarded later, ARES_OPT_SERVERS is set.
-           * If this flag is not set here the result shall be the same but
-           * ares_init_options() will do needless work. */
-          optmask |= ARES_OPT_SERVERS;
-          break;
-
-        case 'c':
-          /* Set the query class. */
-          for (i = 0; i < nclasses; i++)
-            {
-              if (strcasecmp(classes[i].name, optarg) == 0)
-                break;
-            }
-          if (i < nclasses)
-            dnsclass = classes[i].value;
-          else
-            usage();
-          break;
-
-        case 't':
-          /* Set the query type. */
-          for (i = 0; i < ntypes; i++)
-            {
-              if (strcasecmp(types[i].name, optarg) == 0)
-                break;
-            }
-          if (i < ntypes)
-            type = types[i].value;
-          else
-            usage();
-          break;
-
-        case 'T':
-          /* Set the TCP port number. */
-          if (!ISDIGIT(*optarg))
-            usage();
-          options.tcp_port = (unsigned short)strtol(optarg, NULL, 0);
-          options.flags |= ARES_FLAG_USEVC;
-          optmask |= ARES_OPT_TCP_PORT;
-          break;
-
-        case 'U':
-          /* Set the UDP port number. */
-          if (!ISDIGIT(*optarg))
-            usage();
-          options.udp_port = (unsigned short)strtol(optarg, NULL, 0);
-          optmask |= ARES_OPT_UDP_PORT;
-          break;
-
-        case 'x':
-          use_ptr_helper++;
-          break;
-        }
-    }
-  argc -= optind;
-  argv += optind;
-  if (argc == 0)
-    usage();
-
-  status = ares_init_options(&channel, &options, optmask);
-
-  if (status != ARES_SUCCESS)
-    {
-      fprintf(stderr, "ares_init_options: %s\n",
-              ares_strerror(status));
-      return 1;
-    }
-
-  if(servers)
-    {
-      status = ares_set_servers(channel, servers);
-      destroy_addr_list(servers);
-      if (status != ARES_SUCCESS)
-        {
-          fprintf(stderr, "ares_init_options: %s\n",
-                  ares_strerror(status));
-          return 1;
-        }
-    }
-
-  /* Initiate the queries, one per command-line argument.  If there is
-   * only one query to do, supply NULL as the callback argument;
-   * otherwise, supply the query name as an argument so we can
-   * distinguish responses for the user when printing them out.
-   */
-  for (i = 1; *argv; i++, argv++)
-    {
-      char *query = *argv;
-
-      if (type == T_PTR && dnsclass == C_IN && use_ptr_helper)
-         if (!convert_query (&query, use_ptr_helper >= 2))
-            continue;
-
-      ares_query(channel, query, dnsclass, type, callback, i < argc-1 ? (void*)query : NULL);
-    }
-
-  /* Wait for all queries to complete. */
-  for (;;)
-    {
-      FD_ZERO(&read_fds);
-      FD_ZERO(&write_fds);
-      nfds = ares_fds(channel, &read_fds, &write_fds);
-      if (nfds == 0)
-        break;
-      tvp = ares_timeout(channel, NULL, &tv);
-      count = select(nfds, &read_fds, &write_fds, NULL, tvp);
-      if (count < 0 && (status = SOCKERRNO) != EINVAL)
-        {
-          printf("select fail: %d", status);
-          return 1;
-        }
-      ares_process(channel, &read_fds, &write_fds);
-    }
-
-  ares_destroy(channel);
-
-  ares_library_cleanup();
-
-#ifdef USE_WINSOCK
-  WSACleanup();
-#endif
-
-  return 0;
-}
-
-static void callback(void *arg, int status, int timeouts,
-                     unsigned char *abuf, int alen)
-{
-  char *name = (char *) arg;
-  int id, qr, opcode, aa, tc, rd, ra, rcode;
-  unsigned int qdcount, ancount, nscount, arcount, i;
-  const unsigned char *aptr;
-
-  (void) timeouts;
-
-  /* Display the query name if given. */
-  if (name)
-    printf("Answer for query %s:\n", name);
-
-  /* Display an error message if there was an error, but only stop if
-   * we actually didn't get an answer buffer.
-   */
-  if (status != ARES_SUCCESS)
-    {
-      printf("%s\n", ares_strerror(status));
-      if (!abuf)
-        return;
-    }
-
-  /* Won't happen, but check anyway, for safety. */
-  if (alen < HFIXEDSZ)
-    return;
-
-  /* Parse the answer header. */
-  id = DNS_HEADER_QID(abuf);
-  qr = DNS_HEADER_QR(abuf);
-  opcode = DNS_HEADER_OPCODE(abuf);
-  aa = DNS_HEADER_AA(abuf);
-  tc = DNS_HEADER_TC(abuf);
-  rd = DNS_HEADER_RD(abuf);
-  ra = DNS_HEADER_RA(abuf);
-  rcode = DNS_HEADER_RCODE(abuf);
-  qdcount = DNS_HEADER_QDCOUNT(abuf);
-  ancount = DNS_HEADER_ANCOUNT(abuf);
-  nscount = DNS_HEADER_NSCOUNT(abuf);
-  arcount = DNS_HEADER_ARCOUNT(abuf);
-
-  /* Display the answer header. */
-  printf("id: %d\n", id);
-  printf("flags: %s%s%s%s%s\n",
-         qr ? "qr " : "",
-         aa ? "aa " : "",
-         tc ? "tc " : "",
-         rd ? "rd " : "",
-         ra ? "ra " : "");
-  printf("opcode: %s\n", opcodes[opcode]);
-  printf("rcode: %s\n", rcodes[rcode]);
-
-  /* Display the questions. */
-  printf("Questions:\n");
-  aptr = abuf + HFIXEDSZ;
-  for (i = 0; i < qdcount; i++)
-    {
-      aptr = display_question(aptr, abuf, alen);
-      if (aptr == NULL)
-        return;
-    }
-
-  /* Display the answers. */
-  printf("Answers:\n");
-  for (i = 0; i < ancount; i++)
-    {
-      aptr = display_rr(aptr, abuf, alen);
-      if (aptr == NULL)
-        return;
-    }
-
-  /* Display the NS records. */
-  printf("NS records:\n");
-  for (i = 0; i < nscount; i++)
-    {
-      aptr = display_rr(aptr, abuf, alen);
-      if (aptr == NULL)
-        return;
-    }
-
-  /* Display the additional records. */
-  printf("Additional records:\n");
-  for (i = 0; i < arcount; i++)
-    {
-      aptr = display_rr(aptr, abuf, alen);
-      if (aptr == NULL)
-        return;
-    }
-}
-
-static const unsigned char *display_question(const unsigned char *aptr,
-                                             const unsigned char *abuf,
-                                             int alen)
-{
-  char *name;
-  int type, dnsclass, status;
-  long len;
-
-  /* Parse the question name. */
-  status = ares_expand_name(aptr, abuf, alen, &name, &len);
-  if (status != ARES_SUCCESS)
-    return NULL;
-  aptr += len;
-
-  /* Make sure there's enough data after the name for the fixed part
-   * of the question.
-   */
-  if (aptr + QFIXEDSZ > abuf + alen)
-    {
-      ares_free_string(name);
-      return NULL;
-    }
-
-  /* Parse the question type and class. */
-  type = DNS_QUESTION_TYPE(aptr);
-  dnsclass = DNS_QUESTION_CLASS(aptr);
-  aptr += QFIXEDSZ;
-
-  /* Display the question, in a format sort of similar to how we will
-   * display RRs.
-   */
-  printf("\t%-15s.\t", name);
-  if (dnsclass != C_IN)
-    printf("\t%s", class_name(dnsclass));
-  printf("\t%s\n", type_name(type));
-  ares_free_string(name);
-  return aptr;
-}
-
-static const unsigned char *display_rr(const unsigned char *aptr,
-                                       const unsigned char *abuf, int alen)
-{
-  const unsigned char *p;
-  int type, dnsclass, ttl, dlen, status, i;
-  long len;
-  int vlen;
-  char addr[46];
-  union {
-    unsigned char * as_uchar;
-             char * as_char;
-  } name;
-
-  /* Parse the RR name. */
-  status = ares_expand_name(aptr, abuf, alen, &name.as_char, &len);
-  if (status != ARES_SUCCESS)
-    return NULL;
-  aptr += len;
-
-  /* Make sure there is enough data after the RR name for the fixed
-   * part of the RR.
-   */
-  if (aptr + RRFIXEDSZ > abuf + alen)
-    {
-      ares_free_string(name.as_char);
-      return NULL;
-    }
-
-  /* Parse the fixed part of the RR, and advance to the RR data
-   * field. */
-  type = DNS_RR_TYPE(aptr);
-  dnsclass = DNS_RR_CLASS(aptr);
-  ttl = DNS_RR_TTL(aptr);
-  dlen = DNS_RR_LEN(aptr);
-  aptr += RRFIXEDSZ;
-  if (aptr + dlen > abuf + alen)
-    {
-      ares_free_string(name.as_char);
-      return NULL;
-    }
-
-  /* Display the RR name, class, and type. */
-  printf("\t%-15s.\t%d", name.as_char, ttl);
-  if (dnsclass != C_IN)
-    printf("\t%s", class_name(dnsclass));
-  printf("\t%s", type_name(type));
-  ares_free_string(name.as_char);
-
-  /* Display the RR data.  Don't touch aptr. */
-  switch (type)
-    {
-    case T_CNAME:
-    case T_MB:
-    case T_MD:
-    case T_MF:
-    case T_MG:
-    case T_MR:
-    case T_NS:
-    case T_PTR:
-      /* For these types, the RR data is just a domain name. */
-      status = ares_expand_name(aptr, abuf, alen, &name.as_char, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t%s.", name.as_char);
-      ares_free_string(name.as_char);
-      break;
-
-    case T_HINFO:
-      /* The RR data is two length-counted character strings. */
-      p = aptr;
-      len = *p;
-      if (p + len + 1 > aptr + dlen)
-        return NULL;
-      status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t%s", name.as_char);
-      ares_free_string(name.as_char);
-      p += len;
-      len = *p;
-      if (p + len + 1 > aptr + dlen)
-        return NULL;
-      status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t%s", name.as_char);
-      ares_free_string(name.as_char);
-      break;
-
-    case T_MINFO:
-      /* The RR data is two domain names. */
-      p = aptr;
-      status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t%s.", name.as_char);
-      ares_free_string(name.as_char);
-      p += len;
-      status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t%s.", name.as_char);
-      ares_free_string(name.as_char);
-      break;
-
-    case T_MX:
-      /* The RR data is two bytes giving a preference ordering, and
-       * then a domain name.
-       */
-      if (dlen < 2)
-        return NULL;
-      printf("\t%d", (int)DNS__16BIT(aptr));
-      status = ares_expand_name(aptr + 2, abuf, alen, &name.as_char, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t%s.", name.as_char);
-      ares_free_string(name.as_char);
-      break;
-
-    case T_SOA:
-      /* The RR data is two domain names and then five four-byte
-       * numbers giving the serial number and some timeouts.
-       */
-      p = aptr;
-      status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t%s.\n", name.as_char);
-      ares_free_string(name.as_char);
-      p += len;
-      status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t\t\t\t\t\t%s.\n", name.as_char);
-      ares_free_string(name.as_char);
-      p += len;
-      if (p + 20 > aptr + dlen)
-        return NULL;
-      printf("\t\t\t\t\t\t( %u %u %u %u %u )",
-             DNS__32BIT(p), DNS__32BIT(p+4),
-             DNS__32BIT(p+8), DNS__32BIT(p+12),
-             DNS__32BIT(p+16));
-      break;
-
-    case T_TXT:
-      /* The RR data is one or more length-counted character
-       * strings. */
-      p = aptr;
-      while (p < aptr + dlen)
-        {
-          len = *p;
-          if (p + len + 1 > aptr + dlen)
-            return NULL;
-          status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
-          if (status != ARES_SUCCESS)
-            return NULL;
-          printf("\t%s", name.as_char);
-          ares_free_string(name.as_char);
-          p += len;
-        }
-      break;
-
-    case T_CAA:
-
-      p = aptr;
-
-      /* Flags */
-      printf(" %u", (int)*p);
-      p += 1;
-
-      /* Remainder of record */
-      vlen = (int)dlen - ((char)*p) - 2;
-
-      /* The Property identifier, one of:
-          - "issue",
-          - "iodef", or
-          - "issuewild" */
-      status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf(" %s", name.as_char);
-      ares_free_string(name.as_char);
-      p += len;
-
-      if (p + vlen > abuf + alen)
-        return NULL;
-
-      /* A sequence of octets representing the Property Value */
-      printf(" %.*s", vlen, p);
-      break;
-
-    case T_A:
-      /* The RR data is a four-byte Internet address. */
-      if (dlen != 4)
-        return NULL;
-      printf("\t%s", ares_inet_ntop(AF_INET,aptr,addr,sizeof(addr)));
-      break;
-
-    case T_AAAA:
-      /* The RR data is a 16-byte IPv6 address. */
-      if (dlen != 16)
-        return NULL;
-      printf("\t%s", ares_inet_ntop(AF_INET6,aptr,addr,sizeof(addr)));
-      break;
-
-    case T_WKS:
-      /* Not implemented yet */
-      break;
-
-    case T_SRV:
-      /* The RR data is three two-byte numbers representing the
-       * priority, weight, and port, followed by a domain name.
-       */
-
-      printf("\t%d", (int)DNS__16BIT(aptr));
-      printf(" %d", (int)DNS__16BIT(aptr + 2));
-      printf(" %d", (int)DNS__16BIT(aptr + 4));
-
-      status = ares_expand_name(aptr + 6, abuf, alen, &name.as_char, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t%s.", name.as_char);
-      ares_free_string(name.as_char);
-      break;
-
-    case T_URI:
-      /* The RR data is two two-byte numbers representing the
-       * priority and weight, followed by a target.
-       */
-
-      printf("\t%d ", (int)DNS__16BIT(aptr));
-      printf("%d \t\t", (int)DNS__16BIT(aptr+2));
-      p = aptr +4;
-      for (i=0; i <dlen-4; ++i)
-        printf("%c",p[i]);
-      break;
-
-    case T_NAPTR:
-
-      printf("\t%d", (int)DNS__16BIT(aptr)); /* order */
-      printf(" %d\n", (int)DNS__16BIT(aptr + 2)); /* preference */
-
-      p = aptr + 4;
-      status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t\t\t\t\t\t%s\n", name.as_char);
-      ares_free_string(name.as_char);
-      p += len;
-
-      status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t\t\t\t\t\t%s\n", name.as_char);
-      ares_free_string(name.as_char);
-      p += len;
-
-      status = ares_expand_string(p, abuf, alen, &name.as_uchar, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t\t\t\t\t\t%s\n", name.as_char);
-      ares_free_string(name.as_char);
-      p += len;
-
-      status = ares_expand_name(p, abuf, alen, &name.as_char, &len);
-      if (status != ARES_SUCCESS)
-        return NULL;
-      printf("\t\t\t\t\t\t%s", name.as_char);
-      ares_free_string(name.as_char);
-      break;
-
-    case T_DS:
-    case T_SSHFP:
-    case T_RRSIG:
-    case T_NSEC:
-    case T_DNSKEY:
-      printf("\t[RR type parsing unavailable]");
-      break;
-
-    default:
-      printf("\t[Unknown RR; cannot parse]");
-      break;
-    }
-  printf("\n");
-
-  return aptr + dlen;
-}
-
-/*
- * With the '-x' (or '-xx') and '-t PTR' options, convert a query for an
- * address into a more useful 'T_PTR' type question.
- * Like with an input 'query':
- *  "a.b.c.d"  ->  "d.c.b.a".in-addr.arpa"          for an IPv4 address.
- *  "a.b.c....x.y.z" -> "z.y.x....c.d.e.IP6.ARPA"   for an IPv6 address.
- *
- * An example from 'dig -x PTR 2001:470:1:1b9::31':
- *
- * QUESTION SECTION:
- * 1.3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.9.b.1.0.1.0.0.0.0.7.4.0.1.0.0.2.IP6.ARPA. IN PTR
- *
- * ANSWER SECTION:
- * 1.3.0.0.0.0.0.0.0.0.0.0.0.0.0.0.9.b.1.0.1.0.0.0.0.7.4.0.1.0.0.2.IP6.ARPA. 254148 IN PTR ipv6.cybernode.com.
- *
- * If 'use_bitstring == 1', try to use the more compact RFC-2673 bitstring format.
- * Thus the above 'dig' query should become:
- *   [x13000000000000009b10100007401002].IP6.ARPA. IN PTR
- */
-static int convert_query (char **name_p, int use_bitstring)
-{
-#ifndef MAX_IP6_RR
-#define MAX_IP6_RR  (16*sizeof(".x.x") + sizeof(".IP6.ARPA") + 1)
-#endif
-
-#ifdef HAVE_INET_PTON
- #define ACCEPTED_RETVAL4 1
- #define ACCEPTED_RETVAL6 1
-#else
- #define ACCEPTED_RETVAL4 32
- #define ACCEPTED_RETVAL6 128
-#endif
-
-  static char new_name [MAX_IP6_RR];
-  static const char hex_chars[] = "0123456789ABCDEF";
-
-  union {
-    struct in_addr       addr4;
-    struct ares_in6_addr addr6;
-  } addr;
-
-  if (ares_inet_pton (AF_INET, *name_p, &addr.addr4) == 1)
-    {
-       unsigned long laddr = ntohl(addr.addr4.s_addr);
-       unsigned long a1 = (laddr >> 24UL) & 0xFFUL;
-       unsigned long a2 = (laddr >> 16UL) & 0xFFUL;
-       unsigned long a3 = (laddr >>  8UL) & 0xFFUL;
-       unsigned long a4 = laddr & 0xFFUL;
-
-       snprintf(new_name, sizeof(new_name), "%lu.%lu.%lu.%lu.in-addr.arpa", a4, a3, a2, a1);
-       *name_p = new_name;
-       return (1);
-    }
-
-  if (ares_inet_pton(AF_INET6, *name_p, &addr.addr6) == 1)
-    {
-       char *c = new_name;
-       const unsigned char *ip = (const unsigned char*) &addr.addr6;
-       int   max_i = (int)sizeof(addr.addr6) - 1;
-       int   i, hi, lo;
-
-       /* Use the more compact RFC-2673 notation?
-        * Currently doesn't work or unsupported by the DNS-servers I've tested against.
-        */
-       if (use_bitstring)
-       {
-         *c++ = '\\';
-         *c++ = '[';
-         *c++ = 'x';
-         for (i = max_i; i >= 0; i--)
-         {
-           hi = ip[i] >> 4;
-           lo = ip[i] & 15;
-           *c++ = hex_chars [lo];
-           *c++ = hex_chars [hi];
-         }
-         strcpy (c, "].IP6.ARPA");
-       }
-       else
-       {
-         for (i = max_i; i >= 0; i--)
-         {
-           hi = ip[i] >> 4;
-           lo = ip[i] & 15;
-           *c++ = hex_chars [lo];
-           *c++ = '.';
-           *c++ = hex_chars [hi];
-           *c++ = '.';
-         }
-         strcpy (c, "IP6.ARPA");
-       }
-       *name_p = new_name;
-       return (1);
-    }
-  printf("Address %s was not legal for this query.\n", *name_p);
-  return (0);
-}
-
-static const char *type_name(int type)
-{
-  int i;
-
-  for (i = 0; i < ntypes; i++)
-    {
-      if (types[i].value == type)
-        return types[i].name;
-    }
-  return "(unknown)";
-}
-
-static const char *class_name(int dnsclass)
-{
-  int i;
-
-  for (i = 0; i < nclasses; i++)
-    {
-      if (classes[i].value == dnsclass)
-        return classes[i].name;
-    }
-  return "(unknown)";
-}
-
-static void usage(void)
-{
-  fprintf(stderr, "usage: adig [-h] [-d] [-f flag] [-s server] [-c class] "
-          "[-t type] [-T|U port] [-x|-xx] name ...\n");
-  exit(1);
-}
-
-static void destroy_addr_list(struct ares_addr_node *head)
-{
-  while(head)
-    {
-      struct ares_addr_node *detached = head;
-      head = head->next;
-      free(detached);
-    }
-}
-
-static void append_addr_list(struct ares_addr_node **head,
-                             struct ares_addr_node *node)
-{
-  struct ares_addr_node *last;
-  node->next = NULL;
-  if(*head)
-    {
-      last = *head;
-      while(last->next)
-        last = last->next;
-      last->next = node;
-    }
-  else
-    *head = node;
-}
-
-
-/* Information from the man page. Formatting taken from man -h */
-static void print_help_info_adig(void) {
-    printf("adig, version %s\n\n", ARES_VERSION_STR);
-    printf("usage: adig [-h] [-d] [-f flag] [[-s server] ...] [-T|U port] [-c class] [-t type] [-x|-xx] name ...\n\n"
-    "  h : Display this help and exit.\n"
-    "  d : Print some extra debugging output.\n\n"
-    "  f flag   : Add a behavior control flag. Possible values are\n"
-    "              igntc - ignore to query in TCP to get truncated UDP answer,\n"
-    "              noaliases - don't honor the HOSTALIASES environment variable,\n"
-    "              norecurse - don't query upstream servers recursively,\n"
-    "              primary - use the first server,\n"
-    "              stayopen - don't close the communication sockets, and\n"
-    "              usevc - use TCP only.\n"
-    "  s server : Connect to the specified DNS server, instead of the system's default one(s).\n"
-    "              Servers are tried in round-robin, if the previous one failed.\n"
-    "  T port   : Connect to the specified TCP port of DNS server.\n"
-    "  U port   : Connect to the specified UDP port of DNS server.\n"
-    "  c class  : Set the query class. Possible values for class are ANY, CHAOS, HS and IN (default)\n"
-    "  t type   : Query records of the specified type.\n"
-    "              Possible values for type are A (default), AAAA, AFSDB, ANY, AXFR,\n"
-    "              CNAME, GPOS, HINFO, ISDN, KEY, LOC, MAILA, MAILB, MB, MD, MF, MG,\n"
-    "              MINFO, MR, MX, NAPTR, NS, NSAP, NSAP_PTR, NULL, PTR, PX, RP, RT,\n"
-    "              SIG, SOA, SRV, TXT, URI, WKS and X25.\n\n"
-    " -x  : For a '-t PTR a.b.c.d' lookup, query for 'd.c.b.a.in-addr.arpa.'\n"
-    " -xx : As above, but for IPv6, compact the format into a bitstring like\n"
-    "       '[xabcdef00000000000000000000000000].IP6.ARPA.'\n");
-    exit(0);
-}

+ 0 - 228
contrib/libs/c-ares/src/tools/ahost.c

@@ -1,228 +0,0 @@
-/* Copyright 1998 by the Massachusetts Institute of Technology.
- *
- *
- * Permission to use, copy, modify, and distribute this
- * software and its documentation for any purpose and without
- * fee is hereby granted, provided that the above copyright
- * notice appear in all copies and that both that copyright
- * notice and this permission notice appear in supporting
- * documentation, and that the name of M.I.T. not be used in
- * advertising or publicity pertaining to distribution of the
- * software without specific, written prior permission.
- * M.I.T. makes no representations about the suitability of
- * this software for any purpose.  It is provided "as is"
- * without express or implied warranty.
- */
-
-#include "ares_setup.h"
-
-#if !defined(WIN32) || defined(WATT32)
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#endif
-
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-#include "ares.h"
-#include "ares_dns.h"
-#include "ares_getopt.h"
-#include "ares_ipv6.h"
-#include "ares_nowarn.h"
-
-#ifndef HAVE_STRDUP
-#  include "ares_strdup.h"
-#  define strdup(ptr) ares_strdup(ptr)
-#endif
-
-#ifndef HAVE_STRCASECMP
-#  include "ares_strcasecmp.h"
-#  define strcasecmp(p1,p2) ares_strcasecmp(p1,p2)
-#endif
-
-#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);
-static void print_help_info_ahost(void);
-
-int main(int argc, char **argv)
-{
-  struct ares_options options;
-  int optmask = 0;
-  ares_channel channel;
-  int status, nfds, c, addr_family = AF_INET;
-  fd_set read_fds, write_fds;
-  struct timeval *tvp, tv;
-  struct in_addr addr4;
-  struct ares_in6_addr addr6;
-
-#ifdef USE_WINSOCK
-  WORD wVersionRequested = MAKEWORD(USE_WINSOCK,USE_WINSOCK);
-  WSADATA wsaData;
-  WSAStartup(wVersionRequested, &wsaData);
-#endif
-
-  memset(&options, 0, sizeof(options));
-
-  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?s:")) != -1)
-    {
-      switch (c)
-        {
-        case 'd':
-#ifdef WATT32
-          dbug_init();
-#endif
-          break;
-        case 's':
-          optmask |= ARES_OPT_DOMAINS;
-          options.ndomains++;
-          options.domains = (char **)realloc(options.domains,
-                                             options.ndomains * sizeof(char *));
-          options.domains[options.ndomains - 1] = strdup(optarg);
-          break;
-        case 't':
-          if (!strcasecmp(optarg,"a"))
-            addr_family = AF_INET;
-          else if (!strcasecmp(optarg,"aaaa"))
-            addr_family = AF_INET6;
-          else if (!strcasecmp(optarg,"u"))
-            addr_family = AF_UNSPEC;
-          else
-            usage();
-          break;
-        case 'h':
-          print_help_info_ahost();
-          break;
-        case '?':
-          print_help_info_ahost();
-          break;
-        default:
-          usage();
-          break;
-        }
-    }
-
-  argc -= optind;
-  argv += optind;
-  if (argc < 1)
-    usage();
-
-  status = ares_init_options(&channel, &options, optmask);
-  if (status != ARES_SUCCESS)
-    {
-      fprintf(stderr, "ares_init: %s\n", ares_strerror(status));
-      return 1;
-    }
-
-  /* Initiate the queries, one per command-line argument. */
-  for ( ; *argv; argv++)
-    {
-      if (ares_inet_pton(AF_INET, *argv, &addr4) == 1)
-        {
-          ares_gethostbyaddr(channel, &addr4, sizeof(addr4), AF_INET, callback,
-                             *argv);
-        }
-      else if (ares_inet_pton(AF_INET6, *argv, &addr6) == 1)
-        {
-          ares_gethostbyaddr(channel, &addr6, sizeof(addr6), AF_INET6, callback,
-                             *argv);
-        }
-      else
-        {
-          ares_gethostbyname(channel, *argv, addr_family, callback, *argv);
-        }
-    }
-
-  /* Wait for all queries to complete. */
-  for (;;)
-    {
-      int res;
-      FD_ZERO(&read_fds);
-      FD_ZERO(&write_fds);
-      nfds = ares_fds(channel, &read_fds, &write_fds);
-      if (nfds == 0)
-        break;
-      tvp = ares_timeout(channel, NULL, &tv);
-      res = select(nfds, &read_fds, &write_fds, NULL, tvp);
-      if (-1 == res)
-        break;
-      ares_process(channel, &read_fds, &write_fds);
-    }
-
-  ares_destroy(channel);
-
-  ares_library_cleanup();
-
-#ifdef USE_WINSOCK
-  WSACleanup();
-#endif
-
-  return 0;
-}
-
-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));
-      return;
-    }
-
-  for (p = host->h_addr_list; *p; p++)
-    {
-      char addr_buf[46] = "??";
-
-      ares_inet_ntop(host->h_addrtype, *p, addr_buf, sizeof(addr_buf));
-      printf("%-32s\t%s", host->h_name, addr_buf);
-#if 0
-      if (host->h_aliases[0])
-        {
-           int i;
-
-           printf (", Aliases: ");
-           for (i = 0; host->h_aliases[i]; i++)
-               printf("%s ", host->h_aliases[i]);
-        }
-#endif
-      puts("");
-    }
-}
-
-static void usage(void)
-{
-  fprintf(stderr, "usage: ahost [-h] [-d] [-s {domain}] [-t {a|aaaa|u}] {host|addr} ...\n");
-  exit(1);
-}
-
-/* Information from the man page. Formatting taken from man -h */
-static void print_help_info_ahost(void) {
-    printf("ahost, version %s\n\n", ARES_VERSION_STR);
-    printf("usage: ahost [-h] [-d] [[-s domain] ...] [-t a|aaaa|u] host|addr ...\n\n"
-    "  h : Display this help and exit.\n"
-    "  d : Print some extra debugging output.\n\n"
-    "  s domain : Specify the domain to search instead of using the default values\n"
-    "               from /etc/resolv.conf. This option only has an effect on\n"
-    "               platforms that use /etc/resolv.conf for DNS configuration;\n"
-    "               it has no effect on other platforms (such as Win32 or Android).\n\n"
-    "  t type   : If type is \"a\", print the A record (default).\n"
-    "               If type is \"aaaa\", print the AAAA record.\n"
-    "               If type is \"u\", look for either AAAA or A record (in that order).\n\n");
-    exit(0);
-} 

+ 0 - 122
contrib/libs/c-ares/src/tools/ares_getopt.c

@@ -1,122 +0,0 @@
-/*
- * Original file name getopt.c  Initial import into the c-ares source tree
- * on 2007-04-11.  Lifted from version 5.2 of the 'Open Mash' project with
- * the modified BSD license, BSD license without the advertising clause.
- *
- */
-
-/*
- * getopt.c --
- *
- *      Standard UNIX getopt function.  Code is from BSD.
- *
- * Copyright (c) 1987-2001 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * A. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * B. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * C. Neither the names of the copyright holders nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
- * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* #if !defined(lint)
- * static char sccsid[] = "@(#)getopt.c 8.2 (Berkeley) 4/2/94";
- * #endif
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "ares_getopt.h"
-
-int   opterr = 1,     /* if error message should be printed */
-      optind = 1;     /* index into parent argv vector */
-int   optopt = 0;     /* character checked for validity */
-static int optreset;  /* reset getopt */
-char  *optarg;        /* argument associated with option */
-
-#define  BADCH   (int)'?'
-#define  BADARG  (int)':'
-#define  EMSG    (char *)""
-
-/*
- * ares_getopt --
- *    Parse argc/argv argument vector.
- */
-int
-ares_getopt(int nargc, char * const nargv[], const char *ostr)
-{
-    static char *place = EMSG;                /* option letter processing */
-    char *oli;                                /* option letter list index */
-
-    if (optreset || !*place) {                /* update scanning pointer */
-        optreset = 0;
-        if (optind >= nargc || *(place = nargv[optind]) != '-') {
-            place = EMSG;
-            return (EOF);
-        }
-        if (place[1] && *++place == '-') {    /* found "--" */
-            ++optind;
-            place = EMSG;
-            return (EOF);
-        }
-    }                                         /* option letter okay? */
-    if ((optopt = (int)*place++) == (int)':' ||
-        (oli = strchr(ostr, optopt)) == NULL) {
-        /*
-         * if the user didn't specify '-' as an option,
-         * assume it means EOF.
-         */
-        if (optopt == (int)'-')
-            return (EOF);
-        if (!*place)
-            ++optind;
-        if (opterr && *ostr != ':')
-            (void)fprintf(stderr,
-                "%s: illegal option -- %c\n", __FILE__, optopt);
-        return (BADCH);
-    }
-    if (*++oli != ':') {                      /* don't need argument */
-        optarg = NULL;
-        if (!*place)
-            ++optind;
-    }
-    else {                                    /* need an argument */
-        if (*place)                           /* no white space */
-            optarg = place;
-        else if (nargc <= ++optind) {         /* no arg */
-            place = EMSG;
-            if (*ostr == ':')
-                return (BADARG);
-            if (opterr)
-                (void)fprintf(stderr,
-                    "%s: option requires an argument -- %c\n",
-                    __FILE__, optopt);
-            return (BADCH);
-        }
-         else                                 /* white space */
-            optarg = nargv[optind];
-        place = EMSG;
-        ++optind;
-    }
-    return (optopt);                          /* dump back option letter */
-}

+ 0 - 53
contrib/libs/c-ares/src/tools/ares_getopt.h

@@ -1,53 +0,0 @@
-#ifndef ARES_GETOPT_H
-#define ARES_GETOPT_H
-
-/*
- * Copyright (c) 1987-2001 The Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- * A. Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- * B. Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- * C. Neither the names of the copyright holders nor the names of its
- *    contributors may be used to endorse or promote products derived from this
- *    software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
- * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
- * POSSIBILITY OF SUCH DAMAGE.
- */
-
-
-int ares_getopt(int nargc, char * const nargv[], const char *ostr);
-
-#undef optarg
-#undef optind
-#undef opterr
-#undef optopt
-#undef optreset
-
-#define optarg   ares_optarg
-#define optind   ares_optind
-#define opterr   ares_opterr
-#define optopt   ares_optopt
-#define optreset ares_optreset
-
-extern char *optarg;
-extern int optind;
-extern int opterr;
-extern int optopt;
-
-#endif /* ARES_GETOPT_H */

+ 0 - 3
contrib/libs/c-ares/ya.make

@@ -110,8 +110,5 @@ SRCS(
 END()
 
 RECURSE(
-    acountry
-    adig
-    ahost
     test
 )