flag fields are u_int's
[unix-history] / usr / src / lib / libc / net / res_debug.c
index 5413e69..bac8d0b 100644 (file)
@@ -1,31 +1,27 @@
-/*
+/*-
  * Copyright (c) 1985, 1990 Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1985, 1990 Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not 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 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
+ *
+ *     @(#)res_debug.c 5.36 (Berkeley) %G%
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
  */
 
 #if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)res_debug.c        5.28 (Berkeley) %G%";
+static char sccsid[] = "@(#)res_debug.c        5.36 (Berkeley) %G%";
 #endif /* LIBC_SCCS and not lint */
 
 #endif /* LIBC_SCCS and not lint */
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <netinet/in.h>
 #include <netinet/in.h>
-#include <stdio.h>
+#include <arpa/inet.h>
 #include <arpa/nameser.h>
 #include <arpa/nameser.h>
+#include <resolv.h>
+#include <stdio.h>
+#include <string.h>
 
 
-extern char *p_cdname(), *p_rr(), *p_type(), *p_class(), *p_time();
-extern char *inet_ntoa();
+void __fp_query();
+char *__p_class(), *__p_time(), *__p_type();
+static char *p_cdname(), *p_rr();
 
 char *_res_opcodes[] = {
        "QUERY",
 
 char *_res_opcodes[] = {
        "QUERY",
@@ -65,17 +61,18 @@ char *_res_resultcodes[] = {
        "NOCHANGE",
 };
 
        "NOCHANGE",
 };
 
-p_query(msg)
+__p_query(msg)
        char *msg;
 {
        char *msg;
 {
-       fp_query(msg,stdout);
+       __fp_query(msg,stdout);
 }
 
 /*
  * Print the contents of a query.
  * This is intended to be primarily a debugging routine.
  */
 }
 
 /*
  * Print the contents of a query.
  * This is intended to be primarily a debugging routine.
  */
-fp_query(msg,file)
+void
+__fp_query(msg,file)
        char *msg;
        FILE *file;
 {
        char *msg;
        FILE *file;
 {
@@ -119,9 +116,10 @@ fp_query(msg,file)
                        cp = p_cdname(cp, msg, file);
                        if (cp == NULL)
                                return;
                        cp = p_cdname(cp, msg, file);
                        if (cp == NULL)
                                return;
-                       fprintf(file,", type = %s", p_type(_getshort(cp)));
+                       fprintf(file,", type = %s", __p_type(_getshort(cp)));
                        cp += sizeof(u_short);
                        cp += sizeof(u_short);
-                       fprintf(file,", class = %s\n\n", p_class(_getshort(cp)));
+                       fprintf(file,
+                           ", class = %s\n\n", __p_class(_getshort(cp)));
                        cp += sizeof(u_short);
                }
        }
                        cp += sizeof(u_short);
                }
        }
@@ -163,7 +161,7 @@ fp_query(msg,file)
        }
 }
 
        }
 }
 
-char *
+static char *
 p_cdname(cp, msg, file)
        char *cp, *msg;
        FILE *file;
 p_cdname(cp, msg, file)
        char *cp, *msg;
        FILE *file;
@@ -171,7 +169,8 @@ p_cdname(cp, msg, file)
        char name[MAXDNAME];
        int n;
 
        char name[MAXDNAME];
        int n;
 
-       if ((n = dn_expand(msg, msg + 512, cp, name, sizeof(name))) < 0)
+       if ((n = dn_expand((u_char *)msg, (u_char *)msg + 512, (u_char *)cp,
+           (u_char *)name, sizeof(name))) < 0)
                return (NULL);
        if (name[0] == '\0') {
                name[0] = '.';
                return (NULL);
        if (name[0] == '\0') {
                name[0] = '.';
@@ -184,22 +183,22 @@ p_cdname(cp, msg, file)
 /*
  * Print resource record fields in human readable form.
  */
 /*
  * Print resource record fields in human readable form.
  */
-char *
+static char *
 p_rr(cp, msg, file)
        char *cp, *msg;
        FILE *file;
 {
        int type, class, dlen, n, c;
        struct in_addr inaddr;
 p_rr(cp, msg, file)
        char *cp, *msg;
        FILE *file;
 {
        int type, class, dlen, n, c;
        struct in_addr inaddr;
-       char *cp1, cp2;
+       char *cp1, *cp2;
 
        if ((cp = p_cdname(cp, msg, file)) == NULL)
                return (NULL);                  /* compression error */
 
        if ((cp = p_cdname(cp, msg, file)) == NULL)
                return (NULL);                  /* compression error */
-       fprintf(file,"\n\ttype = %s", p_type(type = _getshort(cp)));
+       fprintf(file,"\n\ttype = %s", __p_type(type = _getshort(cp)));
        cp += sizeof(u_short);
        cp += sizeof(u_short);
-       fprintf(file,", class = %s", p_class(class = _getshort(cp)));
+       fprintf(file,", class = %s", __p_class(class = _getshort(cp)));
        cp += sizeof(u_short);
        cp += sizeof(u_short);
-       fprintf(file,", ttl = %s", p_time(_getlong(cp)));
+       fprintf(file,", ttl = %s", __p_time(_getlong(cp)));
        cp += sizeof(u_long);
        fprintf(file,", dlen = %d\n", dlen = _getshort(cp));
        cp += sizeof(u_short);
        cp += sizeof(u_long);
        fprintf(file,", dlen = %d\n", dlen = _getshort(cp));
        cp += sizeof(u_short);
@@ -259,13 +258,13 @@ p_rr(cp, msg, file)
                cp = p_cdname(cp, msg, file);
                fprintf(file,"\n\tserial = %ld", _getlong(cp));
                cp += sizeof(u_long);
                cp = p_cdname(cp, msg, file);
                fprintf(file,"\n\tserial = %ld", _getlong(cp));
                cp += sizeof(u_long);
-               fprintf(file,"\n\trefresh = %s", p_time(_getlong(cp)));
+               fprintf(file,"\n\trefresh = %s", __p_time(_getlong(cp)));
                cp += sizeof(u_long);
                cp += sizeof(u_long);
-               fprintf(file,"\n\tretry = %s", p_time(_getlong(cp)));
+               fprintf(file,"\n\tretry = %s", __p_time(_getlong(cp)));
                cp += sizeof(u_long);
                cp += sizeof(u_long);
-               fprintf(file,"\n\texpire = %s", p_time(_getlong(cp)));
+               fprintf(file,"\n\texpire = %s", __p_time(_getlong(cp)));
                cp += sizeof(u_long);
                cp += sizeof(u_long);
-               fprintf(file,"\n\tmin = %s\n", p_time(_getlong(cp)));
+               fprintf(file,"\n\tmin = %s\n", __p_time(_getlong(cp)));
                cp += sizeof(u_long);
                break;
 
                cp += sizeof(u_long);
                break;
 
@@ -367,7 +366,7 @@ static      char nbuf[40];
  * Return a string for the type
  */
 char *
  * Return a string for the type
  */
 char *
-p_type(type)
+__p_type(type)
        int type;
 {
        switch (type) {
        int type;
 {
        switch (type) {
@@ -427,7 +426,7 @@ p_type(type)
  * Return a mnemonic for class
  */
 char *
  * Return a mnemonic for class
  */
 char *
-p_class(class)
+__p_class(class)
        int class;
 {
 
        int class;
 {
 
@@ -448,12 +447,17 @@ p_class(class)
  * Return a mnemonic for a time to live
  */
 char *
  * Return a mnemonic for a time to live
  */
 char *
-p_time(value)
+__p_time(value)
        u_long value;
 {
        int secs, mins, hours;
        register char *p;
 
        u_long value;
 {
        int secs, mins, hours;
        register char *p;
 
+       if (value == 0) {
+               strcpy(nbuf, "0 secs");
+               return(nbuf);
+       }
+
        secs = value % 60;
        value /= 60;
        mins = value % 60;
        secs = value % 60;
        value /= 60;
        mins = value % 60;