3 Copyright 1993, 1994, 1998 The Open Group
5 Permission to use, copy, modify, distribute, and sell this software and its
6 documentation for any purpose is hereby granted without fee, provided that
7 the above copyright notice appear in all copies and that both that
8 copyright notice and this permission notice appear in supporting
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 OTHER DEALINGS IN THE SOFTWARE.
22 Except as contained in this notice, the name of The Open Group shall
23 not be used in advertising or otherwise to promote the sale, use or
24 other dealings in this Software without prior written authorization
27 * Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
31 * Permission to use, copy, modify, and distribute this software and its
32 * documentation for any purpose and without fee is hereby granted, provided
33 * that the above copyright notice appear in all copies and that both that
34 * copyright notice and this permission notice appear in supporting
35 * documentation, and that the name NCR not be used in advertising
36 * or publicity pertaining to distribution of the software without specific,
37 * written prior permission. NCR makes no representations about the
38 * suitability of this software for any purpose. It is provided "as is"
39 * without express or implied warranty.
41 * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
42 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
43 * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
44 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
45 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
46 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
47 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
53 #include <X11/Xfuncproto.h>
57 #include <sys/socket.h>
62 * Set the functions names according to where this code is being compiled.
66 #if !defined(UNIXCPP) || defined(ANSICPP)
67 #define TRANS(func) _X11Trans##func
69 #define TRANS(func) _X11Trans/**/func
72 static char* __xtransname = "_X11Trans";
77 #if !defined(UNIXCPP) || defined(ANSICPP)
78 #define TRANS(func) _XSERVTrans##func
80 #define TRANS(func) _XSERVTrans/**/func
83 static char* __xtransname = "_XSERVTrans";
89 #if !defined(UNIXCPP) || defined(ANSICPP)
90 #define TRANS(func) _XimXTrans##func
92 #define TRANS(func) _XimXTrans/**/func
95 static char* __xtransname = "_XimTrans";
100 #if !defined(UNIXCPP) || defined(ANSICPP)
101 #define TRANS(func) _FSTrans##func
103 #define TRANS(func) _FSTrans/**/func
106 static char* __xtransname = "_FSTrans";
111 #if !defined(UNIXCPP) || defined(ANSICPP)
112 #define TRANS(func) _FontTrans##func
114 #define TRANS(func) _FontTrans/**/func
117 static char* __xtransname = "_FontTrans";
122 #if !defined(UNIXCPP) || defined(ANSICPP)
123 #define TRANS(func) _IceTrans##func
125 #define TRANS(func) _IceTrans/**/func
128 static char* __xtransname = "_IceTrans";
133 #if !defined(UNIXCPP) || defined(ANSICPP)
134 #define TRANS(func) _TESTTrans##func
136 #define TRANS(func) _TESTTrans/**/func
139 static char* __xtransname = "_TESTTrans";
144 #if !defined(UNIXCPP) || defined(ANSICPP)
145 #define TRANS(func) _LBXPROXYTrans##func
147 #define TRANS(func) _LBXPROXYTrans/**/func
149 #define X11_t /* The server defines this - so should the LBX proxy */
151 static char* __xtransname = "_LBXPROXYTrans";
153 #endif /* LBXPROXY_t */
156 #if !defined(UNIXCPP) || defined(ANSICPP)
157 #define TRANS(func) _XTrans##func
159 #define TRANS(func) _XTrans/**/func
162 static char* __xtransname = "_XTrans";
168 * Create a single address structure that can be used wherever
169 * an address structure is needed. struct sockaddr is not big enough
170 * to hold a sockadd_un, so we create this definition to have a single
171 * structure that is big enough for all the structures we might need.
173 * This structure needs to be independent of the socket/TLI interface used.
176 #if defined(IPv6) && defined(AF_INET6)
177 typedef struct sockaddr_storage Xtransaddr;
179 #define XTRANS_MAX_ADDR_LEN 128 /* large enough to hold sun_path */
182 unsigned char addr[XTRANS_MAX_ADDR_LEN];
187 typedef int BytesReadable_t;
189 typedef long BytesReadable_t;
193 #if defined(WIN32) || defined(USG)
196 * TRANS(Readv) and TRANS(Writev) use struct iovec, normally found
197 * in Berkeley systems in <sys/uio.h>. See the readv(2) and writev(2)
198 * manual pages for details.
210 typedef struct _XtransConnInfo *XtransConnInfo;
214 * Transport Option definitions
217 #define TRANS_NONBLOCKING 1
218 #define TRANS_CLOSEONEXEC 2
222 * Return values of Connect (0 is success)
225 #define TRANS_CONNECT_FAILED -1
226 #define TRANS_TRY_CONNECT_AGAIN -2
227 #define TRANS_IN_PROGRESS -3
231 * Return values of CreateListener (0 is success)
234 #define TRANS_CREATE_LISTENER_FAILED -1
235 #define TRANS_ADDR_IN_USE -2
239 * Return values of Accept (0 is success)
242 #define TRANS_ACCEPT_BAD_MALLOC -1
243 #define TRANS_ACCEPT_FAILED -2
244 #define TRANS_ACCEPT_MISC_ERROR -3
248 * ResetListener return values
251 #define TRANS_RESET_NOOP 1
252 #define TRANS_RESET_NEW_FD 2
253 #define TRANS_RESET_FAILURE 3
257 * Function prototypes for the exposed interface
260 void TRANS(FreeConnInfo) (
261 XtransConnInfo /* ciptr */
266 XtransConnInfo TRANS(OpenCOTSClient)(
270 #endif /* TRANS_CLIENT */
274 XtransConnInfo TRANS(OpenCOTSServer)(
278 #endif /* TRANS_SERVER */
282 XtransConnInfo TRANS(OpenCLTSClient)(
286 #endif /* TRANS_CLIENT */
290 XtransConnInfo TRANS(OpenCLTSServer)(
294 #endif /* TRANS_SERVER */
298 XtransConnInfo TRANS(ReopenCOTSServer)(
304 XtransConnInfo TRANS(ReopenCLTSServer)(
310 int TRANS(GetReopenInfo)(
311 XtransConnInfo, /* ciptr */
312 int *, /* trans_id */
317 #endif /* TRANS_REOPEN */
320 int TRANS(SetOption)(
321 XtransConnInfo, /* ciptr */
328 int TRANS(CreateListener)(
329 XtransConnInfo, /* ciptr */
331 unsigned int /* flags */
334 int TRANS(NoListen) (
338 int TRANS(ResetListener)(
339 XtransConnInfo /* ciptr */
342 XtransConnInfo TRANS(Accept)(
343 XtransConnInfo, /* ciptr */
347 #endif /* TRANS_SERVER */
352 XtransConnInfo, /* ciptr */
356 #endif /* TRANS_CLIENT */
358 int TRANS(BytesReadable)(
359 XtransConnInfo, /* ciptr */
360 BytesReadable_t * /* pend */
364 XtransConnInfo, /* ciptr */
370 XtransConnInfo, /* ciptr */
376 XtransConnInfo, /* ciptr */
377 struct iovec *, /* buf */
382 XtransConnInfo, /* ciptr */
383 struct iovec *, /* buf */
387 int TRANS(Disconnect)(
388 XtransConnInfo /* ciptr */
392 XtransConnInfo /* ciptr */
395 int TRANS(CloseForCloning)(
396 XtransConnInfo /* ciptr */
400 XtransConnInfo /* ciptr */
403 int TRANS(GetMyAddr)(
404 XtransConnInfo, /* ciptr */
406 int *, /* addrlenp */
407 Xtransaddr ** /* addrp */
410 int TRANS(GetPeerAddr)(
411 XtransConnInfo, /* ciptr */
413 int *, /* addrlenp */
414 Xtransaddr ** /* addrp */
417 int TRANS(GetConnectionNumber)(
418 XtransConnInfo /* ciptr */
423 int TRANS(MakeAllCOTSServerListeners)(
426 int *, /* count_ret */
427 XtransConnInfo ** /* ciptrs_ret */
430 int TRANS(MakeAllCLTSServerListeners)(
433 int *, /* count_ret */
434 XtransConnInfo ** /* ciptrs_ret */
437 #endif /* TRANS_SERVER */
441 * Function Prototypes for Utility Functions.
446 int TRANS(ConvertAddress)(
448 int *, /* addrlenp */
449 Xtransaddr ** /* addrp */
457 TRANS(GetMyNetworkId)(
458 XtransConnInfo /* ciptr */
462 TRANS(GetPeerNetworkId)(
463 XtransConnInfo /* ciptr */
474 #if defined(WIN32) && defined(TCPCONN)
475 int TRANS(WSAStartup)();
478 #endif /* _XTRANS_H_ */