00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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
00054
00055
00056 #define IceVendorString "MIT"
00057 #define IceReleaseString "1.0"
00058
00059
00060
00061
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
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
00080
00081
00082 #define WORD64COUNT(_bytes) (((unsigned int) ((_bytes) + 7)) >> 3)
00083
00084
00085
00086
00087
00088
00089 #define WORD32COUNT(_bytes) (((unsigned int) ((_bytes) + 3)) >> 2)
00090
00091
00092
00093
00094
00095
00096 #define STRING_BYTES(_string) \
00097 (2 + strlen (_string) + PAD32 (2 + strlen (_string)))
00098
00099
00100
00101
00102
00103
00104 #define ICE_INBUFSIZE 1024
00105
00106 #define ICE_OUTBUFSIZE 1024
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117 #define MAX_ICE_AUTH_NAMES 32
00118 #define ICE_MAX_AUTH_DATA_ENTRIES 100
00119
00120
00121
00122
00123
00124
00125 struct _IceListenObj {
00126 struct _XtransConnInfo *trans_conn;
00127 char *network_id;
00128 IceHostBasedAuthProc host_based_auth_proc;
00129 };
00130
00131
00132
00133
00134
00135
00136 typedef void (*_IceProcessCoreMsgProc) (
00137 #if NeedFunctionPrototypes
00138 IceConn ,
00139 int ,
00140 unsigned long ,
00141 Bool ,
00142 IceReplyWaitInfo * ,
00143 Bool * ,
00144 Bool *
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
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
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
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
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
00244
00245 #define EXTRACT_CARD16(_pBuf, _swap, _val) \
00246 { \
00247 _val = *(_pBuf + 0) & 0xff; \
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; \
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
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
00312
00313
00314
00315 #define lswapl(_val) ((((_val) & 0xff) << 24) |\
00316 (((_val) & 0xff00) << 8) |\
00317 (((_val) & 0xff0000) >> 8) |\
00318 (((_val) >> 24) & 0xff))
00319
00320
00321 #define lswaps(_val) ((((_val) & 0xff) << 8) | (((_val) >> 8) & 0xff))
00322
00323
00324
00325
00326
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
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
00389
00390
00391 #define IceLockConn(_iceConn)
00392 #define IceUnlockConn(_iceConn)
00393
00394
00395
00396
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 ,
00416 int ,
00417 int ,
00418 int
00419 #endif
00420 );
00421
00422 #define _IceErrorNoAuthentication _KDE_IceErrorNoAuthentication
00423
00424 extern void _IceErrorNoAuthentication (
00425 #if NeedFunctionPrototypes
00426 IceConn ,
00427 int
00428 #endif
00429 );
00430
00431 #define _IceErrorNoVersion _KDE_IceErrorNoVersion
00432
00433 extern void _IceErrorNoVersion (
00434 #if NeedFunctionPrototypes
00435 IceConn ,
00436 int
00437 #endif
00438 );
00439
00440 #define _IceErrorSetupFailed _KDE_IceErrorSetupFailed
00441
00442 extern void _IceErrorSetupFailed (
00443 #if NeedFunctionPrototypes
00444 IceConn ,
00445 int ,
00446 const char *
00447 #endif
00448 );
00449
00450 #define _IceErrorAuthenticationRejected _KDE_IceErrorAuthenticationRejected
00451
00452 extern void _IceErrorAuthenticationRejected (
00453 #if NeedFunctionPrototypes
00454 IceConn ,
00455 int ,
00456 const char *
00457 #endif
00458 );
00459
00460 #define _IceErrorAuthenticationFailed _KDE_IceErrorAuthenticationFailed
00461
00462 extern void _IceErrorAuthenticationFailed (
00463 #if NeedFunctionPrototypes
00464 IceConn ,
00465 int ,
00466 const char *
00467 #endif
00468 );
00469
00470 #define _IceErrorProtocolDuplicate _KDE_IceErrorProtocolDuplicate
00471
00472 extern void _IceErrorProtocolDuplicate (
00473 #if NeedFunctionPrototypes
00474 IceConn ,
00475 const char *
00476 #endif
00477 );
00478
00479 #define _IceErrorMajorOpcodeDuplicate _KDE_IceErrorMajorOpcodeDuplicate
00480
00481 extern void _IceErrorMajorOpcodeDuplicate (
00482 #if NeedFunctionPrototypes
00483 IceConn ,
00484 int
00485 #endif
00486 );
00487
00488 #define _IceErrorUnknownProtocol _KDE_IceErrorUnknownProtocol
00489
00490 extern void _IceErrorUnknownProtocol (
00491 #if NeedFunctionPrototypes
00492 IceConn ,
00493 const char *
00494 #endif
00495 );
00496
00497 #define _IceAddOpcodeMapping _KDE_IceAddOpcodeMapping
00498
00499 extern void _IceAddOpcodeMapping (
00500 #if NeedFunctionPrototypes
00501 IceConn ,
00502 int ,
00503 int
00504 #endif
00505 );
00506
00507 #define _IceGetPeerName _KDE_IceGetPeerName
00508
00509 extern char *_IceGetPeerName (
00510 #if NeedFunctionPrototypes
00511 IceConn
00512 #endif
00513 );
00514
00515 #define _IceFreeConnection _KDE_IceFreeConnection
00516
00517 extern void _IceFreeConnection (
00518 #if NeedFunctionPrototypes
00519 IceConn
00520 #endif
00521 );
00522
00523 #define _IceAddReplyWait _KDE_IceAddReplyWait
00524
00525 extern void _IceAddReplyWait (
00526 #if NeedFunctionPrototypes
00527 IceConn ,
00528 IceReplyWaitInfo *
00529 #endif
00530 );
00531
00532 #define _IceSearchReplyWaits _KDE_IceSearchReplyWaits
00533
00534 extern IceReplyWaitInfo *_IceSearchReplyWaits (
00535 #if NeedFunctionPrototypes
00536 IceConn ,
00537 int
00538 #endif
00539 );
00540
00541 #define _IceSetReplyReady _KDE_IceSetReplyReady
00542
00543 extern void _IceSetReplyReady (
00544 #if NeedFunctionPrototypes
00545 IceConn ,
00546 IceReplyWaitInfo *
00547 #endif
00548 );
00549
00550 #define _IceCheckReplyReady _KDE_IceCheckReplyReady
00551
00552 extern Bool _IceCheckReplyReady (
00553 #if NeedFunctionPrototypes
00554 IceConn ,
00555 IceReplyWaitInfo *
00556 #endif
00557 );
00558
00559 #define _IceConnectionOpened _KDE_IceConnectionOpened
00560
00561 extern void _IceConnectionOpened (
00562 #if NeedFunctionPrototypes
00563 IceConn
00564 #endif
00565 );
00566
00567 #define _IceConnectionClosed _KDE_IceConnectionClosed
00568
00569 extern void _IceConnectionClosed (
00570 #if NeedFunctionPrototypes
00571 IceConn
00572 #endif
00573 );
00574
00575 #define _IceGetPoAuthData _KDE_IceGetPoAuthData
00576
00577 extern void _IceGetPoAuthData (
00578 #if NeedFunctionPrototypes
00579 const char * ,
00580 const char * ,
00581 const char * ,
00582 unsigned short * ,
00583 char **
00584 #endif
00585 );
00586
00587 #define _IceGetPaAuthData _KDE_IceGetPaAuthData
00588
00589 extern void _IceGetPaAuthData (
00590 #if NeedFunctionPrototypes
00591 const char * ,
00592 const char * ,
00593 const char * ,
00594 unsigned short * ,
00595 char **
00596 #endif
00597 );
00598
00599 #define _IceGetPoValidAuthIndices _KDE_IceGetPoValidAuthIndices
00600
00601 extern void _IceGetPoValidAuthIndices (
00602 #if NeedFunctionPrototypes
00603 const char * ,
00604 const char * ,
00605 int ,
00606 const char ** ,
00607 int * ,
00608 int *
00609 #endif
00610 );
00611
00612 #define _IceGetPaValidAuthIndices _KDE_IceGetPaValidAuthIndices
00613
00614 extern void _IceGetPaValidAuthIndices (
00615 #if NeedFunctionPrototypes
00616 const char * ,
00617 const char * ,
00618 int ,
00619 const char ** ,
00620 int * ,
00621 int *
00622 #endif
00623 );
00624
00625 #endif