BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.sbin / named / tools / nslookup / list.c
index fe25ebe..eced63a 100644 (file)
@@ -2,23 +2,37 @@
  * Copyright (c) 1985,1989 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1985,1989 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted provided
- * that: (1) source distributions retain this entire copyright notice and
- * comment, and (2) distributions including binaries display the following
- * acknowledgement:  ``This product includes software developed by the
- * University of California, Berkeley and its contributors'' in the
- * documentation or other materials provided with the distribution and in
- * all advertising materials mentioning features or use of this software.
- * 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * 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.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)list.c     5.20 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)list.c     5.23 (Berkeley) 3/21/91";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -33,17 +47,17 @@ static char sccsid[] = "@(#)list.c  5.20 (Berkeley) 6/1/90";
  *******************************************************************************
  */
 
  *******************************************************************************
  */
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <arpa/inet.h>
+#include <resolv.h>
 #include <netdb.h>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
 #include <netdb.h>
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
-#include <arpa/nameser.h>
-#include <arpa/inet.h>
-#include <resolv.h>
 #include "res.h"
 
 /*
 #include "res.h"
 
 /*
@@ -222,7 +236,7 @@ ListSubr(qtype, domain, cmd)
         *  Create a query packet for the requested domain name.
         */
        msglen = res_mkquery(QUERY, domain, queryClass, T_AXFR,
         *  Create a query packet for the requested domain name.
         */
        msglen = res_mkquery(QUERY, domain, queryClass, T_AXFR,
-                               (char *)0, 0, (char *)0,
+                               (char *)0, 0, 0,
                                (char *) &buf, sizeof(buf));
        if (msglen < 0) {
            if (_res.options & RES_DEBUG) {
                                (char *) &buf, sizeof(buf));
        if (msglen < 0) {
            if (_res.options & RES_DEBUG) {
@@ -255,7 +269,7 @@ ListSubr(qtype, domain, cmd)
            perror("ls: socket");
            return(ERROR);
        }
            perror("ls: socket");
            return(ERROR);
        }
-       if (connect(sockFD, &sin, sizeof(sin)) < 0) {
+       if (connect(sockFD, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
            int e;
            if (errno == ECONNREFUSED) {
                e = NO_RESPONSE;
            int e;
            if (errno == ECONNREFUSED) {
                e = NO_RESPONSE;
@@ -429,11 +443,13 @@ ListSubr(qtype, domain, cmd)
            }
            cp = answer + sizeof(HEADER);
            if (ntohs(((HEADER* )answer)->qdcount) > 0)
            }
            cp = answer + sizeof(HEADER);
            if (ntohs(((HEADER* )answer)->qdcount) > 0)
-               cp += dn_skipname(cp, answer + len) + QFIXEDSZ;
+               cp += dn_skipname((u_char *)cp,
+                   (u_char *)answer + len) + QFIXEDSZ;
            nmp = cp;
            nmp = cp;
-           cp += dn_skipname(cp, (u_char *)answer + len);
+           cp += dn_skipname((u_char *)cp, (u_char *)answer + len);
            if ((_getshort(cp) == T_SOA)) {
            if ((_getshort(cp) == T_SOA)) {
-               dn_expand(answer, answer + len, nmp, dname[soacnt],
+               dn_expand((u_char *)answer, (u_char *)answer + len,
+                   (u_char *)nmp, (u_char *)dname[soacnt],
                        sizeof(dname[0]));
                if (soacnt) {
                    if (strcmp(dname[0], dname[1]) == 0)
                        sizeof(dname[0]));
                if (soacnt) {
                    if (strcmp(dname[0], dname[1]) == 0)
@@ -523,11 +539,11 @@ strip_domain(string, domain)
 
 PrintListInfo(file, msg, eom, qtype, domain)
     FILE       *file;
 
 PrintListInfo(file, msg, eom, qtype, domain)
     FILE       *file;
-    char       *msg, *eom;
+    u_char     *msg, *eom;
     int                qtype;
     char       *domain;
 {
     int                qtype;
     char       *domain;
 {
-    register char      *cp;
+    register u_char    *cp;
     HEADER             *headerPtr;
     int                        type, class, dlen, nameLen;
     u_long             ttl;
     HEADER             *headerPtr;
     int                        type, class, dlen, nameLen;
     u_long             ttl;
@@ -561,7 +577,8 @@ PrintListInfo(file, msg, eom, qtype, domain)
                return (ERROR);
            cp += nameLen + QFIXEDSZ;
        }
                return (ERROR);
            cp += nameLen + QFIXEDSZ;
        }
-       if ((nameLen = dn_expand(msg, eom, cp, name, sizeof(name))) < 0)
+       if ((nameLen =
+           dn_expand(msg, eom, cp, (u_char *)name, sizeof(name))) < 0)
            return (ERROR);
        cp += nameLen;
 
            return (ERROR);
        cp += nameLen;
 
@@ -622,8 +639,8 @@ PrintListInfo(file, msg, eom, qtype, domain)
            case T_MB:
            case T_MG:
            case T_MR:
            case T_MB:
            case T_MG:
            case T_MR:
-               if ((nameLen =
-                       dn_expand(msg, eom, cp, name2, sizeof(name2))) < 0) {
+               if ((nameLen = dn_expand(msg, eom,
+                   cp, (u_char *)name2, sizeof(name2))) < 0) {
                    fprintf(file, " ***\n");
                    return (ERROR);
                }
                    fprintf(file, " ***\n");
                    return (ERROR);
                }
@@ -635,7 +652,7 @@ PrintListInfo(file, msg, eom, qtype, domain)
                putc(' ', file);
                if (qtype != T_ANY)
                    fprintf(file,"%s = ", type == T_PTR ? "host" : "server");
                putc(' ', file);
                if (qtype != T_ANY)
                    fprintf(file,"%s = ", type == T_PTR ? "host" : "server");
-               cp = Print_cdname2(cp, msg, eom, file);
+               cp = (u_char *)Print_cdname2(cp, msg, eom, file);
                break;
 
            case T_HINFO:
                break;
 
            case T_HINFO:
@@ -653,15 +670,15 @@ PrintListInfo(file, msg, eom, qtype, domain)
                break;
 
            case T_SOA:
                break;
 
            case T_SOA:
-               if ((nameLen =
-                       dn_expand(msg, eom, cp, name2, sizeof(name2))) < 0) {
+               if ((nameLen = dn_expand(msg,
+                   eom, cp, (u_char *)name2, sizeof(name2))) < 0) {
                    fprintf(file, " ***\n");
                    return (ERROR);
                }
                cp += nameLen;
                fprintf(file, " %s", name2);
                    fprintf(file, " ***\n");
                    return (ERROR);
                }
                cp += nameLen;
                fprintf(file, " %s", name2);
-               if ((nameLen =
-                       dn_expand(msg, eom, cp, name2, sizeof(name2))) < 0) {
+               if ((nameLen = dn_expand(msg,
+                   eom, cp, (u_char *)name2, sizeof(name2))) < 0) {
                    fprintf(file, " ***\n");
                    return (ERROR);
                }
                    fprintf(file, " ***\n");
                    return (ERROR);
                }
@@ -681,8 +698,8 @@ PrintListInfo(file, msg, eom, qtype, domain)
                pref = _getshort(cp);
                cp += sizeof(u_short);
                fprintf(file," %-3d ",pref);
                pref = _getshort(cp);
                cp += sizeof(u_short);
                fprintf(file," %-3d ",pref);
-               if ((nameLen =
-                       dn_expand(msg, eom, cp, name2, sizeof(name2))) < 0) {
+               if ((nameLen = dn_expand(msg,
+                   eom, cp, (u_char *)name2, sizeof(name2))) < 0) {
                    fprintf(file, " ***\n");
                    return (ERROR);
                }
                    fprintf(file, " ***\n");
                    return (ERROR);
                }
@@ -691,7 +708,7 @@ PrintListInfo(file, msg, eom, qtype, domain)
 
            case T_TXT:
                {
 
            case T_TXT:
                {
-                   char *cp2 = cp + dlen;
+                   u_char *cp2 = cp + dlen;
                    int c;
 
                    (void) fputs(" \"", file);
                    int c;
 
                    (void) fputs(" \"", file);
@@ -711,9 +728,9 @@ PrintListInfo(file, msg, eom, qtype, domain)
 
            case T_MINFO:
                (void) putc(' ', file);
 
            case T_MINFO:
                (void) putc(' ', file);
-               cp = Print_cdname(cp, msg, eom, file);
+               cp = (u_char *)Print_cdname(cp, msg, eom, file);
                fprintf(file, "  ");
                fprintf(file, "  ");
-               cp = Print_cdname(cp, msg, eom, file);
+               cp = (u_char *)Print_cdname(cp, msg, eom, file);
                break;
 
            case T_UINFO:
                break;
 
            case T_UINFO:
@@ -861,7 +878,7 @@ Finger(string, putToFile)
            return (ERROR);
        }
 
            return (ERROR);
        }
 
-       if (connect(sockFD, (char *)&sin, sizeof (sin)) < 0) {
+       if (connect(sockFD, (struct sockaddr *)&sin, sizeof (sin)) < 0) {
            fflush(stdout);
            perror("finger: connect");
            close(sockFD);
            fflush(stdout);
            perror("finger: connect");
            close(sockFD);