1 /* Convert DNS domain names from network format to textual presentation format.
2 * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (c) 1996,1999 by Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
15 * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 #include <arpa/nameser.h>
20 #include <shlib-compat.h>
23 /* Thinking in noninternationalized US-ASCII (per the DNS spec), is
24 this character special ("in need of quoting")? */
36 /* Special modifiers in zone files. */
45 /* Thinking in noninternationalized US-ASCII (per the DNS spec), is
46 this character visible and not a space when printed? */
50 return ch
> 0x20 && ch
< 0x7f;
53 /* Converts an uncompressed, encoded domain name to printable ASCII as
54 per RFC1035. Returns the number of bytes written to buffer, or -1
55 (with errno set). The root is returned as "." All other domains
56 are returned in non absolute form. */
58 ___ns_name_ntop (const unsigned char *src
, char *dst
, size_t dstsiz
)
60 const unsigned char *cp
;
69 while ((l
= *cp
++) != 0)
73 /* Some kind of compression pointer. */
74 __set_errno (EMSGSIZE
);
81 __set_errno (EMSGSIZE
);
93 __set_errno (EMSGSIZE
);
99 else if (!printable (c
))
103 __set_errno (EMSGSIZE
);
107 *dn
++ = '0' + (c
/ 100);
108 *dn
++ = '0' + ((c
% 100) / 10);
109 *dn
++ = '0' + (c
% 10);
115 __set_errno (EMSGSIZE
);
126 __set_errno (EMSGSIZE
);
133 __set_errno (EMSGSIZE
);
139 versioned_symbol (libc
, ___ns_name_ntop
, ns_name_ntop
, GLIBC_2_34
);
140 versioned_symbol (libc
, ___ns_name_ntop
, __ns_name_ntop
, GLIBC_PRIVATE
);
141 libc_hidden_ver (___ns_name_ntop
, __ns_name_ntop
)
143 #if OTHER_SHLIB_COMPAT (libresolv, GLIBC_2_9, GLIBC_2_34)
144 compat_symbol (libresolv
, ___ns_name_ntop
, ns_name_ntop
, GLIBC_2_9
);