| 1 |
/* |
| 2 |
|
| 3 |
Copyright 1993, 1994, 1998 The Open Group |
| 4 |
|
| 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 |
| 9 |
documentation. |
| 10 |
|
| 11 |
The above copyright notice and this permission notice shall be included |
| 12 |
in all copies or substantial portions of the Software. |
| 13 |
|
| 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. |
| 21 |
|
| 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 |
| 25 |
from The Open Group. |
| 26 |
|
| 27 |
* Copyright 1993, 1994 NCR Corporation - Dayton, Ohio, USA |
| 28 |
* |
| 29 |
* All Rights Reserved |
| 30 |
* |
| 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. |
| 40 |
* |
| 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. |
| 48 |
*/ |
| 49 |
|
| 50 |
#ifndef _XTRANS_H_ |
| 51 |
#define _XTRANS_H_ |
| 52 |
|
| 53 |
#include <nx-X11/Xfuncproto.h> |
| 54 |
#include <nx-X11/Xos.h> |
| 55 |
#include <nx-X11/Xmd.h> |
| 56 |
|
| 57 |
#ifndef WIN32 |
| 58 |
#include <sys/socket.h> |
| 59 |
#endif |
| 60 |
|
| 61 |
#ifdef __clang__ |
| 62 |
/* Not all clients make use of all provided statics */ |
| 63 |
#pragma clang diagnostic push |
| 64 |
#pragma clang diagnostic ignored "-Wunused-function" |
| 65 |
#endif |
| 66 |
|
| 67 |
/* |
| 68 |
* Set the functions names according to where this code is being compiled. |
| 69 |
*/ |
| 70 |
|
| 71 |
#ifdef X11_t |
| 72 |
#define TRANS(func) _X11Trans##func |
| 73 |
#ifdef XTRANSDEBUG |
| 74 |
static const char *__xtransname = "_X11Trans"; |
| 75 |
#endif |
| 76 |
#endif /* X11_t */ |
| 77 |
|
| 78 |
#ifdef XSERV_t |
| 79 |
#define TRANS(func) _XSERVTrans##func |
| 80 |
#ifdef XTRANSDEBUG |
| 81 |
static const char *__xtransname = "_XSERVTrans"; |
| 82 |
#endif |
| 83 |
#define X11_t |
| 84 |
#endif /* XSERV_t */ |
| 85 |
|
| 86 |
#ifdef XIM_t |
| 87 |
#define TRANS(func) _XimXTrans##func |
| 88 |
#ifdef XTRANSDEBUG |
| 89 |
static const char *__xtransname = "_XimTrans"; |
| 90 |
#endif |
| 91 |
#endif /* XIM_t */ |
| 92 |
|
| 93 |
#ifdef FS_t |
| 94 |
#define TRANS(func) _FSTrans##func |
| 95 |
#ifdef XTRANSDEBUG |
| 96 |
static const char *__xtransname = "_FSTrans"; |
| 97 |
#endif |
| 98 |
#endif /* FS_t */ |
| 99 |
|
| 100 |
#ifdef FONT_t |
| 101 |
#define TRANS(func) _FontTrans##func |
| 102 |
#ifdef XTRANSDEBUG |
| 103 |
static const char *__xtransname = "_FontTrans"; |
| 104 |
#endif |
| 105 |
#endif /* FONT_t */ |
| 106 |
|
| 107 |
#ifdef ICE_t |
| 108 |
#define TRANS(func) _IceTrans##func |
| 109 |
#ifdef XTRANSDEBUG |
| 110 |
static const char *__xtransname = "_IceTrans"; |
| 111 |
#endif |
| 112 |
#endif /* ICE_t */ |
| 113 |
|
| 114 |
#if !defined(TRANS) |
| 115 |
#define TRANS(func) _XTrans##func |
| 116 |
#ifdef XTRANSDEBUG |
| 117 |
static const char *__xtransname = "_XTrans"; |
| 118 |
#endif |
| 119 |
#endif /* !TRANS */ |
| 120 |
|
| 121 |
#ifdef __clang__ |
| 122 |
#pragma clang diagnostic pop |
| 123 |
#endif |
| 124 |
|
| 125 |
/* |
| 126 |
* Create a single address structure that can be used wherever |
| 127 |
* an address structure is needed. struct sockaddr is not big enough |
| 128 |
* to hold a sockadd_un, so we create this definition to have a single |
| 129 |
* structure that is big enough for all the structures we might need. |
| 130 |
* |
| 131 |
* This structure needs to be independent of the socket/TLI interface used. |
| 132 |
*/ |
| 133 |
|
| 134 |
#if defined(IPv6) && defined(AF_INET6) |
| 135 |
typedef struct sockaddr_storage Xtransaddr; |
| 136 |
#else |
| 137 |
#define XTRANS_MAX_ADDR_LEN 128 /* large enough to hold sun_path */ |
| 138 |
|
| 139 |
typedef struct { |
| 140 |
unsigned char addr[XTRANS_MAX_ADDR_LEN]; |
| 141 |
} Xtransaddr; |
| 142 |
#endif |
| 143 |
|
| 144 |
#ifdef LONG64 |
| 145 |
typedef int BytesReadable_t; |
| 146 |
#else |
| 147 |
typedef long BytesReadable_t; |
| 148 |
#endif |
| 149 |
|
| 150 |
|
| 151 |
#if defined(WIN32) || defined(USG) |
| 152 |
|
| 153 |
/* |
| 154 |
* TRANS(Readv) and TRANS(Writev) use struct iovec, normally found |
| 155 |
* in Berkeley systems in <sys/uio.h>. See the readv(2) and writev(2) |
| 156 |
* manual pages for details. |
| 157 |
*/ |
| 158 |
|
| 159 |
struct iovec { |
| 160 |
caddr_t iov_base; |
| 161 |
int iov_len; |
| 162 |
}; |
| 163 |
|
| 164 |
#else |
| 165 |
#include <sys/uio.h> |
| 166 |
#endif |
| 167 |
|
| 168 |
typedef struct _XtransConnInfo *XtransConnInfo; |
| 169 |
|
| 170 |
|
| 171 |
/* |
| 172 |
* Transport Option definitions |
| 173 |
*/ |
| 174 |
|
| 175 |
#define TRANS_NONBLOCKING 1 |
| 176 |
#define TRANS_CLOSEONEXEC 2 |
| 177 |
|
| 178 |
|
| 179 |
/* |
| 180 |
* Return values of Connect (0 is success) |
| 181 |
*/ |
| 182 |
|
| 183 |
#define TRANS_CONNECT_FAILED -1 |
| 184 |
#define TRANS_TRY_CONNECT_AGAIN -2 |
| 185 |
#define TRANS_IN_PROGRESS -3 |
| 186 |
|
| 187 |
|
| 188 |
/* |
| 189 |
* Return values of CreateListener (0 is success) |
| 190 |
*/ |
| 191 |
|
| 192 |
#define TRANS_CREATE_LISTENER_FAILED -1 |
| 193 |
#define TRANS_ADDR_IN_USE -2 |
| 194 |
|
| 195 |
|
| 196 |
/* |
| 197 |
* Return values of Accept (0 is success) |
| 198 |
*/ |
| 199 |
|
| 200 |
#define TRANS_ACCEPT_BAD_MALLOC -1 |
| 201 |
#define TRANS_ACCEPT_FAILED -2 |
| 202 |
#define TRANS_ACCEPT_MISC_ERROR -3 |
| 203 |
|
| 204 |
|
| 205 |
/* |
| 206 |
* ResetListener return values |
| 207 |
*/ |
| 208 |
|
| 209 |
#define TRANS_RESET_NOOP 1 |
| 210 |
#define TRANS_RESET_NEW_FD 2 |
| 211 |
#define TRANS_RESET_FAILURE 3 |
| 212 |
|
| 213 |
|
| 214 |
/* |
| 215 |
* Function prototypes for the exposed interface |
| 216 |
*/ |
| 217 |
|
| 218 |
void TRANS(FreeConnInfo) ( |
| 219 |
XtransConnInfo /* ciptr */ |
| 220 |
); |
| 221 |
|
| 222 |
#ifdef TRANS_CLIENT |
| 223 |
|
| 224 |
XtransConnInfo TRANS(OpenCOTSClient)( |
| 225 |
const char * /* address */ |
| 226 |
); |
| 227 |
|
| 228 |
#endif /* TRANS_CLIENT */ |
| 229 |
|
| 230 |
#ifdef TRANS_SERVER |
| 231 |
|
| 232 |
XtransConnInfo TRANS(OpenCOTSServer)( |
| 233 |
const char * /* address */ |
| 234 |
); |
| 235 |
|
| 236 |
#endif /* TRANS_SERVER */ |
| 237 |
|
| 238 |
#ifdef TRANS_REOPEN |
| 239 |
|
| 240 |
XtransConnInfo TRANS(ReopenCOTSServer)( |
| 241 |
int, /* trans_id */ |
| 242 |
int, /* fd */ |
| 243 |
const char * /* port */ |
| 244 |
); |
| 245 |
|
| 246 |
int TRANS(GetReopenInfo)( |
| 247 |
XtransConnInfo, /* ciptr */ |
| 248 |
int *, /* trans_id */ |
| 249 |
int *, /* fd */ |
| 250 |
char ** /* port */ |
| 251 |
); |
| 252 |
|
| 253 |
#endif /* TRANS_REOPEN */ |
| 254 |
|
| 255 |
|
| 256 |
int TRANS(SetOption)( |
| 257 |
XtransConnInfo, /* ciptr */ |
| 258 |
int, /* option */ |
| 259 |
int /* arg */ |
| 260 |
); |
| 261 |
|
| 262 |
#ifdef TRANS_SERVER |
| 263 |
|
| 264 |
int TRANS(CreateListener)( |
| 265 |
XtransConnInfo, /* ciptr */ |
| 266 |
const char *, /* port */ |
| 267 |
unsigned int /* flags */ |
| 268 |
); |
| 269 |
|
| 270 |
int TRANS(Received) ( |
| 271 |
const char* /* protocol*/ |
| 272 |
); |
| 273 |
|
| 274 |
int TRANS(NoListen) ( |
| 275 |
const char* /* protocol*/ |
| 276 |
); |
| 277 |
|
| 278 |
int TRANS(Listen) ( |
| 279 |
const char* /* protocol*/ |
| 280 |
); |
| 281 |
|
| 282 |
int TRANS(IsListening) ( |
| 283 |
const char* /* protocol*/ |
| 284 |
); |
| 285 |
|
| 286 |
int TRANS(ResetListener)( |
| 287 |
XtransConnInfo /* ciptr */ |
| 288 |
); |
| 289 |
|
| 290 |
XtransConnInfo TRANS(Accept)( |
| 291 |
XtransConnInfo, /* ciptr */ |
| 292 |
int * /* status */ |
| 293 |
); |
| 294 |
|
| 295 |
#endif /* TRANS_SERVER */ |
| 296 |
|
| 297 |
#ifdef TRANS_CLIENT |
| 298 |
|
| 299 |
int TRANS(Connect)( |
| 300 |
XtransConnInfo, /* ciptr */ |
| 301 |
const char * /* address */ |
| 302 |
); |
| 303 |
|
| 304 |
#endif /* TRANS_CLIENT */ |
| 305 |
|
| 306 |
int TRANS(BytesReadable)( |
| 307 |
XtransConnInfo, /* ciptr */ |
| 308 |
BytesReadable_t * /* pend */ |
| 309 |
); |
| 310 |
|
| 311 |
int TRANS(Read)( |
| 312 |
XtransConnInfo, /* ciptr */ |
| 313 |
char *, /* buf */ |
| 314 |
int /* size */ |
| 315 |
); |
| 316 |
|
| 317 |
int TRANS(Write)( |
| 318 |
XtransConnInfo, /* ciptr */ |
| 319 |
char *, /* buf */ |
| 320 |
int /* size */ |
| 321 |
); |
| 322 |
|
| 323 |
int TRANS(Readv)( |
| 324 |
XtransConnInfo, /* ciptr */ |
| 325 |
struct iovec *, /* buf */ |
| 326 |
int /* size */ |
| 327 |
); |
| 328 |
|
| 329 |
int TRANS(Writev)( |
| 330 |
XtransConnInfo, /* ciptr */ |
| 331 |
struct iovec *, /* buf */ |
| 332 |
int /* size */ |
| 333 |
); |
| 334 |
|
| 335 |
int TRANS(SendFd) (XtransConnInfo ciptr, int fd, int do_close); |
| 336 |
|
| 337 |
int TRANS(RecvFd) (XtransConnInfo ciptr); |
| 338 |
|
| 339 |
int TRANS(Disconnect)( |
| 340 |
XtransConnInfo /* ciptr */ |
| 341 |
); |
| 342 |
|
| 343 |
int TRANS(Close)( |
| 344 |
XtransConnInfo /* ciptr */ |
| 345 |
); |
| 346 |
|
| 347 |
int TRANS(CloseForCloning)( |
| 348 |
XtransConnInfo /* ciptr */ |
| 349 |
); |
| 350 |
|
| 351 |
int TRANS(IsLocal)( |
| 352 |
XtransConnInfo /* ciptr */ |
| 353 |
); |
| 354 |
|
| 355 |
#ifdef NX_TRANS_SOCKET |
| 356 |
/* needed for pre-xcb libX11 as we have in NX */ |
| 357 |
int TRANS(GetMyAddr)( |
| 358 |
XtransConnInfo, /* ciptr */ |
| 359 |
int *, /* familyp */ |
| 360 |
int *, /* addrlenp */ |
| 361 |
Xtransaddr ** /* addrp */ |
| 362 |
); |
| 363 |
#endif |
| 364 |
|
| 365 |
int TRANS(GetPeerAddr)( |
| 366 |
XtransConnInfo, /* ciptr */ |
| 367 |
int *, /* familyp */ |
| 368 |
int *, /* addrlenp */ |
| 369 |
Xtransaddr ** /* addrp */ |
| 370 |
); |
| 371 |
|
| 372 |
int TRANS(GetConnectionNumber)( |
| 373 |
XtransConnInfo /* ciptr */ |
| 374 |
); |
| 375 |
|
| 376 |
#ifdef TRANS_SERVER |
| 377 |
|
| 378 |
int TRANS(MakeAllCOTSServerListeners)( |
| 379 |
const char *, /* port */ |
| 380 |
int *, /* partial */ |
| 381 |
int *, /* count_ret */ |
| 382 |
XtransConnInfo ** /* ciptrs_ret */ |
| 383 |
); |
| 384 |
|
| 385 |
#endif /* TRANS_SERVER */ |
| 386 |
|
| 387 |
|
| 388 |
/* |
| 389 |
* Function Prototypes for Utility Functions. |
| 390 |
*/ |
| 391 |
|
| 392 |
#ifdef X11_t |
| 393 |
|
| 394 |
int TRANS(ConvertAddress)( |
| 395 |
int *, /* familyp */ |
| 396 |
int *, /* addrlenp */ |
| 397 |
Xtransaddr ** /* addrp */ |
| 398 |
); |
| 399 |
|
| 400 |
#endif /* X11_t */ |
| 401 |
|
| 402 |
#ifdef ICE_t |
| 403 |
|
| 404 |
char * |
| 405 |
TRANS(GetMyNetworkId)( |
| 406 |
XtransConnInfo /* ciptr */ |
| 407 |
); |
| 408 |
|
| 409 |
char * |
| 410 |
TRANS(GetPeerNetworkId)( |
| 411 |
XtransConnInfo /* ciptr */ |
| 412 |
); |
| 413 |
|
| 414 |
#endif /* ICE_t */ |
| 415 |
|
| 416 |
int |
| 417 |
TRANS(GetHostname) ( |
| 418 |
char * /* buf */, |
| 419 |
int /* maxlen */ |
| 420 |
); |
| 421 |
|
| 422 |
#if defined(WIN32) && defined(TCPCONN) |
| 423 |
int TRANS(WSAStartup)(); |
| 424 |
#endif |
| 425 |
|
| 426 |
#endif /* _XTRANS_H_ */ |