]> granicus.if.org Git - php/commitdiff
That should be it
authorZeev Suraski <zeev@php.net>
Fri, 31 Mar 2000 19:55:33 +0000 (19:55 +0000)
committerZeev Suraski <zeev@php.net>
Fri, 31 Mar 2000 19:55:33 +0000 (19:55 +0000)
12 files changed:
bindlib_w32/bindlib.dsw [deleted file]
bindlib_w32/gethnamaddr.c [deleted file]
bindlib_w32/getnetent.c [deleted file]
bindlib_w32/getnetnamadr.c [deleted file]
bindlib_w32/inet_net_ntop.c [deleted file]
bindlib_w32/inet_neta.c [deleted file]
bindlib_w32/nsap_addr.c [deleted file]
bindlib_w32/res_init.c [deleted file]
bindlib_w32/res_mkquery.c [deleted file]
bindlib_w32/res_send.c [deleted file]
bindlib_w32/resolv.h [deleted file]
bindlib_w32/sethostent.c [deleted file]

diff --git a/bindlib_w32/bindlib.dsw b/bindlib_w32/bindlib.dsw
deleted file mode 100644 (file)
index f3cddd6..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-Microsoft Developer Studio Workspace File, Format Version 6.00\r
-# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r
-\r
-###############################################################################\r
-\r
-Project: "bindlib"=.\bindlib.dsp - Package Owner=<4>\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<4>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
-Global:\r
-\r
-Package=<5>\r
-{{{\r
-}}}\r
-\r
-Package=<3>\r
-{{{\r
-}}}\r
-\r
-###############################################################################\r
-\r
diff --git a/bindlib_w32/gethnamaddr.c b/bindlib_w32/gethnamaddr.c
deleted file mode 100644 (file)
index 98b49f3..0000000
+++ /dev/null
@@ -1,1184 +0,0 @@
-/*
- * ++Copyright++ 1985, 1988, 1993
- * -
- * Copyright (c) 1985, 1988, 1993
- *    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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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.
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- * 
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)gethostnamadr.c    8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id$";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#ifndef WINNT
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#endif
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-
-#include <stdio.h>
-#include <netdb.h>
-#include <resolv.h>
-#include <ctype.h>      
-#include <errno.h>
-#ifndef WINNT
-#include <syslog.h>
-#endif
-
-#ifndef LOG_AUTH
-#define LOG_AUTH 0
-#endif
-
-#define MULTI_PTRS_ARE_ALIASES 1       /* XXX - experimental */
-
-#if defined(BSD) && (BSD >= 199103) && defined(AF_INET6)
-#include <stdlib.h>
-#include <string.h>
-#else
-#include "conf/portability.h"
-#endif
-
-#if defined(USE_OPTIONS_H)
-#include <conf/options.h>
-#endif
-
-#ifdef SPRINTF_CHAR
-#define SPRINTF(x) strlen(sprintf/**/x)
-#else
-#define SPRINTF(x) ((size_t)sprintf x)
-#endif
-
-#ifdef WINNT
-extern char *pathhosts;
-extern int res_paths_initialized;
-extern init_res_paths();
-#endif
-
-#define        MAXALIASES      35
-#define        MAXADDRS        35
-
-static const char AskedForGot[] =
-                         "gethostby*.getanswer: asked for \"%s\", got \"%s\"";
-
-static char *h_addr_ptrs[MAXADDRS + 1];
-
-static struct hostent host;
-static char *host_aliases[MAXALIASES];
-static char hostbuf[8*1024];
-static u_char host_addr[16];   /* IPv4 or IPv6 */
-static FILE *hostf = NULL;
-static int stayopen = 0;
-
-int inet_pton();
-static void map_v4v6_address __P((const char *src, char *dst));
-static void map_v4v6_hostent __P((struct hostent *hp, char **bp, int *len));
-
-#ifdef RESOLVSORT
-static void addrsort __P((char **, int));
-#endif
-
-#if PACKETSZ > 1024
-#define        MAXPACKET       PACKETSZ
-#else
-#define        MAXPACKET       1024
-#endif
-
-typedef union {
-    HEADER hdr;
-    u_char buf[MAXPACKET];
-} querybuf;
-
-typedef union {
-    int32_t al;
-    char ac;
-} align;
-
-#ifndef WINNT
-extern int h_errno;
-#endif
-
-#ifdef DEBUG
-static void
-dprintf(msg, num)
-       char *msg;
-       int num;
-{
-       if (_res.options & RES_DEBUG) {
-               int save = errno;
-
-               printf(msg, num);
-#ifndef WINNT
-               errno = save;
-#else
-               WSASetLastError(save);
-               SetLastError(save);
-#endif
-       }
-}
-#else
-#define dprintf(msg, num) /*nada*/
-#endif
-
-#ifndef WINNT
-#define BOUNDED_INCR(x) \
-       do { \
-               cp += x; \
-               if (cp > eom) { \
-                       h_errno = NO_RECOVERY; \
-                       return (NULL); \
-               } \
-       } while (0)
-
-#else
-
-#define BOUNDED_INCR(x) \
-       do { \
-               cp += x; \
-               if (cp > eom) { \
-               WSASetLastError(NO_RECOVERY); \
-                       return (NULL); \
-               } \
-       } while (0)
-
-#endif
-
-#ifndef WINNT  
-#define BOUNDS_CHECK(ptr, count) \
-       do { \
-               if ((ptr) + (count) > eom) { \
-                       h_errno = NO_RECOVERY; \
-                       return (NULL); \
-               } \
-       } while (0)
-#else
-#define BOUNDS_CHECK(ptr, count) \
-       do { \
-               if ((ptr) + (count) > eom) { \
-               WSASetLastError(NO_RECOVERY); \
-                       return (NULL); \
-               } \
-       } while (0)
-#endif
-       
-static struct hostent *
-getanswer(answer, anslen, qname, qtype)
-       const querybuf *answer;
-       int anslen;
-       const char *qname;
-       int qtype;
-{
-       register const HEADER *hp;
-       register const u_char *cp;
-       register int n;
-       const u_char *eom, *erdata;
-       char *bp, **ap, **hap;
-       int type, class, buflen, ancount, qdcount;
-       int haveanswer, had_error;
-       int toobig = 0;
-       char tbuf[MAXDNAME];
-       const char *tname;
-       int (*name_ok) __P((const char *));
-
-       tname = qname;
-       host.h_name = NULL;
-       eom = answer->buf + anslen;
-       switch (qtype) {
-       case T_A:
-       case T_AAAA:
-               name_ok = res_hnok;
-               break;
-       case T_PTR:
-               name_ok = res_dnok;
-               break;
-       default:
-               return (NULL);  /* XXX should be abort(); */
-       }
-       /*
-        * find first satisfactory answer
-        */
-       hp = &answer->hdr;
-       ancount = ntohs((u_short)hp->ancount);
-       qdcount = ntohs((u_short)hp->qdcount);
-       bp = hostbuf;
-       buflen = sizeof hostbuf;
-       cp = answer->buf;
-       BOUNDED_INCR(HFIXEDSZ);
-       if (qdcount != 1) {
-#ifndef WINNT
-               h_errno = NO_RECOVERY;
-#else
-               WSASetLastError(NO_RECOVERY);
-#endif
-               return (NULL);
-       }
-       n = dn_expand(answer->buf, eom, cp, bp, buflen);
-       if ((n < 0) || !(*name_ok)(bp)) {
-#ifndef WINNT
-               h_errno = NO_RECOVERY;
-#else
-               WSASetLastError(NO_RECOVERY);
-#endif
-               return (NULL);
-       }
-       BOUNDED_INCR(n + QFIXEDSZ);
-       if (qtype == T_A || qtype == T_AAAA) {
-               /* res_send() has already verified that the query name is the
-                * same as the one we sent; this just gets the expanded name
-                * (i.e., with the succeeding search-domain tacked on).
-                */
-               n = strlen(bp) + 1;             /* for the \0 */
-               if (n >= MAXHOSTNAMELEN) {
-#ifndef WINNT
-               h_errno = NO_RECOVERY;
-#else
-               WSASetLastError(NO_RECOVERY);
-#endif
-                       return (NULL);
-               }
-               host.h_name = bp;
-               bp += n;
-               buflen -= n;
-               /* The qname can be abbreviated, but h_name is now absolute. */
-               qname = host.h_name;
-       }
-       ap = host_aliases;
-       *ap = NULL;
-       host.h_aliases = host_aliases;
-       hap = h_addr_ptrs;
-       *hap = NULL;
-       host.h_addr_list = h_addr_ptrs;
-       haveanswer = 0;
-       had_error = 0;
-       while (ancount-- > 0 && cp < eom && !had_error) {
-               n = dn_expand(answer->buf, eom, cp, bp, buflen);
-               if ((n < 0) || !(*name_ok)(bp)) {
-                       had_error++;
-                       continue;
-               }
-               cp += n;                        /* name */
-               BOUNDS_CHECK(cp, 3 * INT16SZ + INT32SZ);
-               type = _getshort(cp);
-               cp += INT16SZ;                  /* type */
-               class = _getshort(cp);
-               cp += INT16SZ + INT32SZ;        /* class, TTL */
-               n = _getshort(cp);
-               cp += INT16SZ;                  /* len */
-               BOUNDS_CHECK(cp, n);
-               erdata = cp + n;
-               if (class != C_IN) {
-                       /* XXX - debug? syslog? */
-                       cp += n;
-                       continue;               /* XXX - had_error++ ? */
-               }
-               if ((qtype == T_A || qtype == T_AAAA) && type == T_CNAME) {
-                       if (ap >= &host_aliases[MAXALIASES-1])
-                               continue;
-                       n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf);
-                       if ((n < 0) || !(*name_ok)(tbuf)) {
-                               had_error++;
-                               continue;
-                       }
-                       cp += n;
-                       if (cp != erdata) {
-#ifndef WINNT
-                       h_errno = NO_RECOVERY;
-#else
-                       WSASetLastError(NO_RECOVERY);
-#endif
-                               return (NULL);
-                       }
-                       /* Store alias. */
-                       *ap++ = bp;
-                       n = strlen(bp) + 1;     /* for the \0 */
-                       if (n >= MAXHOSTNAMELEN) {
-                               had_error++;
-                               continue;
-                       }
-                       bp += n;
-                       buflen -= n;
-                       /* Get canonical name. */
-                       n = strlen(tbuf) + 1;   /* for the \0 */
-                       if (n > buflen || n >= MAXHOSTNAMELEN) {
-                               had_error++;
-                               continue;
-                       }
-                       strcpy(bp, tbuf);
-                       host.h_name = bp;
-                       bp += n;
-                       buflen -= n;
-                       continue;
-               }
-               if (qtype == T_PTR && type == T_CNAME) {
-                       n = dn_expand(answer->buf, eom, cp, tbuf, sizeof tbuf);
-                       if (n < 0 || !res_dnok(tbuf)) {
-                               had_error++;
-                               continue;
-                       }
-                       cp += n;
-                       if (cp != erdata) {
-#ifndef WINNT
-                       h_errno = NO_RECOVERY;
-#else
-                       WSASetLastError(NO_RECOVERY);
-#endif
-                               return (NULL);
-                       }
-                       /* Get canonical name. */
-                       n = strlen(tbuf) + 1;   /* for the \0 */
-                       if (n > buflen || n >= MAXHOSTNAMELEN) {
-                               had_error++;
-                               continue;
-                       }
-                       strcpy(bp, tbuf);
-                       tname = bp;
-                       bp += n;
-                       buflen -= n;
-                       continue;
-               }
-               if (type != qtype) {
-                       syslog(LOG_NOTICE|LOG_AUTH,
-              "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"",
-                              qname, p_class(C_IN), p_type(qtype),
-                              p_type(type));
-                       cp += n;
-                       continue;               /* XXX - had_error++ ? */
-               }
-               switch (type) {
-               case T_PTR:
-                       if (strcasecmp(tname, bp) != 0) {
-                               syslog(LOG_NOTICE|LOG_AUTH,
-                                      (char *) AskedForGot, qname, bp);
-                               cp += n;
-                               continue;       /* XXX - had_error++ ? */
-                       }
-                       n = dn_expand(answer->buf, eom, cp, bp, buflen);
-                       if ((n < 0) || !res_hnok(bp)) {
-                               had_error++;
-                               break;
-                       }
-#if MULTI_PTRS_ARE_ALIASES
-                       cp += n;
-                       if (cp != erdata) {
-#ifndef WINNT
-                       h_errno = NO_RECOVERY;
-#else
-                       WSASetLastError(NO_RECOVERY);
-#endif
-                               return (NULL);
-                       }
-                       if (!haveanswer)
-                               host.h_name = bp;
-                       else if (ap < &host_aliases[MAXALIASES-1])
-                               *ap++ = bp;
-                       else
-                               n = -1;
-                       if (n != -1) {
-                               n = strlen(bp) + 1;     /* for the \0 */
-                               if (n >= MAXHOSTNAMELEN) {
-                                       had_error++;
-                                       break;
-                               }
-                               bp += n;
-                               buflen -= n;
-                       }
-                       break;
-#else
-                       host.h_name = bp;
-                       if (_res.options & RES_USE_INET6) {
-                               n = strlen(bp) + 1;     /* for the \0 */
-                               if (n >= MAXHOSTNAMELEN) {
-                                       had_error++;
-                                       break;
-                               }
-                               bp += n;
-                               buflen -= n;
-                               map_v4v6_hostent(&host, &bp, &buflen);
-                       }
-#ifndef WINNT
-                      h_errno = NETDB_SUCCESS;
-#else
-                      WSASetLastError(NETDB_SUCCESS);
-#endif
-                       return (&host);
-#endif
-               case T_A:
-               case T_AAAA:
-                       if (strcasecmp(host.h_name, bp) != 0) {
-                               syslog(LOG_NOTICE|LOG_AUTH,
-                                      (char *)AskedForGot, host.h_name, bp);
-                               cp += n;
-                               continue;       /* XXX - had_error++ ? */
-                       }
-                       if (n != host.h_length) {
-                               cp += n;
-                               continue;
-                       }
-                       if (!haveanswer) {
-                               register int nn;
-
-                               host.h_name = bp;
-                               nn = strlen(bp) + 1;    /* for the \0 */
-                               bp += nn;
-                               buflen -= nn;
-                       }
-
-                       bp += sizeof(align) - ((u_long)bp % sizeof(align));
-
-                       if (bp + n >= &hostbuf[sizeof hostbuf]) {
-                               dprintf("size (%d) too big\n", n);
-                               had_error++;
-                               continue;
-                       }
-                       if (hap >= &h_addr_ptrs[MAXADDRS-1]) {
-                               if (!toobig++)
-                                       dprintf("Too many addresses (%d)\n",
-                                               MAXADDRS);
-                               cp += n;
-                               continue;
-                       }
-                       bcopy(cp, *hap++ = bp, n);
-                       bp += n;
-                       buflen -= n;
-                       cp += n;
-                       if (cp != erdata) {
-#ifndef WINNT
-                               h_errno = NO_RECOVERY;
-#else
-                               WSASetLastError(NO_RECOVERY);
-#endif
-                               return (NULL);
-                       }
-                       break;
-               default:
-                       abort();
-               }
-               if (!had_error)
-                       haveanswer++;
-       }
-       if (haveanswer) {
-               *ap = NULL;
-               *hap = NULL;
-#if defined(RESOLVSORT)
-               /*
-                * Note: we sort even if host can take only one address
-                * in its return structures - should give it the "best"
-                * address in that case, not some random one
-                */
-               if (_res.nsort && haveanswer > 1 && qtype == T_A)
-                       addrsort(h_addr_ptrs, haveanswer);
-#endif /*RESOLVSORT*/
-               if (!host.h_name) {
-                       n = strlen(qname) + 1;  /* for the \0 */
-                       if (n > buflen || n >= MAXHOSTNAMELEN)
-                               goto no_recovery;
-                       strcpy(bp, qname);
-                       host.h_name = bp;
-                       bp += n;
-                       buflen -= n;
-               }
-               if (_res.options & RES_USE_INET6)
-                       map_v4v6_hostent(&host, &bp, &buflen);
-#ifndef WINNT
-                      h_errno = NETDB_SUCCESS;
-#else
-                      WSASetLastError(NETDB_SUCCESS);
-#endif
-               return (&host);
-       }
- no_recovery:
-#ifndef WINNT
-               h_errno = NO_RECOVERY;
-#else
-               WSASetLastError(NO_RECOVERY);
-#endif
-       return (NULL);
-}
-
-
-struct hostent *
-gethostbyname2(name, af)
-       const char *name;
-       int af;
-{
-       querybuf buf;
-       register const char *cp;
-       char *bp;
-       int n, size, type, len;
-       extern struct hostent *_gethtbyname2();
-
-       if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
-#ifndef WINNT
-               h_errno = NETDB_INTERNAL;
-#else
-               WSASetLastError(NETDB_INTERNAL);
-#endif
-               return (NULL);
-       }
-
-       switch (af) {
-       case AF_INET:
-               size = INADDRSZ;
-               type = T_A;
-               break;
-       case AF_INET6:
-               size = IN6ADDRSZ;
-               type = T_AAAA;
-               break;
-       default:
-#ifndef WINNT
-               h_errno = NETDB_INTERNAL;
-               errno = EAFNOSUPPORT;
-#else
-               WSASetLastError(NETDB_INTERNAL);
-               SetLastError(WSAEAFNOSUPPORT);
-#endif
-               return (NULL);
-       }
-
-       host.h_addrtype = af;
-       host.h_length = size;
-
-       /*
-        * if there aren't any dots, it could be a user-level alias.
-        * this is also done in res_query() since we are not the only
-        * function that looks up host names.
-        */
-       if (!strchr(name, '.') && (cp = __hostalias(name)))
-               name = cp;
-
-       /*
-        * disallow names consisting only of digits/dots, unless
-        * they end in a dot.
-        */
-       if (isdigit(name[0]))
-               for (cp = name;; ++cp) {
-                       if (!*cp) {
-                               if (*--cp == '.')
-                                       break;
-                               /*
-                                * All-numeric, no dot at the end.
-                                * Fake up a hostent as if we'd actually
-                                * done a lookup.
-                                */
-                               if (inet_pton(af, name, host_addr) <= 0) {
-#ifndef WINNT
-                                       h_errno = HOST_NOT_FOUND;
-#else
-                                        WSASetLastError(HOST_NOT_FOUND);
-#endif
-                                       return (NULL);
-                               }
-                               strncpy(hostbuf, name, MAXDNAME);
-                               hostbuf[MAXDNAME] = '\0';
-                               bp = hostbuf + MAXDNAME;
-                               len = sizeof hostbuf - MAXDNAME;
-                               host.h_name = hostbuf;
-                               host.h_aliases = host_aliases;
-                               host_aliases[0] = NULL;
-                               h_addr_ptrs[0] = (char *)host_addr;
-                               h_addr_ptrs[1] = NULL;
-                               host.h_addr_list = h_addr_ptrs;
-                               if (_res.options & RES_USE_INET6)
-                                       map_v4v6_hostent(&host, &bp, &len);
-#ifndef WINNT
-                                h_errno = NETDB_SUCCESS;
-#else
-                                WSASetLastError(NETDB_SUCCESS);
-#endif
-                               return (&host);
-                       }
-                       if (!isdigit(*cp) && *cp != '.') 
-                               break;
-               }
-       if ((isxdigit(name[0]) && strchr(name, ':') != NULL) ||
-           name[0] == ':')
-               for (cp = name;; ++cp) {
-                       if (!*cp) {
-                               if (*--cp == '.')
-                                       break;
-                               /*
-                                * All-IPv6-legal, no dot at the end.
-                                * Fake up a hostent as if we'd actually
-                                * done a lookup.
-                                */
-                               if (inet_pton(af, name, host_addr) <= 0) {
-#ifndef WINNT
-                                       h_errno = HOST_NOT_FOUND;
-#else
-                                        WSASetLastError(HOST_NOT_FOUND);
-#endif
-                                       return (NULL);
-                               }
-                               strncpy(hostbuf, name, MAXDNAME);
-                               hostbuf[MAXDNAME] = '\0';
-                               bp = hostbuf + MAXDNAME;
-                               len = sizeof hostbuf - MAXDNAME;
-                               host.h_name = hostbuf;
-                               host.h_aliases = host_aliases;
-                               host_aliases[0] = NULL;
-                               h_addr_ptrs[0] = (char *)host_addr;
-                               h_addr_ptrs[1] = NULL;
-                               host.h_addr_list = h_addr_ptrs;
-#ifndef WINNT
-                               h_errno = NETDB_SUCCESS;
-#else
-                               WSASetLastError(NETDB_SUCCESS);
-#endif
-                               return (&host);
-                       }
-                       if (!isxdigit(*cp) && *cp != ':' && *cp != '.') 
-                               break;
-               }
-
-       if ((n = res_search(name, C_IN, type, buf.buf, sizeof(buf))) < 0) {
-               dprintf("res_search failed (%d)\n", n);
-               if (errno == ECONNREFUSED)
-                       return (_gethtbyname2(name, af));
-               return (NULL);
-       }
-       return (getanswer(&buf, n, name, type));
-}
-
-struct hostent *
-#ifndef WINNT
-gethostbyname(name)
-#else
-gethostbyname_nt(name)
-#endif
-       const char *name;
-{
-       struct hostent *hp;
-
-       if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
-#ifndef WINNT
-               h_errno = NETDB_INTERNAL;
-#else
-               WSASetLastError(NETDB_INTERNAL);
-#endif
-               return (NULL);
-       }
-       if (_res.options & RES_USE_INET6) {
-               hp = gethostbyname2(name, AF_INET6);
-               if (hp)
-                       return (hp);
-       }
-       return (gethostbyname2(name, AF_INET));
-}
-
-struct hostent *
-#ifndef WINNT
-gethostbyaddr(addr, len, af)
-#else
-gethostbyaddr_nt(addr, len, af)
-#endif
-       const char *addr;       /* XXX should have been def'd as u_char! */
-       int len, af;
-{
-       const u_char *uaddr = (const u_char *)addr;
-       static const u_char mapped[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0xff,0xff };
-       static const u_char tunnelled[] = { 0,0, 0,0, 0,0, 0,0, 0,0, 0,0 };
-       int n, size;
-       querybuf buf;
-       register struct hostent *hp;
-       char qbuf[MAXDNAME+1], *qp;
-#ifdef SUNSECURITY
-       register struct hostent *rhp;
-       char **haddr;
-       u_long old_options;
-       char hname2[MAXDNAME+1];
-#endif /*SUNSECURITY*/
-extern struct hostent *_gethtbyaddr();
-       
-       if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
-#ifndef WINNT
-               h_errno = NETDB_INTERNAL;
-#else
-               WSASetLastError(NETDB_INTERNAL);
-#endif
-               return (0);
-       }
-       if (af == AF_INET6 && len == IN6ADDRSZ &&
-           (!bcmp(uaddr, mapped, sizeof mapped) ||
-            !bcmp(uaddr, tunnelled, sizeof tunnelled))) {
-               /* Unmap. */
-               addr += sizeof mapped;
-               uaddr += sizeof mapped;
-               af = AF_INET;
-               len = INADDRSZ;
-       }
-       switch (af) {
-       case AF_INET:
-               size = INADDRSZ;
-               break;
-       case AF_INET6:
-               size = IN6ADDRSZ;
-               break;
-       default:
-#ifndef WINNT
-               errno = EAFNOSUPPORT;
-               h_errno = NETDB_INTERNAL;
-#else
-               SetLastError(WSAEAFNOSUPPORT);
-               WSASetLastError(NETDB_INTERNAL);
-#endif
-               return (0);
-       }
-       if (size != len) {
-#ifndef WINNT
-               errno = EINVAL;
-               h_errno = NETDB_INTERNAL;
-#else
-               SetLastError(WSAEINVAL);
-               WSASetLastError(NETDB_INTERNAL);
-#endif
-               return (0);
-       }
-       switch (af) {
-       case AF_INET:
-               (void) sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa",
-                              (uaddr[3] & 0xff),
-                              (uaddr[2] & 0xff),
-                              (uaddr[1] & 0xff),
-                              (uaddr[0] & 0xff));
-               break;
-       case AF_INET6:
-               qp = qbuf;
-               for (n = IN6ADDRSZ - 1; n >= 0; n--) {
-                       qp += SPRINTF((qp, "%x.%x.",
-                                      uaddr[n] & 0xf,
-                                      (uaddr[n] >> 4) & 0xf));
-               }
-               strcpy(qp, "ip6.int");
-               break;
-       default:
-               abort();
-       }
-       n = res_query(qbuf, C_IN, T_PTR, (u_char *)buf.buf, sizeof buf.buf);
-       if (n < 0) {
-               dprintf("res_query failed (%d)\n", n);
-               if (errno == ECONNREFUSED)
-                       return (_gethtbyaddr(addr, len, af));
-               return (0);
-       }
-       if (!(hp = getanswer(&buf, n, qbuf, T_PTR)))
-               return (0);     /* h_errno was set by getanswer() */
-#ifdef SUNSECURITY
-       if (af == AF_INET) {
-           /*
-            * turn off search as the name should be absolute,
-            * 'localhost' should be matched by defnames
-            */
-           strncpy(hname2, hp->h_name, MAXDNAME);
-           hname2[MAXDNAME] = '\0';
-           old_options = _res.options;
-           _res.options &= ~RES_DNSRCH;
-           _res.options |= RES_DEFNAMES;
-           if (!(rhp = gethostbyname_nt(hname2))) {
-               syslog(LOG_NOTICE|LOG_AUTH,
-                      "gethostbyaddr: No A record for %s (verifying [%s])",
-                      hname2, inet_ntoa(*((struct in_addr *)addr)));
-               _res.options = old_options;
-#ifndef WINNT
-                   h_errno = HOST_NOT_FOUND;
-#else
-                    WSASetLastError(HOST_NOT_FOUND);
-#endif
-               return (NULL);
-           }
-           _res.options = old_options;
-           for (haddr = rhp->h_addr_list; *haddr; haddr++)
-               if (!memcmp(*haddr, addr, INADDRSZ))
-                       break;
-           if (!*haddr) {
-               syslog(LOG_NOTICE|LOG_AUTH,
-                      "gethostbyaddr: A record of %s != PTR record [%s]",
-                      hname2, inet_ntoa(*((struct in_addr *)addr)));
-#ifndef WINNT
-                   h_errno = HOST_NOT_FOUND;
-#else
-                    WSASetLastError(HOST_NOT_FOUND);
-#endif
-               return (NULL);
-           }
-       }
-#endif /*SUNSECURITY*/
-       hp->h_addrtype = af;
-       hp->h_length = len;
-       bcopy(addr, host_addr, len);
-       h_addr_ptrs[0] = (char *)host_addr;
-       h_addr_ptrs[1] = NULL;
-       if (af == AF_INET && (_res.options & RES_USE_INET6)) {
-               map_v4v6_address((char*)host_addr, (char*)host_addr);
-               hp->h_addrtype = AF_INET6;
-               hp->h_length = IN6ADDRSZ;
-       }
-#ifndef WINNT
-                      h_errno = NETDB_SUCCESS;
-#else
-                      WSASetLastError(NETDB_SUCCESS);
-#endif
-       return (hp);
-}
-
-void
-_sethtent(f)
-       int f;
-{
-    
-#ifndef WINNT
-       if (!hostf)
-               hostf = fopen(_PATH_HOSTS, "r" );
-#else
-        if (!res_paths_initialized)
-          init_res_paths();
-
-       if (!hostf)
-               hostf = fopen(pathhosts, "r" );
-#endif
-
-       else
-               rewind(hostf);
-       stayopen = f;
-}
-
-void
-_endhtent()
-{
-       if (hostf && !stayopen) {
-               (void) fclose(hostf);
-               hostf = NULL;
-       }
-}
-
-struct hostent *
-_gethtent()
-{
-       char *p;
-       register char *cp, **q;
-       int af, len;
-
-#ifndef WINNT
-       if (!hostf && !(hostf = fopen(_PATH_HOSTS, "r" ))) {
-#else
-        if (!res_paths_initialized)
-           init_res_paths();
-       if (!hostf && !(hostf = fopen(pathhosts, "r" ))) {
-#endif
-#ifndef WINNT
-               h_errno = NETDB_INTERNAL;
-#else
-               WSASetLastError(NETDB_INTERNAL);
-#endif
-               return (NULL);
-       }
- again:
-       if (!(p = fgets(hostbuf, sizeof hostbuf, hostf))) {
-#ifndef WINNT
-                   h_errno = HOST_NOT_FOUND;
-#else
-                    WSASetLastError(HOST_NOT_FOUND);
-#endif
-               return (NULL);
-       }
-       if (*p == '#')
-               goto again;
-       if (!(cp = strpbrk(p, "#\n")))
-               goto again;
-       *cp = '\0';
-       if (!(cp = strpbrk(p, " \t")))
-               goto again;
-       *cp++ = '\0';
-       if (inet_pton(AF_INET6, p, host_addr) > 0) {
-               af = AF_INET6;
-               len = IN6ADDRSZ;
-       } else if (inet_pton(AF_INET, p, host_addr) > 0) {
-               if (_res.options & RES_USE_INET6) {
-                       map_v4v6_address((char*)host_addr, (char*)host_addr);
-                       af = AF_INET6;
-                       len = IN6ADDRSZ;
-               } else {
-                       af = AF_INET;
-                       len = INADDRSZ;
-               }
-       } else {
-               goto again;
-       }
-       h_addr_ptrs[0] = (char *)host_addr;
-       h_addr_ptrs[1] = NULL;
-       host.h_addr_list = h_addr_ptrs;
-       host.h_length = len;
-       host.h_addrtype = af;
-       while (*cp == ' ' || *cp == '\t')
-               cp++;
-       host.h_name = cp;
-       q = host.h_aliases = host_aliases;
-       if (cp = strpbrk(cp, " \t"))
-               *cp++ = '\0';
-       while (cp && *cp) {
-               if (*cp == ' ' || *cp == '\t') {
-                       cp++;
-                       continue;
-               }
-               if (q < &host_aliases[MAXALIASES - 1])
-                       *q++ = cp;
-               if (cp = strpbrk(cp, " \t"))
-                       *cp++ = '\0';
-       }
-       *q = NULL;
-#ifndef WINNT
-                      h_errno = NETDB_SUCCESS;
-#else
-                      WSASetLastError(NETDB_SUCCESS);
-#endif
-       return (&host);
-}
-
-struct hostent *
-_gethtbyname(name)
-       const char *name;
-{
-       extern struct hostent *_gethtbyname2();
-       struct hostent *hp;
-
-       if (_res.options & RES_USE_INET6) {
-               hp = _gethtbyname2(name, AF_INET6);
-               if (hp)
-                       return (hp);
-       }
-       return (_gethtbyname2(name, AF_INET));
-}
-
-struct hostent *
-_gethtbyname2(name, af)
-       const char *name;
-       int af;
-{
-       register struct hostent *p;
-       register char **cp;
-       
-       _sethtent(0);
-       while (p = _gethtent()) {
-               if (p->h_addrtype != af)
-                       continue;
-               if (strcasecmp(p->h_name, name) == 0)
-                       break;
-               for (cp = p->h_aliases; *cp != 0; cp++)
-                       if (strcasecmp(*cp, name) == 0)
-                               goto found;
-       }
- found:
-       _endhtent();
-       return (p);
-}
-
-struct hostent *
-_gethtbyaddr(addr, len, af)
-       const char *addr;
-       int len, af;
-{
-       register struct hostent *p;
-
-       _sethtent(0);
-       while (p = _gethtent())
-               if (p->h_addrtype == af && !bcmp(p->h_addr, addr, len))
-                       break;
-       _endhtent();
-       return (p);
-}
-
-static void
-map_v4v6_address(src, dst)
-       const char *src;
-       char *dst;
-{
-       u_char *p = (u_char *)dst;
-       char tmp[INADDRSZ];
-       int i;
-
-       /* Stash a temporary copy so our caller can update in place. */
-       bcopy(src, tmp, INADDRSZ);
-       /* Mark this ipv6 addr as a mapped ipv4. */
-       for (i = 0; i < 10; i++)
-               *p++ = 0x00;
-       *p++ = 0xff;
-       *p++ = 0xff;
-       /* Retrieve the saved copy and we're done. */
-       bcopy(tmp, (void*)p, INADDRSZ);
-}
-
-static void
-map_v4v6_hostent(hp, bpp, lenp)
-       struct hostent *hp;
-       char **bpp;
-       int *lenp;
-{
-       char **ap;
-
-       if (hp->h_addrtype != AF_INET || hp->h_length != INADDRSZ)
-               return;
-       hp->h_addrtype = AF_INET6;
-       hp->h_length = IN6ADDRSZ;
-       for (ap = hp->h_addr_list; *ap; ap++) {
-               int i = sizeof(align) - ((u_long)*bpp % sizeof(align));
-
-               if (*lenp < (i + IN6ADDRSZ)) {
-                       /* Out of memory.  Truncate address list here.  XXX */
-                       *ap = NULL;
-                       return;
-               }
-               *bpp += i;
-               *lenp -= i;
-               map_v4v6_address(*ap, *bpp);
-               *ap = *bpp;
-               *bpp += IN6ADDRSZ;
-               *lenp -= IN6ADDRSZ;
-       }
-}
-
-#ifdef RESOLVSORT
-static void
-addrsort(ap, num)
-       char **ap;
-       int num;
-{
-       int i, j;
-       char **p;
-       short aval[MAXADDRS];
-       int needsort = 0;
-
-       p = ap;
-       for (i = 0; i < num; i++, p++) {
-           for (j = 0 ; (unsigned)j < _res.nsort; j++)
-               if (_res.sort_list[j].addr.s_addr == 
-                   (((struct in_addr *)(*p))->s_addr & _res.sort_list[j].mask))
-                       break;
-           aval[i] = j;
-           if (needsort == 0 && i > 0 && j < aval[i-1])
-               needsort = i;
-       }
-       if (!needsort)
-           return;
-
-       while (needsort < num) {
-           for (j = needsort - 1; j >= 0; j--) {
-               if (aval[j] > aval[j+1]) {
-                   char *hp;
-
-                   i = aval[j];
-                   aval[j] = aval[j+1];
-                   aval[j+1] = i;
-
-                   hp = ap[j];
-                   ap[j] = ap[j+1];
-                   ap[j+1] = hp;
-
-               } else
-                   break;
-           }
-           needsort++;
-       }
-}
-#endif
-
-#if defined(BSD43_BSD43_NFS) || defined(sun)
-/* some libc's out there are bound internally to these names (UMIPS) */
-void
-ht_sethostent(stayopen)
-       int stayopen;
-{
-       _sethtent(stayopen);
-}
-
-void
-ht_endhostent()
-{
-       _endhtent();
-}
-
-struct hostent *
-ht_gethostbyname(name)
-       char *name;
-{
-       return (_gethtbyname(name));
-}
-
-struct hostent *
-ht_gethostbyaddr(addr, len, af)
-       const char *addr;
-       int len, af;
-{
-       return (_gethtbyaddr(addr, len, af));
-}
-
-struct hostent *
-gethostent()
-{
-       return (_gethtent());
-}
-
-void
-dns_service()
-{
-       return;
-}
-
-#undef dn_skipname
-dn_skipname(comp_dn, eom)
-       const u_char *comp_dn, *eom;
-{
-       return (__dn_skipname(comp_dn, eom));
-}
-#endif /*old-style libc with yp junk in it*/
diff --git a/bindlib_w32/getnetent.c b/bindlib_w32/getnetent.c
deleted file mode 100644 (file)
index e562848..0000000
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (c) 1983 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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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.
- */
-
-/* Portions Copyright (c) 1993 Carlos Leandro and Rui Salgueiro
- *     Dep. Matematica Universidade de Coimbra, Portugal, Europe
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * from getnetent.c    1.1 (Coimbra) 93/06/02
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getnetent.c        8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id$";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#ifndef WINNT
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#endif
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-
-#include <stdio.h>
-#include <resolv.h>
-#include <netdb.h>
-#include <string.h>
-#ifdef WINNT
-#include "conf/portability.h"
-extern char *pathnetworks;
-extern int res_paths_initialized;
-extern init_res_paths();
-#endif
-
-#ifndef _PATH_NETWORKS 
-#define _PATH_NETWORKS  "/etc/networks"
-#endif
-
-
-
-#define        MAXALIASES      35
-
-static FILE *netf;
-static char line[BUFSIZ+1];
-static struct netent net;
-static char *net_aliases[MAXALIASES];
-int _net_stayopen;
-
-void _setnetent __P((int));
-void _endnetent __P((void));
-
-void
-setnetent(stayopen)
-       int stayopen;
-{
-
-       sethostent(stayopen);
-       _setnetent(stayopen);
-}
-
-void
-endnetent()
-{
-
-       endhostent();
-       _endnetent();
-}
-
-void
-_setnetent(f)
-       int f;
-{
-
-#ifndef WINNT
-       if (netf == NULL)
-               netf = fopen(_PATH_NETWORKS, "r" );
-#else
-       if (!res_paths_initialized)
-         init_res_paths();
-
-       if (netf == NULL)
-               netf = fopen(pathnetworks, "r" );
-#endif
-       else
-               rewind(netf);
-       _net_stayopen |= f;
-}
-
-void
-_endnetent()
-{
-
-       if (netf) {
-               fclose(netf);
-               netf = NULL;
-       }
-       _net_stayopen = 0;
-}
-
-struct netent *
-getnetent()
-{
-       char *p;
-       register char *cp, **q;
-
-#ifndef WINNT
-       if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "r" )) == NULL)
-#else
-       if (!res_paths_initialized)
-         init_res_paths();
-
-       if (netf == NULL && (netf = fopen(pathnetworks, "r" )) == NULL)
-#endif
-
-               return (NULL);
-again:
-       p = fgets(line, sizeof line, netf);
-       if (p == NULL)
-               return (NULL);
-       if (*p == '#')
-               goto again;
-       cp = strpbrk(p, "#\n");
-       if (cp == NULL)
-               goto again;
-       *cp = '\0';
-       net.n_name = p;
-       cp = strpbrk(p, " \t");
-       if (cp == NULL)
-               goto again;
-       *cp++ = '\0';
-       while (*cp == ' ' || *cp == '\t')
-               cp++;
-       p = strpbrk(cp, " \t");
-       if (p != NULL)
-               *p++ = '\0';
-       net.n_net = inet_network(cp);
-       net.n_addrtype = AF_INET;
-       q = net.n_aliases = net_aliases;
-       if (p != NULL) {
-               cp = p;
-               while (cp && *cp) {
-                       if (*cp == ' ' || *cp == '\t') {
-                               cp++;
-                               continue;
-                       }
-                       if (q < &net_aliases[MAXALIASES - 1])
-                               *q++ = cp;
-                       cp = strpbrk(cp, " \t");
-                       if (cp != NULL)
-                               *cp++ = '\0';
-               }
-       }
-       *q = NULL;
-       return (&net);
-}
diff --git a/bindlib_w32/getnetnamadr.c b/bindlib_w32/getnetnamadr.c
deleted file mode 100644 (file)
index 7653675..0000000
+++ /dev/null
@@ -1,310 +0,0 @@
-/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro
- *     Dep. Matematica Universidade de Coimbra, Portugal, Europe
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- */
-/*
- * Copyright (c) 1983, 1993
- *     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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getnetbyaddr.c     8.1 (Berkeley) 6/4/93";
-static char sccsid_[] = "from getnetnamadr.c   1.4 (Coimbra) 93/06/03";
-static char rcsid[] = "$Id$";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#ifndef WINNT
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#endif
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-
-#include <stdio.h>
-#include <netdb.h>
-#include <resolv.h>
-#include <ctype.h>
-#include <errno.h>
-#include <string.h>
-
-#ifndef WINNT
-extern int h_errno;
-#else
-#include "conf/portability.h"
-#endif
-
-#if defined(mips) && defined(SYSTYPE_BSD43)
-extern int errno;
-#endif
-
-struct netent *_getnetbyaddr __P((u_long net, int type));
-struct netent *_getnetbyname __P((const char *name));
-
-#define BYADDR 0
-#define BYNAME 1
-#define        MAXALIASES      35
-
-#if PACKETSZ > 1024
-#define        MAXPACKET       PACKETSZ
-#else
-#define        MAXPACKET       1024
-#endif
-
-typedef union {
-       HEADER  hdr;
-       u_char  buf[MAXPACKET];
-} querybuf;
-
-typedef union {
-       long    al;
-       char    ac;
-} align;
-
-static struct netent *
-getnetanswer(answer, anslen, net_i)
-       querybuf *answer;
-       int anslen;
-       int net_i;
-{
-
-       register HEADER *hp;
-       register u_char *cp;
-       register int n;
-       u_char *eom;
-       int type, class, buflen, ancount, qdcount, haveanswer, i, nchar;
-       char aux1[30], aux2[30], ans[30], *in, *st, *pauxt, *bp, **ap,
-               *paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0;
-static struct netent net_entry;
-static char *net_aliases[MAXALIASES], netbuf[PACKETSZ];
-
-       /*
-        * find first satisfactory answer
-        *
-        *      answer --> +------------+  ( MESSAGE )
-        *                 |   Header   |
-        *                 +------------+
-        *                 |  Question  | the question for the name server
-        *                 +------------+
-        *                 |   Answer   | RRs answering the question
-        *                 +------------+
-        *                 | Authority  | RRs pointing toward an authority
-        *                 | Additional | RRs holding additional information
-        *                 +------------+
-        */
-       eom = answer->buf + anslen;
-       hp = &answer->hdr;
-       ancount = ntohs( (u_short) hp->ancount); /* #/records in the answer section */
-       qdcount = ntohs( (u_short) hp->qdcount); /* #/entries in the question section */
-       bp = netbuf;
-       buflen = sizeof(netbuf);
-       cp = answer->buf + HFIXEDSZ;
-       if (!qdcount) {
-               if (hp->aa)
-#ifndef WINNT
-                       h_errno = HOST_NOT_FOUND;
-#else
-                       WSASetLastError(HOST_NOT_FOUND);
-#endif
-               else
-#ifndef WINNT
-                       h_errno = TRY_AGAIN;
-#else
-                       WSASetLastError(HOST_NOT_FOUND);
-#endif
-               return (NULL);
-       }
-       while (qdcount-- > 0)
-               cp += __dn_skipname(cp, eom) + QFIXEDSZ;
-       ap = net_aliases;
-       *ap = NULL;
-       net_entry.n_aliases = net_aliases;
-       haveanswer = 0;
-       while (--ancount >= 0 && cp < eom) {
-               n = dn_expand(answer->buf, eom, cp, bp, buflen);
-               if ((n < 0) || !res_dnok(bp))
-                       break;
-               cp += n;
-               ans[0] = '\0';
-               (void)strcpy(&ans[0], bp);
-               GETSHORT(type, cp);
-               GETSHORT(class, cp);
-               cp += INT32SZ;          /* TTL */
-               GETSHORT(n, cp);
-               if (class == C_IN && type == T_PTR) {
-                       n = dn_expand(answer->buf, eom, cp, bp, buflen);
-                       if ((n < 0) || !res_hnok(bp)) {
-                               cp += n;
-                               return (NULL);
-                       }
-                       cp += n; 
-                       *ap++ = bp;
-                       bp += strlen(bp) + 1;
-                       net_entry.n_addrtype =
-                               (class == C_IN) ? AF_INET : AF_UNSPEC;
-                       haveanswer++;
-               }
-       }
-       if (haveanswer) {
-               *ap = NULL;
-               switch (net_i) {
-               case BYADDR:
-                       net_entry.n_name = *net_entry.n_aliases;
-                       net_entry.n_net = 0L;
-                       break;
-               case BYNAME:
-                       in = *net_entry.n_aliases;
-                       net_entry.n_name = &ans[0];
-                       aux2[0] = '\0';
-                       for (i = 0; i < 4; i++) {
-                               for (st = in, nchar = 0;
-                                    *st != '.';
-                                    st++, nchar++)
-                                       ;
-                               if (nchar != 1 || *in != '0' || flag) {
-                                       flag = 1;
-                                       (void)strncpy(paux1,
-                                                     (i==0) ? in : in-1,
-                                                     (i==0) ?nchar : nchar+1);
-                                       paux1[(i==0) ? nchar : nchar+1] = '\0';
-                                       pauxt = paux2;
-                                       paux2 = strcat(paux1, paux2);
-                                       paux1 = pauxt;
-                               }
-                               in = ++st;
-                       }                 
-                       net_entry.n_net = inet_network(paux2);
-                       break;
-               }
-               net_entry.n_aliases++;
-               return (&net_entry);
-       }
-#ifndef WINNT
-       h_errno = TRY_AGAIN;
-#else
-       WSASetLastError(TRY_AGAIN);
-#endif
-       return (NULL);
-}
-
-struct netent *
-getnetbyaddr(net, net_type)
-       register u_long net;
-       register int net_type;
-{
-       unsigned int netbr[4];
-       int nn, anslen;
-       querybuf buf;
-       char qbuf[MAXDNAME];
-       unsigned long net2;
-       struct netent *net_entry;
-
-       if (net_type != AF_INET)
-               return (_getnetbyaddr(net, net_type));
-
-       for (nn = 4, net2 = net; net2; net2 >>= 8)
-               netbr[--nn] = net2 & 0xff;
-       switch (nn) {
-       case 3:         /* Class A */
-               sprintf(qbuf, "0.0.0.%u.in-addr.arpa", netbr[3]);
-               break;
-       case 2:         /* Class B */
-               sprintf(qbuf, "0.0.%u.%u.in-addr.arpa", netbr[3], netbr[2]);
-               break;
-       case 1:         /* Class C */
-               sprintf(qbuf, "0.%u.%u.%u.in-addr.arpa", netbr[3], netbr[2],
-                   netbr[1]);
-               break;
-       case 0:         /* Class D - E */
-               sprintf(qbuf, "%u.%u.%u.%u.in-addr.arpa", netbr[3], netbr[2],
-                   netbr[1], netbr[0]);
-               break;
-       }
-       anslen = res_query(qbuf, C_IN, T_PTR, (u_char *)&buf, sizeof(buf));
-       if (anslen < 0) {
-#ifdef DEBUG
-               if (_res.options & RES_DEBUG)
-                       printf("res_query failed\n");
-#endif
-               if (errno == ECONNREFUSED)
-                       return (_getnetbyaddr(net, net_type));
-               return (NULL);
-       }
-       net_entry = getnetanswer(&buf, anslen, BYADDR);
-       if (net_entry) {
-               unsigned u_net = net;   /* maybe net should be unsigned ? */
-
-               /* Strip trailing zeros */
-               while ((u_net & 0xff) == 0 && u_net != 0)
-                       u_net >>= 8;
-               net_entry->n_net = u_net;
-               return (net_entry);
-       }
-       return (_getnetbyaddr(net, net_type));
-}
-
-struct netent *
-getnetbyname(net)
-       register const char *net;
-{
-       int anslen;
-       querybuf buf;
-       char qbuf[MAXDNAME];
-       struct netent *net_entry;
-
-       if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
-#ifndef WINNT
-               h_errno = NETDB_INTERNAL;
-#else
-               WSASetLastError(NETDB_INTERNAL);
-#endif
-               return (NULL);
-       }
-       strcpy(&qbuf[0], net);
-       anslen = res_search(qbuf, C_IN, T_PTR, (u_char *)&buf, sizeof(buf));
-       if (anslen < 0) {
-#ifdef DEBUG
-               if (_res.options & RES_DEBUG)
-                       printf("res_query failed\n");
-#endif
-               if (errno == ECONNREFUSED)
-                       return (_getnetbyname(net));
-               return (_getnetbyname(net));
-       }
-       net_entry = getnetanswer(&buf, anslen, BYNAME);
-       if (net_entry)
-               return (net_entry);
-       return (_getnetbyname(net));
-}
diff --git a/bindlib_w32/inet_net_ntop.c b/bindlib_w32/inet_net_ntop.c
deleted file mode 100644 (file)
index d2c0993..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 1996 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id$";
-#endif
-
-#include <sys/types.h>
-#ifndef WINNT
-#include <sys/socket.h>
-#include <netinet/in.h>
-#endif
-#include <arpa/inet.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-
-#ifdef SPRINTF_CHAR
-# define SPRINTF(x) strlen(sprintf/**/x)
-#else
-# define SPRINTF(x) ((size_t)sprintf x)
-#endif
-
-static char *  inet_net_ntop_ipv4 __P((const u_char *src, int bits,
-                                       char *dst, size_t size));
-
-/*
- * char *
- * inet_net_ntop(af, src, bits, dst, size)
- *     convert network number from network to presentation format.
- *     generates CIDR style result always.
- * return:
- *     pointer to dst, or NULL if an error occurred (check errno).
- * author:
- *     Paul Vixie (ISC), July 1996
- */
-char *
-inet_net_ntop(af, src, bits, dst, size)
-       int af;
-       const void *src;
-       int bits;
-       char *dst;
-       size_t size;
-{
-       switch (af) {
-       case AF_INET:
-               return (inet_net_ntop_ipv4(src, bits, dst, size));
-       default:
-
-#ifndef WINNT
-       errno = EAFNOSUPPORT;
-     return (NULL);
-#else
-
-       WSASetLastError(WSAEAFNOSUPPORT);
-       SetLastError(WSAEAFNOSUPPORT);
-     return (NULL);
-#endif
-
-       }
-}
-
-/*
- * static char *
- * inet_net_ntop_ipv4(src, bits, dst, size)
- *     convert IPv4 network number from network to presentation format.
- *     generates CIDR style result always.
- * return:
- *     pointer to dst, or NULL if an error occurred (check errno).
- * note:
- *     network byte order assumed.  this means 192.5.5.240/28 has
- *     0x11110000 in its fourth octet.
- * author:
- *     Paul Vixie (ISC), July 1996
- */
-static char *
-inet_net_ntop_ipv4(src, bits, dst, size)
-       const u_char *src;
-       int bits;
-       char *dst;
-       size_t size;
-{
-       char *odst = dst;
-       char *t;
-       u_int m;
-       int b;
-
-       if (bits < 0 || bits > 32) {
-               errno = EINVAL;
-               return (NULL);
-       }
-       if (bits == 0) {
-               if (size < sizeof "0")
-                       goto emsgsize;
-               *dst++ = '0';
-               *dst = '\0';
-       }
-
-       /* Format whole octets. */
-       for (b = bits / 8; b > 0; b--) {
-               if (size < sizeof "255.")
-                       goto emsgsize;
-               t = dst;
-               dst += SPRINTF((dst, "%u", *src++));
-               if (b > 1) {
-                       *dst++ = '.';
-                       *dst = '\0';
-               }
-               size -= (size_t)(dst - t);
-       }
-
-       /* Format partial octet. */
-       b = bits % 8;
-       if (b > 0) {
-               if (size < sizeof ".255")
-                       goto emsgsize;
-               t = dst;
-               if (dst != odst)
-                       *dst++ = '.';
-               m = ((1 << b) - 1) << (8 - b);
-               dst += SPRINTF((dst, "%u", *src & m));
-               size -= (size_t)(dst - t);
-       }
-
-       /* Format CIDR /width. */
-       if (size < sizeof "/32")
-               goto emsgsize;
-       dst += SPRINTF((dst, "/%u", bits));
-       return (odst);
-
- emsgsize:
-
- #ifndef WINNT
-     errno = EMSGSIZE;
-     return (NULL);
-#else
-     WSASetLastError(WSAEMSGSIZE);
-     SetLastError(WSAEMSGSIZE);
-     return (NULL);
-#endif
-
-
-}
diff --git a/bindlib_w32/inet_neta.c b/bindlib_w32/inet_neta.c
deleted file mode 100644 (file)
index 9e28ff9..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 1996 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id$";
-#endif
-
-#include <sys/types.h>
-#ifndef WINNT
-#include <sys/socket.h>
-#include <netinet/in.h>
-#endif
-#include <arpa/inet.h>
-
-#include <errno.h>
-#include <stdio.h>
-
-#ifdef SPRINTF_CHAR
-# define SPRINTF(x) strlen(sprintf/**/x)
-#else
-# define SPRINTF(x) ((size_t)sprintf x)
-#endif
-
-/*
- * char *
- * inet_neta(src, dst, size)
- *     format a u_long network number into presentation format.
- * return:
- *     pointer to dst, or NULL if an error occurred (check errno).
- * note:
- *     format of ``src'' is as for inet_network().
- * author:
- *     Paul Vixie (ISC), July 1996
- */
-char *
-inet_neta(src, dst, size)
-       u_long src;
-       char *dst;
-       size_t size;
-{
-       char *odst = dst;
-       char *tp;
-
-       while (src & 0xffffffff) {
-               u_char b = (u_char)((src & 0xff000000) >> 24);
-
-               src <<= 8;
-               if (b) {
-                       if (size < sizeof "255.")
-                               goto emsgsize;
-                       tp = dst;
-                       dst += SPRINTF((dst, "%u", b));
-                       if (src != 0L) {
-                               *dst++ = '.';
-                               *dst = '\0';
-                       }
-                       size -= (size_t)(dst - tp);
-               }
-       }
-       if (dst == odst) {
-               if (size < sizeof "0.0.0.0")
-                       goto emsgsize;
-               strcpy(dst, "0.0.0.0");
-       }
-       return (odst);
-
- emsgsize:
-
- #ifndef WINNT
-     errno = EMSGSIZE;
-     return (NULL);
-#else
-     WSASetLastError(WSAEMSGSIZE);
-     SetLastError(WSAEMSGSIZE);
-     return (NULL);
-#endif
-
-}
diff --git a/bindlib_w32/nsap_addr.c b/bindlib_w32/nsap_addr.c
deleted file mode 100644 (file)
index f38bddf..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 1996 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$Id$";
-#endif /* LIBC_SCCS and not lint */
-
-#ifndef WINNT
-#include <sys/types.h>
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#endif
-#include <arpa/nameser.h>
-#include <ctype.h>
-#include <resolv.h>
-
-#include "conf/portability.h"
-
-#if !defined(isxdigit) /* XXX - could be a function */
-static int
-isxdigit(c)
-       register int c;
-{
-       return ((c >= '0') && (c <= '9')) || ((c >= 'A') && (c <= 'F'));
-}
-#endif
-
-static char
-xtob(c)
-       register int c;
-{
-       return (c - (((c >= '0') && (c <= '9')) ? '0' : '7'));
-}
-
-u_int
-inet_nsap_addr(ascii, binary, maxlen)
-       const char *ascii;
-       u_char *binary;
-       u_int maxlen;
-{
-       register u_char c, nib;
-       u_int len = 0;
-
-       while ((c = *ascii++) != '\0' && len < maxlen) {
-               if (c == '.' || c == '+' || c == '/')
-                       continue;
-               if (!isascii(c))
-                       return (0);
-               if (islower(c))
-                       c = toupper(c);
-               if (isxdigit(c)) {
-                       nib = xtob(c);
-                       if (c = *ascii++) {
-                               c = toupper(c);
-                               if (isxdigit(c)) {
-                                       *binary++ = (nib << 4) | xtob(c);
-                                       len++;
-                               } else
-                                       return (0);
-                       }
-                       else
-                               return (0);
-               }
-               else
-                       return (0);
-       }
-       return (len);
-}
-
-char *
-inet_nsap_ntoa(binlen, binary, ascii)
-       int binlen;
-       register const u_char *binary;
-       register char *ascii;
-{
-       register int nib;
-       int i;
-       static char tmpbuf[255*3];
-       char *start;
-
-       if (ascii)
-               start = ascii;
-       else {
-               ascii = tmpbuf;
-               start = tmpbuf;
-       }
-
-       if (binlen > 255)
-               binlen = 255;
-
-       for (i = 0; i < binlen; i++) {
-               nib = *binary >> 4;
-               *ascii++ = nib + (nib < 10 ? '0' : '7');
-               nib = *binary++ & 0x0f;
-               *ascii++ = nib + (nib < 10 ? '0' : '7');
-               if (((i % 2) == 0 && (i + 1) < binlen))
-                       *ascii++ = '.';
-       }
-       *ascii = '\0';
-       return (start);
-}
diff --git a/bindlib_w32/res_init.c b/bindlib_w32/res_init.c
deleted file mode 100644 (file)
index 12a979e..0000000
+++ /dev/null
@@ -1,685 +0,0 @@
-/*
- * ++Copyright++ 1985, 1989, 1993
- * -
- * Copyright (c) 1985, 1989, 1993
- *    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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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.
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- * 
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
-static char rcsid[] = "$Id$";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#ifndef WINNT
-#include <sys/param.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#include <netinet/in.h>
-#endif /* WINNT */
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-
-#include <stdio.h>
-#include <ctype.h>
-#include <resolv.h>
-#if defined(BSD) && (BSD >= 199103)
-# include <unistd.h>
-# include <stdlib.h>
-# include <string.h>
-#else
-#include "conf/portability.h"
-#endif
-
-#ifdef WINNT
-#include <netdb.h>
-#include "conf/portability.h"
-extern char *pathresconf;
-extern int res_paths_initialized;
-extern init_res_paths();
-#endif
-
-/*-------------------------------------- info about "sortlist" --------------
- * Marc Majka          1994/04/16
- * Allan Nathanson     1994/10/29 (BIND 4.9.3.x)
- *
- * NetInfo resolver configuration directory support.
- *
- * Allow a NetInfo directory to be created in the hierarchy which
- * contains the same information as the resolver configuration file.
- *
- * - The local domain name is stored as the value of the "domain" property.
- * - The Internet address(es) of the name server(s) are stored as values
- *   of the "nameserver" property.
- * - The name server addresses are stored as values of the "nameserver"
- *   property.
- * - The search list for host-name lookup is stored as values of the
- *   "search" property.
- * - The sortlist comprised of IP address netmask pairs are stored as
- *   values of the "sortlist" property. The IP address and optional netmask
- *   should be seperated by a slash (/) or ampersand (&) character.
- * - Internal resolver variables can be set from the value of the "options"
- *   property.
- */
-#if defined(NeXT)
-#  include <netinfo/ni.h>
-#  define NI_PATH_RESCONF "/locations/resolver"
-#  define NI_TIMEOUT 10
-static int netinfo_res_init __P((int *haveenv, int *havesearch));
-#endif
-
-#if defined(USE_OPTIONS_H)
-# include "conf/options.h"
-#endif
-
-static void res_setoptions __P((char *, char *));
-
-#ifdef RESOLVSORT
-static const char sort_mask[] = "/&";
-#define ISSORTMASK(ch) (strchr(sort_mask, ch) != NULL)
-static u_int32_t net_mask __P((struct in_addr));
-#endif
-
-#if !defined(isascii)  /* XXX - could be a function */
-# define isascii(c) (!(c & 0200))
-#endif
-
-/*
- * Resolver state default settings.
- */
-
-struct __res_state _res
-# if defined(__BIND_RES_TEXT)
-       = { RES_TIMEOUT, }      /* Motorola, et al. */
-# endif
-       ;
-
-/*
- * Set up default settings.  If the configuration file exist, the values
- * there will have precedence.  Otherwise, the server address is set to
- * INADDR_ANY and the default domain name comes from the gethostname().
- *
- * An interrim version of this code (BIND 4.9, pre-4.4BSD) used 127.0.0.1
- * rather than INADDR_ANY ("0.0.0.0") as the default name server address
- * since it was noted that INADDR_ANY actually meant ``the first interface
- * you "ifconfig"'d at boot time'' and if this was a SLIP or PPP interface,
- * it had to be "up" in order for you to reach your own name server.  It
- * was later decided that since the recommended practice is to always 
- * install local static routes through 127.0.0.1 for all your network
- * interfaces, that we could solve this problem without a code change.
- *
- * The configuration file should always be used, since it is the only way
- * to specify a default domain.  If you are running a server on your local
- * machine, you should say "nameserver 0.0.0.0" or "nameserver 127.0.0.1"
- * in the configuration file.
- *
- * Return 0 if completes successfully, -1 on error
- */
-int
-res_init()
-{
-       register FILE *fp;
-       register char *cp, **pp;
-       register int n;
-       char buf[MAXDNAME];
-       int nserv = 0;    /* number of nameserver records read from file */
-       int haveenv = 0;
-       int havesearch = 0;
-#ifdef RESOLVSORT
-       int nsort = 0;
-       char *net;
-#endif
-#ifndef RFC1535
-       int dots;
-#endif
-
-
-#ifdef WINNT
-       WORD wVersionRequested;
-       WSADATA wsaData;
-
-       wVersionRequested = MAKEWORD(1,1);
-       if (WSAStartup(wVersionRequested, &wsaData)) {
-               syslog(LOG_ERR, "No useable winsock.dll: %m");
-               return (-1);
-       }
-#endif /* WINNT */
-
-       /*
-        * These three fields used to be statically initialized.  This made
-        * it hard to use this code in a shared library.  It is necessary,
-        * now that we're doing dynamic initialization here, that we preserve
-        * the old semantics: if an application modifies one of these three
-        * fields of _res before res_init() is called, res_init() will not
-        * alter them.  Of course, if an application is setting them to
-        * _zero_ before calling res_init(), hoping to override what used
-        * to be the static default, we can't detect it and unexpected results
-        * will follow.  Zero for any of these fields would make no sense,
-        * so one can safely assume that the applications were already getting
-        * unexpected results.
-        *
-        * _res.options is tricky since some apps were known to diddle the bits
-        * before res_init() was first called. We can't replicate that semantic
-        * with dynamic initialization (they may have turned bits off that are
-        * set in RES_DEFAULT).  Our solution is to declare such applications
-        * "broken".  They could fool us by setting RES_INIT but none do (yet).
-        */
-       if (!_res.retrans)
-               _res.retrans = RES_TIMEOUT;
-       if (!_res.retry)
-               _res.retry = 4;
-       if (!(_res.options & RES_INIT))
-               _res.options = RES_DEFAULT;
-
-       /*
-        * This one used to initialize implicitly to zero, so unless the app
-        * has set it to something in particular, we can randomize it now.
-        */
-       if (!_res.id)
-               _res.id = res_randomid();
-
-#ifdef USELOOPBACK
-       _res.nsaddr.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
-#else
-       _res.nsaddr.sin_addr.s_addr = INADDR_ANY;
-#endif
-       _res.nsaddr.sin_family = AF_INET;
-       _res.nsaddr.sin_port = htons(NAMESERVER_PORT);
-       _res.nscount = 1;
-       _res.ndots = 1;
-       _res.pfcode = 0;
-
-       /* Allow user to override the local domain definition */
-       if ((cp = getenv("LOCALDOMAIN")) != NULL) {
-               (void)strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
-               haveenv++;
-
-               /*
-                * Set search list to be blank-separated strings
-                * from rest of env value.  Permits users of LOCALDOMAIN
-                * to still have a search list, and anyone to set the
-                * one that they want to use as an individual (even more
-                * important now that the rfc1535 stuff restricts searches)
-                */
-               cp = _res.defdname;
-               pp = _res.dnsrch;
-               *pp++ = cp;
-               for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) {
-                       if (*cp == '\n')        /* silly backwards compat */
-                               break;
-                       else if (*cp == ' ' || *cp == '\t') {
-                               *cp = 0;
-                               n = 1;
-                       } else if (n) {
-                               *pp++ = cp;
-                               n = 0;
-                               havesearch = 1;
-                       }
-               }
-               /* null terminate last domain if there are excess */
-               while (*cp != '\0' && *cp != ' ' && *cp != '\t' && *cp != '\n')
-                       cp++;
-               *cp = '\0';
-               *pp++ = 0;
-       }
-
-#define        MATCH(line, name) \
-       (!strncmp(line, name, sizeof(name) - 1) && \
-       (line[sizeof(name) - 1] == ' ' || \
-        line[sizeof(name) - 1] == '\t'))
-
-#ifdef NeXT
-       if (netinfo_res_init(&haveenv, &havesearch) == 0)
-#endif
-#ifndef WINNT
-       if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
-#else
-       if (!res_paths_initialized)
-         init_res_paths();
-
-       if ((fp = fopen(pathresconf, "r")) != NULL) {
-
-#endif
-           /* read the config file */
-           while (fgets(buf, sizeof(buf), fp) != NULL) {
-               /* skip comments */
-               if (*buf == ';' || *buf == '#')
-                       continue;
-               /* read default domain name */
-               if (MATCH(buf, "domain")) {
-                   if (haveenv)        /* skip if have from environ */
-                           continue;
-                   cp = buf + sizeof("domain") - 1;
-                   while (*cp == ' ' || *cp == '\t')
-                           cp++;
-                   if ((*cp == '\0') || (*cp == '\n'))
-                           continue;
-                   strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
-                   if ((cp = strpbrk(_res.defdname, " \t\n")) != NULL)
-                           *cp = '\0';
-                   havesearch = 0;
-                   continue;
-               }
-               /* set search list */
-               if (MATCH(buf, "search")) {
-                   if (haveenv)        /* skip if have from environ */
-                           continue;
-                   cp = buf + sizeof("search") - 1;
-                   while (*cp == ' ' || *cp == '\t')
-                           cp++;
-                   if ((*cp == '\0') || (*cp == '\n'))
-                           continue;
-                   strncpy(_res.defdname, cp, sizeof(_res.defdname) - 1);
-                   if ((cp = strchr(_res.defdname, '\n')) != NULL)
-                           *cp = '\0';
-                   /*
-                    * Set search list to be blank-separated strings
-                    * on rest of line.
-                    */
-                   cp = _res.defdname;
-                   pp = _res.dnsrch;
-                   *pp++ = cp;
-                   for (n = 0; *cp && pp < _res.dnsrch + MAXDNSRCH; cp++) {
-                           if (*cp == ' ' || *cp == '\t') {
-                                   *cp = 0;
-                                   n = 1;
-                           } else if (n) {
-                                   *pp++ = cp;
-                                   n = 0;
-                           }
-                   }
-                   /* null terminate last domain if there are excess */
-                   while (*cp != '\0' && *cp != ' ' && *cp != '\t')
-                           cp++;
-                   *cp = '\0';
-                   *pp++ = 0;
-                   havesearch = 1;
-                   continue;
-               }
-               /* read nameservers to query */
-               if (MATCH(buf, "nameserver") && nserv < MAXNS) {
-                   struct in_addr a;
-
-                   cp = buf + sizeof("nameserver") - 1;
-                   while (*cp == ' ' || *cp == '\t')
-                       cp++;
-                   if ((*cp != '\0') && (*cp != '\n') && inet_aton(cp, &a)) {
-                       _res.nsaddr_list[nserv].sin_addr = a;
-                       _res.nsaddr_list[nserv].sin_family = AF_INET;
-                       _res.nsaddr_list[nserv].sin_port =
-                               htons(NAMESERVER_PORT);
-                       nserv++;
-                   }
-                   continue;
-               }
-#ifdef RESOLVSORT
-               if (MATCH(buf, "sortlist")) {
-                   struct in_addr a;
-
-                   cp = buf + sizeof("sortlist") - 1;
-                   while (nsort < MAXRESOLVSORT) {
-                       while (*cp == ' ' || *cp == '\t')
-                           cp++;
-                       if (*cp == '\0' || *cp == '\n' || *cp == ';')
-                           break;
-                       net = cp;
-                       while (*cp && !ISSORTMASK(*cp) && *cp != ';' &&
-                              isascii(*cp) && !isspace(*cp))
-                               cp++;
-                       n = *cp;
-                       *cp = 0;
-                       if (inet_aton(net, &a)) {
-                           _res.sort_list[nsort].addr = a;
-                           if (ISSORTMASK(n)) {
-                               *cp++ = n;
-                               net = cp;
-                               while (*cp && *cp != ';' &&
-                                       isascii(*cp) && !isspace(*cp))
-                                   cp++;
-                               n = *cp;
-                               *cp = 0;
-                               if (inet_aton(net, &a)) {
-                                   _res.sort_list[nsort].mask = a.s_addr;
-                               } else {
-                                   _res.sort_list[nsort].mask = 
-                                       net_mask(_res.sort_list[nsort].addr);
-                               }
-                           } else {
-                               _res.sort_list[nsort].mask = 
-                                   net_mask(_res.sort_list[nsort].addr);
-                           }
-                           nsort++;
-                       }
-                       *cp = n;
-                   }
-                   continue;
-               }
-#endif
-               if (MATCH(buf, "options")) {
-                   res_setoptions(buf + sizeof("options") - 1, "conf");
-                   continue;
-               }
-           }
-           if (nserv > 1) 
-               _res.nscount = nserv;
-#ifdef RESOLVSORT
-           _res.nsort = nsort;
-#endif
-           (void) fclose(fp);
-       }
-       if (_res.defdname[0] == 0 &&
-           gethostname(buf, sizeof(_res.defdname) - 1) == 0 &&
-           (cp = strchr(buf, '.')) != NULL)
-               strcpy(_res.defdname, cp + 1);
-
-       /* find components of local domain that might be searched */
-       if (havesearch == 0) {
-               pp = _res.dnsrch;
-               *pp++ = _res.defdname;
-               *pp = NULL;
-
-#ifndef RFC1535
-               dots = 0;
-               for (cp = _res.defdname; *cp; cp++)
-                       dots += (*cp == '.');
-
-               cp = _res.defdname;
-               while (pp < _res.dnsrch + MAXDFLSRCH) {
-                       if (dots < LOCALDOMAINPARTS)
-                               break;
-                       cp = strchr(cp, '.') + 1;    /* we know there is one */
-                       *pp++ = cp;
-                       dots--;
-               }
-               *pp = NULL;
-#ifdef DEBUG
-               if (_res.options & RES_DEBUG) {
-                       printf(";; res_init()... default dnsrch list:\n");
-                       for (pp = _res.dnsrch; *pp; pp++)
-                               printf(";;\t%s\n", *pp);
-                       printf(";;\t..END..\n");
-               }
-#endif /* DEBUG */
-#endif /* !RFC1535 */
-       }
-
-       if ((cp = getenv("RES_OPTIONS")) != NULL)
-               res_setoptions(cp, "env");
-       _res.options |= RES_INIT;
-       return (0);
-}
-
-static void
-res_setoptions(options, source)
-       char *options, *source;
-{
-       char *cp = options;
-       int i;
-
-#ifdef DEBUG
-       if (_res.options & RES_DEBUG)
-               printf(";; res_setoptions(\"%s\", \"%s\")...\n",
-                      options, source);
-#endif
-       while (*cp) {
-               /* skip leading and inner runs of spaces */
-               while (*cp == ' ' || *cp == '\t')
-                       cp++;
-               /* search for and process individual options */
-               if (!strncmp(cp, "ndots:", sizeof("ndots:") - 1)) {
-                       i = atoi(cp + sizeof("ndots:") - 1);
-                       if (i <= RES_MAXNDOTS)
-                               _res.ndots = i;
-                       else
-                               _res.ndots = RES_MAXNDOTS;
-#ifdef DEBUG
-                       if (_res.options & RES_DEBUG)
-                               printf(";;\tndots=%d\n", _res.ndots);
-#endif
-               } else if (!strncmp(cp, "debug", sizeof("debug") - 1)) {
-#ifdef DEBUG
-                       if (!(_res.options & RES_DEBUG)) {
-                               printf(";; res_setoptions(\"%s\", \"%s\")..\n",
-                                      options, source);
-                               _res.options |= RES_DEBUG;
-                       }
-                       printf(";;\tdebug\n");
-#endif
-               } else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) {
-                       _res.options |= RES_USE_INET6;
-               } else {
-                       /* XXX - print a warning here? */
-               }
-               /* skip to next run of spaces */
-               while (*cp && *cp != ' ' && *cp != '\t')
-                       cp++;
-       }
-}
-
-#ifdef RESOLVSORT
-/* XXX - should really support CIDR which means explicit masks always. */
-static u_int32_t
-net_mask(in)           /* XXX - should really use system's version of this */
-       struct in_addr in;
-{
-       register u_int32_t i = ntohl(in.s_addr);
-
-       if (IN_CLASSA(i))
-               return (htonl(IN_CLASSA_NET));
-       else if (IN_CLASSB(i))
-               return (htonl(IN_CLASSB_NET));
-       return (htonl(IN_CLASSC_NET));
-}
-#endif
-
-#ifdef NeXT
-static int
-netinfo_res_init(haveenv, havesearch)
-       int *haveenv;
-       int *havesearch;
-{
-    register   int n;
-    void       *domain, *parent;
-    ni_id      dir;
-    ni_status  status;
-    ni_namelist        nl;
-    int                nserv = 0;
-#ifdef RESOLVSORT
-    int                nsort = 0;
-#endif
-
-    status = ni_open(NULL, ".", &domain);
-    if (status == NI_OK) {
-       ni_setreadtimeout(domain, NI_TIMEOUT);
-       ni_setabort(domain, 1);
-
-       /* climb the NetInfo hierarchy to find a resolver directory */
-       while (status == NI_OK) {
-           status = ni_pathsearch(domain, &dir, NI_PATH_RESCONF);
-           if (status == NI_OK) {
-           /* found a resolver directory */
-
-               if (*haveenv == 0) {
-                   /* get the default domain name */
-                   status = ni_lookupprop(domain, &dir, "domain", &nl);
-                   if (status == NI_OK && nl.ni_namelist_len > 0) {
-                       (void)strncpy(_res.defdname,
-                                     nl.ni_namelist_val[0],
-                                     sizeof(_res.defdname) - 1);
-                       _res.defdname[sizeof(_res.defdname) - 1] = '\0';
-                       ni_namelist_free(&nl);
-                       *havesearch = 0;
-                   }
-
-                   /* get search list */
-                   status = ni_lookupprop(domain, &dir, "search", &nl);
-                   if (status == NI_OK && nl.ni_namelist_len > 0) {
-                       (void)strncpy(_res.defdname,
-                                     nl.ni_namelist_val[0],
-                                     sizeof(_res.defdname) - 1);
-                       _res.defdname[sizeof(_res.defdname) - 1] = '\0';
-                       /* copy  */
-                       for (n = 0;
-                            n < nl.ni_namelist_len && n < MAXDNSRCH;
-                            n++) {
-                            /* duplicate up to MAXDNSRCH servers */
-                            char *cp = nl.ni_namelist_val[n];
-                           _res.dnsrch[n] =
-                               strcpy((char *)malloc(strlen(cp) + 1), cp);
-                       }
-                       ni_namelist_free(&nl);
-                       *havesearch = 1;
-                   }
-               }
-
-               /* get list of nameservers */
-               status = ni_lookupprop(domain, &dir, "nameserver", &nl);
-               if (status == NI_OK && nl.ni_namelist_len > 0) {
-                   /* copy up to MAXNS servers */
-                   for (n = 0;
-                        n < nl.ni_namelist_len && nserv < MAXNS;
-                        n++) {
-                       struct in_addr a;
-
-                       if (inet_aton(nl.ni_namelist_val[n], &a)) {
-                           _res.nsaddr_list[nserv].sin_addr = a;
-                           _res.nsaddr_list[nserv].sin_family = AF_INET;
-                           _res.nsaddr_list[nserv].sin_port =
-                               htons(NAMESERVER_PORT);
-                           nserv++;
-                       }
-                   }
-                   ni_namelist_free(&nl);
-               }
-               
-               if (nserv > 1)
-                   _res.nscount = nserv;
-
-#ifdef RESOLVSORT
-               /* get sort order */
-               status = ni_lookupprop(domain, &dir, "sortlist", &nl);
-               if (status == NI_OK && nl.ni_namelist_len > 0) {
-
-                   /* copy up to MAXRESOLVSORT address/netmask pairs */
-                   for (n = 0;
-                        n < nl.ni_namelist_len && nsort < MAXRESOLVSORT;
-                        n++) {
-                       char ch;
-                       char *cp;
-                       const char *sp;
-                       struct in_addr a;
-
-                       cp = NULL;
-                       for (sp = sort_mask; *sp; sp++) {
-                               char *cp1;
-                               cp1 = strchr(nl.ni_namelist_val[n], *sp);
-                               if (cp && cp1)
-                                       cp = (cp < cp1)? cp : cp1;
-                               else if (cp1)
-                                       cp = cp1;
-                       }
-                       if (cp != NULL) {
-                               ch = *cp;
-                               *cp = '\0';
-                               break;
-                       }
-                       if (inet_aton(nl.ni_namelist_val[n], &a)) {
-                           _res.sort_list[nsort].addr = a;
-                           if (*cp && ISSORTMASK(ch)) {
-                               *cp++ = ch;
-                               if (inet_aton(cp, &a)) {
-                                   _res.sort_list[nsort].mask = a.s_addr;
-                               } else {
-                                   _res.sort_list[nsort].mask =
-                                       net_mask(_res.sort_list[nsort].addr);
-                               }
-                           } else {
-                               _res.sort_list[nsort].mask =
-                                   net_mask(_res.sort_list[nsort].addr);
-                           }
-                           nsort++;
-                       }
-                   }
-                   ni_namelist_free(&nl);
-               }
-
-               _res.nsort = nsort;
-#endif
-
-               /* get resolver options */
-               status = ni_lookupprop(domain, &dir, "options", &nl);
-               if (status == NI_OK && nl.ni_namelist_len > 0) {
-                   res_setoptions(nl.ni_namelist_val[0], "conf");
-                   ni_namelist_free(&nl);
-               }
-
-               ni_free(domain);
-               return(1);      /* using DNS configuration from NetInfo */
-           }
-
-           status = ni_open(domain, "..", &parent);
-           ni_free(domain);
-           if (status == NI_OK)
-               domain = parent;
-       }
-    }
-    return(0); /* if not using DNS configuration from NetInfo */
-}
-#endif /* NeXT */
-
-u_int
-res_randomid()
-{
-       struct timeval now;
-
-       gettimeofday(&now, NULL);
-       return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
-}
diff --git a/bindlib_w32/res_mkquery.c b/bindlib_w32/res_mkquery.c
deleted file mode 100644 (file)
index ef86ed7..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * ++Copyright++ 1985, 1993
- * -
- * Copyright (c) 1985, 1993
- *    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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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.
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- * 
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)res_mkquery.c      8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id$";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#ifndef WINNT
-#include <sys/param.h>
-#include <netinet/in.h>
-#endif
-#include <arpa/nameser.h>
-
-#include <stdio.h>
-#include <netdb.h>
-#include <resolv.h>
-#if defined(BSD) && (BSD >= 199103)
-# include <string.h>
-#else
-# include "conf/portability.h"
-#endif
-
-#if defined(USE_OPTIONS_H)
-# include <conf/options.h>
-#endif
-
-/*
- * Form all types of queries.
- * Returns the size of the result or -1.
- */
-int
-res_mkquery(op, dname, class, type, data, datalen, newrr_in, buf, buflen)
-       int op;                 /* opcode of query */
-       const char *dname;      /* domain name */
-       int class, type;        /* class and type of query */
-       const u_char *data;     /* resource record data */
-       int datalen;            /* length of data */
-       const u_char *newrr_in; /* new rr for modify or append */
-       u_char *buf;            /* buffer to put query */
-       int buflen;             /* size of buffer */
-{
-       register HEADER *hp;
-       register u_char *cp;
-       register int n;
-       u_char *dnptrs[20], **dpp, **lastdnptr;
-
-       if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
-#ifndef WINNT
-               h_errno = NETDB_INTERNAL;
-#else
-               WSASetLastError(NETDB_INTERNAL);
-#endif
-               return (-1);
-       }
-#ifdef DEBUG
-       if (_res.options & RES_DEBUG)
-               printf(";; res_mkquery(%d, %s, %d, %d)\n",
-                      op, dname, class, type);
-#endif
-       /*
-        * Initialize header fields.
-        */
-       if ((buf == NULL) || (buflen < HFIXEDSZ))
-               return (-1);
-       bzero(buf, HFIXEDSZ);
-       hp = (HEADER *) buf;
-       hp->id = htons(++_res.id);
-       hp->opcode = op;
-       hp->rd = (_res.options & RES_RECURSE) != 0;
-       hp->rcode = NOERROR;
-       cp = buf + HFIXEDSZ;
-       buflen -= HFIXEDSZ;
-       dpp = dnptrs;
-       *dpp++ = buf;
-       *dpp++ = NULL;
-       lastdnptr = dnptrs + sizeof dnptrs / sizeof dnptrs[0];
-       /*
-        * perform opcode specific processing
-        */
-       switch (op) {
-       case QUERY:     /*FALLTHROUGH*/
-       case NS_NOTIFY_OP:
-               if ((buflen -= QFIXEDSZ) < 0)
-                       return (-1);
-               if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
-                       return (-1);
-               cp += n;
-               buflen -= n;
-               __putshort(type, cp);
-               cp += INT16SZ;
-               __putshort(class, cp);
-               cp += INT16SZ;
-               hp->qdcount = htons(1);
-               if (op == QUERY || data == NULL)
-                       break;
-               /*
-                * Make an additional record for completion domain.
-                */
-               buflen -= RRFIXEDSZ;
-               n = dn_comp((char *)data, cp, buflen, dnptrs, lastdnptr);
-               if (n < 0)
-                       return (-1);
-               cp += n;
-               buflen -= n;
-               __putshort(T_NULL, cp);
-               cp += INT16SZ;
-               __putshort(class, cp);
-               cp += INT16SZ;
-               __putlong(0, cp);
-               cp += INT32SZ;
-               __putshort(0, cp);
-               cp += INT16SZ;
-               hp->arcount = htons(1);
-               break;
-
-       case IQUERY:
-               /*
-                * Initialize answer section
-                */
-               if (buflen < 1 + RRFIXEDSZ + datalen)
-                       return (-1);
-               *cp++ = '\0';   /* no domain name */
-               __putshort(type, cp);
-               cp += INT16SZ;
-               __putshort(class, cp);
-               cp += INT16SZ;
-               __putlong(0, cp);
-               cp += INT32SZ;
-               __putshort(datalen, cp);
-               cp += INT16SZ;
-               if (datalen) {
-                       bcopy(data, cp, datalen);
-                       cp += datalen;
-               }
-               hp->ancount = htons(1);
-               break;
-
-       default:
-               return (-1);
-       }
-       return (cp - buf);
-}
diff --git a/bindlib_w32/res_send.c b/bindlib_w32/res_send.c
deleted file mode 100644 (file)
index 670a87e..0000000
+++ /dev/null
@@ -1,970 +0,0 @@
-/*
- * ++Copyright++ 1985, 1989, 1993
- * -
- * Copyright (c) 1985, 1989, 1993
- *    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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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.
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- * 
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id$";
-#endif /* LIBC_SCCS and not lint */
-
-       /* change this to "0"
-        * if you talk to a lot
-        * of multi-homed SunOS
-        * ("broken") name servers.
-        */
-#define        CHECK_SRVR_ADDR 1       /* XXX - should be in options.h */
-
-/*
- * Send query to name server and wait for reply.
- */
-
-#include <sys/types.h>
-#ifndef WINNT
-#include <sys/param.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <sys/uio.h>
-#include <netinet/in.h>
-#endif
-#include <arpa/nameser.h>
-#include <arpa/inet.h>
-
-#include <stdio.h>
-#include <netdb.h>
-#include <errno.h>
-#include <resolv.h>
-#if defined(BSD) && (BSD >= 199306)
-# include <stdlib.h>
-# include <string.h>
-# include <unistd.h>
-#else
-# include "conf/portability.h"
-#endif
-
-#if defined(USE_OPTIONS_H)
-# include <conf/options.h>
-#endif
-
-#ifndef WINNT
-static int s = -1;     /* socket used for communications */
-#else
-static SOCKET s = INVALID_SOCKET;
-typedef char * caddr_t;
-#endif
-static int connected = 0;      /* is the socket connected */
-static int vc = 0;     /* is the socket a virtual ciruit? */
-
-#ifndef FD_SET
-/* XXX - should be in portability.h */
-#define        NFDBITS         32
-#define        FD_SETSIZE      32
-#define        FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
-#define        FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
-#define        FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
-#define FD_ZERO(p)     bzero((char *)(p), sizeof(*(p)))
-#endif
-
-/* XXX - this should be done in portability.h */
-#if (defined(BSD) && (BSD >= 199103)) || defined(linux)
-# define CAN_RECONNECT 1
-#else
-# define CAN_RECONNECT 0
-#endif
-
-#ifndef DEBUG
-#   define Dprint(cond, args) /*empty*/
-#   define DprintQ(cond, args, query, size) /*empty*/
-#   define Aerror(file, string, error, address) /*empty*/
-#   define Perror(file, string, error) /*empty*/
-#else
-#   define Dprint(cond, args) if (cond) {fprintf args;} else {}
-#   define DprintQ(cond, args, query, size) if (cond) {\
-                       fprintf args;\
-                       __fp_nquery(query, size, stdout);\
-               } else {}
-    static void
-    Aerror(file, string, error, address)
-       FILE *file;
-       char *string;
-       int error;
-       struct sockaddr_in address;
-    {
-       int save = errno;
-
-       if (_res.options & RES_DEBUG) {
-               fprintf(file, "res_send: %s ([%s].%u): %s\n",
-                       string,
-                       inet_ntoa(address.sin_addr),
-                       ntohs(address.sin_port),
-                       strerror(error));
-       }
-#ifndef WINNT
-       errno = save;
-#else
-       WSASetLastError(save);
-       SetLastError(save);
-#endif
-    }
-    static void
-    Perror(file, string, error)
-       FILE *file;
-       char *string;
-       int error;
-    {
-       int save = errno;
-
-       if (_res.options & RES_DEBUG) {
-               fprintf(file, "res_send: %s: %s\n",
-                       string, strerror(error));
-       }
-#ifndef WINNT
-       errno = save;
-#else
-       SetLastError(save);
-#endif
-    }
-#endif
-
-static res_send_qhook Qhook = NULL;
-static res_send_rhook Rhook = NULL;
-
-void
-res_send_setqhook(hook)
-       res_send_qhook hook;
-{
-
-       Qhook = hook;
-}
-
-void
-res_send_setrhook(hook)
-       res_send_rhook hook;
-{
-
-       Rhook = hook;
-}
-
-/* int
- * res_isourserver(ina)
- *     looks up "ina" in _res.ns_addr_list[]
- * returns:
- *     0  : not found
- *     >0 : found
- * author:
- *     paul vixie, 29may94
- */
-int
-res_isourserver(inp)
-       const struct sockaddr_in *inp;
-{
-       struct sockaddr_in ina;
-       register int ns, ret;
-
-       ina = *inp;
-       ret = 0;
-       for (ns = 0;  ns < _res.nscount;  ns++) {
-               register const struct sockaddr_in *srv = &_res.nsaddr_list[ns];
-
-               if (srv->sin_family == ina.sin_family &&
-                   srv->sin_port == ina.sin_port &&
-                   (srv->sin_addr.s_addr == INADDR_ANY ||
-                    srv->sin_addr.s_addr == ina.sin_addr.s_addr)) {
-                       ret++;
-                       break;
-               }
-       }
-       return (ret);
-}
-
-/* int
- * res_nameinquery(name, type, class, buf, eom)
- *     look for (name,type,class) in the query section of packet (buf,eom)
- * requires:
- *     buf + HFIXESDZ <= eom
- * returns:
- *     -1 : format error
- *     0  : not found
- *     >0 : found
- * author:
- *     paul vixie, 29may94
- */
-int
-res_nameinquery(name, type, class, buf, eom)
-       const char *name;
-       register int type, class;
-       const u_char *buf, *eom;
-{
-       register const u_char *cp = buf + HFIXEDSZ;
-       int qdcount = ntohs( (u_short) ((HEADER*)buf)->qdcount);
-
-       while (qdcount-- > 0) {
-               char tname[MAXDNAME+1];
-               register int n, ttype, tclass;
-
-               n = dn_expand(buf, eom, cp, tname, sizeof tname);
-               if (n < 0)
-                       return (-1);
-               cp += n;
-               if (cp + 2 * INT16SZ > eom)
-                       return (-1);
-               ttype = _getshort(cp); cp += INT16SZ;
-               tclass = _getshort(cp); cp += INT16SZ;
-               if (ttype == type &&
-                   tclass == class &&
-                   strcasecmp(tname, name) == 0)
-                       return (1);
-       }
-       return (0);
-}
-
-/* int
- * res_queriesmatch(buf1, eom1, buf2, eom2)
- *     is there a 1:1 mapping of (name,type,class)
- *     in (buf1,eom1) and (buf2,eom2)?
- * returns:
- *     -1 : format error
- *     0  : not a 1:1 mapping
- *     >0 : is a 1:1 mapping
- * author:
- *     paul vixie, 29may94
- */
-int
-res_queriesmatch(buf1, eom1, buf2, eom2)
-       const u_char *buf1, *eom1;
-       const u_char *buf2, *eom2;
-{
-       register const u_char *cp = buf1 + HFIXEDSZ;
-       int qdcount = ntohs( (u_short) ((HEADER*)buf1)->qdcount);
-
-       if (buf1 + HFIXEDSZ > eom1 || buf2 + HFIXEDSZ > eom2)
-               return (-1);
-
-       if (qdcount != ntohs( (u_short) ((HEADER*)buf2)->qdcount))
-               return (0);
-       while (qdcount-- > 0) {
-               char tname[MAXDNAME+1];
-               register int n, ttype, tclass;
-
-               n = dn_expand(buf1, eom1, cp, tname, sizeof tname);
-               if (n < 0)
-                       return (-1);
-               cp += n;
-               if (cp + 2 * INT16SZ > eom1)
-                       return (-1);
-               ttype = _getshort(cp);  cp += INT16SZ;
-               tclass = _getshort(cp); cp += INT16SZ;
-               if (!res_nameinquery(tname, ttype, tclass, buf2, eom2))
-                       return (0);
-       }
-       return (1);
-}
-
-int
-res_send(buf, buflen, ans, anssiz)
-       const u_char *buf;
-       int buflen;
-       u_char *ans;
-       int anssiz;
-{
-       HEADER *hp = (HEADER *) buf;
-       HEADER *anhp = (HEADER *) ans;
-       int gotsomewhere, connreset, terrno, try, v_circuit, resplen, ns;
-       register int n;
-       u_int badns;    /* XXX NSMAX can't exceed #/bits in this var */
-#ifdef WINNT
-       int optionValue = SO_SYNCHRONOUS_NONALERT;
-       DWORD BytesRead;
-#endif
-
-       if ((_res.options & RES_INIT) == 0 && res_init() == -1) {
-               /* errno should have been set by res_init() in this case. */
-               return (-1);
-       }
-       if (anssiz < HFIXEDSZ) {
-#ifndef WINNT
-        errno = EINVAL;
-#else
-       SetLastError(EINVAL);
-#endif
-               return (-1);
-       }
-       DprintQ((_res.options & RES_DEBUG) || (_res.pfcode & RES_PRF_QUERY),
-               (stdout, ";; res_send()\n"), buf, buflen);
-       v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ;
-       gotsomewhere = 0;
-       connreset = 0;
-       terrno = ETIMEDOUT;
-       badns = 0;
-
-       /*
-        * Send request, RETRY times, or until successful
-        */
-       for (try = 0; try < _res.retry; try++) {
-           for (ns = 0; ns < _res.nscount; ns++) {
-               struct sockaddr_in *nsap = &_res.nsaddr_list[ns];
-    same_ns:
-               if (badns & (1 << ns)) {
-                       res_close();
-                       goto next_ns;
-               }
-
-               if (Qhook) {
-                       int done = 0, loops = 0;
-
-                       do {
-                               res_sendhookact act;
-
-                               act = (*Qhook)(&nsap, &buf, &buflen,
-                                              ans, anssiz, &resplen);
-                               switch (act) {
-                               case res_goahead:
-                                       done = 1;
-                                       break;
-                               case res_nextns:
-                                       res_close();
-                                       goto next_ns;
-                               case res_done:
-                                       return (resplen);
-                               case res_modified:
-                                       /* give the hook another try */
-                                       if (++loops < 42) /*doug adams*/
-                                               break;
-                                       /*FALLTHROUGH*/
-                               case res_error:
-                                       /*FALLTHROUGH*/
-                               default:
-                                       return (-1);
-                               }
-                       } while (!done);
-               }
-
-               Dprint(_res.options & RES_DEBUG,
-                      (stdout, ";; Querying server (# %d) address = %s\n",
-                       ns + 1, inet_ntoa(nsap->sin_addr)));
-
-               if (v_circuit) {
-                       int truncated;
-                       struct iovec iov[2];
-                       u_short len;
-                       u_char *cp;
-#ifdef WINNT
-                       /* set up things so that subsequent socket()
-                          calls will open blocking sockets */
-                       if (setsockopt(INVALID_SOCKET, SOL_SOCKET,
-                                       SO_OPENTYPE, (char *)&optionValue,
-                                       sizeof(optionValue)) != NO_ERROR) {
-                                               Perror(stderr, "cannot open nonoverlapped socket", errno);
-                                               return (-1);
-                       }
-#endif
-                       /*
-                        * Use virtual circuit;
-                        * at most one attempt per server.
-                        */
-                       try = _res.retry;
-                       truncated = 0;
-                       if ((s < 0) || (!vc)) {
-                               if (s >= 0)
-                                       res_close();
-
-                               s = socket(PF_INET, SOCK_STREAM, 0);
-#ifndef WINNT
-                               if (s < 0) {
-#else
-                               if (s == INVALID_SOCKET) {
-#endif
-                                       terrno = errno;
-                                       Perror(stderr, "socket(vc)", errno);
-                                       return (-1);
-                               }
-#ifndef WINNT
-                               errno = 0;
-#else
-                               SetLastError(0);
-#endif
-                               if (connect(s, (struct sockaddr *)nsap,
-                                           sizeof(struct sockaddr)) < 0) {
-                                       terrno = errno;
-                                       Aerror(stderr, "connect/vc",
-                                              errno, *nsap);
-                                       badns |= (1 << ns);
-                                       res_close();
-                                       goto next_ns;
-                               }
-                               vc = 1;
-                       }
-                       /*
-                        * Send length & message
-                        */
-                       putshort((u_short)buflen, (u_char*)&len);
-                       iov[0].iov_base = (caddr_t)&len;
-                       iov[0].iov_len = INT16SZ;
-                       iov[1].iov_base = (caddr_t)buf;
-                       iov[1].iov_len = buflen;
-                       if (writev(s, iov, 2) != (INT16SZ + buflen)) {
-                               terrno = errno;
-                               Perror(stderr, "write failed", errno);
-                               badns |= (1 << ns);
-                               res_close();
-                               goto next_ns;
-                       }
-                       /*
-                        * Receive length & response
-                        */
-read_len:
-                       cp = ans;
-                       len = INT16SZ;
-#ifndef WINNT
-                       while ((n = read(s, (char *)cp, (int)len)) > 0) {
-#else
-                       while (ReadFile((HANDLE)s, (char *)cp, (DWORD)len,
-                                            &BytesRead, NULL) &&
-                                  (n = (int)BytesRead) > 0) {
-#endif
-                               cp += n;
-                               if ((len -= n) <= 0)
-                                       break;
-                       }
-                       if (n <= 0) {
-                               terrno = errno;
-                               Perror(stderr, "read failed", errno);
-                               res_close();
-                               /*
-                                * A long running process might get its TCP
-                                * connection reset if the remote server was
-                                * restarted.  Requery the server instead of
-                                * trying a new one.  When there is only one
-                                * server, this means that a query might work
-                                * instead of failing.  We only allow one reset
-                                * per query to prevent looping.
-                                */
-                               if (terrno == ECONNRESET && !connreset) {
-                                       connreset = 1;
-                                       res_close();
-                                       goto same_ns;
-                               }
-                               res_close();
-                               goto next_ns;
-                       }
-                       resplen = _getshort(ans);
-                       if (resplen > anssiz) {
-                               Dprint(_res.options & RES_DEBUG,
-                                      (stdout, ";; response truncated\n")
-                                      );
-                               truncated = 1;
-                               len = anssiz;
-                       } else
-                               len = resplen;
-                       if (len < HFIXEDSZ) {
-                               /*
-                                * Undersized message.
-                                */
-                               Dprint(_res.options & RES_DEBUG,
-                                      (stdout, ";; undersized: %d\n", len));
-#ifndef WINNT
-                               terrno = EMSGSIZE;
-#else
-                               terrno = WSAEMSGSIZE;
-#endif
-                               badns |= (1 << ns);
-                               res_close();
-                               goto next_ns;
-                       }
-                       cp = ans;
-                       while (len != 0 &&
-#ifndef WINNT
-                              (n = read(s, (char *)cp, (int)len)) > 0) {
-#else
-                                       ReadFile((HANDLE)s, (char *)cp, (DWORD)len,
-                                            &BytesRead, NULL) &&
-                                   (n = (int)BytesRead) > 0) {
-#endif
-                               cp += n;
-                               len -= n;
-                       }
-                       if (n <= 0) {
-                               terrno = errno;
-                               Perror(stderr, "read(vc)", errno);
-                               res_close();
-                               goto next_ns;
-                       }
-                       if (truncated) {
-                               /*
-                                * Flush rest of answer
-                                * so connection stays in synch.
-                                */
-                               anhp->tc = 1;
-                               len = resplen - anssiz;
-                               while (len != 0) {
-                                       char junk[PACKETSZ];
-
-                                       n = (len > sizeof(junk)
-                                            ? sizeof(junk)
-                                            : len);
-#ifndef WINNT
-                                       if ((n = read(s, junk, n)) > 0)
-#else
-                                       if (ReadFile((HANDLE)s, (char *)junk, (DWORD)n,
-                                            &BytesRead, NULL) &&
-                                       (n = (int)BytesRead) > 0)
-#endif
-                                               len -= n;
-                                       else
-                                               break;
-                               }
-                       }
-                       /*
-                        * The calling applicating has bailed out of
-                        * a previous call and failed to arrange to have
-                        * the circuit closed or the server has got
-                        * itself confused. Anyway drop the packet and
-                        * wait for the correct one.
-                        */
-                       if (hp->id != anhp->id) {
-                               DprintQ((_res.options & RES_DEBUG) ||
-                                       (_res.pfcode & RES_PRF_REPLY),
-                                       (stdout, ";; old answer (unexpected):\n"),
-                                       ans, (resplen>anssiz)?anssiz:resplen);
-                               goto read_len;
-                       }
-               } else {
-                       /*
-                        * Use datagrams.
-                        */
-                       struct timeval timeout;
-                       fd_set dsmask;
-                       struct sockaddr_in from;
-                       int fromlen;
-
-#ifndef WINNT
-                       if ((s < 0) || vc) {
-#else
-                       if ((s == INVALID_SOCKET) || vc) {
-#endif
-                               if (vc)
-                                       res_close();
-                               s = socket(PF_INET, SOCK_DGRAM, 0);
-#ifndef WINNT
-                               if (s < 0) {
-#else
-                               if (s == INVALID_SOCKET) {
-#endif
-#if !CAN_RECONNECT
- bad_dg_sock:
-#endif
-                                       terrno = errno;
-                                       Perror(stderr, "socket(dg)", errno);
-                                       return (-1);
-                               }
-                               connected = 0;
-                       }
-                       /*
-                        * On a 4.3BSD+ machine (client and server,
-                        * actually), sending to a nameserver datagram
-                        * port with no nameserver will cause an
-                        * ICMP port unreachable message to be returned.
-                        * If our datagram socket is "connected" to the
-                        * server, we get an ECONNREFUSED error on the next
-                        * socket operation, and select returns if the
-                        * error message is received.  We can thus detect
-                        * the absence of a nameserver without timing out.
-                        * If we have sent queries to at least two servers,
-                        * however, we don't want to remain connected,
-                        * as we wish to receive answers from the first
-                        * server to respond.
-                        */
-#ifndef WINNT
-                       if (_res.nscount == 1 || (try == 0 && ns == 0)) {
-                               /*
-                                * Connect only if we are sure we won't
-                                * receive a response from another server.
-                                */
-                               if (!connected) {
-                                       if (connect(s, (struct sockaddr *)nsap,
-                                                   sizeof(struct sockaddr)
-                                                   ) < 0) {
-                                               Aerror(stderr,
-                                                      "connect(dg)",
-                                                      errno, *nsap);
-                                               badns |= (1 << ns);
-                                               res_close();
-                                               goto next_ns;
-                                       }
-                                       connected = 1;
-                               }
-                               if (send(s, (char*)buf, buflen, 0) != buflen) {
-                                       Perror(stderr, "send", errno);
-                                       badns |= (1 << ns);
-                                       res_close();
-                                       goto next_ns;
-                               }
-                       } else {
-#endif /* WINNT */
-                               /*
-                                * Disconnect if we want to listen
-                                * for responses from more than one server.
-                                */
-                               if (connected) {
-#if CAN_RECONNECT
-                                       struct sockaddr_in no_addr;
-
-                                       no_addr.sin_family = AF_INET;
-                                       no_addr.sin_addr.s_addr = INADDR_ANY;
-                                       no_addr.sin_port = 0;
-                                       (void) connect(s,
-                                                      (struct sockaddr *)
-                                                       &no_addr,
-                                                      sizeof(no_addr));
-#else
-                                       int s1 = socket(PF_INET, SOCK_DGRAM,0);
-#ifndef WINNT
-                                       if (s1 < 0)
-#else
-                                       if (s1 == INVALID_SOCKET)
-#endif
-                                               goto bad_dg_sock;
-                                       (void) dup2(s1, s);
-                                       (void) close(s1);
-                                       Dprint(_res.options & RES_DEBUG,
-                                              (stdout, ";; new DG socket\n"))
-#endif
-                                       connected = 0;
-#ifndef WINNT
-                                       errno = 0;
-#else
-                                       SetLastError(0);
-#endif
-                               }
-                               if (sendto(s, (char*)buf, buflen, 0,
-                                          (struct sockaddr *)nsap,
-                                          sizeof(struct sockaddr))
-                                   != buflen) {
-                                       Aerror(stderr, "sendto", errno, *nsap);
-                                       badns |= (1 << ns);
-                                       res_close();
-                                       goto next_ns;
-                               }
-#ifndef WINNT
-                       }
-#endif
-
-                       /*
-                        * Wait for reply
-                        */
-                       timeout.tv_sec = (_res.retrans << try);
-                       if (try > 0)
-                               timeout.tv_sec /= _res.nscount;
-                       if ((long) timeout.tv_sec <= 0)
-                               timeout.tv_sec = 1;
-                       timeout.tv_usec = 0;
-    wait:
-                       if (s < 0 || s >= FD_SETSIZE) {
-                               Perror(stderr, "s out-of-bounds", EMFILE);
-                               res_close();
-                               goto next_ns;
-                       }
-                       FD_ZERO(&dsmask);
-                       FD_SET(s, &dsmask);
-                       n = select(s+1, &dsmask, (fd_set *)NULL,
-                                  (fd_set *)NULL, &timeout);
-                       if (n < 0) {
-#ifndef WINNT
-                               if (errno == EINTR)
-#else
-                               if (errno == WSAEINTR)
-#endif
-                                       goto wait;
-                               Perror(stderr, "select", errno);
-                               res_close();
-                               goto next_ns;
-                       }
-                       if (n == 0) {
-                               /*
-                                * timeout
-                                */
-                               Dprint(_res.options & RES_DEBUG,
-                                      (stdout, ";; timeout\n"));
-                               gotsomewhere = 1;
-                               res_close();
-                               goto next_ns;
-                       }
-#ifndef WINNT
-                       errno = 0;
-#else
-                       WSASetLastError(0);
-                       SetLastError(0);
-#endif
-                       fromlen = sizeof(struct sockaddr_in);
-                       resplen = recvfrom(s, (char*)ans, anssiz, 0,
-                                          (struct sockaddr *)&from, &fromlen);
-                       if (resplen <= 0) {
-#ifndef WINNT
-                               Perror(stderr, "recvfrom", errno);
-#else
-                               Perror(stderr, "recvfrom", WSAGetLastError());
-#endif
-                               res_close();
-                               goto next_ns;
-                       }
-                       gotsomewhere = 1;
-                       if (resplen < HFIXEDSZ) {
-                               /*
-                                * Undersized message.
-                                */
-                               Dprint(_res.options & RES_DEBUG,
-                                      (stdout, ";; undersized: %d\n",
-                                       resplen));
-#ifndef WINNT
-                               terrno = EMSGSIZE;
-#else
-                               terrno = WSAEMSGSIZE;
-#endif
-                               badns |= (1 << ns);
-                               res_close();
-                               goto next_ns;
-                       }
-                       if (hp->id != anhp->id) {
-                               /*
-                                * response from old query, ignore it.
-                                * XXX - potential security hazard could
-                                *       be detected here.
-                                */
-                               DprintQ((_res.options & RES_DEBUG) ||
-                                       (_res.pfcode & RES_PRF_REPLY),
-                                       (stdout, ";; old answer:\n"),
-                                       ans, (resplen>anssiz)?anssiz:resplen);
-                               goto wait;
-                       }
-#if CHECK_SRVR_ADDR
-                       if (!(_res.options & RES_INSECURE1) &&
-                           !res_isourserver(&from)) {
-                               /*
-                                * response from wrong server? ignore it.
-                                * XXX - potential security hazard could
-                                *       be detected here.
-                                */
-                               DprintQ((_res.options & RES_DEBUG) ||
-                                       (_res.pfcode & RES_PRF_REPLY),
-                                       (stdout, ";; not our server:\n"),
-                                       ans, (resplen>anssiz)?anssiz:resplen);
-                               goto wait;
-                       }
-#endif
-                       if (!(_res.options & RES_INSECURE2) &&
-                           !res_queriesmatch(buf, buf + buflen,
-                                             ans, ans + anssiz)) {
-                               /*
-                                * response contains wrong query? ignore it.
-                                * XXX - potential security hazard could
-                                *       be detected here.
-                                */
-                               DprintQ((_res.options & RES_DEBUG) ||
-                                       (_res.pfcode & RES_PRF_REPLY),
-                                       (stdout, ";; wrong query name:\n"),
-                                       ans, (resplen>anssiz)?anssiz:resplen);
-                               goto wait;
-                       }
-                       if (anhp->rcode == SERVFAIL ||
-                           anhp->rcode == NOTIMP ||
-                           anhp->rcode == REFUSED) {
-                               DprintQ(_res.options & RES_DEBUG,
-                                       (stdout, "server rejected query:\n"),
-                                       ans, (resplen>anssiz)?anssiz:resplen);
-                               badns |= (1 << ns);
-                               res_close();
-                               /* don't retry if called from dig */
-                               if (!_res.pfcode)
-                                       goto next_ns;
-                       }
-                       if (!(_res.options & RES_IGNTC) && anhp->tc) {
-                               /*
-                                * get rest of answer;
-                                * use TCP with same server.
-                                */
-                               Dprint(_res.options & RES_DEBUG,
-                                      (stdout, ";; truncated answer\n"));
-                               v_circuit = 1;
-                               res_close();
-                               goto same_ns;
-                       }
-               } /*if vc/dg*/
-               Dprint((_res.options & RES_DEBUG) ||
-                      ((_res.pfcode & RES_PRF_REPLY) &&
-                       (_res.pfcode & RES_PRF_HEAD1)),
-                      (stdout, ";; got answer:\n"));
-               DprintQ((_res.options & RES_DEBUG) ||
-                       (_res.pfcode & RES_PRF_REPLY),
-                       (stdout, ""),
-                       ans, (resplen>anssiz)?anssiz:resplen);
-               /*
-                * If using virtual circuits, we assume that the first server
-                * is preferred over the rest (i.e. it is on the local
-                * machine) and only keep that one open.
-                * If we have temporarily opened a virtual circuit,
-                * or if we haven't been asked to keep a socket open,
-                * close the socket.
-                */
-               if ((v_circuit && (!(_res.options & RES_USEVC) || ns != 0)) ||
-                   !(_res.options & RES_STAYOPEN)) {
-                       res_close();
-               }
-               if (Rhook) {
-                       int done = 0, loops = 0;
-
-                       do {
-                               res_sendhookact act;
-
-                               act = (*Rhook)(nsap, buf, buflen,
-                                              ans, anssiz, &resplen);
-                               switch (act) {
-                               case res_goahead:
-                               case res_done:
-                                       done = 1;
-                                       break;
-                               case res_nextns:
-                                       res_close();
-                                       goto next_ns;
-                               case res_modified:
-                                       /* give the hook another try */
-                                       if (++loops < 42) /*doug adams*/
-                                               break;
-                                       /*FALLTHROUGH*/
-                               case res_error:
-                                       /*FALLTHROUGH*/
-                               default:
-                                       return (-1);
-                               }
-                       } while (!done);
-
-               }
-               return (resplen);
-    next_ns: ;
-          } /*foreach ns*/
-       } /*foreach retry*/
-       res_close();
-       if (!v_circuit)
-               if (!gotsomewhere) {
-#ifndef WINNT
-                       errno = ECONNREFUSED;   /* no nameservers found */
-#else
-                       WSASetLastError(ECONNREFUSED);
-                       SetLastError(ECONNREFUSED);
-#endif
-               } else {
-#ifndef WINNT
-                       errno = ETIMEDOUT;      /* no answer obtained */
-#else
-                       WSASetLastError(ETIMEDOUT);
-                       SetLastError(ETIMEDOUT);
-#endif
-               } else {
-#ifndef WINNT
-               errno = terrno;
-#else
-               WSASetLastError(terrno);
-               SetLastError(terrno);
-#endif
-       return (-1);
- }
-}
-
-/*
- * This routine is for closing the socket if a virtual circuit is used and
- * the program wants to close it.  This provides support for endhostent()
- * which expects to close the socket.
- *
- * This routine is not expected to be user visible.
- */
-void
-res_close()
-{
-       if (s >= 0) {
-#ifndef WINNT
-               (void) close(s);
-#else
-    (void) closesocket(s);
-#endif
-
-#ifndef WINNT
-               s = -1;
-#else
-               s = INVALID_SOCKET;
-#endif
-               connected = 0;
-               vc = 0;
-       }
-}
-
-#ifdef ultrix
-/* ultrix 4.0 had some icky packaging in its libc.a.  alias for it here.
- * there is more gunk of this kind over in res_debug.c.
- */
-
-void
-_res_close()
-{
-       res_close();
-}
-
-#undef res_send
-int
-res_send(buf, buflen, ans, anssiz)
-       const u_char *buf;
-       int buflen;
-       u_char *ans;
-       int anssiz;
-{
-       return (__res_send(buf, buflen, ans, anssiz));
-}
-#endif /* Ultrix 4.0 hackery */
diff --git a/bindlib_w32/resolv.h b/bindlib_w32/resolv.h
deleted file mode 100644 (file)
index 8e2e61d..0000000
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
- * ++Copyright++ 1983, 1987, 1989, 1993
- * -
- * Copyright (c) 1983, 1987, 1989, 1993
- *    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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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.
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- * 
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-/*
- *     @(#)resolv.h    8.1 (Berkeley) 6/2/93
- *     $Id$
- */
-
-#ifndef _RESOLV_H_
-#define        _RESOLV_H_
-
-#ifndef WINNT
-#include <sys/param.h>
-#endif
-#if (!defined(BSD)) || (BSD < 199306)
-#include <sys/bitypes.h>
-#else
-#include <sys/types.h>
-#endif
-#include <sys/cdefs.h>
-#include <stdio.h>
-#ifdef WINNT
-#define FD_SETSIZE 512
-#include <winsock.h>
-#include "conf\portability.h"
-#endif
-
-/*
- * Revision information.  This is the release date in YYYYMMDD format.
- * It can change every day so the right thing to do with it is use it
- * in preprocessor commands such as "#if (__RES > 19931104)".  Do not
- * compare for equality; rather, use it to determine whether your resolver
- * is new enough to contain a certain feature.
- */
-
-#define        __RES   19960801
-
-/*
- * Resolver configuration file.
- * Normally not present, but may contain the address of the
- * inital name server(s) to query and the domain search list.
- */
-
-#ifndef _PATH_RESCONF
-#ifndef WINNT
-#define _PATH_RESCONF        "/etc/resolv.conf"
-#else
-#define _PATH_RESCONF           "%windir%\\RESOLV.CONF"
-#define _ALT_PATH_RESCONF       "%windir%\\RESOLV.INI"
-#endif /* WINNT */
-#endif
-
-/*
- * Global defines and variables for resolver stub.
- */
-#define        MAXNS                   3       /* max # name servers we'll track */
-#define        MAXDFLSRCH              3       /* # default domain levels to try */
-#define        MAXDNSRCH               6       /* max # domains in search path */
-#define        LOCALDOMAINPARTS        2       /* min levels in name that is "local" */
-
-#define        RES_TIMEOUT             5       /* min. seconds between retries */
-#define        MAXRESOLVSORT           10      /* number of net to sort on */
-#define        RES_MAXNDOTS            15      /* should reflect bit field size */
-
-struct __res_state {
-       int     retrans;                /* retransmition time interval */
-       int     retry;                  /* number of times to retransmit */
-       u_long  options;                /* option flags - see below. */
-       int     nscount;                /* number of name servers */
-       struct sockaddr_in
-               nsaddr_list[MAXNS];     /* address of name server */
-#define        nsaddr  nsaddr_list[0]          /* for backward compatibility */
-       u_short id;                     /* current message id */
-       char    *dnsrch[MAXDNSRCH+1];   /* components of domain to search */
-       char    defdname[256];          /* default domain (deprecated) */
-       u_long  pfcode;                 /* RES_PRF_ flags - see below. */
-       unsigned ndots:4;               /* threshold for initial abs. query */
-       unsigned nsort:4;               /* number of elements in sort_list[] */
-       char    unused[3];
-       struct {
-               struct in_addr  addr;
-               u_int32_t       mask;
-       } sort_list[MAXRESOLVSORT];
-       char    pad[72];                /* on an i386 this means 512b total */
-};
-
-/*
- * Resolver options (keep these in synch with res_debug.c, please)
- */
-#define RES_INIT       0x00000001      /* address initialized */
-#define RES_DEBUG      0x00000002      /* print debug messages */
-#define RES_AAONLY     0x00000004      /* authoritative answers only (!IMPL)*/
-#define RES_USEVC      0x00000008      /* use virtual circuit */
-#define RES_PRIMARY    0x00000010      /* query primary server only (!IMPL) */
-#define RES_IGNTC      0x00000020      /* ignore trucation errors */
-#define RES_RECURSE    0x00000040      /* recursion desired */
-#define RES_DEFNAMES   0x00000080      /* use default domain name */
-#define RES_STAYOPEN   0x00000100      /* Keep TCP socket open */
-#define RES_DNSRCH     0x00000200      /* search up local domain tree */
-#define        RES_INSECURE1   0x00000400      /* type 1 security disabled */
-#define        RES_INSECURE2   0x00000800      /* type 2 security disabled */
-#define        RES_NOALIASES   0x00001000      /* shuts off HOSTALIASES feature */
-#define        RES_USE_INET6   0x00002000      /* use/map IPv6 in gethostbyname() */
-
-#define RES_DEFAULT    (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
-
-/*
- * Resolver "pfcode" values.  Used by dig.
- */
-#define RES_PRF_STATS  0x00000001
-/*                     0x00000002      */
-#define RES_PRF_CLASS   0x00000004
-#define RES_PRF_CMD    0x00000008
-#define RES_PRF_QUES   0x00000010
-#define RES_PRF_ANS    0x00000020
-#define RES_PRF_AUTH   0x00000040
-#define RES_PRF_ADD    0x00000080
-#define RES_PRF_HEAD1  0x00000100
-#define RES_PRF_HEAD2  0x00000200
-#define RES_PRF_TTLID  0x00000400
-#define RES_PRF_HEADX  0x00000800
-#define RES_PRF_QUERY  0x00001000
-#define RES_PRF_REPLY  0x00002000
-#define RES_PRF_INIT    0x00004000
-/*                     0x00008000      */
-
-/* hooks are still experimental as of 4.9.2 */
-typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
-       res_sendhookact;
-
-typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr_in * const *ns,
-                                             const u_char **query,
-                                             int *querylen,
-                                             u_char *ans,
-                                             int anssiz,
-                                             int *resplen));
-
-typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr_in *ns,
-                                             const u_char *query,
-                                             int querylen,
-                                             u_char *ans,
-                                             int anssiz,
-                                             int *resplen));
-
-struct res_sym {
-       int     number;         /* Identifying number, like T_MX */
-       char *  name;           /* Its symbolic name, like "MX" */
-       char *  humanname;      /* Its fun name, like "mail exchanger" */
-};
-
-extern struct __res_state _res;
-extern const struct res_sym __p_class_syms[];
-extern const struct res_sym __p_type_syms[];
-
-/* Private routines shared between libc/net, named, nslookup and others. */
-#define        res_hnok        __res_hnok
-#define        res_ownok       __res_ownok
-#define        res_mailok      __res_mailok
-#define        res_dnok        __res_dnok
-#define        sym_ston        __sym_ston
-#define        sym_ntos        __sym_ntos
-#define        sym_ntop        __sym_ntop
-#define b64_ntop       __b64_ntop
-#define        b64_pton        __b64_pton
-#define        loc_ntoa        __loc_ntoa
-#define        loc_aton        __loc_aton
-#define        dn_skipname     __dn_skipname
-#define        fp_resstat      __fp_resstat
-#define        fp_query        __fp_query
-#define        fp_nquery       __fp_nquery
-#define        hostalias       __hostalias
-#define        putlong         __putlong
-#define        putshort        __putshort
-#define p_class                __p_class
-#define p_time         __p_time
-#define p_type         __p_type
-#define        p_query         __p_query
-#define        p_cdnname       __p_cdnname
-#define        p_cdname        __p_cdname
-#define        p_fqnname       __p_fqnname
-#define        p_fqname        __p_fqname
-#define        p_rr            __p_rr
-#define        p_option        __p_option
-#define        p_secstodate    __p_secstodate
-#define        dn_count_labels __dn_count_labels
-#define        dn_comp         __dn_comp
-#define        res_randomid    __res_randomid
-#define        res_isourserver __res_isourserver
-#define        res_nameinquery __res_nameinquery
-#define        res_queriesmatch __res_queriesmatch
-#define        res_close       __res_close
-
-#ifdef BIND_RES_POSIX3
-#define        dn_expand       __dn_expand
-#define        res_init        __res_init
-#define        res_query       __res_query
-#define        res_search      __res_search
-#define        res_querydomain __res_querydomain
-#define        res_mkquery     __res_mkquery
-#define        res_send        __res_send
-#endif
-
-__BEGIN_DECLS
-int            res_hnok __P((const char *));
-int            res_ownok __P((const char *));
-int            res_mailok __P((const char *));
-int            res_dnok __P((const char *));
-int            sym_ston __P((const struct res_sym *, char *, int *));
-const char *   sym_ntos __P((const struct res_sym *, int, int *));
-const char *   sym_ntop __P((const struct res_sym *, int, int *));
-int            b64_ntop __P((u_char const *, size_t, char *, size_t));
-int            b64_pton __P((char const *, u_char *, size_t));
-int            loc_aton __P((const char *, u_char *));
-const char *   loc_ntoa __P((const u_char *, char *));
-int            dn_skipname __P((const u_char *, const u_char *));
-void           fp_resstat __P((struct __res_state *, FILE *));
-void           fp_query __P((const u_char *, FILE *));
-void           fp_nquery __P((const u_char *, int, FILE *));
-const char *   hostalias __P((const char *));
-void           putlong __P((u_int32_t, u_char *));
-void           putshort __P((u_int16_t, u_char *));
-const char *   p_class __P((int));
-const char *   p_time __P((u_int32_t));
-const char *   p_type __P((int));
-void           p_query __P((const u_char *));
-const u_char * p_cdnname __P((const u_char *, const u_char *, int, FILE *));
-const u_char * p_cdname __P((const u_char *, const u_char *, FILE *));
-const u_char * p_fqnname __P((const u_char *cp, const u_char *msg,
-                              int, char *, int));
-const u_char * p_fqname __P((const u_char *, const u_char *, FILE *));
-const u_char * p_rr __P((const u_char *, const u_char *, FILE *));
-const char *   p_option __P((u_long option));
-char *         p_secstodate __P((u_long));
-int            dn_count_labels __P((char *));
-int            dn_comp __P((const char *, u_char *, int,
-                            u_char **, u_char **));
-int            dn_expand __P((const u_char *, const u_char *, const u_char *,
-                              char *, int));
-int            res_init __P((void));
-u_int          res_randomid __P((void));
-int            res_query __P((const char *, int, int, u_char *, int));
-int            res_search __P((const char *, int, int, u_char *, int));
-int            res_querydomain __P((const char *, const char *, int, int,
-                                    u_char *, int));
-int            res_mkquery __P((int, const char *, int, int, const u_char *, int,
-                                const u_char *, u_char *, int));
-int            res_send __P((const u_char *, int, u_char *, int));
-int            res_isourserver __P((const struct sockaddr_in *));
-int            res_nameinquery __P((const char *, int, int,
-                                    const u_char *, const u_char *));
-int            res_queriesmatch __P((const u_char *, const u_char *,
-                                     const u_char *, const u_char *));
-void           res_close __P((void));
-__END_DECLS
-
-#endif /* !_RESOLV_H_ */
diff --git a/bindlib_w32/sethostent.c b/bindlib_w32/sethostent.c
deleted file mode 100644 (file)
index 79f9c6a..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (c) 1985, 1993
- *     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:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. All advertising materials mentioning features or use of this software
- *    must display the following acknowledgement:
- *     This product includes software developed by the University of
- *     California, Berkeley and its contributors.
- * 4. Neither the name of the University 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 REGENTS 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(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)sethostent.c       8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id$";
-#endif /* LIBC_SCCS and not lint */
-
-#include <sys/types.h>
-#ifndef WINNT
-#include <sys/param.h>
-#include <netinet/in.h>
-#endif
-#include <arpa/nameser.h>
-#include <netdb.h>
-#include <resolv.h>
-
-void
-sethostent(stayopen)
-       int stayopen;
-{
-       if ((_res.options & RES_INIT) == 0 && res_init() == -1)
-               return;
-       if (stayopen)
-               _res.options |= RES_STAYOPEN | RES_USEVC;
-}
-
-void
-endhostent()
-{
-       _res.options &= ~(RES_STAYOPEN | RES_USEVC);
-       res_close();
-}