BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.sbin / named / tools / nslookup / getinfo.c
index 111f353..6b875c1 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[] = "@(#)getinfo.c  5.22 (Berkeley) 6/1/90";
+static char sccsid[] = "@(#)getinfo.c  5.26 (Berkeley) 3/21/91";
 #endif /* not lint */
 
 /*
 #endif /* not lint */
 
 /*
@@ -34,14 +48,14 @@ static char sccsid[] = "@(#)getinfo.c       5.22 (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 <stdio.h>
-#include <ctype.h>
 #include <arpa/nameser.h>
 #include <arpa/inet.h>
 #include <resolv.h>
 #include <arpa/nameser.h>
 #include <arpa/inet.h>
 #include <resolv.h>
+#include <stdio.h>
+#include <ctype.h>
 #include "res.h"
 
 extern char *_res_resultcodes[];
 #include "res.h"
 
 extern char *_res_resultcodes[];
@@ -56,7 +70,7 @@ static char *addr_list[MAXADDRS + 1];
 
 static char *host_aliases[MAXALIASES];
 static int   host_aliases_len[MAXALIASES];
 
 static char *host_aliases[MAXALIASES];
 static int   host_aliases_len[MAXALIASES];
-static char  hostbuf[BUFSIZ+1];
+static u_char  hostbuf[BUFSIZ+1];
 
 typedef struct {
     char *name;
 
 typedef struct {
     char *name;
@@ -110,9 +124,10 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
     Boolean            isServer;
 {
     register HEADER    *headerPtr;
     Boolean            isServer;
 {
     register HEADER    *headerPtr;
-    register char      *cp;
+    register u_char    *cp;
     querybuf           answer;
     querybuf           answer;
-    char               *eom, *bp, **aliasPtr;
+    char               **aliasPtr;
+    u_char             *eom, *bp;
     char               **addrPtr;
     char               *namePtr;
     char               *dnamePtr;
     char               **addrPtr;
     char               *namePtr;
     char               *dnamePtr;
@@ -143,7 +158,7 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
                    printf("SendRequest failed\n");
            return (status);
     }
                    printf("SendRequest failed\n");
            return (status);
     }
-    eom = (char *) &answer + n;
+    eom = (u_char *) &answer + n;
 
     headerPtr = (HEADER *) &answer;
 
 
     headerPtr = (HEADER *) &answer;
 
@@ -167,7 +182,7 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
 
     bp    = hostbuf;
     buflen = sizeof(hostbuf);
 
     bp    = hostbuf;
     buflen = sizeof(hostbuf);
-    cp    = (char *) &answer + sizeof(HEADER);
+    cp    = (u_char *) &answer + sizeof(HEADER);
 
     /* Skip over question section. */
     while (qdcount-- > 0) {
 
     /* Skip over question section. */
     while (qdcount-- > 0) {
@@ -190,14 +205,16 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
 
        if (queryType != T_A && !(iquery && queryType == T_PTR)) {
            while (--ancount >= 0 && cp < eom) {
 
        if (queryType != T_A && !(iquery && queryType == T_PTR)) {
            while (--ancount >= 0 && cp < eom) {
-               if ((cp = Print_rr(cp, (char *)&answer, eom, stdout)) == NULL) {
+               if ((cp = (u_char *)Print_rr(cp,
+                   (char *)&answer, eom, stdout)) == NULL) {
                    return(ERROR);
                }
            }
            printedAnswers = TRUE;
        } else {
            while (--ancount >= 0 && cp < eom) {
                    return(ERROR);
                }
            }
            printedAnswers = TRUE;
        } else {
            while (--ancount >= 0 && cp < eom) {
-               if ((n = dn_expand((char *)&answer, eom, cp, bp, buflen)) < 0) {
+               if ((n =
+                   dn_expand((u_char *)&answer, eom, cp, bp, buflen)) < 0) {
                    return(ERROR);
                }
                cp   += n;
                    return(ERROR);
                }
                cp   += n;
@@ -213,8 +230,8 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
                    if (aliasPtr >= &host_aliases[MAXALIASES-1]) {
                        continue;
                    }
                    if (aliasPtr >= &host_aliases[MAXALIASES-1]) {
                        continue;
                    }
-                   *aliasPtr++ = bp;
-                   n = strlen(bp) + 1;
+                   *aliasPtr++ = (char *)bp;
+                   n = strlen((char *)bp) + 1;
                    host_aliases_len[numAliases] = n;
                    numAliases++;
                    bp += n;
                    host_aliases_len[numAliases] = n;
                    numAliases++;
                    bp += n;
@@ -224,7 +241,8 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
                    /*
                     *  Found a "pointer" to the real name.
                     */
                    /*
                     *  Found a "pointer" to the real name.
                     */
-                   if((n=dn_expand((char *)&answer, eom, cp, bp,buflen)) < 0) {
+                   if ((n =
+                       dn_expand((u_char *)&answer, eom, cp, bp,buflen)) < 0) {
                        cp += n;
                        continue;
                    }
                        cp += n;
                        continue;
                    }
@@ -271,7 +289,7 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
                    }
                    break;
                }
                    }
                    break;
                }
-               bcopy(cp, *addrPtr++ = bp, dlen);
+               bcopy(cp, *addrPtr++ = (char *)bp, dlen);
                bp +=dlen;
                cp += dlen;
                numAddresses++;
                bp +=dlen;
                cp += dlen;
                numAddresses++;
@@ -327,7 +345,7 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
        printf("Authoritative answers can be found from:\n");
     }
 
        printf("Authoritative answers can be found from:\n");
     }
 
-    cp = res_skip((char *) &answer, 2, eom);
+    cp = (u_char *)res_skip((char *) &answer, 2, eom);
 
     numServers = 0;
     if (queryType != T_A) {
 
     numServers = 0;
     if (queryType != T_A) {
@@ -335,7 +353,8 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
         * If we don't need to save the record, just print it.
         */
        while (--nscount >= 0 && cp < eom) {
         * If we don't need to save the record, just print it.
         */
        while (--nscount >= 0 && cp < eom) {
-           if ((cp = Print_rr(cp, (char *) &answer, eom, stdout)) == NULL) {
+           if ((cp = (u_char *)Print_rr(cp,
+               (char *) &answer, eom, stdout)) == NULL) {
                return(ERROR);
            }
        }
                return(ERROR);
            }
        }
@@ -346,7 +365,7 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
             *  that serve the requested domain.
             */
 
             *  that serve the requested domain.
             */
 
-           if ((n = dn_expand((char *) &answer, eom, cp, bp, buflen)) < 0) {
+           if ((n = dn_expand((u_char *) &answer, eom, cp, bp, buflen)) < 0) {
                return(ERROR);
            }
            cp += n;
                return(ERROR);
            }
            cp += n;
@@ -364,7 +383,8 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
            } else {
                Boolean found;
 
            } else {
                Boolean found;
 
-               if ((n = dn_expand((char *) &answer, eom, cp, bp, buflen)) < 0){
+               if ((n =
+                   dn_expand((u_char *) &answer, eom, cp, bp, buflen)) < 0) {
                    return(ERROR);
                }
                cp += n;
                    return(ERROR);
                }
                cp += n;
@@ -405,20 +425,21 @@ GetAnswer(nsAddrPtr, queryType, msg, msglen, iquery, hostPtr, isServer)
     /*
      * Additional resource records contain addresses of servers.
      */
     /*
      * Additional resource records contain addresses of servers.
      */
-    cp = res_skip((char *) &answer, 3, eom);
+    cp = (u_char *)res_skip((char *) &answer, 3, eom);
 
     if (queryType != T_A) {
        /*
         * If we don't need to save the record, just print it.
         */
        while (--arcount >= 0 && cp < eom) {
 
     if (queryType != T_A) {
        /*
         * If we don't need to save the record, just print it.
         */
        while (--arcount >= 0 && cp < eom) {
-           if ((cp = Print_rr(cp, (char *) &answer, eom, stdout)) == NULL) {
+           if ((cp = (u_char *)Print_rr(cp,
+               (char *) &answer, eom, stdout)) == NULL) {
                return(ERROR);
            }
        }
     } else {
        while (--arcount >= 0 && cp < eom) {
                return(ERROR);
            }
        }
     } else {
        while (--arcount >= 0 && cp < eom) {
-           if ((n = dn_expand((char *) &answer, eom, cp, bp, buflen)) < 0) {
+           if ((n = dn_expand((u_char *) &answer, eom, cp, bp, buflen)) < 0) {
                break;
            }
            cp   += n;
                break;
            }
            cp   += n;
@@ -520,7 +541,6 @@ GetHostInfoByName(nsAddrPtr, queryClass, queryType, name, hostPtr, isServer)
     int                        n;
     register int       result;
     register char      *cp, **domain;
     int                        n;
     register int       result;
     register char      *cp, **domain;
-    extern char                *hostalias();
     Boolean            got_nodata = FALSE;
     unsigned long      ina;
 
     Boolean            got_nodata = FALSE;
     unsigned long      ina;
 
@@ -628,7 +648,7 @@ GetHostDomain(nsAddrPtr, queryClass, queryType, name, domain, hostPtr, isServer)
            longname = nbuf;
     }
     n = res_mkquery(QUERY, longname, queryClass, queryType,
            longname = nbuf;
     }
     n = res_mkquery(QUERY, longname, queryClass, queryType,
-                   (char *)0, 0, (char *)0, (char *) &buf, sizeof(buf));
+                   (char *)0, 0, 0, (char *) &buf, sizeof(buf));
     if (n < 0) {
        if (_res.options & RES_DEBUG) {
            printf("Res_mkquery failed\n");
     if (n < 0) {
        if (_res.options & RES_DEBUG) {
            printf("Res_mkquery failed\n");