ICElib.h revision 9ef0b394
1/****************************************************************************** 2 3 4Copyright 1993, 1998 The Open Group 5 6Permission to use, copy, modify, distribute, and sell this software and its 7documentation for any purpose is hereby granted without fee, provided that 8the above copyright notice appear in all copies and that both that 9copyright notice and this permission notice appear in supporting 10documentation. 11 12The above copyright notice and this permission notice shall be included in 13all copies or substantial portions of the Software. 14 15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 22Except as contained in this notice, the name of The Open Group shall not be 23used in advertising or otherwise to promote the sale, use or other dealings 24in this Software without prior written authorization from The Open Group. 25 26Author: Ralph Mor, X Consortium 27******************************************************************************/ 28 29#ifndef _ICELIB_H_ 30#define _ICELIB_H_ 31 32#include <X11/ICE/ICE.h> 33#include <X11/Xfuncproto.h> 34 35#define Bool int 36#define Status int 37#define True 1 38#define False 0 39 40typedef void *IcePointer; 41 42typedef enum { 43 IcePoAuthHaveReply, 44 IcePoAuthRejected, 45 IcePoAuthFailed, 46 IcePoAuthDoneCleanup 47} IcePoAuthStatus; 48 49typedef enum { 50 IcePaAuthContinue, 51 IcePaAuthAccepted, 52 IcePaAuthRejected, 53 IcePaAuthFailed 54} IcePaAuthStatus; 55 56typedef enum { 57 IceConnectPending, 58 IceConnectAccepted, 59 IceConnectRejected, 60 IceConnectIOError 61} IceConnectStatus; 62 63typedef enum { 64 IceProtocolSetupSuccess, 65 IceProtocolSetupFailure, 66 IceProtocolSetupIOError, 67 IceProtocolAlreadyActive 68} IceProtocolSetupStatus; 69 70typedef enum { 71 IceAcceptSuccess, 72 IceAcceptFailure, 73 IceAcceptBadMalloc 74} IceAcceptStatus; 75 76typedef enum { 77 IceClosedNow, 78 IceClosedASAP, 79 IceConnectionInUse, 80 IceStartedShutdownNegotiation 81} IceCloseStatus; 82 83typedef enum { 84 IceProcessMessagesSuccess, 85 IceProcessMessagesIOError, 86 IceProcessMessagesConnectionClosed 87} IceProcessMessagesStatus; 88 89typedef struct { 90 unsigned long sequence_of_request; 91 int major_opcode_of_request; 92 int minor_opcode_of_request; 93 IcePointer reply; 94} IceReplyWaitInfo; 95 96typedef struct _IceConn *IceConn; 97typedef struct _IceListenObj *IceListenObj; 98 99typedef void (*IceWatchProc) ( 100 IceConn /* iceConn */, 101 IcePointer /* clientData */, 102 Bool /* opening */, 103 IcePointer * /* watchData */ 104); 105 106typedef void (*IcePoProcessMsgProc) ( 107 IceConn /* iceConn */, 108 IcePointer /* clientData */, 109 int /* opcode */, 110 unsigned long /* length */, 111 Bool /* swap */, 112 IceReplyWaitInfo * /* replyWait */, 113 Bool * /* replyReadyRet */ 114); 115 116typedef void (*IcePaProcessMsgProc) ( 117 IceConn /* iceConn */, 118 IcePointer /* clientData */, 119 int /* opcode */, 120 unsigned long /* length */, 121 Bool /* swap */ 122); 123 124typedef struct { 125 int major_version; 126 int minor_version; 127 IcePoProcessMsgProc process_msg_proc; 128} IcePoVersionRec; 129 130typedef struct { 131 int major_version; 132 int minor_version; 133 IcePaProcessMsgProc process_msg_proc; 134} IcePaVersionRec; 135 136typedef IcePoAuthStatus (*IcePoAuthProc) ( 137 IceConn /* iceConn */, 138 IcePointer * /* authStatePtr */, 139 Bool /* cleanUp */, 140 Bool /* swap */, 141 int /* authDataLen */, 142 IcePointer /* authData */, 143 int * /* replyDataLenRet */, 144 IcePointer * /* replyDataRet */, 145 char ** /* errorStringRet */ 146); 147 148typedef IcePaAuthStatus (*IcePaAuthProc) ( 149 IceConn /* iceConn */, 150 IcePointer * /* authStatePtr */, 151 Bool /* swap */, 152 int /* authDataLen */, 153 IcePointer /* authData */, 154 int * /* replyDataLenRet */, 155 IcePointer * /* replyDataRet */, 156 char ** /* errorStringRet */ 157); 158 159typedef Bool (*IceHostBasedAuthProc) ( 160 char * /* hostName */ 161); 162 163typedef Status (*IceProtocolSetupProc) ( 164 IceConn /* iceConn */, 165 int /* majorVersion */, 166 int /* minorVersion */, 167 char * /* vendor */, 168 char * /* release */, 169 IcePointer * /* clientDataRet */, 170 char ** /* failureReasonRet */ 171); 172 173typedef void (*IceProtocolActivateProc) ( 174 IceConn /* iceConn */, 175 IcePointer /* clientData */ 176); 177 178typedef void (*IceIOErrorProc) ( 179 IceConn /* iceConn */ 180); 181 182typedef void (*IcePingReplyProc) ( 183 IceConn /* iceConn */, 184 IcePointer /* clientData */ 185); 186 187typedef void (*IceErrorHandler) ( 188 IceConn /* iceConn */, 189 Bool /* swap */, 190 int /* offendingMinorOpcode */, 191 unsigned long /* offendingSequence */, 192 int /* errorClass */, 193 int /* severity */, 194 IcePointer /* values */ 195); 196 197typedef void (*IceIOErrorHandler) ( 198 IceConn /* iceConn */ 199); 200 201 202/* 203 * Function prototypes 204 */ 205 206_XFUNCPROTOBEGIN 207 208extern int IceRegisterForProtocolSetup ( 209 const char * /* protocolName */, 210 const char * /* vendor */, 211 const char * /* release */, 212 int /* versionCount */, 213 IcePoVersionRec * /* versionRecs */, 214 int /* authCount */, 215 const char ** /* authNames */, 216 IcePoAuthProc * /* authProcs */, 217 IceIOErrorProc /* IOErrorProc */ 218); 219 220extern int IceRegisterForProtocolReply ( 221 const char * /* protocolName */, 222 const char * /* vendor */, 223 const char * /* release */, 224 int /* versionCount */, 225 IcePaVersionRec * /* versionRecs */, 226 int /* authCount */, 227 const char ** /* authNames */, 228 IcePaAuthProc * /* authProcs */, 229 IceHostBasedAuthProc /* hostBasedAuthProc */, 230 IceProtocolSetupProc /* protocolSetupProc */, 231 IceProtocolActivateProc /* protocolActivateProc */, 232 IceIOErrorProc /* IOErrorProc */ 233); 234 235extern IceConn IceOpenConnection ( 236 char * /* networkIdsList */, 237 IcePointer /* context */, 238 Bool /* mustAuthenticate */, 239 int /* majorOpcodeCheck */, 240 int /* errorLength */, 241 char * /* errorStringRet */ 242); 243 244extern IcePointer IceGetConnectionContext ( 245 IceConn /* iceConn */ 246); 247 248extern Status IceListenForConnections ( 249 int * /* countRet */, 250 IceListenObj ** /* listenObjsRet */, 251 int /* errorLength */, 252 char * /* errorStringRet */ 253); 254 255extern Status IceListenForWellKnownConnections ( 256 char * /* port */, 257 int * /* countRet */, 258 IceListenObj ** /* listenObjsRet */, 259 int /* errorLength */, 260 char * /* errorStringRet */ 261); 262 263extern int IceGetListenConnectionNumber ( 264 IceListenObj /* listenObj */ 265); 266 267extern char *IceGetListenConnectionString ( 268 IceListenObj /* listenObj */ 269); 270 271extern char *IceComposeNetworkIdList ( 272 int /* count */, 273 IceListenObj * /* listenObjs */ 274); 275 276extern void IceFreeListenObjs ( 277 int /* count */, 278 IceListenObj * /* listenObjs */ 279); 280 281extern void IceSetHostBasedAuthProc ( 282 IceListenObj /* listenObj */, 283 IceHostBasedAuthProc /* hostBasedAuthProc */ 284); 285 286extern IceConn IceAcceptConnection ( 287 IceListenObj /* listenObj */, 288 IceAcceptStatus * /* statusRet */ 289); 290 291extern void IceSetShutdownNegotiation ( 292 IceConn /* iceConn */, 293 Bool /* negotiate */ 294); 295 296extern Bool IceCheckShutdownNegotiation ( 297 IceConn /* iceConn */ 298); 299 300extern IceCloseStatus IceCloseConnection ( 301 IceConn /* iceConn */ 302); 303 304extern Status IceAddConnectionWatch ( 305 IceWatchProc /* watchProc */, 306 IcePointer /* clientData */ 307); 308 309extern void IceRemoveConnectionWatch ( 310 IceWatchProc /* watchProc */, 311 IcePointer /* clientData */ 312); 313 314extern IceProtocolSetupStatus IceProtocolSetup ( 315 IceConn /* iceConn */, 316 int /* myOpcode */, 317 IcePointer /* clientData */, 318 Bool /* mustAuthenticate */, 319 int * /* majorVersionRet */, 320 int * /* minorVersionRet */, 321 char ** /* vendorRet */, 322 char ** /* releaseRet */, 323 int /* errorLength */, 324 char * /* errorStringRet */ 325); 326 327extern Status IceProtocolShutdown ( 328 IceConn /* iceConn */, 329 int /* majorOpcode */ 330); 331 332extern IceProcessMessagesStatus IceProcessMessages ( 333 IceConn /* iceConn */, 334 IceReplyWaitInfo * /* replyWait */, 335 Bool * /* replyReadyRet */ 336); 337 338extern Status IcePing ( 339 IceConn /* iceConn */, 340 IcePingReplyProc /* pingReplyProc */, 341 IcePointer /* clientData */ 342); 343 344extern char *IceAllocScratch ( 345 IceConn /* iceConn */, 346 unsigned long /* size */ 347); 348 349extern int IceFlush ( 350 IceConn /* iceConn */ 351); 352 353extern int IceGetOutBufSize ( 354 IceConn /* iceConn */ 355); 356 357extern int IceGetInBufSize ( 358 IceConn /* iceConn */ 359); 360 361extern IceConnectStatus IceConnectionStatus ( 362 IceConn /* iceConn */ 363); 364 365extern char *IceVendor ( 366 IceConn /* iceConn */ 367); 368 369extern char *IceRelease ( 370 IceConn /* iceConn */ 371); 372 373extern int IceProtocolVersion ( 374 IceConn /* iceConn */ 375); 376 377extern int IceProtocolRevision ( 378 IceConn /* iceConn */ 379); 380 381extern int IceConnectionNumber ( 382 IceConn /* iceConn */ 383); 384 385extern char *IceConnectionString ( 386 IceConn /* iceConn */ 387); 388 389extern unsigned long IceLastSentSequenceNumber ( 390 IceConn /* iceConn */ 391); 392 393extern unsigned long IceLastReceivedSequenceNumber ( 394 IceConn /* iceConn */ 395); 396 397extern Bool IceSwapping ( 398 IceConn /* iceConn */ 399); 400 401extern IceErrorHandler IceSetErrorHandler ( 402 IceErrorHandler /* handler */ 403); 404 405extern IceIOErrorHandler IceSetIOErrorHandler ( 406 IceIOErrorHandler /* handler */ 407); 408 409extern char *IceGetPeerName ( 410 IceConn /* iceConn */ 411); 412 413/* 414 * Multithread Routines 415 */ 416 417extern Status IceInitThreads ( 418 void 419); 420 421extern void IceAppLockConn ( 422 IceConn /* iceConn */ 423); 424 425extern void IceAppUnlockConn ( 426 IceConn /* iceConn */ 427); 428 429_XFUNCPROTOEND 430 431#endif /* _ICELIB_H_ */ 432