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
00027
00028
00029
00030
00031 #ifndef _ICEMSG_H_
00032 #define _ICEMSG_H_
00033
00034 #include <KDE-ICE/ICEconn.h>
00035
00036
00037
00038
00039
00040 #define _IceRead _kde_IceRead
00041
00042 extern Status _IceRead (
00043 #if NeedFunctionPrototypes
00044 IceConn ,
00045 unsigned long ,
00046 char *
00047 #endif
00048 );
00049
00050 #define _IceReadSkip _kde_IceReadSkip
00051
00052 extern void _IceReadSkip (
00053 #if NeedFunctionPrototypes
00054 IceConn ,
00055 unsigned long
00056 #endif
00057 );
00058
00059 #define _IceWrite _kde_IceWrite
00060
00061 extern void _IceWrite (
00062 #if NeedFunctionPrototypes
00063 IceConn ,
00064 unsigned long ,
00065 char *
00066 #endif
00067 );
00068
00069 #define _IceWriteHandler _kde_IceWriteHandler
00070 extern IceWriteHandler _IceWriteHandler;
00071
00072 #define _IceErrorBadMinor _kde_IceErrorBadMinor
00073
00074 extern void _IceErrorBadMinor (
00075 #if NeedFunctionPrototypes
00076 IceConn ,
00077 int ,
00078 int ,
00079 int
00080 #endif
00081 );
00082
00083 #define _IceErrorBadState _kde_IceErrorBadState
00084
00085 extern void _IceErrorBadState (
00086 #if NeedFunctionPrototypes
00087 IceConn ,
00088 int ,
00089 int ,
00090 int
00091 #endif
00092 );
00093
00094 #define _IceErrorBadLength _kde_IceErrorBadLength
00095
00096 extern void _IceErrorBadLength (
00097 #if NeedFunctionPrototypes
00098 IceConn ,
00099 int ,
00100 int ,
00101 int
00102 #endif
00103 );
00104
00105 #define _IceErrorBadValue _kde_IceErrorBadValue
00106
00107 extern void _IceErrorBadValue (
00108 #if NeedFunctionPrototypes
00109 IceConn ,
00110 int ,
00111 int ,
00112 int ,
00113 int ,
00114 IcePointer
00115 #endif
00116 );
00117
00118
00119
00120
00121
00122
00123 #define IceValidIO(_iceConn) _iceConn->io_ok
00124
00125
00126
00127
00128
00129
00130 #define IceGetHeader(_iceConn, _major, _minor, _headerSize, _msgType, _pMsg) \
00131 if ((_iceConn->outbufptr + _headerSize) > _iceConn->outbufmax) \
00132 IceFlush (_iceConn); \
00133 _pMsg = (_msgType *) _iceConn->outbufptr; \
00134 _pMsg->majorOpcode = _major; \
00135 _pMsg->minorOpcode = _minor; \
00136 _pMsg->length = (_headerSize - SIZEOF (iceMsg)) >> 3; \
00137 _iceConn->outbufptr += _headerSize; \
00138 _iceConn->send_sequence++
00139
00140 #define IceGetHeaderExtra(_iceConn, _major, _minor, _headerSize, _extra, _msgType, _pMsg, _pData) \
00141 if ((_iceConn->outbufptr + \
00142 _headerSize + ((_extra) << 3)) > _iceConn->outbufmax) \
00143 IceFlush (_iceConn); \
00144 _pMsg = (_msgType *) _iceConn->outbufptr; \
00145 if ((_iceConn->outbufptr + \
00146 _headerSize + ((_extra) << 3)) <= _iceConn->outbufmax) \
00147 _pData = (char *) _pMsg + _headerSize; \
00148 else \
00149 _pData = NULL; \
00150 _pMsg->majorOpcode = _major; \
00151 _pMsg->minorOpcode = _minor; \
00152 _pMsg->length = ((_headerSize - SIZEOF (iceMsg)) >> 3) + (_extra); \
00153 _iceConn->outbufptr += (_headerSize + ((_extra) << 3)); \
00154 _iceConn->send_sequence++
00155
00156 #define IceSimpleMessage(_iceConn, _major, _minor) \
00157 { \
00158 iceMsg *_pMsg; \
00159 IceGetHeader (_iceConn, _major, _minor, SIZEOF (iceMsg), iceMsg, _pMsg); \
00160 }
00161
00162 #define IceErrorHeader(_iceConn, _offendingMajorOpcode, _offendingMinorOpcode, _offendingSequenceNum, _severity, _errorClass, _dataLength) \
00163 { \
00164 iceErrorMsg *_pMsg; \
00165 \
00166 IceGetHeader (_iceConn, _offendingMajorOpcode, ICE_Error, \
00167 SIZEOF (iceErrorMsg), iceErrorMsg, _pMsg); \
00168 _pMsg->length += (_dataLength); \
00169 _pMsg->offendingMinorOpcode = _offendingMinorOpcode; \
00170 _pMsg->severity = _severity; \
00171 _pMsg->offendingSequenceNum = _offendingSequenceNum; \
00172 _pMsg->errorClass = _errorClass; \
00173 }
00174
00175
00176
00177
00178
00179
00180 #define IceWriteData(_iceConn, _bytes, _data) \
00181 { \
00182 if ((_iceConn->outbufptr + (_bytes)) > _iceConn->outbufmax) \
00183 { \
00184 IceFlush (_iceConn); \
00185 (*_IceWriteHandler) (_iceConn, (unsigned long) (_bytes), _data); \
00186 } \
00187 else \
00188 { \
00189 memcpy (_iceConn->outbufptr, _data, _bytes); \
00190 _iceConn->outbufptr += (_bytes); \
00191 } \
00192 }
00193
00194 #ifndef WORD64
00195
00196 #define IceWriteData16(_iceConn, _bytes, _data) \
00197 IceWriteData (_iceConn, _bytes, (char *) _data)
00198
00199 #define IceWriteData32(_iceConn, _bytes, _data) \
00200 IceWriteData (_iceConn, _bytes, (char *) _data)
00201
00202 #else
00203
00204
00205
00206 #endif
00207
00208
00209
00210
00211
00212
00213
00214
00215 #define IceSendData(_iceConn, _bytes, _data) \
00216 { \
00217 if (_iceConn->outbufptr > _iceConn->outbuf) \
00218 IceFlush (_iceConn); \
00219 (*_IceWriteHandler) (_iceConn, (unsigned long) (_bytes), _data); \
00220 }
00221
00222
00223
00224
00225
00226
00227
00228 #define IceWritePad(_iceConn, _bytes) \
00229 { \
00230 if ((_iceConn->outbufptr + (_bytes)) > _iceConn->outbufmax) \
00231 { \
00232 char _dummy[7]; \
00233 IceFlush (_iceConn); \
00234 (*_IceWriteHandler) (_iceConn, (unsigned long) (_bytes), _dummy); \
00235 } \
00236 else \
00237 { \
00238 _iceConn->outbufptr += (_bytes); \
00239 } \
00240 }
00241
00242
00243
00244
00245
00246
00247 #define IceReadCompleteMessage(_iceConn, _headerSize, _msgType, _pMsg, _pData)\
00248 { \
00249 unsigned long _bytes; \
00250 IceReadMessageHeader (_iceConn, _headerSize, _msgType, _pMsg); \
00251 _bytes = (_pMsg->length << 3) - (_headerSize - SIZEOF (iceMsg)); \
00252 if ((unsigned long)(_iceConn->inbufmax - _iceConn->inbufptr) >= _bytes) \
00253 { \
00254 _IceRead (_iceConn, _bytes, _iceConn->inbufptr); \
00255 _pData = _iceConn->inbufptr; \
00256 _iceConn->inbufptr += _bytes; \
00257 } \
00258 else \
00259 { \
00260 _pData = (char *) malloc ((unsigned) _bytes); \
00261 if (_pData) \
00262 _IceRead (_iceConn, _bytes, _pData); \
00263 else \
00264 _IceReadSkip (_iceConn, _bytes); \
00265 } \
00266 }
00267
00268 #define IceDisposeCompleteMessage(_iceConn, _pData) \
00269 if ((char *) _pData < _iceConn->inbuf || \
00270 (char *) _pData >= _iceConn->inbufmax) \
00271 free ((char *) _pData);
00272
00273
00274 #define IceReadSimpleMessage(_iceConn, _msgType, _pMsg) \
00275 _pMsg = (_msgType *) (_iceConn->inbuf);
00276
00277 #define IceReadMessageHeader(_iceConn, _headerSize, _msgType, _pMsg) \
00278 { \
00279 _IceRead (_iceConn, \
00280 (unsigned long) (_headerSize - SIZEOF (iceMsg)), \
00281 _iceConn->inbufptr); \
00282 _pMsg = (_msgType *) (_iceConn->inbuf); \
00283 _iceConn->inbufptr += (_headerSize - SIZEOF (iceMsg)); \
00284 }
00285
00286 #define IceReadData(_iceConn, _bytes, _pData) \
00287 _IceRead (_iceConn, (unsigned long) (_bytes), (char *) _pData); \
00288
00289 #ifndef WORD64
00290
00291 #define IceReadData16(_iceConn, _swap, _bytes, _pData) \
00292 { \
00293 _IceRead (_iceConn, (unsigned long) (_bytes), (char *) _pData); \
00294 }
00295
00296 #define IceReadData32(_iceConn, _swap, _bytes, _pData) \
00297 { \
00298 _IceRead (_iceConn, (unsigned long) (_bytes), (char *) _pData); \
00299 }
00300
00301 #else
00302
00303
00304
00305 #endif
00306
00307
00308
00309
00310
00311
00312
00313 #define IceReadPad(_iceConn, _bytes) \
00314 { \
00315 char _dummy[7]; \
00316 _IceRead (_iceConn, (unsigned long) (_bytes), _dummy); \
00317 }
00318
00319 #endif