00001 /* $TOG: Xtrans.h /main/31 1998年02月06日 15:55:22 kaleb $ */
00002 /*
00003
00004 Copyright 1993, 1994, 1998 The Open Group
00005
00006 All Rights Reserved.
00007
00008 The above copyright notice and this permission notice shall be included
00009 in all copies or substantial portions of the Software.
00010
00011 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00012 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00013 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00014 IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
00015 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00016 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00017 OTHER DEALINGS IN THE SOFTWARE.
00018
00019 Except as contained in this notice, the name of The Open Group shall
00020 not be used in advertising or otherwise to promote the sale, use or
00021 other dealings in this Software without prior written authorization
00022 from The Open Group.
00023
00024 */
00025 /* $XFree86: xc/lib/xtrans/Xtrans.h,v 3.14 1999年12月13日 02:52:54 robin Exp $ */
00026
00027 /* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA
00028 *
00029 * All Rights Reserved
00030 *
00031 * Permission to use, copy, modify, and distribute this software and its
00032 * documentation for any purpose and without fee is hereby granted, provided
00033 * that the above copyright notice appear in all copies and that both that
00034 * copyright notice and this permission notice appear in supporting
00035 * documentation, and that the name NCR not be used in advertising
00036 * or publicity pertaining to distribution of the software without specific,
00037 * written prior permission. NCR makes no representations about the
00038 * suitability of this software for any purpose. It is provided "as is"
00039 * without express or implied warranty.
00040 *
00041 * NCR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
00042 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
00043 * NO EVENT SHALL NCR BE LIABLE FOR ANY SPECIAL, INDIRECT OR
00044 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
00045 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
00046 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
00047 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
00048 */
00049
00050 #ifndef _XTRANS_H_
00051 #define _XTRANS_H_
00052
00053 #include "config.h"
00054 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
00055 #include <X11/Xfuncproto.h>
00056 #include <X11/Xos.h>
00057 #else
00058 #include <KDE-ICE/Xfuncproto.h>
00059 #include <fcntl.h>
00060 #endif
00061
00062 /*
00063 * Set the functions names according to where this code is being compiled.
00064 */
00065
00066 #ifdef X11_t
00067 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
00068 #define TRANS(func) _X11Trans##func
00069 #else
00070 #define TRANS(func) _X11Transfunc
00071 #endif
00072 #ifdef XTRANSDEBUG
00073 static char* __xtransname = "_X11Trans";
00074 #endif
00075 #endif /* X11_t */
00076
00077 #ifdef XSERV_t
00078 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
00079 #define TRANS(func) _XSERVTrans##func
00080 #else
00081 #define TRANS(func) _XSERVTransfunc
00082 #endif
00083 #ifdef XTRANSDEBUG
00084 static char* __xtransname = "_XSERVTrans";
00085 #endif
00086 #define X11_t
00087 #endif /* X11_t */
00088
00089 #ifdef XIM_t
00090 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
00091 #define TRANS(func) _XimXTrans##func
00092 #else
00093 #define TRANS(func) _XimXTransfunc
00094 #endif
00095 #ifdef XTRANSDEBUG
00096 static char* __xtransname = "_XimTrans";
00097 #endif
00098 #endif /* XIM_t */
00099
00100 #ifdef FS_t
00101 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
00102 #define TRANS(func) _FSTrans##func
00103 #else
00104 #define TRANS(func) _FSTransfunc
00105 #endif
00106 #ifdef XTRANSDEBUG
00107 static char* __xtransname = "_FSTrans";
00108 #endif
00109 #endif /* FS_t */
00110
00111 #ifdef FONT_t
00112 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
00113 #define TRANS(func) _FontTrans##func
00114 #else
00115 #define TRANS(func) _FontTransfunc
00116 #endif
00117 #ifdef XTRANSDEBUG
00118 static char* __xtransname = "_FontTrans";
00119 #endif
00120 #endif /* FONT_t */
00121
00122 #ifdef ICE_t
00123 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
00124 #define TRANS(func) _kde_IceTrans##func
00125 #else
00126 #define TRANS(func) _kde_IceTransfunc
00127 #endif
00128 #ifdef XTRANSDEBUG
00129 static char* __xtransname = (char *)"_kde_IceTrans";
00130 #endif
00131 #endif /* ICE_t */
00132
00133 #ifdef TEST_t
00134 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
00135 #define TRANS(func) _TESTTrans##func
00136 #else
00137 #define TRANS(func) _TESTTransfunc
00138 #endif
00139 #ifdef XTRANSDEBUG
00140 static char* __xtransname = "_TESTTrans";
00141 #endif
00142 #endif /* TEST_t */
00143
00144 #ifdef LBXPROXY_t
00145 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
00146 #define TRANS(func) _LBXPROXYTrans##func
00147 #else
00148 #define TRANS(func) _LBXPROXYTransfunc
00149 #endif
00150 #define X11_t /* The server defines this - so should the LBX proxy */
00151 #ifdef XTRANSDEBUG
00152 static char* __xtransname = "_LBXPROXYTrans";
00153 #endif
00154 #endif /* LBXPROXY_t */
00155
00156 #if !defined(TRANS)
00157 #if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
00158 #define TRANS(func) _XTrans##func
00159 #else
00160 #define TRANS(func) _XTransfunc
00161 #endif
00162 #ifdef XTRANSDEBUG
00163 static char* __xtransname = "_XTrans";
00164 #endif
00165 #endif /* !TRANS */
00166
00167
00168 /*
00169 * Create a single address structure that can be used wherever
00170 * an address structure is needed. struct sockaddr is not big enough
00171 * to hold a sockadd_un, so we create this definition to have a single
00172 * structure that is big enough for all the structures we might need.
00173 *
00174 * This structure needs to be independent of the socket/TLI interface used.
00175 */
00176
00177 #define XTRANS_MAX_ADDR_LEN 128 /* large enough to hold sun_path */
00178
00179 typedef struct {
00180 unsigned char addr[XTRANS_MAX_ADDR_LEN];
00181 } Xtransaddr;
00182
00183
00184 #ifdef LONG64
00185 typedef int BytesReadable_t;
00186 #else
00187 typedef long BytesReadable_t;
00188 #endif
00189
00190
00191 #if defined(_WIN32) || (defined(USG) && !defined(CRAY) && !defined(umips) && !defined(MOTOROLA) && !defined(uniosu) && !defined(__sxg__)) || defined(MINIX)
00192
00193 /*
00194 * TRANS(Readv) and TRANS(Writev) use struct iovec, normally found
00195 * in Berkeley systems in <sys/uio.h>. See the readv(2) and writev(2)
00196 * manual pages for details.
00197 */
00198
00199 struct iovec {
00200 caddr_t iov_base;
00201 int iov_len;
00202 };
00203
00204 #else
00205 #ifndef Lynx
00206 #include <sys/uio.h>
00207 #else
00208 #include <uio.h>
00209 #endif
00210 #endif
00211
00212 typedef struct _XtransConnInfo *XtransConnInfo;
00213
00214
00215 /*
00216 * Transport Option definitions
00217 */
00218
00219 #define TRANS_NONBLOCKING 1
00220 #define TRANS_CLOSEONEXEC 2
00221
00222
00223 /*
00224 * Return values of Connect (0 is success)
00225 */
00226
00227 #define TRANS_CONNECT_FAILED -1
00228 #define TRANS_TRY_CONNECT_AGAIN -2
00229 #define TRANS_IN_PROGRESS -3
00230
00231
00232 /*
00233 * Return values of CreateListener (0 is success)
00234 */
00235
00236 #define TRANS_CREATE_LISTENER_FAILED -1
00237 #define TRANS_ADDR_IN_USE -2
00238
00239
00240 /*
00241 * Return values of Accept (0 is success)
00242 */
00243
00244 #define TRANS_ACCEPT_BAD_MALLOC -1
00245 #define TRANS_ACCEPT_FAILED -2
00246 #define TRANS_ACCEPT_MISC_ERROR -3
00247
00248
00249 /*
00250 * ResetListener return values
00251 */
00252
00253 #define TRANS_RESET_NOOP 1
00254 #define TRANS_RESET_NEW_FD 2
00255 #define TRANS_RESET_FAILURE 3
00256
00257
00258 /*
00259 * Function prototypes for the exposed interface
00260 */
00261
00262 void TRANS(FreeConnInfo) (
00263 XtransConnInfo /* ciptr */
00264 );
00265
00266 #ifdef TRANS_CLIENT
00267
00268 XtransConnInfo TRANS(OpenCOTSClient)(
00269 char * /* address */
00270 );
00271
00272 #endif /* TRANS_CLIENT */
00273
00274 #ifdef TRANS_SERVER
00275
00276 XtransConnInfo TRANS(OpenCOTSServer)(
00277 char * /* address */
00278 );
00279
00280 #endif /* TRANS_SERVER */
00281
00282 #ifdef TRANS_CLIENT
00283
00284 XtransConnInfo TRANS(OpenCLTSClient)(
00285 char * /* address */
00286 );
00287
00288 #endif /* TRANS_CLIENT */
00289
00290 #ifdef TRANS_SERVER
00291
00292 XtransConnInfo TRANS(OpenCLTSServer)(
00293 char * /* address */
00294 );
00295
00296 #endif /* TRANS_SERVER */
00297
00298 #ifdef TRANS_REOPEN
00299
00300 XtransConnInfo TRANS(ReopenCOTSServer)(
00301 int, /* trans_id */
00302 int, /* fd */
00303 char * /* port */
00304 );
00305
00306 XtransConnInfo TRANS(ReopenCLTSServer)(
00307 int, /* trans_id */
00308 int, /* fd */
00309 char * /* port */
00310 );
00311
00312 int TRANS(GetReopenInfo)(
00313 XtransConnInfo, /* ciptr */
00314 int *, /* trans_id */
00315 int *, /* fd */
00316 char ** /* port */
00317 );
00318
00319 #endif /* TRANS_REOPEN */
00320
00321
00322 int TRANS(SetOption)(
00323 XtransConnInfo, /* ciptr */
00324 int, /* option */
00325 int /* arg */
00326 );
00327
00328 #ifdef TRANS_SERVER
00329
00330 int TRANS(CreateListener)(
00331 XtransConnInfo, /* ciptr */
00332 char * /* port */
00333 );
00334
00335 int TRANS(NoListen) (
00336 char* /* protocol*/
00337 );
00338
00339 int TRANS(ResetListener)(
00340 XtransConnInfo /* ciptr */
00341 );
00342
00343 XtransConnInfo TRANS(Accept)(
00344 XtransConnInfo, /* ciptr */
00345 int * /* status */
00346 );
00347
00348 #endif /* TRANS_SERVER */
00349
00350 #ifdef TRANS_CLIENT
00351
00352 int TRANS(Connect)(
00353 XtransConnInfo, /* ciptr */
00354 char * /* address */
00355 );
00356
00357 #endif /* TRANS_CLIENT */
00358
00359 int TRANS(BytesReadable)(
00360 XtransConnInfo, /* ciptr */
00361 BytesReadable_t * /* pend */
00362 );
00363
00364 int TRANS(Read)(
00365 XtransConnInfo, /* ciptr */
00366 char *, /* buf */
00367 int /* size */
00368 );
00369
00370 int TRANS(Write)(
00371 XtransConnInfo, /* ciptr */
00372 char *, /* buf */
00373 int /* size */
00374 );
00375
00376 int TRANS(Readv)(
00377 XtransConnInfo, /* ciptr */
00378 struct iovec *, /* buf */
00379 int /* size */
00380 );
00381
00382 int TRANS(Writev)(
00383 XtransConnInfo, /* ciptr */
00384 struct iovec *, /* buf */
00385 int /* size */
00386 );
00387
00388 int TRANS(Disconnect)(
00389 XtransConnInfo /* ciptr */
00390 );
00391
00392 int TRANS(Close)(
00393 XtransConnInfo /* ciptr */
00394 );
00395
00396 int TRANS(CloseForCloning)(
00397 XtransConnInfo /* ciptr */
00398 );
00399
00400 int TRANS(IsLocal)(
00401 XtransConnInfo /* ciptr */
00402 );
00403
00404 int TRANS(GetMyAddr)(
00405 XtransConnInfo, /* ciptr */
00406 int *, /* familyp */
00407 int *, /* addrlenp */
00408 Xtransaddr ** /* addrp */
00409 );
00410
00411 int TRANS(GetPeerAddr)(
00412 XtransConnInfo, /* ciptr */
00413 int *, /* familyp */
00414 int *, /* addrlenp */
00415 Xtransaddr ** /* addrp */
00416 );
00417
00418 int TRANS(GetConnectionNumber)(
00419 XtransConnInfo /* ciptr */
00420 );
00421
00422 #ifdef TRANS_SERVER
00423
00424 int TRANS(MakeAllCOTSServerListeners)(
00425 char *, /* port */
00426 int *, /* partial */
00427 int *, /* count_ret */
00428 XtransConnInfo ** /* ciptrs_ret */
00429 );
00430
00431 int TRANS(MakeAllCLTSServerListeners)(
00432 char *, /* port */
00433 int *, /* partial */
00434 int *, /* count_ret */
00435 XtransConnInfo ** /* ciptrs_ret */
00436 );
00437
00438 #endif /* TRANS_SERVER */
00439
00440
00441 /*
00442 * Function Prototypes for Utility Functions.
00443 */
00444
00445 #ifdef X11_t
00446
00447 int TRANS(ConvertAddress)(
00448 int *, /* familyp */
00449 int *, /* addrlenp */
00450 Xtransaddr ** /* addrp */
00451 );
00452
00453 #endif /* X11_t */
00454
00455 #if defined(ICE_t)
00456
00457 char *
00458 TRANS(GetMyNetworkId)(
00459 XtransConnInfo /* ciptr */
00460 );
00461
00462 char *
00463 TRANS(GetPeerNetworkId)(
00464 XtransConnInfo /* ciptr */
00465 );
00466
00467 #endif /* ICE_t */
00468
00469 int
00470 TRANS(GetHostname) (
00471 char * /* buf */,
00472 int /* maxlen */
00473 );
00474
00475 #if defined(_WIN32) && (defined(TCPCONN) || defined(DNETCONN))
00476 int TRANS(WSAStartup)();
00477 #endif
00478
00479 #endif /* _XTRANS_H_ */