1 /* $XConsortium: Xtrans.h,v 1.24 94/05/02 10:45:32 mor Exp $ */
2 /*
3 
4 Copyright (c) 1993, 1994  X Consortium
5 
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
13 
14 The above copyright notice and this permission notice shall be included
15 in all copies or substantial portions of the Software.
16 
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 OTHER DEALINGS IN THE SOFTWARE.
24 
25 Except as contained in this notice, the name of the X Consortium shall
26 not be used in advertising or otherwise to promote the sale, use or
27 other dealings in this Software without prior written authorization
28 from the X Consortium.
29 
30 */
31 
32 /* Copyright (c) 1993, 1994 NCR Corporation - Dayton, Ohio, USA
33  *
34  * All Rights Reserved
35  *
36  * Permission to use, copy, modify, and distribute this software and its
37  * documentation for any purpose and without fee is hereby granted, provided
38  * that the above copyright notice appear in all copies and that both that
39  * copyright notice and this permission notice appear in supporting
40  * documentation, and that the name NCR not be used in advertising
41  * or publicity pertaining to distribution of the software without specific,
42  * written prior permission.  NCR makes no representations about the
43  * suitability of this software for any purpose.  It is provided "as is"
44  * without express or implied warranty.
45  *
46  * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
47  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
48  * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
49  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
50  * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
51  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
52  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
53  */
54 
55 #ifndef _XTRANS_H_
56 #define _XTRANS_H_
57 
58 #include <X11/Xfuncproto.h>
59 #include <X11/Xos.h>
60 
61 
62 /*
63  * Set the functions names according to where this code is being compiled.
64  */
65 
66 #ifdef X11_t
67 #if (__STDC__ && !defined(UNIXCPP)) || defined(ANSICPP)
68 #define TRANS(func) _X11Trans##func
69 #else
70 #define TRANS(func) _X11Trans/**/func
71 #endif
72 #endif /* X11_t */
73 
74 #ifdef XSERV_t
75 #if (__STDC__ && !defined(UNIXCPP)) || defined(ANSICPP)
76 #define TRANS(func) _XSERVTrans##func
77 #else
78 #define TRANS(func) _XSERVTrans/**/func
79 #endif
80 #define X11_t
81 #endif /* X11_t */
82 
83 #ifdef XIM_t
84 #if (__STDC__ && !defined(UNIXCPP)) || defined(ANSICPP)
85 #define TRANS(func) _XimdXTrans##func
86 #else
87 #define TRANS(func) _XimdXTrans/**/func
88 #endif
89 #endif /* XIM_t */
90 
91 #ifdef FS_t
92 #if (__STDC__ && !defined(UNIXCPP)) || defined(ANSICPP)
93 #define TRANS(func) _FSTrans##func
94 #else
95 #define TRANS(func) _FSTrans/**/func
96 #endif
97 #endif /* FS_t */
98 
99 #ifdef FONT_t
100 #if (__STDC__ && !defined(UNIXCPP)) || defined(ANSICPP)
101 #define TRANS(func) _FontTrans##func
102 #else
103 #define TRANS(func) _FontTrans/**/func
104 #endif
105 #endif /* FONT_t */
106 
107 #ifdef ICE_t
108 #if (__STDC__ && !defined(UNIXCPP)) || defined(ANSICPP)
109 #define TRANS(func) _IceTrans##func
110 #else
111 #define TRANS(func) _IceTrans/**/func
112 #endif
113 #endif /* ICE_t */
114 
115 #ifdef TEST_t
116 #if (__STDC__ && !defined(UNIXCPP)) || defined(ANSICPP)
117 #define TRANS(func) _TESTTrans##func
118 #else
119 #define TRANS(func) _TESTTrans/**/func
120 #endif
121 #endif /* TEST_t */
122 
123 #if !defined(TRANS)
124 #if (__STDC__ && !defined(UNIXCPP)) || defined(ANSICPP)
125 #define TRANS(func) _XTrans##func
126 #else
127 #define TRANS(func) _XTrans/**/func
128 #endif
129 #endif /* !TRANS */
130 
131 
132 /*
133  * Create a single address structure that can be used wherever
134  * an address structure is needed. struct sockaddr is not big enough
135  * to hold a sockadd_un, so we create this definition to have a single
136  * structure that is big enough for all the structures we might need.
137  *
138  * This structure needs to be independent of the socket/TLI interface used.
139  */
140 
141 #define XTRANS_MAX_ADDR_LEN	128	/* large enough to hold sun_path */
142 
143 typedef	struct {
144     unsigned char	addr[XTRANS_MAX_ADDR_LEN];
145 } Xtransaddr;
146 
147 
148 #ifdef LONG64
149 typedef int BytesReadable_t;
150 #else
151 typedef long BytesReadable_t;
152 #endif
153 
154 
155 #if defined(WIN32) || (defined(USG) && !defined(CRAY) && !defined(umips) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__))
156 
157 /*
158  *      TRANS(Readv) and TRANS(Writev) use struct iovec, normally found
159  *      in Berkeley systems in <sys/uio.h>.  See the readv(2) and writev(2)
160  *      manual pages for details.
161  */
162 
163 struct iovec {
164     caddr_t iov_base;
165     int iov_len;
166 };
167 
168 #else
169 #include <sys/uio.h>
170 #endif
171 
172 typedef struct _XtransConnInfo *XtransConnInfo;
173 
174 
175 /*
176  * Transport Option definitions
177  */
178 
179 #define TRANS_NONBLOCKING	1
180 #define	TRANS_CLOSEONEXEC	2
181 
182 
183 /*
184  * Return values of Connect (0 is success)
185  */
186 
187 #define TRANS_CONNECT_FAILED 	-1
188 #define TRANS_TRY_CONNECT_AGAIN -2
189 
190 
191 /*
192  * Return values of Accept (0 is success)
193  */
194 
195 #define TRANS_ACCEPT_BAD_MALLOC			-1
196 #define TRANS_ACCEPT_FAILED 			-2
197 #define TRANS_ACCEPT_MISC_ERROR			-3
198 
199 
200 /*
201  * ResetListener return values
202  */
203 
204 #define TRANS_RESET_NOOP	1
205 #define TRANS_RESET_NEW_FD	2
206 #define TRANS_RESET_FAILURE	3
207 
208 
209 /*
210  * Function prototypes for the exposed interface
211  */
212 
213 #ifdef TRANS_CLIENT
214 
215 XtransConnInfo TRANS(OpenCOTSClient)(
216 #if NeedFunctionPrototypes
217     char *		/* address */
218 #endif
219 );
220 
221 #endif /* TRANS_CLIENT */
222 
223 #ifdef TRANS_SERVER
224 
225 XtransConnInfo TRANS(OpenCOTSServer)(
226 #if NeedFunctionPrototypes
227     char *		/* address */
228 #endif
229 );
230 
231 #endif /* TRANS_SERVER */
232 
233 #ifdef TRANS_CLIENT
234 
235 XtransConnInfo TRANS(OpenCLTSClient)(
236 #if NeedFunctionPrototypes
237     char *		/* address */
238 #endif
239 );
240 
241 #endif /* TRANS_CLIENT */
242 
243 #ifdef TRANS_SERVER
244 
245 XtransConnInfo TRANS(OpenCLTSServer)(
246 #if NeedFunctionPrototypes
247     char *		/* address */
248 #endif
249 );
250 
251 #endif /* TRANS_SERVER */
252 
253 #ifdef TRANS_REOPEN
254 
255 XtransConnInfo TRANS(ReopenCOTSServer)(
256 #if NeedFunctionPrototypes
257     int,		/* trans_id */
258     int,		/* fd */
259     char *		/* port */
260 #endif
261 );
262 
263 XtransConnInfo TRANS(ReopenCLTSServer)(
264 #if NeedFunctionPrototypes
265     int,		/* trans_id */
266     int,		/* fd */
267     char *		/* port */
268 #endif
269 );
270 
271 int TRANS(GetReopenInfo)(
272 #if NeedFunctionPrototypes
273     XtransConnInfo,	/* ciptr */
274     int *,		/* trans_id */
275     int *,		/* fd */
276     char **		/* port */
277 #endif
278 );
279 
280 #endif /* TRANS_REOPEN */
281 
282 
283 int TRANS(SetOption)(
284 #if NeedFunctionPrototypes
285     XtransConnInfo,	/* ciptr */
286     int,		/* option */
287     int			/* arg */
288 #endif
289 );
290 
291 #ifdef TRANS_SERVER
292 
293 int TRANS(CreateListener)(
294 #if NeedFunctionPrototypes
295     XtransConnInfo,	/* ciptr */
296     char *		/* port */
297 #endif
298 );
299 
300 int TRANS(ResetListener)(
301 #if NeedFunctionPrototypes
302     XtransConnInfo	/* ciptr */
303 #endif
304 );
305 
306 XtransConnInfo TRANS(Accept)(
307 #if NeedFunctionPrototypes
308     XtransConnInfo,	/* ciptr */
309     int *		/* status */
310 #endif
311 );
312 
313 #endif /* TRANS_SERVER */
314 
315 #ifdef TRANS_CLIENT
316 
317 int TRANS(Connect)(
318 #if NeedFunctionPrototypes
319     XtransConnInfo,	/* ciptr */
320     char *		/* address */
321 #endif
322 );
323 
324 #endif /* TRANS_CLIENT */
325 
326 int TRANS(BytesReadable)(
327 #if NeedFunctionPrototypes
328     XtransConnInfo,	/* ciptr */
329     BytesReadable_t *	/* pend */
330 #endif
331 );
332 
333 int TRANS(Read)(
334 #if NeedFunctionPrototypes
335     XtransConnInfo,	/* ciptr */
336     char *,		/* buf */
337     int			/* size */
338 #endif
339 );
340 
341 int TRANS(Write)(
342 #if NeedFunctionPrototypes
343     XtransConnInfo,	/* ciptr */
344     char *,		/* buf */
345     int			/* size */
346 #endif
347 );
348 
349 int TRANS(Readv)(
350 #if NeedFunctionPrototypes
351     XtransConnInfo,	/* ciptr */
352     struct iovec *,	/* buf */
353     int			/* size */
354 #endif
355 );
356 
357 int TRANS(Writev)(
358 #if NeedFunctionPrototypes
359     XtransConnInfo,	/* ciptr */
360     struct iovec *,	/* buf */
361     int			/* size */
362 #endif
363 );
364 
365 int TRANS(Disconnect)(
366 #if NeedFunctionPrototypes
367     XtransConnInfo	/* ciptr */
368 #endif
369 );
370 
371 int TRANS(Close)(
372 #if NeedFunctionPrototypes
373     XtransConnInfo	/* ciptr */
374 #endif
375 );
376 
377 int TRANS(CloseForCloning)(
378 #if NeedFunctionPrototypes
379     XtransConnInfo	/* ciptr */
380 #endif
381 );
382 
383 int TRANS(IsLocal)(
384 #if NeedFunctionPrototypes
385     XtransConnInfo	/* ciptr */
386 #endif
387 );
388 
389 int TRANS(GetMyAddr)(
390 #if NeedFunctionPrototypes
391     XtransConnInfo,	/* ciptr */
392     int *,		/* familyp */
393     int *,		/* addrlenp */
394     Xtransaddr **	/* addrp */
395 #endif
396 );
397 
398 int TRANS(GetPeerAddr)(
399 #if NeedFunctionPrototypes
400     XtransConnInfo,	/* ciptr */
401     int *,		/* familyp */
402     int *,		/* addrlenp */
403     Xtransaddr **	/* addrp */
404 #endif
405 );
406 
407 int TRANS(GetConnectionNumber)(
408 #if NeedFunctionPrototypes
409     XtransConnInfo	/* ciptr */
410 #endif
411 );
412 
413 #ifdef TRANS_SERVER
414 
415 int TRANS(MakeAllCOTSServerListeners)(
416 #if NeedFunctionPrototypes
417     char *,		/* port */
418     int *,		/* partial */
419     int *,		/* count_ret */
420     XtransConnInfo **	/* ciptrs_ret */
421 #endif
422 );
423 
424 int TRANS(MakeAllCLTSServerListeners)(
425 #if NeedFunctionPrototypes
426     char *,		/* port */
427     int *,		/* partial */
428     int *,		/* count_ret */
429     XtransConnInfo **	/* ciptrs_ret */
430 #endif
431 );
432 
433 #endif /* TRANS_SERVER */
434 
435 
436 /*
437  * Function Prototypes for Utility Functions.
438  */
439 
440 #ifdef X11_t
441 
442 int TRANS(ConvertAddress)(
443 #if NeedFunctionPrototypes
444     int *,		/* familyp */
445     int *,		/* addrlenp */
446     Xtransaddr *	/* addrp */
447 #endif
448 );
449 
450 #endif /* X11_t */
451 
452 #ifdef ICE_t
453 
454 char *
455 TRANS(GetMyNetworkId)(
456 #if NeedFunctionPrototypes
457     XtransConnInfo	/* ciptr */
458 #endif
459 );
460 
461 char *
462 TRANS(GetPeerNetworkId)(
463 #if NeedFunctionPrototypes
464     XtransConnInfo	/* ciptr */
465 #endif
466 );
467 
468 #endif /* ICE_t */
469 
470 #endif /* _XTRANS_H_ */
471