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>
61 /* Not all clients make use of all provided statics */
62 #pragma clang diagnostic push
63 #pragma clang diagnostic ignored "-Wunused-function"
67 * Set the functions names according to where this code is being compiled.
71 #define TRANS(func) _X11Trans##func
73 static const char *__xtransname = "_X11Trans";
78 #define TRANS(func) _XSERVTrans##func
80 static const char *__xtransname = "_XSERVTrans";
86 #define TRANS(func) _XimXTrans##func
88 static const char *__xtransname = "_XimTrans";
93 #define TRANS(func) _FSTrans##func
95 static const char *__xtransname = "_FSTrans";
100 #define TRANS(func) _FontTrans##func
102 static const char *__xtransname = "_FontTrans";
107 #define TRANS(func) _IceTrans##func
109 static const char *__xtransname = "_IceTrans";
114 #define TRANS(func) _TESTTrans##func
116 static const char *__xtransname = "_TESTTrans";
121 #define TRANS(func) _LBXPROXYTrans##func
122 #define X11_t /* The server defines this - so should the LBX proxy */
124 static const char *__xtransname = "_LBXPROXYTrans";
126 #endif /* LBXPROXY_t */
129 #define TRANS(func) _XTrans##func
131 static const char *__xtransname = "_XTrans";
136 #pragma clang diagnostic pop
140 * Create a single address structure that can be used wherever
141 * an address structure is needed. struct sockaddr is not big enough
142 * to hold a sockadd_un, so we create this definition to have a single
143 * structure that is big enough for all the structures we might need.
145 * This structure needs to be independent of the socket/TLI interface used.
148 #if defined(IPv6) && defined(AF_INET6)
149 typedef struct sockaddr_storage Xtransaddr;
151 #define XTRANS_MAX_ADDR_LEN 128 /* large enough to hold sun_path */
154 unsigned char addr[XTRANS_MAX_ADDR_LEN];
159 typedef int BytesReadable_t;
161 typedef long BytesReadable_t;
165 #if defined(WIN32) || defined(USG)
168 * TRANS(Readv) and TRANS(Writev) use struct iovec, normally found
169 * in Berkeley systems in <sys/uio.h>. See the readv(2) and writev(2)
170 * manual pages for details.
182 typedef struct _XtransConnInfo *XtransConnInfo;
186 * Transport Option definitions
189 #define TRANS_NONBLOCKING 1
190 #define TRANS_CLOSEONEXEC 2
194 * Return values of Connect (0 is success)
197 #define TRANS_CONNECT_FAILED -1
198 #define TRANS_TRY_CONNECT_AGAIN -2
199 #define TRANS_IN_PROGRESS -3
203 * Return values of CreateListener (0 is success)
206 #define TRANS_CREATE_LISTENER_FAILED -1
207 #define TRANS_ADDR_IN_USE -2
211 * Return values of Accept (0 is success)
214 #define TRANS_ACCEPT_BAD_MALLOC -1
215 #define TRANS_ACCEPT_FAILED -2
216 #define TRANS_ACCEPT_MISC_ERROR -3
220 * ResetListener return values
223 #define TRANS_RESET_NOOP 1
224 #define TRANS_RESET_NEW_FD 2
225 #define TRANS_RESET_FAILURE 3
229 * Function prototypes for the exposed interface
232 void TRANS(FreeConnInfo) (
233 XtransConnInfo /* ciptr */
238 XtransConnInfo TRANS(OpenCOTSClient)(
242 #endif /* TRANS_CLIENT */
246 XtransConnInfo TRANS(OpenCOTSServer)(
250 #endif /* TRANS_SERVER */
254 XtransConnInfo TRANS(OpenCLTSClient)(
258 #endif /* TRANS_CLIENT */
262 XtransConnInfo TRANS(OpenCLTSServer)(
266 #endif /* TRANS_SERVER */
270 XtransConnInfo TRANS(ReopenCOTSServer)(
276 XtransConnInfo TRANS(ReopenCLTSServer)(
282 int TRANS(GetReopenInfo)(
283 XtransConnInfo, /* ciptr */
284 int *, /* trans_id */
289 #endif /* TRANS_REOPEN */
292 int TRANS(SetOption)(
293 XtransConnInfo, /* ciptr */
300 int TRANS(CreateListener)(
301 XtransConnInfo, /* ciptr */
303 unsigned int /* flags */
306 int TRANS(NoListen) (
307 const char* /* protocol*/
310 int TRANS(ResetListener)(
311 XtransConnInfo /* ciptr */
314 XtransConnInfo TRANS(Accept)(
315 XtransConnInfo, /* ciptr */
319 #endif /* TRANS_SERVER */
324 XtransConnInfo, /* ciptr */
328 #endif /* TRANS_CLIENT */
330 int TRANS(BytesReadable)(
331 XtransConnInfo, /* ciptr */
332 BytesReadable_t * /* pend */
336 XtransConnInfo, /* ciptr */
342 XtransConnInfo, /* ciptr */
348 XtransConnInfo, /* ciptr */
349 struct iovec *, /* buf */
354 XtransConnInfo, /* ciptr */
355 struct iovec *, /* buf */
359 int TRANS(Disconnect)(
360 XtransConnInfo /* ciptr */
364 XtransConnInfo /* ciptr */
367 int TRANS(CloseForCloning)(
368 XtransConnInfo /* ciptr */
372 XtransConnInfo /* ciptr */
375 int TRANS(GetMyAddr)(
376 XtransConnInfo, /* ciptr */
378 int *, /* addrlenp */
379 Xtransaddr ** /* addrp */
382 int TRANS(GetPeerAddr)(
383 XtransConnInfo, /* ciptr */
385 int *, /* addrlenp */
386 Xtransaddr ** /* addrp */
389 int TRANS(GetConnectionNumber)(
390 XtransConnInfo /* ciptr */
395 int TRANS(MakeAllCOTSServerListeners)(
398 int *, /* count_ret */
399 XtransConnInfo ** /* ciptrs_ret */
402 int TRANS(MakeAllCLTSServerListeners)(
405 int *, /* count_ret */
406 XtransConnInfo ** /* ciptrs_ret */
409 #endif /* TRANS_SERVER */
413 * Function Prototypes for Utility Functions.
418 int TRANS(ConvertAddress)(
420 int *, /* addrlenp */
421 Xtransaddr ** /* addrp */
429 TRANS(GetMyNetworkId)(
430 XtransConnInfo /* ciptr */
434 TRANS(GetPeerNetworkId)(
435 XtransConnInfo /* ciptr */
446 #if defined(WIN32) && defined(TCPCONN)
447 int TRANS(WSAStartup)();
450 #endif /* _XTRANS_H_ */