1 /* $XConsortium: Xtrans.h,v 1.29 95/06/08 23:20:39 gildea Exp $ */
2 /* $XFree86: xc/lib/xtrans/Xtrans.h,v 3.9 1997/01/18 06:52:39 dawes Exp $ */
5 Copyright (c) 1993, 1994 X Consortium
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
15 The above copyright notice and this permission notice shall be included
16 in all copies or substantial portions of the Software.
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 OTHER DEALINGS IN THE SOFTWARE.
26 Except as contained in this notice, the name of the X Consortium shall
27 not be used in advertising or otherwise to promote the sale, use or
28 other dealings in this Software without prior written authorization
29 from the X Consortium.
33 /* Copyright (c) 1993, 1994 NCR Corporation - Dayton, Ohio, USA
37 * Permission to use, copy, modify, and distribute this software and its
38 * documentation for any purpose and without fee is hereby granted, provided
39 * that the above copyright notice appear in all copies and that both that
40 * copyright notice and this permission notice appear in supporting
41 * documentation, and that the name NCR not be used in advertising
42 * or publicity pertaining to distribution of the software without specific,
43 * written prior permission. NCR makes no representations about the
44 * suitability of this software for any purpose. It is provided "as is"
45 * without express or implied warranty.
47 * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
48 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
49 * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
50 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
51 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
52 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
53 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
59 #include <X11/Xfuncproto.h>
64 * Set the functions names according to where this code is being compiled.
68 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
69 #define TRANS(func) _X11Trans##func
71 #define TRANS(func) _X11Trans/**/func
73 static char* __xtransname = "_X11Trans";
77 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
78 #define TRANS(func) _XSERVTrans##func
80 #define TRANS(func) _XSERVTrans/**/func
82 static char* __xtransname = "_XSERVTrans";
87 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
88 #define TRANS(func) _XimXTrans##func
90 #define TRANS(func) _XimXTrans/**/func
92 static char* __xtransname = "_XimTrans";
96 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
97 #define TRANS(func) _FSTrans##func
99 #define TRANS(func) _FSTrans/**/func
101 static char* __xtransname = "_FSTrans";
105 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
106 #define TRANS(func) _FontTrans##func
108 #define TRANS(func) _FontTrans/**/func
110 static char* __xtransname = "_FontTrans";
114 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
115 #define TRANS(func) _IceTrans##func
117 #define TRANS(func) _IceTrans/**/func
119 static char* __xtransname = "_IceTrans";
123 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
124 #define TRANS(func) _TESTTrans##func
126 #define TRANS(func) _TESTTrans/**/func
128 static char* __xtransname = "_TESTTrans";
132 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
133 #define TRANS(func) _XTrans##func
135 #define TRANS(func) _XTrans/**/func
137 static char* __xtransname = "_XTrans";
142 * Create a single address structure that can be used wherever
143 * an address structure is needed. struct sockaddr is not big enough
144 * to hold a sockadd_un, so we create this definition to have a single
145 * structure that is big enough for all the structures we might need.
147 * This structure needs to be independent of the socket/TLI interface used.
150 #define XTRANS_MAX_ADDR_LEN 128 /* large enough to hold sun_path */
153 unsigned char addr[XTRANS_MAX_ADDR_LEN];
158 typedef int BytesReadable_t;
160 typedef long BytesReadable_t;
164 #if defined(WIN32) || (defined(USG) && !defined(CRAY) && !defined(umips) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__)) || defined(MINIX)
167 * TRANS(Readv) and TRANS(Writev) use struct iovec, normally found
168 * in Berkeley systems in <sys/uio.h>. See the readv(2) and writev(2)
169 * manual pages for details.
185 typedef struct _XtransConnInfo *XtransConnInfo;
189 * Transport Option definitions
192 #define TRANS_NONBLOCKING 1
193 #define TRANS_CLOSEONEXEC 2
197 * Return values of Connect (0 is success)
200 #define TRANS_CONNECT_FAILED -1
201 #define TRANS_TRY_CONNECT_AGAIN -2
205 * Return values of CreateListener (0 is success)
208 #define TRANS_CREATE_LISTENER_FAILED -1
209 #define TRANS_ADDR_IN_USE -2
213 * Return values of Accept (0 is success)
216 #define TRANS_ACCEPT_BAD_MALLOC -1
217 #define TRANS_ACCEPT_FAILED -2
218 #define TRANS_ACCEPT_MISC_ERROR -3
222 * ResetListener return values
225 #define TRANS_RESET_NOOP 1
226 #define TRANS_RESET_NEW_FD 2
227 #define TRANS_RESET_FAILURE 3
231 * Function prototypes for the exposed interface
236 XtransConnInfo TRANS(OpenCOTSClient)(
237 #if NeedFunctionPrototypes
242 #endif /* TRANS_CLIENT */
246 XtransConnInfo TRANS(OpenCOTSServer)(
247 #if NeedFunctionPrototypes
252 #endif /* TRANS_SERVER */
256 XtransConnInfo TRANS(OpenCLTSClient)(
257 #if NeedFunctionPrototypes
262 #endif /* TRANS_CLIENT */
266 XtransConnInfo TRANS(OpenCLTSServer)(
267 #if NeedFunctionPrototypes
272 #endif /* TRANS_SERVER */
276 XtransConnInfo TRANS(ReopenCOTSServer)(
277 #if NeedFunctionPrototypes
284 XtransConnInfo TRANS(ReopenCLTSServer)(
285 #if NeedFunctionPrototypes
292 int TRANS(GetReopenInfo)(
293 #if NeedFunctionPrototypes
294 XtransConnInfo, /* ciptr */
295 int *, /* trans_id */
301 #endif /* TRANS_REOPEN */
304 int TRANS(SetOption)(
305 #if NeedFunctionPrototypes
306 XtransConnInfo, /* ciptr */
314 int TRANS(CreateListener)(
315 #if NeedFunctionPrototypes
316 XtransConnInfo, /* ciptr */
321 int TRANS(NoListen) (
322 #if NeedFunctionPrototypes
327 int TRANS(ResetListener)(
328 #if NeedFunctionPrototypes
329 XtransConnInfo /* ciptr */
333 XtransConnInfo TRANS(Accept)(
334 #if NeedFunctionPrototypes
335 XtransConnInfo, /* ciptr */
340 #endif /* TRANS_SERVER */
345 #if NeedFunctionPrototypes
346 XtransConnInfo, /* ciptr */
351 #endif /* TRANS_CLIENT */
353 int TRANS(BytesReadable)(
354 #if NeedFunctionPrototypes
355 XtransConnInfo, /* ciptr */
356 BytesReadable_t * /* pend */
361 #if NeedFunctionPrototypes
362 XtransConnInfo, /* ciptr */
369 #if NeedFunctionPrototypes
370 XtransConnInfo, /* ciptr */
377 #if NeedFunctionPrototypes
378 XtransConnInfo, /* ciptr */
379 struct iovec *, /* buf */
385 #if NeedFunctionPrototypes
386 XtransConnInfo, /* ciptr */
387 struct iovec *, /* buf */
392 int TRANS(Disconnect)(
393 #if NeedFunctionPrototypes
394 XtransConnInfo /* ciptr */
399 #if NeedFunctionPrototypes
400 XtransConnInfo /* ciptr */
404 int TRANS(CloseForCloning)(
405 #if NeedFunctionPrototypes
406 XtransConnInfo /* ciptr */
411 #if NeedFunctionPrototypes
412 XtransConnInfo /* ciptr */
416 int TRANS(GetMyAddr)(
417 #if NeedFunctionPrototypes
418 XtransConnInfo, /* ciptr */
420 int *, /* addrlenp */
421 Xtransaddr ** /* addrp */
425 int TRANS(GetPeerAddr)(
426 #if NeedFunctionPrototypes
427 XtransConnInfo, /* ciptr */
429 int *, /* addrlenp */
430 Xtransaddr ** /* addrp */
434 int TRANS(GetConnectionNumber)(
435 #if NeedFunctionPrototypes
436 XtransConnInfo /* ciptr */
442 int TRANS(MakeAllCOTSServerListeners)(
443 #if NeedFunctionPrototypes
446 int *, /* count_ret */
447 XtransConnInfo ** /* ciptrs_ret */
451 int TRANS(MakeAllCLTSServerListeners)(
452 #if NeedFunctionPrototypes
455 int *, /* count_ret */
456 XtransConnInfo ** /* ciptrs_ret */
460 #endif /* TRANS_SERVER */
464 * Function Prototypes for Utility Functions.
469 int TRANS(ConvertAddress)(
470 #if NeedFunctionPrototypes
472 int *, /* addrlenp */
473 Xtransaddr ** /* addrp */
482 TRANS(GetMyNetworkId)(
483 #if NeedFunctionPrototypes
484 XtransConnInfo /* ciptr */
489 TRANS(GetPeerNetworkId)(
490 #if NeedFunctionPrototypes
491 XtransConnInfo /* ciptr */
497 #if defined(WIN32) && (defined(TCPCONN) || defined(DNETCONN))
498 int TRANS(WSAStartup)();
501 #endif /* _XTRANS_H_ */