No empty .Rs/.Re
[netbsd-mini2440.git] / external / bsd / bind / dist / contrib / idn / idnkit-1.0-src / wsock / common / dump.c
blob68891c655a95a23e44abbfdefadc7c9fa1313099
1 /* $NetBSD$ */
3 /*
4 * dump.c - dump data
5 */
7 /*
8 * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
9 *
10 * By using this file, you agree to the terms and conditions set forth bellow.
12 * LICENSE TERMS AND CONDITIONS
14 * The following License Terms and Conditions apply, unless a different
15 * license is obtained from Japan Network Information Center ("JPNIC"),
16 * a Japanese association, Kokusai-Kougyou-Kanda Bldg 6F, 2-3-4 Uchi-Kanda,
17 * Chiyoda-ku, Tokyo 101-0047, Japan.
19 * 1. Use, Modification and Redistribution (including distribution of any
20 * modified or derived work) in source and/or binary forms is permitted
21 * under this License Terms and Conditions.
23 * 2. Redistribution of source code must retain the copyright notices as they
24 * appear in each source code file, this License Terms and Conditions.
26 * 3. Redistribution in binary form must reproduce the Copyright Notice,
27 * this License Terms and Conditions, in the documentation and/or other
28 * materials provided with the distribution. For the purposes of binary
29 * distribution the "Copyright Notice" refers to the following language:
30 * "Copyright (c) 2000-2002 Japan Network Information Center. All rights reserved."
32 * 4. The name of JPNIC may not be used to endorse or promote products
33 * derived from this Software without specific prior written approval of
34 * JPNIC.
36 * 5. Disclaimer/Limitation of Liability: THIS SOFTWARE IS PROVIDED BY JPNIC
37 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
38 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
39 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JPNIC BE LIABLE
40 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
41 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
42 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
43 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
44 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
45 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
46 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
49 #include <windows.h>
50 #include <stdio.h>
51 #include <stdlib.h>
52 #include <string.h>
54 #include "wrapcommon.h"
56 char *
57 dumpAddr(const char FAR *addr, int len, char *buff, size_t size) {
58 int i;
59 char *p;
61 buff[0] = '\0';
62 for (i = 0, p = buff; i < len; i++) {
63 char digits[8];
65 sprintf(digits, "%d", (addr[i] & 0xff));
66 if (i + 1 < len) {
67 strcat(digits, ".");
69 if (strlen(digits) >= size) {
70 break;
72 strcpy(p, digits);
73 p += strlen(digits);
74 size -= strlen(digits);
76 return (buff);
79 char *
80 dumpHost(const struct hostent FAR *hp, char *buff, size_t size) {
81 char *p = buff;
83 p[0] = '\0';
84 if (strlen(hp->h_name) + 1 < size) {
85 sprintf(p, "%s ", hp->h_name);
86 p += strlen(p);
87 size -= strlen(p);
89 dumpAddr(hp->h_addr_list[0], hp->h_length, p, size);
90 return (buff);
93 char *
94 dumpName(const char *name, char *buff, size_t size) {
95 const char *sp;
96 char *dp;
98 for (sp = name, dp = buff; *sp != '\0'; sp++) {
99 if (*sp >= 0x21 && *sp <= 0x7e) {
100 if (size < 2) {
101 break;
103 *dp++ = *sp;
104 size--;
105 } else {
106 if (size < 5) {
107 break;
109 dp[0] = '\\';
110 dp[1] = 'x';
111 sprintf(dp + 2, "%02x", *sp & 0xff);
112 dp += 4;
113 size -= 4;
116 *dp = '\0';
118 return (buff);