]> git.proxmox.com Git - mirror_edk2.git/blobdiff - StdLib/BsdSocketLib/res_debug.c
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / StdLib / BsdSocketLib / res_debug.c
diff --git a/StdLib/BsdSocketLib/res_debug.c b/StdLib/BsdSocketLib/res_debug.c
deleted file mode 100644 (file)
index 791ac83..0000000
+++ /dev/null
@@ -1,988 +0,0 @@
-/*\r
- * Copyright (c) 1985\r
- *    The Regents of the University of California.  All rights reserved.\r
- *\r
- * Portions copyright (c) 1999, 2000\r
- * Intel Corporation.\r
- * All rights reserved.\r
- *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- * 1. Redistributions of source code must retain the above copyright\r
- *    notice, this list of conditions and the following disclaimer.\r
- *\r
- * 2. Redistributions in binary form must reproduce the above copyright\r
- *    notice, this list of conditions and the following disclaimer in the\r
- *    documentation and/or other materials provided with the distribution.\r
- *\r
- * 3. All advertising materials mentioning features or use of this software\r
- *    must display the following acknowledgement:\r
- *\r
- *    This product includes software developed by the University of\r
- *    California, Berkeley, Intel Corporation, and its contributors.\r
- *\r
- * 4. Neither the name of University, Intel Corporation, or their respective\r
- *    contributors may be used to endorse or promote products derived from\r
- *    this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS, INTEL CORPORATION AND\r
- * CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,\r
- * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
- * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS,\r
- * INTEL CORPORATION OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,\r
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\r
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\r
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\r
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\r
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\r
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
- *\r
- */\r
-\r
-/*\r
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.\r
- *\r
- * Permission to use, copy, modify, and distribute this software for any\r
- * purpose with or without fee is hereby granted, provided that the above\r
- * copyright notice and this permission notice appear in all copies, and that\r
- * the name of Digital Equipment Corporation not be used in advertising or\r
- * publicity pertaining to distribution of the document or software without\r
- * specific, written prior permission.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL\r
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES\r
- * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT\r
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL\r
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR\r
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS\r
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\r
- * SOFTWARE.\r
- */\r
-\r
-/*\r
- * Portions Copyright (c) 1995 by International Business Machines, Inc.\r
- *\r
- * International Business Machines, Inc. (hereinafter called IBM) grants\r
- * permission under its copyrights to use, copy, modify, and distribute this\r
- * Software with or without fee, provided that the above copyright notice and\r
- * all paragraphs of this notice appear in all copies, and that the name of IBM\r
- * not be used in connection with the marketing of any product incorporating\r
- * the Software or modifications thereof, without specific, written prior\r
- * permission.\r
- *\r
- * To the extent it has a right to do so, IBM grants an immunity from suit\r
- * under its patents, if any, for the use, sale or manufacture of products to\r
- * the extent that such products are used for performing Domain Name System\r
- * dynamic updates in TCP/IP networks by means of the Software.  No immunity is\r
- * granted for any product per se or for any other function of any product.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES,\r
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A\r
- * PARTICULAR PURPOSE.  IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL,\r
- * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING\r
- * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN\r
- * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.\r
- */\r
-\r
-/*\r
- * Portions Copyright (c) 1996 by Internet Software Consortium.\r
- *\r
- * Permission to use, copy, modify, and distribute this software for any\r
- * purpose with or without fee is hereby granted, provided that the above\r
- * copyright notice and this permission notice appear in all copies.\r
- *\r
- * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS\r
- * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES\r
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE\r
- * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL\r
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR\r
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS\r
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS\r
- * SOFTWARE.\r
- */\r
-\r
-#if defined(LIBC_SCCS) && !defined(lint)\r
-static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";\r
-static char rcsid[] = "$Id: res_debug.c,v 1.1.1.1 2003/11/19 01:51:36 kyu3 Exp $";\r
-#endif /* LIBC_SCCS and not lint */\r
-\r
-#include <sys/types.h>\r
-#include <sys/param.h>\r
-#include <sys/socket.h>\r
-\r
-#include <netinet/in.h>\r
-#include <arpa/inet.h>\r
-#include <arpa/nameser.h>\r
-\r
-#include <ctype.h>\r
-#include <errno.h>\r
-#include <math.h>\r
-#include <netdb.h>\r
-#include <resolv.h>\r
-#include <stdio.h>\r
-#include <stdlib.h>\r
-#include <string.h>\r
-#include <time.h>\r
-\r
-#define SPRINTF(x) sprintf x\r
-\r
-extern const char *_res_opcodes[];\r
-extern const char *_res_resultcodes[];\r
-extern const char *_res_sectioncodes[];\r
-\r
-/*\r
- * Print the current options.\r
- */\r
-void\r
-fp_resstat(struct __res_state *statp, FILE *file) {\r
-    u_long mask;\r
-\r
-    fprintf(file, ";; res options:");\r
-    if (!statp)\r
-        statp = &_res;\r
-    for (mask = 1;  mask != 0;  mask <<= 1)\r
-        if (statp->options & mask)\r
-            fprintf(file, " %s", p_option(mask));\r
-    putc('\n', file);\r
-}\r
-\r
-static void\r
-do_section(ns_msg *handle, ns_sect section, int pflag, FILE *file) {\r
-    int n, sflag, rrnum;\r
-    ns_opcode opcode;\r
-    ns_rr rr;\r
-\r
-    /*\r
-     * Print answer records.\r
-     */\r
-    sflag = (int)(_res.pfcode & pflag);\r
-    if (_res.pfcode && !sflag)\r
-        return;\r
-\r
-    opcode = ns_msg_getflag(*handle, ns_f_opcode);\r
-    rrnum = 0;\r
-    for (;;) {\r
-        if (ns_parserr(handle, section, rrnum, &rr)) {\r
-            if (errno != ENODEV)\r
-                fprintf(file, ";; ns_parserr: %s\n",\r
-                    strerror(errno));\r
-            else if (rrnum > 0 && sflag != 0 &&\r
-                 (_res.pfcode & RES_PRF_HEAD1))\r
-                putc('\n', file);\r
-            return;\r
-        }\r
-        if (rrnum == 0 && sflag != 0 && (_res.pfcode & RES_PRF_HEAD1))\r
-            fprintf(file, ";; %s SECTION:\n",\r
-                p_section(section, opcode));\r
-        if (section == ns_s_qd)\r
-            fprintf(file, ";;\t%s, type = %s, class = %s\n",\r
-                ns_rr_name(rr),\r
-                p_type(ns_rr_type(rr)),\r
-                p_class(ns_rr_class(rr)));\r
-        else {\r
-            char *buf;\r
-            buf = (char*)malloc(2024);\r
-            if (buf) {\r
-                n = ns_sprintrr(handle, &rr, NULL, NULL,\r
-                        buf, sizeof buf);\r
-                if (n < 0) {\r
-                    fprintf(file, ";; ns_sprintrr: %s\n",\r
-                        strerror(errno));\r
-                    free(buf);\r
-                    return;\r
-                }\r
-                fputs(buf, file);\r
-                fputc('\n', file);\r
-                free(buf);\r
-            }\r
-        }\r
-        rrnum++;\r
-    }\r
-}\r
-\r
-void\r
-p_query(const u_char *msg) {\r
-    fp_query(msg, stdout);\r
-}\r
-\r
-void\r
-fp_query(const u_char *msg, FILE *file) {\r
-    fp_nquery(msg, PACKETSZ, file);\r
-}\r
-\r
-/*\r
- * Print the contents of a query.\r
- * This is intended to be primarily a debugging routine.\r
- */\r
-void\r
-fp_nquery(const u_char *msg, int len, FILE *file) {\r
-    ns_msg handle;\r
-    int qdcount, ancount, nscount, arcount;\r
-    u_int opcode, rcode, id;\r
-\r
-    if ((_res.options & RES_INIT) == 0 && res_init() == -1)\r
-        return;\r
-\r
-    if (ns_initparse(msg, len, &handle) < 0) {\r
-        fprintf(file, ";; ns_initparse: %s\n", strerror(errno));\r
-        return;\r
-    }\r
-    opcode = ns_msg_getflag(handle, ns_f_opcode);\r
-    rcode = ns_msg_getflag(handle, ns_f_rcode);\r
-    id = ns_msg_id(handle);\r
-    qdcount = ns_msg_count(handle, ns_s_qd);\r
-    ancount = ns_msg_count(handle, ns_s_an);\r
-    nscount = ns_msg_count(handle, ns_s_ns);\r
-    arcount = ns_msg_count(handle, ns_s_ar);\r
-\r
-    /*\r
-     * Print header fields.\r
-     */\r
-    if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX) || rcode)\r
-        fprintf(file,\r
-            ";; ->>HEADER<<- opcode: %s, status: %s, id: %d\n",\r
-            _res_opcodes[opcode], _res_resultcodes[rcode], (int)id);\r
-    if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEADX))\r
-        putc(';', file);\r
-    if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD2)) {\r
-        fprintf(file, "; flags:");\r
-        if (ns_msg_getflag(handle, ns_f_qr))\r
-            fprintf(file, " qr");\r
-        if (ns_msg_getflag(handle, ns_f_aa))\r
-            fprintf(file, " aa");\r
-        if (ns_msg_getflag(handle, ns_f_tc))\r
-            fprintf(file, " tc");\r
-        if (ns_msg_getflag(handle, ns_f_rd))\r
-            fprintf(file, " rd");\r
-        if (ns_msg_getflag(handle, ns_f_ra))\r
-            fprintf(file, " ra");\r
-        if (ns_msg_getflag(handle, ns_f_z))\r
-            fprintf(file, " ??");\r
-        if (ns_msg_getflag(handle, ns_f_ad))\r
-            fprintf(file, " ad");\r
-        if (ns_msg_getflag(handle, ns_f_cd))\r
-            fprintf(file, " cd");\r
-    }\r
-    if ((!_res.pfcode) || (_res.pfcode & RES_PRF_HEAD1)) {\r
-        fprintf(file, "; %s: %d",\r
-            p_section(ns_s_qd, (int)opcode), qdcount);\r
-        fprintf(file, ", %s: %d",\r
-            p_section(ns_s_an, (int)opcode), ancount);\r
-        fprintf(file, ", %s: %d",\r
-            p_section(ns_s_ns, (int)opcode), nscount);\r
-        fprintf(file, ", %s: %d",\r
-            p_section(ns_s_ar, (int)opcode), arcount);\r
-    }\r
-    if ((!_res.pfcode) || (_res.pfcode &\r
-        (RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) {\r
-        putc('\n',file);\r
-    }\r
-    /*\r
-     * Print the various sections.\r
-     */\r
-    do_section(&handle, ns_s_qd, RES_PRF_QUES, file);\r
-    do_section(&handle, ns_s_an, RES_PRF_ANS, file);\r
-    do_section(&handle, ns_s_ns, RES_PRF_AUTH, file);\r
-    do_section(&handle, ns_s_ar, RES_PRF_ADD, file);\r
-    if (qdcount == 0 && ancount == 0 &&\r
-        nscount == 0 && arcount == 0)\r
-        putc('\n', file);\r
-}\r
-\r
-const u_char *\r
-p_cdnname(const u_char *cp, const u_char *msg, int len, FILE *file) {\r
-    char name[MAXDNAME];\r
-    int n;\r
-\r
-    if ((n = dn_expand(msg, msg + len, cp, name, sizeof name)) < 0)\r
-        return (NULL);\r
-    if (name[0] == '\0')\r
-        putc('.', file);\r
-    else\r
-        fputs(name, file);\r
-    return (cp + n);\r
-}\r
-\r
-const u_char *\r
-p_cdname(const u_char *cp, const u_char *msg, FILE *file) {\r
-    return (p_cdnname(cp, msg, PACKETSZ, file));\r
-}\r
-\r
-/* Return a fully-qualified domain name from a compressed name (with\r
-   length supplied).  */\r
-\r
-const u_char *\r
-p_fqnname(\r
-    const u_char *cp,\r
-    const u_char *msg,\r
-    int msglen,\r
-    char *name,\r
-    int namelen\r
-    )\r
-{\r
-    int n, newlen;\r
-\r
-    if ((n = dn_expand(msg, cp + msglen, cp, name, namelen)) < 0)\r
-        return (NULL);\r
-    newlen = (int)strlen(name);\r
-    if (newlen == 0 || name[newlen - 1] != '.') {\r
-        if (newlen + 1 >= namelen)  /* Lack space for final dot */\r
-            return (NULL);\r
-        else\r
-            strcpy(name + newlen, ".");\r
-    }\r
-    return (cp + n);\r
-}\r
-\r
-/* XXX: the rest of these functions need to become length-limited, too. */\r
-\r
-const u_char *\r
-p_fqname(const u_char *cp, const u_char *msg, FILE *file) {\r
-    char name[MAXDNAME];\r
-    const u_char *n;\r
-\r
-    n = p_fqnname(cp, msg, MAXCDNAME, name, sizeof name);\r
-    if (n == NULL)\r
-        return (NULL);\r
-    fputs(name, file);\r
-    return (n);\r
-}\r
-\r
-/*\r
- * Names of RR classes and qclasses.  Classes and qclasses are the same, except\r
- * that C_ANY is a qclass but not a class.  (You can ask for records of class\r
- * C_ANY, but you can't have any records of that class in the database.)\r
- */\r
-const struct res_sym __p_class_syms[] = {\r
-    {C_IN,      "IN"},\r
-    {C_CHAOS,   "CHAOS"},\r
-    {C_HS,      "HS"},\r
-    {C_HS,      "HESIOD"},\r
-    {C_ANY,     "ANY"},\r
-    {C_NONE,    "NONE"},\r
-    {C_IN,      (char *)0}\r
-};\r
-\r
-/*\r
- * Names of message sections.\r
- */\r
-const struct res_sym __p_default_section_syms[] = {\r
-    {ns_s_qd,   "QUERY"},\r
-    {ns_s_an,   "ANSWER"},\r
-    {ns_s_ns,   "AUTHORITY"},\r
-    {ns_s_ar,   "ADDITIONAL"},\r
-    {0,             (char *)0}\r
-};\r
-\r
-const struct res_sym __p_update_section_syms[] = {\r
-    {S_ZONE,    "ZONE"},\r
-    {S_PREREQ,  "PREREQUISITE"},\r
-    {S_UPDATE,  "UPDATE"},\r
-    {S_ADDT,    "ADDITIONAL"},\r
-    {0,             (char *)0}\r
-};\r
-\r
-/*\r
- * Names of RR types and qtypes.  Types and qtypes are the same, except\r
- * that T_ANY is a qtype but not a type.  (You can ask for records of type\r
- * T_ANY, but you can't have any records of that type in the database.)\r
- */\r
-const struct res_sym __p_type_syms[] = {\r
-    {T_A,       "A",        "address"},\r
-    {T_NS,      "NS",       "name server"},\r
-    {T_MD,      "MD",       "mail destination (deprecated)"},\r
-    {T_MF,      "MF",       "mail forwarder (deprecated)"},\r
-    {T_CNAME,   "CNAME",    "canonical name"},\r
-    {T_SOA,     "SOA",      "start of authority"},\r
-    {T_MB,      "MB",       "mailbox"},\r
-    {T_MG,      "MG",       "mail group member"},\r
-    {T_MR,      "MR",       "mail rename"},\r
-    {T_NULL,    "NULL",     "null"},\r
-    {T_WKS,     "WKS",      "well-known service (deprecated)"},\r
-    {T_PTR,     "PTR",      "domain name pointer"},\r
-    {T_HINFO,   "HINFO",    "host information"},\r
-    {T_MINFO,   "MINFO",    "mailbox information"},\r
-    {T_MX,      "MX",       "mail exchanger"},\r
-    {T_TXT,     "TXT",      "text"},\r
-    {T_RP,      "RP",       "responsible person"},\r
-    {T_AFSDB,   "AFSDB",    "DCE or AFS server"},\r
-    {T_X25,     "X25",      "X25 address"},\r
-    {T_ISDN,    "ISDN",     "ISDN address"},\r
-    {T_RT,      "RT",       "router"},\r
-    {T_NSAP,    "NSAP",     "nsap address"},\r
-    {T_NSAP_PTR,    "NSAP_PTR", "domain name pointer"},\r
-    {T_SIG,     "SIG",      "signature"},\r
-    {T_KEY,     "KEY",      "key"},\r
-    {T_PX,      "PX",       "mapping information"},\r
-    {T_GPOS,    "GPOS",     "geographical position (withdrawn)"},\r
-    {T_AAAA,    "AAAA",     "IPv6 address"},\r
-    {T_LOC,     "LOC",      "location"},\r
-    {T_NXT,     "NXT",      "next valid name (unimplemented)"},\r
-    {T_EID,     "EID",      "endpoint identifier (unimplemented)"},\r
-    {T_NIMLOC,  "NIMLOC",   "NIMROD locator (unimplemented)"},\r
-    {T_SRV,     "SRV",      "server selection"},\r
-    {T_ATMA,    "ATMA",     "ATM address (unimplemented)"},\r
-    {T_IXFR,    "IXFR",     "incremental zone transfer"},\r
-    {T_AXFR,    "AXFR",     "zone transfer"},\r
-    {T_MAILB,   "MAILB",    "mailbox-related data (deprecated)"},\r
-    {T_MAILA,   "MAILA",    "mail agent (deprecated)"},\r
-    {T_NAPTR,   "NAPTR",    "URN Naming Authority"},\r
-    {T_ANY,     "ANY",      "\"any\""},\r
-    {0,         NULL,       NULL}\r
-};\r
-\r
-int\r
-sym_ston(const struct res_sym *syms, const char *name, int *success) {\r
-    for ((void)NULL; syms->name != 0; syms++) {\r
-        if (strcasecmp (name, syms->name) == 0) {\r
-            if (success)\r
-                *success = 1;\r
-            return (syms->number);\r
-        }\r
-    }\r
-    if (success)\r
-        *success = 0;\r
-    return (syms->number);      /* The default value. */\r
-}\r
-\r
-const char *\r
-sym_ntos(const struct res_sym *syms, int number, int *success) {\r
-    static char unname[20];\r
-\r
-    for ((void)NULL; syms->name != 0; syms++) {\r
-        if (number == syms->number) {\r
-            if (success)\r
-                *success = 1;\r
-            return (syms->name);\r
-        }\r
-    }\r
-\r
-    sprintf(unname, "%d", number);\r
-    if (success)\r
-        *success = 0;\r
-    return (unname);\r
-}\r
-\r
-const char *\r
-sym_ntop(const struct res_sym *syms, int number, int *success) {\r
-    static char unname[20];\r
-\r
-    for ((void)NULL; syms->name != 0; syms++) {\r
-        if (number == syms->number) {\r
-            if (success)\r
-                *success = 1;\r
-            return (syms->humanname);\r
-        }\r
-    }\r
-    sprintf(unname, "%d", number);\r
-    if (success)\r
-        *success = 0;\r
-    return (unname);\r
-}\r
-\r
-/*\r
- * Return a string for the type.\r
- */\r
-const char *\r
-p_type(int type) {\r
-    return (sym_ntos(__p_type_syms, type, (int *)0));\r
-}\r
-\r
-/*\r
- * Return a string for the type.\r
- */\r
-const char *\r
-p_section(int section, int opcode) {\r
-    const struct res_sym *symbols;\r
-\r
-    switch (opcode) {\r
-    case ns_o_update:\r
-        symbols = __p_update_section_syms;\r
-        break;\r
-    default:\r
-        symbols = __p_default_section_syms;\r
-        break;\r
-    }\r
-    return (sym_ntos(symbols, section, (int *)0));\r
-}\r
-\r
-/*\r
- * Return a mnemonic for class.\r
- */\r
-const char *\r
-p_class(int class) {\r
-    return (sym_ntos(__p_class_syms, class, (int *)0));\r
-}\r
-\r
-/*\r
- * Return a mnemonic for an option\r
- */\r
-const char *\r
-p_option(u_long option) {\r
-    static char nbuf[40];\r
-\r
-    switch (option) {\r
-    case RES_INIT:      return "init";\r
-    case RES_DEBUG:     return "debug";\r
-    case RES_AAONLY:    return "aaonly(unimpl)";\r
-    case RES_USEVC:     return "usevc";\r
-    case RES_PRIMARY:   return "primry(unimpl)";\r
-    case RES_IGNTC:     return "igntc";\r
-    case RES_RECURSE:   return "recurs";\r
-    case RES_DEFNAMES:  return "defnam";\r
-    case RES_STAYOPEN:  return "styopn";\r
-    case RES_DNSRCH:    return "dnsrch";\r
-    case RES_INSECURE1: return "insecure1";\r
-    case RES_INSECURE2: return "insecure2";\r
-    default:        sprintf(nbuf, "?0x%lx?", (unsigned long)option);\r
-                return (nbuf);\r
-    }\r
-}\r
-\r
-/*\r
- * Return a mnemonic for a time to live.\r
- */\r
-const char *\r
-p_time(u_int32_t value) {\r
-    static char nbuf[40];\r
-\r
-    if (ns_format_ttl(value, nbuf, sizeof nbuf) < 0)\r
-        sprintf(nbuf, "%u", value);\r
-    return (nbuf);\r
-}\r
-\r
-\r
-/*\r
- * routines to convert between on-the-wire RR format and zone file format.\r
- * Does not contain conversion to/from decimal degrees; divide or multiply\r
- * by 60*60*1000 for that.\r
- */\r
-\r
-static unsigned int poweroften[10] = {1, 10, 100, 1000, 10000, 100000,\r
-                      1000000,10000000,100000000,1000000000};\r
-\r
-/* takes an XeY precision/size value, returns a string representation. */\r
-static const char *\r
-precsize_ntoa(\r
-    u_int8_t prec\r
-    )\r
-{\r
-    static char retbuf[sizeof "90000000.00"];\r
-    unsigned long val;\r
-    int mantissa, exponent;\r
-\r
-    mantissa = (int)((prec >> 4) & 0x0f) % 10;\r
-    exponent = (int)((prec >> 0) & 0x0f) % 10;\r
-\r
-    val = mantissa * poweroften[exponent];\r
-\r
-    (void) sprintf(retbuf, "%ld.%.2ld", val/100, val%100);\r
-    return (retbuf);\r
-}\r
-\r
-/* converts ascii size/precision X * 10**Y(cm) to 0xXY.  moves pointer. */\r
-static u_int8_t\r
-precsize_aton(\r
-    char **strptr\r
-    )\r
-{\r
-    unsigned int mval = 0, cmval = 0;\r
-    u_int8_t retval = 0;\r
-    char *cp;\r
-    int exponent;\r
-    int mantissa;\r
-\r
-    cp = *strptr;\r
-\r
-    while (isdigit(*cp))\r
-        mval = mval * 10 + (*cp++ - '0');\r
-\r
-    if (*cp == '.') {       /* centimeters */\r
-        cp++;\r
-        if (isdigit(*cp)) {\r
-            cmval = (*cp++ - '0') * 10;\r
-            if (isdigit(*cp)) {\r
-                cmval += (*cp++ - '0');\r
-            }\r
-        }\r
-    }\r
-    cmval = (mval * 100) + cmval;\r
-\r
-    for (exponent = 0; exponent < 9; exponent++)\r
-        if (cmval < poweroften[exponent+1])\r
-            break;\r
-\r
-    mantissa = cmval / poweroften[exponent];\r
-    if (mantissa > 9)\r
-        mantissa = 9;\r
-\r
-    retval = (u_int8_t)((mantissa << 4) | exponent);\r
-\r
-    *strptr = cp;\r
-\r
-    return (retval);\r
-}\r
-\r
-/* converts ascii lat/lon to unsigned encoded 32-bit number.  moves pointer. */\r
-static u_int32_t\r
-latlon2ul(\r
-    char **latlonstrptr,\r
-    int *which\r
-    )\r
-{\r
-    char *cp;\r
-    u_int32_t retval;\r
-    int deg = 0, min = 0, secs = 0, secsfrac = 0;\r
-\r
-    cp = *latlonstrptr;\r
-\r
-    while (isdigit(*cp))\r
-        deg = deg * 10 + (*cp++ - '0');\r
-\r
-    while (isspace(*cp))\r
-        cp++;\r
-\r
-    if (!(isdigit(*cp)))\r
-        goto fndhemi;\r
-\r
-    while (isdigit(*cp))\r
-        min = min * 10 + (*cp++ - '0');\r
-\r
-    while (isspace(*cp))\r
-        cp++;\r
-\r
-    if (!(isdigit(*cp)))\r
-        goto fndhemi;\r
-\r
-    while (isdigit(*cp))\r
-        secs = secs * 10 + (*cp++ - '0');\r
-\r
-    if (*cp == '.') {       /* decimal seconds */\r
-        cp++;\r
-        if (isdigit(*cp)) {\r
-            secsfrac = (*cp++ - '0') * 100;\r
-            if (isdigit(*cp)) {\r
-                secsfrac += (*cp++ - '0') * 10;\r
-                if (isdigit(*cp)) {\r
-                    secsfrac += (*cp++ - '0');\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    while (!isspace(*cp))   /* if any trailing garbage */\r
-        cp++;\r
-\r
-    while (isspace(*cp))\r
-        cp++;\r
-\r
- fndhemi:\r
-    switch (*cp) {\r
-    case 'N': case 'n':\r
-    case 'E': case 'e':\r
-        retval = ((unsigned)1<<31)\r
-            + (((((deg * 60) + min) * 60) + secs) * 1000)\r
-            + secsfrac;\r
-        break;\r
-    case 'S': case 's':\r
-    case 'W': case 'w':\r
-        retval = ((unsigned)1<<31)\r
-            - (((((deg * 60) + min) * 60) + secs) * 1000)\r
-            - secsfrac;\r
-        break;\r
-    default:\r
-        retval = 0; /* invalid value -- indicates error */\r
-        break;\r
-    }\r
-\r
-    switch (*cp) {\r
-    case 'N': case 'n':\r
-    case 'S': case 's':\r
-        *which = 1; /* latitude */\r
-        break;\r
-    case 'E': case 'e':\r
-    case 'W': case 'w':\r
-        *which = 2; /* longitude */\r
-        break;\r
-    default:\r
-        *which = 0; /* error */\r
-        break;\r
-    }\r
-\r
-    cp++;           /* skip the hemisphere */\r
-\r
-    while (!isspace(*cp))   /* if any trailing garbage */\r
-        cp++;\r
-\r
-    while (isspace(*cp))    /* move to next field */\r
-        cp++;\r
-\r
-    *latlonstrptr = cp;\r
-\r
-    return (retval);\r
-}\r
-\r
-/* converts a zone file representation in a string to an RDATA on-the-wire\r
- * representation. */\r
-int\r
-loc_aton(\r
-    const char *ascii,\r
-    u_char *binary\r
-    )\r
-{\r
-    const char *cp, *maxcp;\r
-    u_char *bcp;\r
-\r
-    u_int32_t latit = 0, longit = 0, alt = 0;\r
-    u_int32_t lltemp1 = 0, lltemp2 = 0;\r
-    int altmeters = 0, altfrac = 0, altsign = 1;\r
-    u_int8_t hp = 0x16; /* default = 1e6 cm = 10000.00m = 10km */\r
-    u_int8_t vp = 0x13; /* default = 1e3 cm = 10.00m */\r
-    u_int8_t siz = 0x12;    /* default = 1e2 cm = 1.00m */\r
-    int which1 = 0, which2 = 0;\r
-\r
-    cp = ascii;\r
-    maxcp = cp + strlen(ascii);\r
-\r
-    lltemp1 = latlon2ul((char **)&cp, &which1);\r
-\r
-    lltemp2 = latlon2ul((char **)&cp, &which2);\r
-\r
-    switch (which1 + which2) {\r
-    case 3:         /* 1 + 2, the only valid combination */\r
-        if ((which1 == 1) && (which2 == 2)) { /* normal case */\r
-            latit = lltemp1;\r
-            longit = lltemp2;\r
-        } else if ((which1 == 2) && (which2 == 1)) { /* reversed */\r
-            longit = lltemp1;\r
-            latit = lltemp2;\r
-        } else {    /* some kind of brokenness */\r
-            return (0);\r
-        }\r
-        break;\r
-    default:        /* we didn't get one of each */\r
-        return (0);\r
-    }\r
-\r
-    /* altitude */\r
-    if (*cp == '-') {\r
-        altsign = -1;\r
-        cp++;\r
-    }\r
-\r
-    if (*cp == '+')\r
-        cp++;\r
-\r
-    while (isdigit(*cp))\r
-        altmeters = altmeters * 10 + (*cp++ - '0');\r
-\r
-    if (*cp == '.') {       /* decimal meters */\r
-        cp++;\r
-        if (isdigit(*cp)) {\r
-            altfrac = (*cp++ - '0') * 10;\r
-            if (isdigit(*cp)) {\r
-                altfrac += (*cp++ - '0');\r
-            }\r
-        }\r
-    }\r
-\r
-    alt = (10000000 + (altsign * (altmeters * 100 + altfrac)));\r
-\r
-    while (!isspace(*cp) && (cp < maxcp)) /* if trailing garbage or m */\r
-        cp++;\r
-\r
-    while (isspace(*cp) && (cp < maxcp))\r
-        cp++;\r
-\r
-    if (cp >= maxcp)\r
-        goto defaults;\r
-\r
-    siz = precsize_aton((char **)&cp);\r
-\r
-    while (!isspace(*cp) && (cp < maxcp))   /* if trailing garbage or m */\r
-        cp++;\r
-\r
-    while (isspace(*cp) && (cp < maxcp))\r
-        cp++;\r
-\r
-    if (cp >= maxcp)\r
-        goto defaults;\r
-\r
-    hp = precsize_aton((char **)&cp);\r
-\r
-    while (!isspace(*cp) && (cp < maxcp))   /* if trailing garbage or m */\r
-        cp++;\r
-\r
-    while (isspace(*cp) && (cp < maxcp))\r
-        cp++;\r
-\r
-    if (cp >= maxcp)\r
-        goto defaults;\r
-\r
-    vp = precsize_aton((char **)&cp);\r
-\r
- defaults:\r
-\r
-    bcp = binary;\r
-    *bcp++ = (u_int8_t) 0;  /* version byte */\r
-    *bcp++ = siz;\r
-    *bcp++ = hp;\r
-    *bcp++ = vp;\r
-    PUTLONG(latit,bcp);\r
-    PUTLONG(longit,bcp);\r
-    PUTLONG(alt,bcp);\r
-\r
-    return (16);        /* size of RR in octets */\r
-}\r
-\r
-/* takes an on-the-wire LOC RR and formats it in a human readable format. */\r
-const char *\r
-loc_ntoa(\r
-    const u_char *binary,\r
-    char *ascii\r
-    )\r
-{\r
-    static char *error = "?";\r
-    const u_char *cp = binary;\r
-\r
-    int latdeg, latmin, latsec, latsecfrac;\r
-    int longdeg, longmin, longsec, longsecfrac;\r
-    char northsouth, eastwest;\r
-    int altmeters, altfrac, altsign;\r
-\r
-    const u_int32_t referencealt = 100000 * 100;\r
-\r
-    int32_t latval, longval, altval;\r
-    u_int32_t templ;\r
-    u_int8_t sizeval, hpval, vpval, versionval;\r
-\r
-    char *sizestr, *hpstr, *vpstr;\r
-\r
-    versionval = *cp++;\r
-\r
-    if (versionval) {\r
-        (void) sprintf(ascii, "; error: unknown LOC RR version");\r
-        return (ascii);\r
-    }\r
-\r
-    sizeval = *cp++;\r
-\r
-    hpval = *cp++;\r
-    vpval = *cp++;\r
-\r
-    GETLONG(templ, cp);\r
-    latval = (templ - ((unsigned)1<<31));\r
-\r
-    GETLONG(templ, cp);\r
-    longval = (templ - ((unsigned)1<<31));\r
-\r
-    GETLONG(templ, cp);\r
-    if (templ < referencealt) { /* below WGS 84 spheroid */\r
-        altval = referencealt - templ;\r
-        altsign = -1;\r
-    } else {\r
-        altval = templ - referencealt;\r
-        altsign = 1;\r
-    }\r
-\r
-    if (latval < 0) {\r
-        northsouth = 'S';\r
-        latval = -latval;\r
-    } else\r
-        northsouth = 'N';\r
-\r
-    latsecfrac = latval % 1000;\r
-    latval = latval / 1000;\r
-    latsec = latval % 60;\r
-    latval = latval / 60;\r
-    latmin = latval % 60;\r
-    latval = latval / 60;\r
-    latdeg = latval;\r
-\r
-    if (longval < 0) {\r
-        eastwest = 'W';\r
-        longval = -longval;\r
-    } else\r
-        eastwest = 'E';\r
-\r
-    longsecfrac = longval % 1000;\r
-    longval = longval / 1000;\r
-    longsec = longval % 60;\r
-    longval = longval / 60;\r
-    longmin = longval % 60;\r
-    longval = longval / 60;\r
-    longdeg = longval;\r
-\r
-    altfrac = altval % 100;\r
-    altmeters = (altval / 100) * altsign;\r
-\r
-    if ((sizestr = strdup(precsize_ntoa(sizeval))) == NULL)\r
-        sizestr = error;\r
-    if ((hpstr = strdup(precsize_ntoa(hpval))) == NULL)\r
-        hpstr = error;\r
-    if ((vpstr = strdup(precsize_ntoa(vpval))) == NULL)\r
-        vpstr = error;\r
-\r
-    sprintf(ascii,\r
-          "%d %.2d %.2d.%.3d %c %d %.2d %.2d.%.3d %c %d.%.2dm %sm %sm %sm",\r
-        latdeg, latmin, latsec, latsecfrac, northsouth,\r
-        longdeg, longmin, longsec, longsecfrac, eastwest,\r
-        altmeters, altfrac, sizestr, hpstr, vpstr);\r
-\r
-    if (sizestr != error)\r
-        free(sizestr);\r
-    if (hpstr != error)\r
-        free(hpstr);\r
-    if (vpstr != error)\r
-        free(vpstr);\r
-\r
-    return (ascii);\r
-}\r
-\r
-\r
-/* Return the number of DNS hierarchy levels in the name. */\r
-int\r
-dn_count_labels(const char *name) {\r
-    int i, len, count;\r
-\r
-    len = (int)strlen(name);\r
-    for (i = 0, count = 0; i < len; i++) {\r
-        /* XXX need to check for \. or use named's nlabels(). */\r
-        if (name[i] == '.')\r
-            count++;\r
-    }\r
-\r
-    /* don't count initial wildcard */\r
-    if (name[0] == '*')\r
-        if (count)\r
-            count--;\r
-\r
-    /* don't count the null label for root. */\r
-    /* if terminating '.' not found, must adjust */\r
-    /* count to include last label */\r
-    if (len > 0 && name[len-1] != '.')\r
-        count++;\r
-    return (count);\r
-}\r
-\r
-\r
-/*\r
- * Make dates expressed in seconds-since-Jan-1-1970 easy to read.\r
- * SIG records are required to be printed like this, by the Secure DNS RFC.\r
- */\r
-char *\r
-p_secstodate (u_long secs) {\r
-    static char output[15];     /* YYYYMMDDHHMMSS and null */\r
-    time_t clock = (time_t)secs;\r
-    struct tm *time;\r
-\r
-    time = gmtime(&clock);\r
-    time->tm_year += 1900;\r
-    time->tm_mon += 1;\r
-    sprintf(output, "%04d%02d%02d%02d%02d%02d",\r
-        time->tm_year, time->tm_mon, time->tm_mday,\r
-        time->tm_hour, time->tm_min, time->tm_sec);\r
-    return (output);\r
-}\r