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 #include "config.h"
00030 #if defined Q_WS_X11 && ! defined K_WS_QTONLY
00031 #include <X11/Xos.h>
00032 #include <X11/Xfuncs.h>
00033 #include <X11/Xmd.h>
00034 #else
00035 #define _SIZEOF(x) sz_##x
00036 #define SIZEOF(x) _SIZEOF(x)
00037 #endif
00038 #include <KDE-ICE/ICEproto.h>
00039 #include <KDE-ICE/ICEconn.h>
00040 #include <KDE-ICE/ICEmsg.h>
00041
00042 #ifndef X_NOT_STDC_ENV
00043 #include <stdlib.h>
00044 #else
00045 char *malloc();
00046 #endif
00047
00048 #ifndef NULL
00049 #define NULL 0
00050 #endif
00051
00052
00053
00054
00055
00056
00057 #define IceVendorString "MIT"
00058 #define IceReleaseString "1.0"
00059
00060
00061
00062
00063
00064
00065 #define PAD64(_bytes) ((8 - ((unsigned int) (_bytes) % 8)) % 8)
00066
00067 #define PADDED_BYTES64(_bytes) (_bytes + PAD64 (_bytes))
00068
00069
00070
00071
00072
00073
00074 #define PAD32(_bytes) ((4 - ((unsigned int) (_bytes) % 4)) % 4)
00075
00076 #define PADDED_BYTES32(_bytes) (_bytes + PAD32 (_bytes))
00077
00078
00079
00080
00081
00082
00083 #define WORD64COUNT(_bytes) (((unsigned int) ((_bytes) + 7)) >> 3)
00084
00085
00086
00087
00088
00089
00090 #define WORD32COUNT(_bytes) (((unsigned int) ((_bytes) + 3)) >> 2)
00091
00092
00093
00094
00095
00096
00097 #define STRING_BYTES(_string) \
00098 (2 + strlen (_string) + PAD32 (2 + strlen (_string)))
00099
00100
00101
00102
00103
00104
00105 #define ICE_INBUFSIZE 1024
00106
00107 #define ICE_OUTBUFSIZE 1024
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118 #define MAX_ICE_AUTH_NAMES 32
00119 #define ICE_MAX_AUTH_DATA_ENTRIES 100
00120
00121
00122
00123
00124
00125
00126 struct _IceListenObj {
00127 struct _XtransConnInfo *trans_conn;
00128 char *network_id;
00129 IceHostBasedAuthProc host_based_auth_proc;
00130 };
00131
00132
00133
00134
00135
00136
00137 typedef void (*_IceProcessCoreMsgProc) (
00138 #if NeedFunctionPrototypes
00139 IceConn ,
00140 int ,
00141 unsigned long ,
00142 Bool ,
00143 IceReplyWaitInfo * ,
00144 Bool * ,
00145 Bool *
00146 #endif
00147 );
00148
00149 typedef struct {
00150 int major_version;
00151 int minor_version;
00152 _IceProcessCoreMsgProc process_core_msg_proc;
00153 } _IceVersion;
00154
00155
00156
00157
00158
00159
00160 #define STORE_CARD8(_pBuf, _val) \
00161 { \
00162 *((CARD8 *) _pBuf) = _val; \
00163 _pBuf += 1; \
00164 }
00165
00166 #ifndef WORD64
00167
00168 #define STORE_CARD16(_pBuf, _val) \
00169 { \
00170 *((CARD16 *) _pBuf) = _val; \
00171 _pBuf += 2; \
00172 }
00173
00174 #define STORE_CARD32(_pBuf, _val) \
00175 { \
00176 *((CARD32 *) _pBuf) = _val; \
00177 _pBuf += 4; \
00178 }
00179
00180 #else
00181
00182 #define STORE_CARD16(_pBuf, _val) \
00183 { \
00184 struct { \
00185 int value :16; \
00186 int pad :16; \
00187 } _d; \
00188 _d.value = _val; \
00189 memcpy (_pBuf, &_d, 2); \
00190 _pBuf += 2; \
00191 }
00192
00193 #define STORE_CARD32(_pBuf, _val) \
00194 { \
00195 struct { \
00196 int value :32; \
00197 } _d; \
00198 _d.value = _val; \
00199 memcpy (_pBuf, &_d, 4); \
00200 _pBuf += 4; \
00201 }
00202
00203 #endif
00204
00205 #define STORE_STRING(_pBuf, _string) \
00206 { \
00207 CARD16 _len = strlen (_string); \
00208 STORE_CARD16 (_pBuf, _len); \
00209 memcpy (_pBuf, _string, _len); \
00210 _pBuf += _len; \
00211 if (PAD32 (2 + _len)) \
00212 _pBuf += PAD32 (2 + _len); \
00213 }
00214
00215
00216
00217
00218
00219
00220 #define EXTRACT_CARD8(_pBuf, _val) \
00221 { \
00222 _val = *((CARD8 *) _pBuf); \
00223 _pBuf += 1; \
00224 }
00225
00226 #ifndef WORD64
00227
00228 #define EXTRACT_CARD16(_pBuf, _swap, _val) \
00229 { \
00230 _val = *((CARD16 *) _pBuf); \
00231 _pBuf += 2; \
00232 if (_swap) \
00233 _val = lswaps (_val); \
00234 }
00235
00236 #define EXTRACT_CARD32(_pBuf, _swap, _val) \
00237 { \
00238 _val = *((CARD32 *) _pBuf); \
00239 _pBuf += 4; \
00240 if (_swap) \
00241 _val = lswapl (_val); \
00242 }
00243
00244 #else
00245
00246 #define EXTRACT_CARD16(_pBuf, _swap, _val) \
00247 { \
00248 _val = *(_pBuf + 0) & 0xff; \
00249 _val <<= 8; \
00250 _val |= *(_pBuf + 1) & 0xff;\
00251 _pBuf += 2; \
00252 if (_swap) \
00253 _val = lswaps (_val); \
00254 }
00255
00256 #define EXTRACT_CARD32(_pBuf, _swap, _val) \
00257 { \
00258 _val = *(_pBuf + 0) & 0xff; \
00259 _val <<= 8; \
00260 _val |= *(_pBuf + 1) & 0xff;\
00261 _val <<= 8; \
00262 _val |= *(_pBuf + 2) & 0xff;\
00263 _val <<= 8; \
00264 _val |= *(_pBuf + 3) & 0xff;\
00265 _pBuf += 4; \
00266 if (_swap) \
00267 _val = lswapl (_val); \
00268 }
00269
00270 #endif
00271
00272 #define EXTRACT_STRING(_pBuf, _swap, _string) \
00273 { \
00274 CARD16 _len; \
00275 EXTRACT_CARD16 (_pBuf, _swap, _len); \
00276 _string = (char *) malloc (_len + 1); \
00277 memcpy (_string, _pBuf, _len); \
00278 _pBuf += _len; \
00279 _string[_len] = '\0'; \
00280 if (PAD32 (2 + _len)) \
00281 _pBuf += PAD32 (2 + _len); \
00282 }
00283
00284 #define EXTRACT_LISTOF_STRING(_pBuf, _swap, _count, _strings) \
00285 { \
00286 int _i; \
00287 for (_i = 0; _i < _count; _i++) \
00288 EXTRACT_STRING (_pBuf, _swap, _strings[_i]); \
00289 }
00290
00291
00292 #define SKIP_STRING(_pBuf, _swap, _end, _bail) \
00293 { \
00294 CARD16 _len; \
00295 EXTRACT_CARD16 (_pBuf, _swap, _len); \
00296 _pBuf += _len + PAD32(2+_len); \
00297 if (_pBuf > _end) { \
00298 _bail; \
00299 } \
00300 }
00301
00302 #define SKIP_LISTOF_STRING(_pBuf, _swap, _count, _end, _bail) \
00303 { \
00304 int _i; \
00305 for (_i = 0; _i < _count; _i++) \
00306 SKIP_STRING (_pBuf, _swap, _end, _bail); \
00307 }
00308
00309
00310
00311
00312
00313
00314
00315
00316 #define lswapl(_val) ((((_val) & 0xff) << 24) |\
00317 (((_val) & 0xff00) << 8) |\
00318 (((_val) & 0xff0000) >> 8) |\
00319 (((_val) >> 24) & 0xff))
00320
00321
00322 #define lswaps(_val) ((((_val) & 0xff) << 8) | (((_val) >> 8) & 0xff))
00323
00324
00325
00326
00327
00328
00329
00330 #define ICE_CONNECTION_REPLY 1
00331 #define ICE_CONNECTION_ERROR 2
00332 #define ICE_PROTOCOL_REPLY 3
00333 #define ICE_PROTOCOL_ERROR 4
00334
00335 typedef struct {
00336 int type;
00337 int version_index;
00338 char *vendor;
00339 char *release;
00340 } _IceConnectionReply;
00341
00342 typedef struct {
00343 int type;
00344 char *error_message;
00345 } _IceConnectionError;
00346
00347 typedef struct {
00348 int type;
00349 int major_opcode;
00350 int version_index;
00351 char *vendor;
00352 char *release;
00353 } _IceProtocolReply;
00354
00355 typedef struct {
00356 int type;
00357 char *error_message;
00358 } _IceProtocolError;
00359
00360
00361 typedef union {
00362 int type;
00363 _IceConnectionReply connection_reply;
00364 _IceConnectionError connection_error;
00365 _IceProtocolReply protocol_reply;
00366 _IceProtocolError protocol_error;
00367 } _IceReply;
00368
00369
00370
00371
00372
00373
00374 typedef struct _IceWatchedConnection {
00375 IceConn iceConn;
00376 IcePointer watch_data;
00377 struct _IceWatchedConnection *next;
00378 } _IceWatchedConnection;
00379
00380 typedef struct _IceWatchProc {
00381 IceWatchProc watch_proc;
00382 IcePointer client_data;
00383 _IceWatchedConnection *watched_connections;
00384 struct _IceWatchProc *next;
00385 } _IceWatchProc;
00386
00387
00388
00389
00390
00391
00392 #define IceLockConn(_iceConn)
00393 #define IceUnlockConn(_iceConn)
00394
00395
00396
00397
00398
00399
00400 extern IceConn _IceConnectionObjs[];
00401 extern char *_IceConnectionStrings[];
00402 extern int _IceConnectionCount;
00403
00404 extern int _IceAuthCount;
00405 extern const char *_IceAuthNames[];
00406 extern IcePoAuthProc _IcePoAuthProcs[];
00407 extern IcePaAuthProc _IcePaAuthProcs[];
00408
00409 extern int _IceVersionCount;
00410
00411 #define _IceErrorBadMajor _kde_IceErrorBadMajor
00412
00413
00414 extern void _IceErrorBadMajor (
00415 #if NeedFunctionPrototypes
00416 IceConn ,
00417 int ,
00418 int ,
00419 int
00420 #endif
00421 );
00422
00423 #define _IceErrorNoAuthentication _kde_IceErrorNoAuthentication
00424
00425 extern void _IceErrorNoAuthentication (
00426 #if NeedFunctionPrototypes
00427 IceConn ,
00428 int
00429 #endif
00430 );
00431
00432 #define _IceErrorNoVersion _kde_IceErrorNoVersion
00433
00434 extern void _IceErrorNoVersion (
00435 #if NeedFunctionPrototypes
00436 IceConn ,
00437 int
00438 #endif
00439 );
00440
00441 #define _IceErrorSetupFailed _kde_IceErrorSetupFailed
00442
00443 extern void _IceErrorSetupFailed (
00444 #if NeedFunctionPrototypes
00445 IceConn ,
00446 int ,
00447 const char *
00448 #endif
00449 );
00450
00451 #define _IceErrorAuthenticationRejected _kde_IceErrorAuthenticationRejected
00452
00453 extern void _IceErrorAuthenticationRejected (
00454 #if NeedFunctionPrototypes
00455 IceConn ,
00456 int ,
00457 const char *
00458 #endif
00459 );
00460
00461 #define _IceErrorAuthenticationFailed _kde_IceErrorAuthenticationFailed
00462
00463 extern void _IceErrorAuthenticationFailed (
00464 #if NeedFunctionPrototypes
00465 IceConn ,
00466 int ,
00467 const char *
00468 #endif
00469 );
00470
00471 #define _IceErrorProtocolDuplicate _kde_IceErrorProtocolDuplicate
00472
00473 extern void _IceErrorProtocolDuplicate (
00474 #if NeedFunctionPrototypes
00475 IceConn ,
00476 const char *
00477 #endif
00478 );
00479
00480 #define _IceErrorMajorOpcodeDuplicate _kde_IceErrorMajorOpcodeDuplicate
00481
00482 extern void _IceErrorMajorOpcodeDuplicate (
00483 #if NeedFunctionPrototypes
00484 IceConn ,
00485 int
00486 #endif
00487 );
00488
00489 #define _IceErrorUnknownProtocol _kde_IceErrorUnknownProtocol
00490
00491 extern void _IceErrorUnknownProtocol (
00492 #if NeedFunctionPrototypes
00493 IceConn ,
00494 const char *
00495 #endif
00496 );
00497
00498 #define _IceAddOpcodeMapping _kde_IceAddOpcodeMapping
00499
00500 extern void _IceAddOpcodeMapping (
00501 #if NeedFunctionPrototypes
00502 IceConn ,
00503 int ,
00504 int
00505 #endif
00506 );
00507
00508 #define _IceGetPeerName _kde_IceGetPeerName
00509
00510 extern char *_IceGetPeerName (
00511 #if NeedFunctionPrototypes
00512 IceConn
00513 #endif
00514 );
00515
00516 #define _IceFreeConnection _kde_IceFreeConnection
00517
00518 extern void _IceFreeConnection (
00519 #if NeedFunctionPrototypes
00520 IceConn
00521 #endif
00522 );
00523
00524 #define _IceAddReplyWait _kde_IceAddReplyWait
00525
00526 extern void _IceAddReplyWait (
00527 #if NeedFunctionPrototypes
00528 IceConn ,
00529 IceReplyWaitInfo *
00530 #endif
00531 );
00532
00533 #define _IceSearchReplyWaits _kde_IceSearchReplyWaits
00534
00535 extern IceReplyWaitInfo *_IceSearchReplyWaits (
00536 #if NeedFunctionPrototypes
00537 IceConn ,
00538 int
00539 #endif
00540 );
00541
00542 #define _IceSetReplyReady _kde_IceSetReplyReady
00543
00544 extern void _IceSetReplyReady (
00545 #if NeedFunctionPrototypes
00546 IceConn ,
00547 IceReplyWaitInfo *
00548 #endif
00549 );
00550
00551 #define _IceCheckReplyReady _kde_IceCheckReplyReady
00552
00553 extern Bool _IceCheckReplyReady (
00554 #if NeedFunctionPrototypes
00555 IceConn ,
00556 IceReplyWaitInfo *
00557 #endif
00558 );
00559
00560 #define _IceConnectionOpened _kde_IceConnectionOpened
00561
00562 extern void _IceConnectionOpened (
00563 #if NeedFunctionPrototypes
00564 IceConn
00565 #endif
00566 );
00567
00568 #define _IceConnectionClosed _kde_IceConnectionClosed
00569
00570 extern void _IceConnectionClosed (
00571 #if NeedFunctionPrototypes
00572 IceConn
00573 #endif
00574 );
00575
00576 #define _IceGetPoAuthData _kde_IceGetPoAuthData
00577
00578 extern void _IceGetPoAuthData (
00579 #if NeedFunctionPrototypes
00580 const char * ,
00581 const char * ,
00582 const char * ,
00583 unsigned short * ,
00584 char **
00585 #endif
00586 );
00587
00588 #define _IceGetPaAuthData _kde_IceGetPaAuthData
00589
00590 extern void _IceGetPaAuthData (
00591 #if NeedFunctionPrototypes
00592 const char * ,
00593 const char * ,
00594 const char * ,
00595 unsigned short * ,
00596 char **
00597 #endif
00598 );
00599
00600 #define _IceGetPoValidAuthIndices _kde_IceGetPoValidAuthIndices
00601
00602 extern void _IceGetPoValidAuthIndices (
00603 #if NeedFunctionPrototypes
00604 const char * ,
00605 const char * ,
00606 int ,
00607 const char ** ,
00608 int * ,
00609 int *
00610 #endif
00611 );
00612
00613 #define _IceGetPaValidAuthIndices _kde_IceGetPaValidAuthIndices
00614
00615 extern void _IceGetPaValidAuthIndices (
00616 #if NeedFunctionPrototypes
00617 const char * ,
00618 const char * ,
00619 int ,
00620 const char ** ,
00621 int * ,
00622 int *
00623 #endif
00624 );
00625
00626 #endif