6.7. Data Definitions for libICE

This section defines global identifiers and their values that are associated with interfaces contained in libICE. These definitions are organized into groups that correspond to system headers. This convention is used as a convenience for the reader, and does not imply the existence of these headers, or their content. Where an interface is defined as requiring a particular system header file all of the data definitions for that system header file presented here shall be in effect.

This section gives data definitions to promote binary application portability, not to repeat source interface definitions available elsewhere. System providers and application developers should use this ABI to supplement - not to replace - source interface definition specifications.

This specification uses the ISO C (1999) C Language as the reference programming language, and data definitions are specified in ISO C format. The C language is used here as a convenient notation. Using a C language description of these data objects does not preclude their use by other programming languages.

6.7.1. X11/ICE/ICE.h


#define ICE_Error	0
#define IceBadMajor	0
#define IceCanContinue	0
#define IceLSBfirst	0
#define IceProtoMinor	0
#define IceBadMinor	0x8000
#define IceBadState	0x8001
#define IceBadLength	0x8002
#define IceBadValue	0x8003
#define ICE_ByteOrder	1
#define IceFatalToProtocol	1
#define IceMSBfirst	1
#define IceNoAuth	1
#define IceProtoMajor	1
#define ICE_PingReply	10
#define ICE_WantToClose	11
#define ICE_NoClose	12
#define ICE_ConnectionSetup	2
#define IceFatalToConnection	2
#define IceNoVersion	2
#define ICE_AuthRequired	3
#define IceSetupFailed	3
#define ICE_AuthReply	4
#define IceAuthRejected	4
#define ICE_AuthNextPhase	5
#define IceAuthFailed	5
#define ICE_ConnectionReply	6
#define IceProtocolDuplicate	6
#define ICE_ProtocolSetup	7
#define IceMajorOpcodeDuplicate	7
#define ICE_ProtocolReply	8
#define IceUnknownProtocol	8
#define ICE_Ping	9

6.7.2. X11/ICE/ICEconn.h


struct _XtransConnInfo;
typedef struct {
    char *vendor;
    char *release;
    int version_count;
    IcePoVersionRec *version_recs;
    int auth_count;
    char **auth_names;
    IcePoAuthProc *auth_procs;
    IceIOErrorProc io_error_proc;
} _IcePoProtocol;
typedef struct {
    char *vendor;
    char *release;
    int version_count;
    IcePaVersionRec *version_recs;
    IceProtocolSetupProc protocol_setup_proc;
    IceProtocolActivateProc protocol_activate_proc;
    int auth_count;
    char **auth_names;
    IcePaAuthProc *auth_procs;
    IceHostBasedAuthProc host_based_auth_proc;
    IceIOErrorProc io_error_proc;
} _IcePaProtocol;
typedef struct {
    char *protocol_name;
    _IcePoProtocol *orig_client;
    _IcePaProtocol *accept_client;
} _IceProtocol;
typedef struct {
    int in_use;
    int my_opcode;
    _IceProtocol *protocol;
    IcePointer client_data;
    int accept_flag;
    union {
	IcePaProcessMsgProc accept_client;
	IcePoProcessMsgProc orig_client;
    } process_msg_proc;
} _IceProcessMsgInfo;
typedef struct _IceSavedReplyWait {
    IceReplyWaitInfo *reply_wait;
    int reply_ready;
    _IceSavedReplyWait *next;
} _IceSavedReplyWait;
typedef struct _IcePingWait {
    IcePingReplyProc ping_reply_proc;
    IcePointer client_data;
    _IcePingWait *next;
} _IcePingWait;
typedef struct {
    int auth_active;
    char my_auth_index;
    IcePointer my_auth_state;
} _IceConnectToYouInfo;
typedef struct {
    int my_opcode;
    int my_auth_count;
    int *my_auth_indices;
    int auth_active;
    char my_auth_index;
    IcePointer my_auth_state;
} _IceProtoSetupToYouInfo;
typedef struct {
    int his_version_index;
    int my_version_index;
    char *his_vendor;
    char *his_release;
    char my_auth_index;
    IcePointer my_auth_state;
    int must_authenticate;
} _IceConnectToMeInfo;
typedef struct {
    int his_opcode;
    int my_opcode;
    int his_version_index;
    int my_version_index;
    char *his_vendor;
    char *his_release;
    char my_auth_index;
    IcePointer my_auth_state;
    int must_authenticate;
} _IceProtoSetupToMeInfo;
struct _IceConn {
    unsigned int io_ok:1;
    unsigned int swap:1;
    unsigned int waiting_for_byteorder:1;
    unsigned int skip_want_to_close:1;
    unsigned int want_to_close:1;
    unsigned int free_asap:1;
    unsigned int unused1:2;
    unsigned int unused2:8;
    IceConnectStatus connection_status;
    unsigned char my_ice_version_index;
    struct _XtransConnInfo *trans_conn;
    long unsigned int send_sequence;
    long unsigned int receive_sequence;
    char *connection_string;
    char *vendor;
    char *release;
    char *inbuf;
    char *inbufptr;
    char *inbufmax;
    char *outbuf;
    char *outbufptr;
    char *outbufmax;
    char *scratch;
    long unsigned int scratch_size;
    int dispatch_level;
    IcePointer context;
    _IceProcessMsgInfo *process_msg_info;
    char his_min_opcode;
    char his_max_opcode;
    unsigned char open_ref_count;
    unsigned char proto_ref_count;
    IceListenObj listen_obj;
    _IceSavedReplyWait *saved_reply_waits;
    _IcePingWait *ping_waits;
    _IceConnectToYouInfo *connect_to_you;
    _IceProtoSetupToYouInfo *protosetup_to_you;
    _IceConnectToMeInfo *connect_to_me;
    _IceProtoSetupToMeInfo *protosetup_to_me;
};

6.7.3. X11/ICE/ICElib.h


typedef void *IcePointer;
typedef struct _IceConn *IceConn;
typedef void (*IcePaProcessMsgProc) (IceConn, IcePointer, int,
				     long unsigned int, int);
typedef struct {
    int major_version;
    int minor_version;
    IcePaProcessMsgProc process_msg_proc;
} IcePaVersionRec;
typedef struct {
    long unsigned int sequence_of_request;
    int major_opcode_of_request;
    int minor_opcode_of_request;
    IcePointer reply;
} IceReplyWaitInfo;
typedef void (*IcePoProcessMsgProc) (IceConn, IcePointer, int,
				     long unsigned int, int,
				     IceReplyWaitInfo *, int *);
typedef struct {
    int major_version;
    int minor_version;
    IcePoProcessMsgProc process_msg_proc;
} IcePoVersionRec;
typedef IcePoAuthStatus(*IcePoAuthProc) (IceConn, IcePointer *, int, int,
					 int, IcePointer, int *,
					 IcePointer *, char **);
typedef IcePaAuthStatus(*IcePaAuthProc) (IceConn, IcePointer *, int, int,
					 IcePointer, int *, IcePointer *,
					 char **);
typedef enum {
    IceAcceptSuccess = 0,
    IceAcceptFailure = 1,
    IceAcceptBadMalloc = 2
} IceAcceptStatus;
struct _IceListenObj;
typedef struct _IceListenObj *IceListenObj;
typedef enum {
    IceConnectPending = 0,
    IceConnectAccepted = 1,
    IceConnectRejected = 2,
    IceConnectIOError = 3
} IceConnectStatus;
typedef void (*IceIOErrorProc) (IceConn);
typedef int (*IceProtocolSetupProc) (IceConn, int, int, char *, char *,
				     IcePointer *, char **);
typedef void (*IceProtocolActivateProc) (IceConn, IcePointer);
typedef int (*IceHostBasedAuthProc) (char *);
typedef void (*IcePingReplyProc) (IceConn, IcePointer);
typedef enum {
    IceProcessMessagesSuccess = 0,
    IceProcessMessagesIOError = 1,
    IceProcessMessagesConnectionClosed = 2
} IceProcessMessagesStatus;
typedef enum {
    IceClosedNow = 0,
    IceClosedASAP = 1,
    IceConnectionInUse = 2,
    IceStartedShutdownNegotiation = 3
} IceCloseStatus;
typedef enum {
    IceProtocolSetupSuccess = 0,
    IceProtocolSetupFailure = 1,
    IceProtocolSetupIOError = 2,
    IceProtocolAlreadyActive = 3
} IceProtocolSetupStatus;
typedef void (*IceWatchProc) (IceConn, IcePointer, int, IcePointer *);
typedef void (*IceIOErrorHandler) (IceConn);
typedef void (*IceErrorHandler) (IceConn, int, int, long unsigned int, int,
				 int, IcePointer);
typedef enum {
    IcePoAuthHaveReply,
    IcePoAuthRejected,
    IcePoAuthFailed,
    IcePoAuthDoneCleanup
} IcePoAuthStatus;
typedef enum {
    IcePaAuthContinue,
    IcePaAuthAccepted,
    IcePaAuthRejected,
    IcePaAuthFailed
} IcePaAuthStatus;
extern IceConn IceAcceptConnection(IceListenObj, IceAcceptStatus *);
extern int IceAddConnectionWatch(IceWatchProc, IcePointer);
extern char *IceAllocScratch(IceConn, long unsigned int);
extern void IceAppLockConn(IceConn);
extern void IceAppUnlockConn(IceConn);
extern int IceCheckShutdownNegotiation(IceConn);
extern IceCloseStatus IceCloseConnection(IceConn);
extern char *IceComposeNetworkIdList(int, IceListenObj *);
extern int IceConnectionNumber(IceConn);
extern IceConnectStatus IceConnectionStatus(IceConn);
extern char *IceConnectionString(IceConn);
extern int IceFlush(IceConn);
extern void IceFreeListenObjs(int, IceListenObj *);
extern IcePointer IceGetConnectionContext(IceConn);
extern int IceGetInBufSize(IceConn);
extern int IceGetListenConnectionNumber(IceListenObj);
extern char *IceGetListenConnectionString(IceListenObj);
extern int IceGetOutBufSize(IceConn);
extern int IceInitThreads(void);
extern long unsigned int IceLastReceivedSequenceNumber(IceConn);
extern long unsigned int IceLastSentSequenceNumber(IceConn);
extern int IceListenForConnections(int *, IceListenObj * *, int, char *);
extern int IceListenForWellKnownConnections(char *, int *,
					    IceListenObj * *, int, char *);
extern IceConn IceOpenConnection(char *, IcePointer, int, int, int,
				 char *);
extern int IcePing(IceConn, IcePingReplyProc, IcePointer);
extern IceProcessMessagesStatus IceProcessMessages(IceConn,
						   IceReplyWaitInfo *,
						   int *);
extern int IceProtocolRevision(IceConn);
extern IceProtocolSetupStatus IceProtocolSetup(IceConn, int, IcePointer,
					       int, int *, int *, char **,
					       char **, int, char *);
extern int IceProtocolShutdown(IceConn, int);
extern int IceProtocolVersion(IceConn);
extern int IceRegisterForProtocolReply(char *, char *, char *, int,
				       IcePaVersionRec *, int,
				       const char **, IcePaAuthProc *,
				       IceHostBasedAuthProc,
				       IceProtocolSetupProc,
				       IceProtocolActivateProc,
				       IceIOErrorProc);
extern int IceRegisterForProtocolSetup(char *, char *, char *, int,
				       IcePoVersionRec *, int,
				       const char **, IcePoAuthProc *,
				       IceIOErrorProc);
extern char *IceRelease(IceConn);
extern void IceRemoveConnectionWatch(IceWatchProc, IcePointer);
extern IceErrorHandler IceSetErrorHandler(IceErrorHandler);
extern void IceSetHostBasedAuthProc(IceListenObj, IceHostBasedAuthProc);
extern IceIOErrorHandler IceSetIOErrorHandler(IceIOErrorHandler);
extern void IceSetShutdownNegotiation(IceConn, int);
extern int IceSwapping(IceConn);
extern char *IceVendor(IceConn);

6.7.4. X11/ICE/ICEmsg.h


#define IceWriteData16(_iceConn,_bytes,_data)	IceWriteData (_iceConn, _bytes, (char *) _data)
#define IceWriteData32(_iceConn,_bytes,_data)	IceWriteData (_iceConn, _bytes, (char *) _data)
#define IceDisposeCompleteMessage(_iceConn,_pData)	if ((char *) _pData < _iceConn->inbuf || (char *) _pData >= _iceConn->inbufmax) \
    free ((char *) _pData);
#define IceGetHeaderExtra(_iceConn,_major,_minor,_headerSize,_extra,_msgType,_pMsg,_pData)	if ((_iceConn->outbufptr + _headerSize + ((_extra) << 3)) > _iceConn->outbufmax) IceFlush (_iceConn);\
 _pMsg = (_msgType *) _iceConn->outbufptr;\
 if ((_iceConn->outbufptr + _headerSize + ((_extra) << 3)) <= _iceConn->outbufmax) _pData = (char *) _pMsg + _headerSize;\
 else _pData = ((void *)0);\
 _pMsg->majorOpcode = _major;\
 _pMsg->minorOpcode = _minor;\
 _pMsg->length = ((_headerSize - SIZEOF (iceMsg)) >> 3) + (_extra);\
 _iceConn->outbufptr += (_headerSize + ((_extra) << 3));\
 _iceConn->send_sequence++
#define IceGetHeader(_iceConn,_major,_minor,_headerSize,_msgType,_pMsg)	if ((_iceConn->outbufptr + _headerSize) > _iceConn->outbufmax) IceFlush (_iceConn);\
 _pMsg = (_msgType *) _iceConn->outbufptr;\
 _pMsg->majorOpcode = _major;\
 _pMsg->minorOpcode = _minor;\
 _pMsg->length = (_headerSize - SIZEOF (iceMsg)) >> 3;\
 _iceConn->outbufptr += _headerSize;\
 _iceConn->send_sequence++
#define IceValidIO(_iceConn)	_iceConn->io_ok
#define IceReadData(_iceConn,_bytes,_pData)	_IceRead (_iceConn, (unsigned long) (_bytes), (char *) _pData);
#define IceReadSimpleMessage(_iceConn,_msgType,_pMsg)	_pMsg = (_msgType *) (_iceConn->inbuf);
#define IceReadPad(_iceConn,_bytes)	{ char _dummy[7]; _IceRead (_iceConn, (unsigned long) (_bytes), _dummy); }
#define IceErrorHeader(_iceConn,_offendingMajorOpcode,_offendingMinorOpcode,_offendingSequenceNum,_severity,_errorClass,_dataLength)	{ iceErrorMsg *_pMsg;\
 IceGetHeader (_iceConn, _offendingMajorOpcode, ICE_Error, SIZEOF (iceErrorMsg), iceErrorMsg, _pMsg);\
 _pMsg->length += (_dataLength);\
 _pMsg->offendingMinorOpcode = _offendingMinorOpcode;\
 _pMsg->severity = _severity;\
 _pMsg->offendingSequenceNum = _offendingSequenceNum;\
 _pMsg->errorClass = _errorClass;\
 }
#define IceSimpleMessage(_iceConn,_major,_minor)	{ iceMsg *_pMsg; IceGetHeader (_iceConn, _major, _minor, SIZEOF (iceMsg), iceMsg, _pMsg) }
#define IceWritePad(_iceConn,_bytes)	{ if ((_iceConn->outbufptr + (_bytes)) > _iceConn->outbufmax) { char _dummy[7];\
 IceFlush (_iceConn);\
 _IceWrite (_iceConn, (unsigned long) (_bytes), _dummy);\
 } else { _iceConn->outbufptr += (_bytes);\
 } }
#define IceWriteData(_iceConn,_bytes,_data)	{ if ((_iceConn->outbufptr + (_bytes)) > _iceConn->outbufmax) { IceFlush (_iceConn);\
 _IceWrite (_iceConn, (unsigned long) (_bytes), _data);\
 } else { memcpy (_iceConn->outbufptr, _data, _bytes);\
 _iceConn->outbufptr += (_bytes);\
 } }
#define IceSendData(_iceConn,_bytes,_data)	{ if (_iceConn->outbufptr > _iceConn->outbuf) IceFlush (_iceConn);\
 _IceWrite (_iceConn, (unsigned long) (_bytes), _data);\
 }
#define IceReadCompleteMessage(_iceConn,_headerSize,_msgType,_pMsg,_pData)	{ \
    unsigned long _bytes; \
    IceReadMessageHeader (_iceConn, _headerSize, _msgType, _pMsg); \
    _bytes = (_pMsg->length << 3) - (_headerSize - SIZEOF (iceMsg)); \
    if ((_iceConn->inbufmax - _iceConn->inbufptr) >= _bytes) \
    { \
        _IceRead (_iceConn, _bytes, _iceConn->inbufptr); \
        _pData = _iceConn->inbufptr; \
        _iceConn->inbufptr += _bytes; \
    } \
    else \
    { \
        _pData = (char *) malloc ((unsigned) _bytes); \
        if (_pData) \
            _IceRead (_iceConn, _bytes, _pData); \
        else \
            _IceReadSkip (_iceConn, _bytes); \
    } \
}
#define IceReadData16(_iceConn,_swap,_bytes,_pData)	{ _IceRead (_iceConn, (unsigned long) (_bytes), (char *) _pData); }
#define IceReadData32(_iceConn,_swap,_bytes,_pData)	{ _IceRead (_iceConn, (unsigned long) (_bytes), (char *) _pData); }
#define IceReadMessageHeader(_iceConn,_headerSize,_msgType,_pMsg)	{ _IceRead (_iceConn, (unsigned long) (_headerSize - SIZEOF (iceMsg)), _iceConn->inbufptr);\
 _pMsg = (_msgType *) (_iceConn->inbuf);\
 _iceConn->inbufptr += (_headerSize - SIZEOF (iceMsg));\
 }

extern int _IceRead(IceConn, unsigned long int, char *);
extern void _IceReadSkip(IceConn, unsigned long int);
extern void _IceWrite(IceConn, unsigned long int, char *);

6.7.5. X11/ICE/ICEproto.h


#define sz_iceAuthNextPhaseMsg	16
#define sz_iceAuthReplyMsg	16
#define sz_iceAuthRequiredMsg	16
#define sz_iceConnectionSetupMsg	16
#define sz_iceErrorMsg	16
#define sz_iceProtocolSetupMsg	16
#define sz_iceByteOrderMsg	8
#define sz_iceConnectionReplyMsg	8
#define sz_iceMsg	8
#define sz_iceNoCloseMsg	8
#define sz_icePingMsg	8
#define sz_icePingReplyMsg	8
#define sz_iceProtocolReplyMsg	8
#define sz_iceWantToCloseMsg	8

typedef iceErrorMsg icePingMsg;
typedef iceErrorMsg icePingReplyMsg;
typedef iceErrorMsg iceWantToCloseMsg;
typedef iceErrorMsg iceNoCloseMsg;

6.7.6. X11/ICE/ICEutil.h


#define IceAuthLockSuccess	0
#define IceAuthLockError	1
#define IceAuthLockTimeout	2

typedef struct {
    char *protocol_name;
    char *network_id;
    char *auth_name;
    short unsigned int auth_data_length;
    char *auth_data;
} IceAuthDataEntry;
typedef struct {
    char *protocol_name;
    short unsigned int protocol_data_length;
    char *protocol_data;
    char *network_id;
    char *auth_name;
    short unsigned int auth_data_length;
    char *auth_data;
} IceAuthFileEntry;
extern char *IceAuthFileName(void);
extern void IceFreeAuthFileEntry(IceAuthFileEntry *);
extern char *IceGenerateMagicCookie(int);
extern IceAuthFileEntry *IceGetAuthFileEntry(char *, char *, char *);
extern int IceLockAuthFile(char *, int, int, long int);
extern IceAuthFileEntry *IceReadAuthFileEntry(FILE *);
extern void IceSetPaAuthData(int, IceAuthDataEntry *);
extern void IceUnlockAuthFile(char *);
extern int IceWriteAuthFileEntry(FILE *, IceAuthFileEntry *);