• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

dcop

ICEmsg.h

Go to the documentation of this file.
00001 /* $XConsortium: ICEmsg.h,v 1.5 94/04/17 20:15:26 mor Exp $ */
00002 /******************************************************************************
00003 
00004 
00005 Copyright (c) 1993  X Consortium
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a copy
00008 of this software and associated documentation files (the "Software"), to deal
00009 in the Software without restriction, including without limitation the rights
00010 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011 copies of the Software, and to permit persons to whom the Software is
00012 furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00020 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023 
00024 Except as contained in this notice, the name of the X Consortium shall not be
00025 used in advertising or otherwise to promote the sale, use or other dealings
00026 in this Software without prior written authorization from the X Consortium.
00027 
00028 Author: Ralph Mor, X Consortium
00029 ******************************************************************************/
00030 
00031 #ifndef _ICEMSG_H_
00032 #define _ICEMSG_H_
00033 
00034 #include <KDE-ICE/ICEconn.h>
00035 
00036 /*
00037  * Function prototypes for internal ICElib functions
00038  */
00039 
00040 #define _IceRead _kde_IceRead
00041 
00042 extern Status _IceRead (
00043 #if NeedFunctionPrototypes
00044     IceConn     /* iceConn */,
00045     unsigned long   /* nbytes */,
00046     char *      /* ptr */
00047 #endif
00048 );
00049 
00050 #define _IceReadSkip _kde_IceReadSkip
00051 
00052 extern void _IceReadSkip (
00053 #if NeedFunctionPrototypes
00054     IceConn     /* iceConn */,
00055     unsigned long   /* nbytes */
00056 #endif
00057 );
00058 
00059 #define _IceWrite _kde_IceWrite
00060 
00061 extern void _IceWrite (
00062 #if NeedFunctionPrototypes
00063     IceConn     /* iceConn */,
00064     unsigned long   /* nbytes */,
00065     char *      /* ptr */
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     /* iceConn */,
00077     int         /* majorOpcode */,
00078     int         /* offendingMinor */,
00079     int         /* severity */
00080 #endif
00081 );
00082 
00083 #define _IceErrorBadState _kde_IceErrorBadState
00084 
00085 extern void _IceErrorBadState (
00086 #if NeedFunctionPrototypes
00087     IceConn     /* iceConn */,
00088     int         /* majorOpcode */,
00089     int         /* offendingMinor */,
00090     int         /* severity */
00091 #endif
00092 );
00093 
00094 #define _IceErrorBadLength _kde_IceErrorBadLength
00095 
00096 extern void _IceErrorBadLength (
00097 #if NeedFunctionPrototypes
00098     IceConn     /* iceConn */,
00099     int         /* majorOpcode */,
00100     int         /* offendingMinor */,
00101     int         /* severity */
00102 #endif
00103 );
00104 
00105 #define _IceErrorBadValue _kde_IceErrorBadValue
00106 
00107 extern void _IceErrorBadValue (
00108 #if NeedFunctionPrototypes
00109     IceConn     /* iceConn */,
00110     int         /* majorOpcode */,
00111     int         /* offendingMinor */,
00112     int         /* offset */,
00113     int         /* length */,
00114     IcePointer      /* value */
00115 #endif
00116 );
00117 
00118 
00119 /*
00120  * Macro to check if IO operations are valid on an ICE connection.
00121  */
00122 
00123 #define IceValidIO(_iceConn) _iceConn->io_ok
00124 
00125 
00126 /*
00127  * Macros for writing messages.
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  * Write data into the ICE output buffer.
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 /* WORD64 */
00203 
00204 /* IceWriteData16 and IceWriteData32 defined in misc.c for WORD64 */
00205 
00206 #endif /* WORD64 */
00207 
00208 
00209 /*
00210  * The IceSendData macro bypasses copying the data to the
00211  * ICE connection buffer and sends the data directly.  If necessary,
00212  * the ICE connection buffer is first flushed.
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  * Write pad bytes.  Used to force 32 or 64 bit alignment.
00225  * A maxium of 7 pad bytes can be specified.
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  * Macros for reading messages.
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 /* WORD64 */
00302 
00303 /* IceReadData16 and IceReadData32 defined in misc.c for WORD64 */
00304 
00305 #endif /* WORD64 */
00306 
00307 
00308 /*
00309  * Read pad bytes (for 32 or 64 bit alignment).
00310  * A maxium of 7 pad bytes can be specified.
00311  */
00312 
00313 #define IceReadPad(_iceConn, _bytes) \
00314 { \
00315     char _dummy[7]; \
00316     _IceRead (_iceConn, (unsigned long) (_bytes), _dummy); \
00317 }
00318 
00319 #endif /* _ICEMSG_H_ */

dcop

Skip menu "dcop"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal