1 /* $NetBSD: dllfunc.c,v 1.3 2014/12/10 04:37:56 christos Exp $ */
4 * dllfunc.c - wrapper functions
8 * Copyright (c) 2000 Japan Network Information Center. All rights reserved.
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
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.
57 WRAPPER_EXPORT
int PASCAL FAR
58 gethostname(char FAR
* name
, int namelen
) {
61 TRACE("ENTER gethostname\n");
62 ret
= _org_gethostname(name
, namelen
);
63 TRACE("LEAVE gethostname %d <%-.100s>\n", ret
, name
);
68 WRAPPER_EXPORT
struct hostent FAR
* PASCAL FAR
69 gethostbyname(const char FAR
* name
) {
70 struct hostent FAR
*ret
;
74 idn_resconf_t encodeCtx
;
76 TRACE("ENTER gethostbyname <%-.100s>\n",
77 (name
!= NULL
? name
: "NULL"));
79 encodeCtx
= idnGetContext();
81 if (encodeCtx
== NULL
) {
82 TRACE("gethostbyname: not encode here\n");
83 ret
= _org_gethostbyname(name
);
84 } else if (name
== NULL
) {
85 TRACE("gethostbyname: name is NULL\n");
86 ret
= _org_gethostbyname(name
);
88 stat
= idnConvReq(encodeCtx
, name
, nbuff
, sizeof(nbuff
));
90 TRACE("idnConvReq failed\n");
93 TRACE("Converted Name <%s>\n",
94 dumpName(nbuff
, hbuff
, sizeof(hbuff
)));
95 ret
= _org_gethostbyname(nbuff
);
99 if (ret
!= NULL
&& encodeCtx
!= NULL
) {
100 TRACE("Resulting Name <%s>\n",
101 dumpName(ret
->h_name
, hbuff
, sizeof(hbuff
)));
102 stat
= idnConvRsp(encodeCtx
, ret
->h_name
, nbuff
,
105 TRACE("Decoding failed - return the name verbatim\n");
107 TRACE("Converted Back <%s>\n",
108 dumpName(nbuff
, hbuff
, sizeof(hbuff
)));
109 strcpy(ret
->h_name
, nbuff
);
114 TRACE("LEAVE gethostbyname NULL\n");
116 TRACE("LEAVE gethostbyname <%s>\n",
117 dumpHost(ret
, hbuff
, sizeof(hbuff
)));
122 WRAPPER_EXPORT
struct hostent FAR
* PASCAL FAR
123 gethostbyaddr(const char FAR
* addr
, int len
, int type
) {
124 struct hostent FAR
*ret
;
129 idn_resconf_t encodeCtx
;
131 TRACE("ENTER gethostbyaddr <%s>\n",
132 dumpAddr(addr
, len
, abuff
, sizeof(abuff
)));
134 encodeCtx
= idnGetContext();
136 ret
= _org_gethostbyaddr(addr
, len
, type
);
138 if (ret
!= NULL
&& encodeCtx
!= NULL
) {
139 TRACE("Resulting Name <%s>\n",
140 dumpName(ret
->h_name
, hbuff
, sizeof(hbuff
)));
141 stat
= idnConvRsp(encodeCtx
, ret
->h_name
,
142 nbuff
, sizeof(nbuff
));
144 TRACE("Decoding failed - return the name verbatim\n");
146 TRACE("Converted Back <%s>\n",
147 dumpName(nbuff
, hbuff
, sizeof(hbuff
)));
148 strcpy(ret
->h_name
, nbuff
);
153 TRACE("LEAVE gethostbyaddr NULL\n") ;
155 TRACE("LEAVE gethostbyaddr <%s>\n",
156 dumpHost(ret
, hbuff
, sizeof(hbuff
)));
161 WRAPPER_EXPORT HANDLE PASCAL FAR
162 WSAAsyncGetHostByName(HWND hWnd
, u_int wMsg
,
163 const char FAR
* name
, char FAR
* buf
, int buflen
)
168 idn_resconf_t encodeCtx
;
170 TRACE("ENTER WSAAsyncGetHostByName <%-.100s>\n", name
);
172 encodeCtx
= idnGetContext();
174 if (encodeCtx
== NULL
|| name
== NULL
) {
175 ret
= _org_WSAAsyncGetHostByName(hWnd
, wMsg
, name
,
178 idnHook(hWnd
, wMsg
, buf
, encodeCtx
);
179 idnConvReq(encodeCtx
, name
, nbuff
, sizeof(nbuff
));
180 TRACE("Converted Name <%s>\n",
181 dumpName(nbuff
, hbuff
, sizeof(hbuff
)));
182 ret
= _org_WSAAsyncGetHostByName(hWnd
, wMsg
, nbuff
,
186 TRACE("LEAVE WSAAsyncGetHostByName HANDLE %08x\n", ret
);
191 WRAPPER_EXPORT HANDLE PASCAL FAR
192 WSAAsyncGetHostByAddr(HWND hWnd
, u_int wMsg
, const char FAR
* addr
,
193 int len
, int type
, char FAR
* buf
, int buflen
)
197 idn_resconf_t encodeCtx
;
199 encodeCtx
= idnGetContext();
201 if (encodeCtx
!= NULL
) {
202 idnHook(hWnd
, wMsg
, buf
, encodeCtx
);
205 TRACE("ENTER WSAAsyncGetHostByAddr <%s>\n",
206 dumpAddr(addr
, len
, abuff
, sizeof(abuff
)));
207 ret
= _org_WSAAsyncGetHostByAddr(hWnd
, wMsg
, addr
, len
, type
,
209 TRACE("LEAVE WSAAsyncGetHostByAddr HANDLE %08x\n", ret
);