Back to index

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