aboutsummaryrefslogtreecommitdiff
path: root/resolv
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2001-08-14 23:29:55 +0000
committerUlrich Drepper <drepper@redhat.com>2001-08-14 23:29:55 +0000
commit5db915715f800d0858346bfbb5eea6aff4287ebd (patch)
tree3e80f9b69ab93f869da0c78cc63eb4ebf5149230 /resolv
parentecad39f050c89d63673101ae0d6b54fb2dfbed1b (diff)
downloadglibc-5db915715f800d0858346bfbb5eea6aff4287ebd.zip
glibc-5db915715f800d0858346bfbb5eea6aff4287ebd.tar.gz
glibc-5db915715f800d0858346bfbb5eea6aff4287ebd.tar.bz2
Update.
2001-08-14 Jakub Jelinek <jakub@redhat.com> * resolv/nss_dns/dns-host.c (RESOLVSORT): Define. (addrsort): New function. * resolv/gethnamaddr.c (RESOLVSORT): Define. 2001-08-14 Jakub Jelinek <jakub@redhat.com> * string/strsignal.c (free_mem): Remove. 2001-08-14 Andreas Jaeger <aj@suse.de> * inet/inet_ntoa.c (free_mem): Remove, it's not used anymore. Closes PR libc/2477, reported by Dylan Alex Simon <dylan@dylex.caltech.edu>. 2001-08-14 Ulrich Drepper <drepper@redhat.com> * locale/Makefile (aux): Add xlocale. * locale/xlocale.c: New file. * include/locale.c (_nl_C_locobj): Declare. * iconv/gconv_charset.h: Use __tolower_l, __isdigit_l, __isspace_l with _nl_C_locobj instead of tolower, isdigit, isspace. * iconv/gconv_conf.c: Likewise. * iconv/gconv_int.h: Likewise. * iconv/gconv_open.c: Likewise. * locale/newlocale.c: Minor cleanups.
Diffstat (limited to 'resolv')
-rw-r--r--resolv/gethnamaddr.c2
-rw-r--r--resolv/nss_dns/dns-host.c49
2 files changed, 50 insertions, 1 deletions
diff --git a/resolv/gethnamaddr.c b/resolv/gethnamaddr.c
index c0e2f70..25ae119 100644
--- a/resolv/gethnamaddr.c
+++ b/resolv/gethnamaddr.c
@@ -68,6 +68,8 @@ static char rcsid[] = "$Id$";
#include <errno.h>
#include <syslog.h>
+#define RESOLVSORT
+
#ifndef LOG_AUTH
# define LOG_AUTH 0
#endif
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index 54645f1..2102f63 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1996-2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Extended from original form by Ulrich Drepper <drepper@cygnus.com>, 1996.
@@ -86,6 +86,8 @@
#include <resolv/mapv4v6addr.h>
#include <resolv/mapv4v6hostent.h>
+#define RESOLVSORT
+
/* Maximum number of aliases we allow. */
#define MAX_NR_ALIASES 48
#define MAX_NR_ADDRS 48
@@ -330,6 +332,51 @@ _nss_dns_gethostbyaddr_r (const void *addr, socklen_t len, int af,
return NSS_STATUS_SUCCESS;
}
+#ifdef RESOLVSORT
+static void addrsort (char **ap, int num);
+
+static void
+addrsort (char **ap, int num)
+{
+ int i, j;
+ char **p;
+ short aval[MAX_NR_ADDRS];
+ int needsort = 0;
+
+ p = ap;
+ if (num > MAX_NR_ADDRS)
+ num = MAX_NR_ADDRS;
+ 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 - 2; 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;
+}
+#endif
static enum nss_status
getanswer_r (const querybuf *answer, int anslen, const char *qname, int qtype,