]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Purge last remnants of inet_ntoa
authorAmos Jeffries <squid3@treenet.co.nz>
Wed, 1 Apr 2009 11:49:17 +0000 (00:49 +1300)
committerAmos Jeffries <squid3@treenet.co.nz>
Wed, 1 Apr 2009 11:49:17 +0000 (00:49 +1300)
 - Now fully replaced by IPAddress::NtoA and inet_ntop()
 - No need for the third-party emulator and license either

CREDITS
configure.in
lib/inet_ntoa.c [deleted file]
lib/rfc1035.c
lib/rfc3596.c
src/recv-announce.cc
test-suite/tcp-banger3.c

diff --git a/CREDITS b/CREDITS
index ede83e1061292d18f0cd3985bc86c5142ff1483e..0aac231c3a81a9bb9f18cf7b548b9e30818899c4 100644 (file)
--- a/CREDITS
+++ b/CREDITS
@@ -242,41 +242,6 @@ http://www.io.com/~paulhart/game/algorithms/tea.html
 
 ==============================================================================
 
-lib/inet_ntoa.c:
-
-/*
- * 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. 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.
- */
-
-static char sccsid[] = "@(#)inet_ntoa.c        5.6 (Berkeley) 2/24/91";
-
-==============================================================================
-
 lib/strnstr.cc:
 
 /*-
index e45aee1e81d21ac9230cfd494817b37b552728e9..4773637a9538daf50e64b922c0db391e65db311c 100644 (file)
@@ -3580,45 +3580,6 @@ AC_TRY_LINK(extern int _dns_ttl_;,return _dns_ttl_;,
 AC_DEFINE(LIBRESOLV_DNS_TTL_HACK,1,[If libresolv.a has been hacked to export _dns_ttl_])],
 AC_MSG_RESULT(no))
 
-AC_MSG_CHECKING(if inet_ntoa() actually works)
-AC_TRY_RUN([
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-main ()
-{
-       FILE *fp;
-       struct in_addr in;
-       in.s_addr = inet_addr("1.2.3.4");
-       fp = fopen("conftestval", "w"); 
-       fprintf (fp, "%s\n", inet_ntoa(in));
-       exit(0);
-}
-],
-INET_NTOA_RESULT=`cat conftestval`,
-INET_NTOA_RESULT="broken",
-INET_NTOA_RESULT="broken")
-if test "$INET_NTOA_RESULT" = "1.2.3.4" ; then
-       AC_MSG_RESULT("yes")
-else
-       AC_MSG_RESULT("no")
-       case "$host_os" in
-       mingw|mingw32)
-         AC_MSG_NOTICE([Using Win32 resolver instead.])
-         ;;
-       *)
-         AC_MSG_NOTICE([Will use our own inet_ntoa().])
-         AC_LIBOBJ(inet_ntoa)
-#        AC_MSG_WARN([This looks bad, and probably prevents Squid from working.])
-#        AC_MSG_WARN([If you're on IRIX and using GCC 2.8, you probably need])
-#        AC_MSG_WARN([to use the IRIX C compiler instead.])
-#        sleep 10
-         ;;
-       esac
-fi
-
 if test "$ac_cv_header_sys_statvfs_h" = "yes" ; then
 AC_MSG_CHECKING(for working statvfs() interface)
 AC_TRY_COMPILE([
diff --git a/lib/inet_ntoa.c b/lib/inet_ntoa.c
deleted file mode 100644 (file)
index 62131ac..0000000
+++ /dev/null
@@ -1,54 +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. 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[] = "@(#)inet_ntoa.c        5.6 (Berkeley) 2/24/91";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * Convert network-format internet address
- * to base 256 d.d.d.d representation.
- */
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <stdio.h>
-
-char *
-inet_ntoa(struct in_addr in)
-{
-    static char b[18];
-    register char *p;
-
-    p = (char *) &in;
-#define        UC(b)   (((int)b)&0xff)
-    (void) snprintf(b, sizeof(b),
-                    "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
-    return (b);
-}
index 626b8faf10558e5f77573ca5b917d62ccb107a48..2fb034e16455e960013910006e5265d4cdf20c4f 100644 (file)
@@ -810,8 +810,9 @@ main(int argc, char *argv[])
                 for (i = 0; i < n; i++) {
                     if (answers[i].type == RFC1035_TYPE_A) {
                         struct in_addr a;
+                        char ipa_str[sizeof(a)];
                         memcpy(&a, answers[i].rdata, 4);
-                        printf("A\t%d\t%s\n", answers[i].ttl, inet_ntoa(a));
+                        printf("A\t%d\t%s\n", answers[i].ttl, inet_ntop(AF_INET,&a,tmp,sizeof(a)));
                     } else if (answers[i].type == RFC1035_TYPE_PTR) {
                         char ptr[128];
                         strncpy(ptr, answers[i].rdata, answers[i].rdlength);
index c80065222ceb1dbbce3e78888200f1e9437d71e7..24ca56360325275ebf2285237e2c95255148e05e 100644 (file)
@@ -347,13 +347,15 @@ while (fgets(input, 512, stdin))
                 if (answers[i].type == RFC1035_TYPE_A) {
 
                     struct in_addr a;
+                    char tmp[16];
                     memcpy(&a, answers[i].rdata, 4);
-                    printf("A\t%d\t%s\n", answers[i].ttl, inet_ntoa(a));
+                    printf("A\t%d\t%s\n", answers[i].ttl, inet_ntop(AF_INET,&a,tmp,16));
                 } else if (answers[i].type == RFC1035_TYPE_AAAA) {
 
                     struct in6_addr a;
+                    char tmp[INET6_ADDRSTRLEN];
                     memcpy(&a, answers[i].rdata, 16);
-                    printf("AAAA\t%d\t%s\n", answers[i].ttl, inet_ntoa(a));
+                    printf("AAAA\t%d\t%s\n", answers[i].ttl, inet_ntop(AF_INET6,&a,tmp,sizeof(tmp)));
                 } else if (answers[i].type == RFC1035_TYPE_PTR) {
                     char ptr[RFC1035_MAXHOSTNAMESZ];
                     strncpy(ptr, answers[i].rdata, answers[i].rdlength);
index f1019c69c500ead4d10510940faddece0801fcf4..29819b4ef083b9077fee4f2c126f72b14edac468 100644 (file)
@@ -114,6 +114,8 @@ main(int argc, char *argv[])
     dup(1);
 
 
+    IPAddress ipa;
+    chat tmp[MAX_HOSTNAMELEN];
     for (;;) {
         memset(buf, '\0', RECV_BUF_SIZE);
         memset(&R, '\0', len = sizeof(R));
@@ -125,9 +127,10 @@ main(int argc, char *argv[])
 
         xmemcpy(ip, &R.sin_addr.s_addr, 4);
         hp = gethostbyaddr(ip, 4, AF_INET);
+        ipa = R.sin_addr;
         printf("==============================================================================\n");
         printf("Received from %s [%s]\n",
-               inet_ntoa(R.sin_addr),
+               ipa.NtoA(tmp,MAX_HOSTNAMELEN),
                (hp && hp->h_name) ? hp->h_name : "Unknown");
         fputs(buf, stdout);
         fflush(stdout);
index 72b8d8fd5508f8960df5af950873c9d177e105e6..d3ac5b21a2687437b0b83016b2e0f537e8544cbe 100644 (file)
@@ -149,8 +149,10 @@ get_url(const char *url)
     memcpy(&S.sin_addr.s_addr, h->h_addr_list[0], sizeof(S.sin_addr.s_addr));
     S.sin_port = htons(port);
     S.sin_family = AF_INET;
-    if (debug)
-        fprintf(stderr, "%s (%s) %d %s\n", host, inet_ntoa(S.sin_addr), (int) port, path);
+    if (debug) {
+        char tmp[16];
+        fprintf(stderr, "%s (%s) %d %s\n", host, inet_ntop(AF_INET, &S.sin_addr,tmp,sizeof(tmp)), (int) port, path);
+    }
     s = socket(PF_INET, SOCK_STREAM, 0);
     if (s < 0) {
         perror("socket");