Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / contrib / idn / idnkit-1.0-src / wsock / wsock11 / dllfunc.c
blobd6558bf0e5daf09bdb3766dab54a23e511f58bbe
1 /* $NetBSD: dllfunc.c,v 1.3 2014/12/10 04:37:56 christos Exp $ */
3 /*
4 * dllfunc.c - wrapper functions
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>
53 #include <process.h>
55 #include "dlldef.h"
57 WRAPPER_EXPORT int PASCAL FAR
58 gethostname(char FAR * name, int namelen) {
59 int ret;
61 TRACE("ENTER gethostname\n");
62 ret = _org_gethostname(name, namelen);
63 TRACE("LEAVE gethostname %d <%-.100s>\n", ret, name);
65 return (ret);
68 WRAPPER_EXPORT struct hostent FAR * PASCAL FAR
69 gethostbyname(const char FAR * name) {
70 struct hostent FAR *ret;
71 char nbuff[256];
72 char hbuff[256];
73 BOOL stat;
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);
87 } else {
88 stat = idnConvReq(encodeCtx, name, nbuff, sizeof(nbuff));
89 if (stat == FALSE) {
90 TRACE("idnConvReq failed\n");
91 ret = NULL;
92 } else {
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,
103 sizeof(nbuff));
104 if (stat == FALSE) {
105 TRACE("Decoding failed - return the name verbatim\n");
106 } else {
107 TRACE("Converted Back <%s>\n",
108 dumpName(nbuff, hbuff, sizeof(hbuff)));
109 strcpy(ret->h_name, nbuff);
113 if (ret == NULL) {
114 TRACE("LEAVE gethostbyname NULL\n");
115 } else {
116 TRACE("LEAVE gethostbyname <%s>\n",
117 dumpHost(ret, hbuff, sizeof(hbuff)));
119 return (ret);
122 WRAPPER_EXPORT struct hostent FAR * PASCAL FAR
123 gethostbyaddr(const char FAR * addr, int len, int type) {
124 struct hostent FAR *ret;
125 char nbuff[256];
126 char abuff[256];
127 char hbuff[256];
128 BOOL stat;
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));
143 if (stat == FALSE) {
144 TRACE("Decoding failed - return the name verbatim\n");
145 } else {
146 TRACE("Converted Back <%s>\n",
147 dumpName(nbuff, hbuff, sizeof(hbuff)));
148 strcpy(ret->h_name, nbuff);
152 if (ret == NULL) {
153 TRACE("LEAVE gethostbyaddr NULL\n") ;
154 } else {
155 TRACE("LEAVE gethostbyaddr <%s>\n",
156 dumpHost(ret, hbuff, sizeof(hbuff)));
158 return (ret);
161 WRAPPER_EXPORT HANDLE PASCAL FAR
162 WSAAsyncGetHostByName(HWND hWnd, u_int wMsg,
163 const char FAR * name, char FAR * buf, int buflen)
165 HANDLE ret;
166 char nbuff[256];
167 char hbuff[256];
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,
176 buf, buflen);
177 } else {
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,
183 buf, buflen);
186 TRACE("LEAVE WSAAsyncGetHostByName HANDLE %08x\n", ret);
188 return (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)
195 HANDLE ret;
196 char abuff[256];
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,
208 buf, buflen);
209 TRACE("LEAVE WSAAsyncGetHostByAddr HANDLE %08x\n", ret);
211 return (ret);