dcop Library API Documentation

ICElibint.h

00001 /* $Xorg: ICElibint.h,v 1.3 2000/08/17 19:44:10 cpqbld Exp $ */
00002 /******************************************************************************
00003 
00004 
00005 Copyright (c) 1993, 1998  The Open Group
00006 
00007 All Rights Reserved. 
00008 
00009 The above copyright notice and this permission notice shall be included in
00010 all copies or substantial portions of the Software.
00011 
00012 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00013 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00014 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00015 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00016 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00017 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00018 
00019 Except as contained in this notice, the name of The Open Group shall not be
00020 used in advertising or otherwise to promote the sale, use or other dealings
00021 in this Software without prior written authorization from The Open Group.
00022 
00023 Author: Ralph Mor, X Consortium
00024 ******************************************************************************/
00025 /* $XFree86: xc/lib/ICE/ICElibint.h,v 1.4 2001/01/17 19:41:29 dawes Exp $ */
00026 #ifndef _ICELIBINT_H_
00027 #define _ICELIBINT_H_
00028 
00029 #ifndef QWS
00030 #include <X11/Xos.h>
00031 #include <X11/Xfuncs.h>
00032 #include <X11/Xmd.h>
00033 #else
00034 #define _SIZEOF(x) sz_##x
00035 #define SIZEOF(x) _SIZEOF(x)
00036 #endif
00037 #include <KDE-ICE/ICEproto.h>
00038 #include <KDE-ICE/ICEconn.h>
00039 #include <KDE-ICE/ICEmsg.h>
00040 
00041 #ifndef X_NOT_STDC_ENV
00042 #include <stdlib.h>
00043 #else
00044 char *malloc();
00045 #endif
00046 
00047 #ifndef NULL
00048 #define NULL 0
00049 #endif
00050 
00051 
00052 /*
00053  * Vendor & Release
00054  */
00055 
00056 #define IceVendorString  "MIT"
00057 #define IceReleaseString "1.0"
00058 
00059 
00060 /*
00061  * Pad to a 64 bit boundary
00062  */
00063 
00064 #define PAD64(_bytes) ((8 - ((unsigned int) (_bytes) % 8)) % 8)
00065 
00066 #define PADDED_BYTES64(_bytes) (_bytes + PAD64 (_bytes))
00067 
00068 
00069 /*
00070  * Pad to 32 bit boundary
00071  */
00072 
00073 #define PAD32(_bytes) ((4 - ((unsigned int) (_bytes) % 4)) % 4)
00074 
00075 #define PADDED_BYTES32(_bytes) (_bytes + PAD32 (_bytes))
00076 
00077 
00078 /*
00079  * Number of 8 byte units in _bytes.
00080  */
00081 
00082 #define WORD64COUNT(_bytes) (((unsigned int) ((_bytes) + 7)) >> 3)
00083 
00084 
00085 /*
00086  * Number of 4 byte units in _bytes.
00087  */
00088 
00089 #define WORD32COUNT(_bytes) (((unsigned int) ((_bytes) + 3)) >> 2)
00090 
00091 
00092 /*
00093  * Given a string, compute the number of bytes for the STRING representation
00094  */
00095 
00096 #define STRING_BYTES(_string) \
00097     (2 + strlen (_string) + PAD32 (2 + strlen (_string)))
00098 
00099 
00100 /*
00101  * Size of ICE input/output buffers
00102  */
00103 
00104 #define ICE_INBUFSIZE 1024
00105 
00106 #define ICE_OUTBUFSIZE 1024
00107 
00108 
00109 /*
00110  * Maxium number of ICE authentication methods allowed, and maxiumum
00111  * number of authentication data entries allowed to be set in the
00112  * IceSetPaAuthData function.
00113  *
00114  * We should use linked lists, but this is easier and should suffice.
00115  */
00116 
00117 #define MAX_ICE_AUTH_NAMES 32
00118 #define ICE_MAX_AUTH_DATA_ENTRIES 100
00119 
00120 
00121 /*
00122  * ICE listen object
00123  */
00124 
00125 struct _IceListenObj {
00126     struct _XtransConnInfo  *trans_conn; /* transport connection object */
00127     char            *network_id;
00128     IceHostBasedAuthProc    host_based_auth_proc;
00129 };
00130 
00131 
00132 /*
00133  * Some internal data structures for processing ICE messages.
00134  */
00135 
00136 typedef void (*_IceProcessCoreMsgProc) (
00137 #if NeedFunctionPrototypes
00138     IceConn         /* iceConn */,
00139     int         /* opcode */,
00140     unsigned long   /* length */,
00141     Bool        /* swap */,
00142     IceReplyWaitInfo *  /* replyWait */,
00143     Bool *      /* replyReadyRet */,
00144     Bool *      /* connectionClosedRet */
00145 #endif
00146 );
00147 
00148 typedef struct {
00149     int             major_version;
00150     int             minor_version;
00151     _IceProcessCoreMsgProc  process_core_msg_proc;
00152 } _IceVersion;
00153 
00154 
00155 /*
00156  * STORE FOO
00157  */
00158 
00159 #define STORE_CARD8(_pBuf, _val) \
00160 { \
00161     *((CARD8 *) _pBuf) = _val; \
00162     _pBuf += 1; \
00163 }
00164 
00165 #ifndef WORD64
00166 
00167 #define STORE_CARD16(_pBuf, _val) \
00168 { \
00169     *((CARD16 *) _pBuf) = _val; \
00170     _pBuf += 2; \
00171 }
00172 
00173 #define STORE_CARD32(_pBuf, _val) \
00174 { \
00175     *((CARD32 *) _pBuf) = _val; \
00176     _pBuf += 4; \
00177 }
00178 
00179 #else /* WORD64 */
00180 
00181 #define STORE_CARD16(_pBuf, _val) \
00182 { \
00183     struct { \
00184         int value   :16; \
00185         int pad     :16; \
00186     } _d; \
00187     _d.value = _val; \
00188     memcpy (_pBuf, &_d, 2); \
00189     _pBuf += 2; \
00190 }
00191 
00192 #define STORE_CARD32(_pBuf, _val) \
00193 { \
00194     struct { \
00195         int value   :32; \
00196     } _d; \
00197     _d.value = _val; \
00198     memcpy (_pBuf, &_d, 4); \
00199     _pBuf += 4; \
00200 }
00201 
00202 #endif /* WORD64 */
00203 
00204 #define STORE_STRING(_pBuf, _string) \
00205 { \
00206     CARD16 _len = strlen (_string); \
00207     STORE_CARD16 (_pBuf, _len); \
00208     memcpy (_pBuf, _string, _len); \
00209     _pBuf += _len; \
00210     if (PAD32 (2 + _len)) \
00211         _pBuf += PAD32 (2 + _len); \
00212 }
00213 
00214 
00215 /*
00216  * EXTRACT FOO
00217  */
00218 
00219 #define EXTRACT_CARD8(_pBuf, _val) \
00220 { \
00221     _val = *((CARD8 *) _pBuf); \
00222     _pBuf += 1; \
00223 }
00224 
00225 #ifndef WORD64
00226 
00227 #define EXTRACT_CARD16(_pBuf, _swap, _val) \
00228 { \
00229     _val = *((CARD16 *) _pBuf); \
00230     _pBuf += 2; \
00231     if (_swap) \
00232         _val = lswaps (_val); \
00233 }
00234 
00235 #define EXTRACT_CARD32(_pBuf, _swap, _val) \
00236 { \
00237     _val = *((CARD32 *) _pBuf); \
00238     _pBuf += 4; \
00239     if (_swap) \
00240         _val = lswapl (_val); \
00241 }
00242 
00243 #else /* WORD64 */
00244 
00245 #define EXTRACT_CARD16(_pBuf, _swap, _val) \
00246 { \
00247     _val = *(_pBuf + 0) & 0xff;     /* 0xff incase _pBuf is signed */ \
00248     _val <<= 8; \
00249     _val |= *(_pBuf + 1) & 0xff;\
00250     _pBuf += 2; \
00251     if (_swap) \
00252         _val = lswaps (_val); \
00253 }
00254 
00255 #define EXTRACT_CARD32(_pBuf, _swap, _val) \
00256 { \
00257     _val = *(_pBuf + 0) & 0xff;     /* 0xff incase _pBuf is signed */ \
00258     _val <<= 8; \
00259     _val |= *(_pBuf + 1) & 0xff;\
00260     _val <<= 8; \
00261     _val |= *(_pBuf + 2) & 0xff;\
00262     _val <<= 8; \
00263     _val |= *(_pBuf + 3) & 0xff;\
00264     _pBuf += 4; \
00265     if (_swap) \
00266         _val = lswapl (_val); \
00267 }
00268 
00269 #endif /* WORD64 */
00270 
00271 #define EXTRACT_STRING(_pBuf, _swap, _string) \
00272 { \
00273     CARD16 _len; \
00274     EXTRACT_CARD16 (_pBuf, _swap, _len); \
00275     _string = (char *) malloc (_len + 1); \
00276     memcpy (_string, _pBuf, _len); \
00277     _pBuf += _len; \
00278     _string[_len] = '\0'; \
00279     if (PAD32 (2 + _len)) \
00280         _pBuf += PAD32 (2 + _len); \
00281 }
00282 
00283 #define EXTRACT_LISTOF_STRING(_pBuf, _swap, _count, _strings) \
00284 { \
00285     int _i; \
00286     for (_i = 0; _i < _count; _i++) \
00287         EXTRACT_STRING (_pBuf, _swap, _strings[_i]); \
00288 }
00289 
00290 
00291 #define SKIP_STRING(_pBuf, _swap, _end, _bail) \
00292 { \
00293     CARD16 _len; \
00294     EXTRACT_CARD16 (_pBuf, _swap, _len); \
00295    _pBuf += _len + PAD32(2+_len); \
00296     if (_pBuf > _end) { \
00297        _bail; \
00298     } \
00299 } 
00300 
00301 #define SKIP_LISTOF_STRING(_pBuf, _swap, _count, _end, _bail) \
00302 { \
00303     int _i; \
00304     for (_i = 0; _i < _count; _i++) \
00305         SKIP_STRING (_pBuf, _swap, _end, _bail); \
00306 }
00307 
00308 
00309 
00310 /*
00311  * Byte swapping
00312  */
00313 
00314 /* byte swap a long literal */
00315 #define lswapl(_val) ((((_val) & 0xff) << 24) |\
00316            (((_val) & 0xff00) << 8) |\
00317            (((_val) & 0xff0000) >> 8) |\
00318            (((_val) >> 24) & 0xff))
00319 
00320 /* byte swap a short literal */
00321 #define lswaps(_val) ((((_val) & 0xff) << 8) | (((_val) >> 8) & 0xff))
00322 
00323 
00324 
00325 /*
00326  * ICE replies (not processed via callbacks because we block)
00327  */
00328 
00329 #define ICE_CONNECTION_REPLY    1
00330 #define ICE_CONNECTION_ERROR    2
00331 #define ICE_PROTOCOL_REPLY  3
00332 #define ICE_PROTOCOL_ERROR  4
00333 
00334 typedef struct {
00335     int       type;
00336     int       version_index;
00337     char      *vendor;
00338     char          *release;
00339 } _IceConnectionReply;
00340 
00341 typedef struct {
00342     int       type;
00343     char      *error_message;
00344 } _IceConnectionError;
00345 
00346 typedef struct {
00347     int       type;
00348     int       major_opcode;
00349     int       version_index;
00350     char      *vendor;
00351     char      *release;
00352 } _IceProtocolReply;
00353 
00354 typedef struct {
00355     int       type;
00356     char      *error_message;
00357 } _IceProtocolError;
00358 
00359 
00360 typedef union {
00361     int         type;
00362     _IceConnectionReply connection_reply;
00363     _IceConnectionError connection_error;
00364     _IceProtocolReply   protocol_reply;
00365     _IceProtocolError   protocol_error;
00366 } _IceReply;
00367 
00368 
00369 /*
00370  * Watch for ICE connection create/destroy.
00371  */
00372 
00373 typedef struct _IceWatchedConnection {
00374     IceConn             iceConn;
00375     IcePointer              watch_data;
00376     struct _IceWatchedConnection    *next;
00377 } _IceWatchedConnection;
00378 
00379 typedef struct _IceWatchProc {
00380     IceWatchProc        watch_proc;
00381     IcePointer          client_data;
00382     _IceWatchedConnection   *watched_connections;
00383     struct _IceWatchProc    *next;
00384 } _IceWatchProc;
00385 
00386 
00387 /*
00388  * Locking
00389  */
00390 
00391 #define IceLockConn(_iceConn)
00392 #define IceUnlockConn(_iceConn)
00393 
00394 
00395 /*
00396  * Extern declarations
00397  */
00398 
00399 extern IceConn      _IceConnectionObjs[];
00400 extern char         *_IceConnectionStrings[];
00401 extern int          _IceConnectionCount;
00402 
00403 extern int      _IceAuthCount;
00404 extern const char   *_IceAuthNames[];
00405 extern IcePoAuthProc    _IcePoAuthProcs[];
00406 extern IcePaAuthProc    _IcePaAuthProcs[];
00407 
00408 extern int      _IceVersionCount;
00409 
00410 #define _IceErrorBadMajor _KDE_IceErrorBadMajor
00411 
00412 
00413 extern void _IceErrorBadMajor (
00414 #if NeedFunctionPrototypes
00415     IceConn     /* iceConn */,
00416     int         /* offendingMajor */,
00417     int         /* offendingMinor */,
00418     int         /* severity */
00419 #endif
00420 );
00421 
00422 #define _IceErrorNoAuthentication _KDE_IceErrorNoAuthentication
00423 
00424 extern void _IceErrorNoAuthentication (
00425 #if NeedFunctionPrototypes
00426     IceConn     /* iceConn */,
00427     int         /* offendingMinor */
00428 #endif
00429 );
00430 
00431 #define _IceErrorNoVersion _KDE_IceErrorNoVersion
00432 
00433 extern void _IceErrorNoVersion (
00434 #if NeedFunctionPrototypes
00435     IceConn     /* iceConn */,
00436     int         /* offendingMinor */
00437 #endif
00438 );
00439 
00440 #define _IceErrorSetupFailed _KDE_IceErrorSetupFailed
00441 
00442 extern void _IceErrorSetupFailed (
00443 #if NeedFunctionPrototypes
00444     IceConn     /* iceConn */,
00445     int         /* offendingMinor */,
00446     const char *    /* reason */
00447 #endif
00448 );
00449 
00450 #define _IceErrorAuthenticationRejected _KDE_IceErrorAuthenticationRejected
00451 
00452 extern void _IceErrorAuthenticationRejected (
00453 #if NeedFunctionPrototypes
00454     IceConn     /* iceConn */,
00455     int         /* offendingMinor */,
00456     const char *    /* reason */
00457 #endif
00458 );
00459 
00460 #define _IceErrorAuthenticationFailed _KDE_IceErrorAuthenticationFailed
00461 
00462 extern void _IceErrorAuthenticationFailed (
00463 #if NeedFunctionPrototypes
00464     IceConn     /* iceConn */,
00465     int         /* offendingMinor */,
00466     const char *    /* reason */
00467 #endif
00468 );
00469 
00470 #define _IceErrorProtocolDuplicate _KDE_IceErrorProtocolDuplicate
00471 
00472 extern void _IceErrorProtocolDuplicate (
00473 #if NeedFunctionPrototypes
00474     IceConn     /* iceConn */,
00475     const char *    /* protocolName */
00476 #endif
00477 );
00478 
00479 #define _IceErrorMajorOpcodeDuplicate _KDE_IceErrorMajorOpcodeDuplicate
00480 
00481 extern void _IceErrorMajorOpcodeDuplicate (
00482 #if NeedFunctionPrototypes
00483     IceConn     /* iceConn */,
00484     int         /* majorOpcode */
00485 #endif
00486 );
00487 
00488 #define _IceErrorUnknownProtocol _KDE_IceErrorUnknownProtocol
00489 
00490 extern void _IceErrorUnknownProtocol (
00491 #if NeedFunctionPrototypes
00492     IceConn     /* iceConn */,
00493     const char *    /* protocolName */
00494 #endif
00495 );
00496 
00497 #define _IceAddOpcodeMapping _KDE_IceAddOpcodeMapping
00498 
00499 extern void _IceAddOpcodeMapping (
00500 #if NeedFunctionPrototypes
00501     IceConn     /* iceConn */,
00502     int         /* hisOpcode */,
00503     int         /* myOpcode */
00504 #endif
00505 );
00506 
00507 #define _IceGetPeerName _KDE_IceGetPeerName
00508 
00509 extern char *_IceGetPeerName (
00510 #if NeedFunctionPrototypes
00511     IceConn     /* iceConn */
00512 #endif
00513 );
00514 
00515 #define _IceFreeConnection _KDE_IceFreeConnection
00516 
00517 extern void _IceFreeConnection (
00518 #if NeedFunctionPrototypes
00519     IceConn     /* iceConn */
00520 #endif
00521 );
00522 
00523 #define _IceAddReplyWait _KDE_IceAddReplyWait
00524 
00525 extern void _IceAddReplyWait (
00526 #if NeedFunctionPrototypes
00527     IceConn     /* iceConn */,
00528     IceReplyWaitInfo *  /* replyWait */
00529 #endif
00530 );
00531 
00532 #define _IceSearchReplyWaits _KDE_IceSearchReplyWaits
00533 
00534 extern IceReplyWaitInfo *_IceSearchReplyWaits (
00535 #if NeedFunctionPrototypes
00536     IceConn     /* iceConn */,
00537     int         /* majorOpcode */
00538 #endif
00539 );
00540 
00541 #define _IceSetReplyReady _KDE_IceSetReplyReady
00542 
00543 extern void _IceSetReplyReady (
00544 #if NeedFunctionPrototypes
00545     IceConn     /* iceConn */,
00546     IceReplyWaitInfo *  /* replyWait */
00547 #endif
00548 );
00549 
00550 #define _IceCheckReplyReady _KDE_IceCheckReplyReady
00551 
00552 extern Bool _IceCheckReplyReady (
00553 #if NeedFunctionPrototypes
00554     IceConn     /* iceConn */,
00555     IceReplyWaitInfo *  /* replyWait */
00556 #endif
00557 );
00558 
00559 #define _IceConnectionOpened _KDE_IceConnectionOpened
00560 
00561 extern void _IceConnectionOpened (
00562 #if NeedFunctionPrototypes
00563     IceConn     /* iceConn */
00564 #endif
00565 );
00566 
00567 #define _IceConnectionClosed _KDE_IceConnectionClosed
00568 
00569 extern void _IceConnectionClosed (
00570 #if NeedFunctionPrototypes
00571     IceConn     /* iceConn */
00572 #endif
00573 );
00574 
00575 #define _IceGetPoAuthData _KDE_IceGetPoAuthData
00576 
00577 extern void _IceGetPoAuthData (
00578 #if NeedFunctionPrototypes
00579     const char *    /* protocol_name */,
00580     const char *    /* address */,
00581     const char *    /* auth_name */,
00582     unsigned short *    /* auth_data_length_ret */,
00583     char **     /* auth_data_ret */
00584 #endif
00585 );
00586 
00587 #define _IceGetPaAuthData _KDE_IceGetPaAuthData
00588 
00589 extern void _IceGetPaAuthData (
00590 #if NeedFunctionPrototypes
00591     const char *    /* protocol_name */,
00592     const char *    /* address */,
00593     const char *    /* auth_name */,
00594     unsigned short *    /* auth_data_length_ret */,
00595     char **     /* auth_data_ret */
00596 #endif
00597 );
00598 
00599 #define _IceGetPoValidAuthIndices _KDE_IceGetPoValidAuthIndices
00600 
00601 extern void _IceGetPoValidAuthIndices (
00602 #if NeedFunctionPrototypes
00603     const char *    /* protocol_name */,
00604     const char *    /* address */,
00605     int         /* num_auth_names */,
00606     const char **   /* auth_names */,
00607     int *       /* num_indices_ret */,
00608     int *       /* indices_ret */
00609 #endif
00610 );
00611 
00612 #define _IceGetPaValidAuthIndices _KDE_IceGetPaValidAuthIndices
00613 
00614 extern void _IceGetPaValidAuthIndices (
00615 #if NeedFunctionPrototypes
00616     const char *    /* protocol_name */,
00617     const char *    /* address */,
00618     int         /* num_auth_names */,
00619     const char **   /* auth_names */,
00620     int *       /* num_indices_ret */,
00621     int *       /* indices_ret */
00622 #endif
00623 );
00624 
00625 #endif /* _ICELIBINT_H_ */
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:14:34 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001