00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00028 #ifndef _RTXCONTEXT_H_
00029 #define _RTXCONTEXT_H_
00030
00031 #include "rtxsrc/rtxDList.h"
00032
00033 #define OSRTENCBUFSIZ 1024
00034
00039
00040
00041 #define OSRTERRSTKSIZ 8
00042 #define OSRTMAXERRPRM 5
00043
00051 typedef struct {
00052 const OSUTF8CHAR* module;
00053 OSINT32 lineno;
00054 } OSRTErrLocn;
00055
00066 typedef struct {
00067 OSRTErrLocn stack[OSRTERRSTKSIZ];
00068 OSINT16 status;
00069 OSUINT8 stkx;
00070 OSUINT8 parmcnt;
00071 OSUTF8CHAR* parms[OSRTMAXERRPRM];
00072 OSUTF8CHAR* elemName;
00073 } OSRTErrInfo;
00074
00075 typedef struct {
00076 OSRTDList list;
00077 OSRTErrInfo reserved;
00078 OSRTDListNode reservedNode;
00079 } OSRTErrInfoList;
00080
00089 typedef struct {
00090 OSOCTET* data;
00091 OSSIZE byteIndex;
00092 OSSIZE size;
00093 OSINT16 bitOffset;
00094 OSBOOL dynamic;
00095 OSBOOL aligned;
00096 } OSRTBuffer;
00097
00098 typedef OSUINT32 OSRTFLAGS;
00099
00106 typedef struct {
00107 OSSIZE byteIndex;
00108 OSINT16 bitOffset;
00109 OSRTFLAGS flags;
00110 } OSRTBufSave;
00111
00112
00113
00114
00115 #define OSDIAG 0x80000000
00116 #define OSTRACE 0x40000000
00117 #define OSDISSTRM 0x20000000
00118 #define OSNOSTRMBACKOFF 0x8000000
00119 #define OS3GMOBORIG 0x4000000
00120
00121 struct OSCTXT;
00128 typedef int (*OSFreeCtxtAppInfoPtr)(struct OSCTXT* pctxt);
00129
00136 typedef int (*OSResetCtxtAppInfoPtr)(struct OSCTXT* pctxt);
00137
00145 typedef void (*OSFreeCtxtGlobalPtr)(struct OSCTXT* pctxt);
00146
00147
00148
00149
00150 #if !defined(OSCDECL)
00151 #if defined(_MSC_VER) || defined(__BORLANDC__)
00152 #define OSCDECL __cdecl
00153 #else
00154 #define OSCDECL
00155 #endif
00156 #endif
00157
00165 typedef struct OSCTXT {
00166 void* pMemHeap;
00167 OSRTBuffer buffer;
00168 OSRTBufSave savedInfo;
00169 OSRTErrInfoList errInfo;
00170 OSUINT32 initCode;
00171 OSRTFLAGS flags;
00172 OSOCTET level;
00173 OSOCTET state;
00174 OSOCTET diagLevel;
00175 OSOCTET lastChar;
00176 #ifndef _NO_STREAM
00177 struct OSRTSTREAM* pStream;
00178 struct OSRTPrintStream *pPrintStrm;
00179 #endif
00180 OSRTDList elemNameStack;
00181 OSRTDList regExpCache;
00182 const OSOCTET* key;
00183 OSSIZE keylen;
00184 OSVoidPtr pXMLInfo;
00185 OSVoidPtr pASN1Info;
00186 OSVoidPtr pUserData;
00187 OSVoidPtr pGlobalData;
00188 OSFreeCtxtGlobalPtr gblFreeFunc;
00189 OSVoidPtr ssl;
00190 struct OSRTDiagBitFieldList* pBitFldList;
00191 OSUINT16 indent;
00192 OSUINT16 version;
00193 } OSCTXT;
00194
00195 #define OSRT_GET_FIRST_ERROR_INFO(pctxt) \
00196 (((pctxt)->errInfo.list.head == 0) ? (OSRTErrInfo*)0 : \
00197 (OSRTErrInfo*)((pctxt)->errInfo.list.head->data))
00198
00199 #define OSRT_GET_LAST_ERROR_INFO(pctxt) \
00200 (((pctxt)->errInfo.list.tail == 0) ? (OSRTErrInfo*)0 : \
00201 (OSRTErrInfo*)((pctxt)->errInfo.list.tail->data))
00202
00206 #ifndef _NO_STREAM
00207
00208 #define OSRTISSTREAM(pctxt) \
00209 ((pctxt)->pStream != 0 && !((pctxt)->flags & OSDISSTRM))
00210
00211 #else
00212
00213 #define OSRTISSTREAM(pctxt) FALSE
00214
00215 #endif
00216
00217 #define OSRTBUFCUR(pctxt) (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00218 #define OSRTBUFPTR(pctxt) &(pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00219 #define OSRTBUFFER(pctxt) (pctxt)->buffer.data
00220 #define OSRTBUFSIZE(pctxt) (pctxt)->buffer.size
00221
00222 #define OSRTBUFSAVE(pctxt) { \
00223 (pctxt)->savedInfo.byteIndex = (pctxt)->buffer.byteIndex; \
00224 (pctxt)->savedInfo.flags = (pctxt)->flags; }
00225
00226 #define OSRTBUFSAVE2(pctxt,pSavedBuf) { \
00227 (pSavedBuf)->byteIndex = (pctxt)->buffer.byteIndex; \
00228 (pSavedBuf)->bitOffset = (pctxt)->buffer.bitOffset; \
00229 (pSavedBuf)->flags = (pctxt)->flags; }
00230
00231 #define OSRTBUFRESTORE(pctxt) { \
00232 (pctxt)->buffer.byteIndex = (pctxt)->savedInfo.byteIndex; \
00233 (pctxt)->flags = (pctxt)->savedInfo.flags; }
00234
00235 #define OSRTBUFRESTORE2(pctxt,pSavedBuf) { \
00236 (pctxt)->buffer.byteIndex = (pSavedBuf)->byteIndex; \
00237 (pctxt)->buffer.bitOffset = (pSavedBuf)->bitOffset; \
00238 (pctxt)->flags = (pSavedBuf)->flags; }
00239
00240 #define OSRTBYTEALIGNED(pctxt) \
00241 ((pctxt)->buffer.bitOffset == 8 || (pctxt)->buffer.bitOffset == 0)
00242
00243
00244
00245 typedef void *(OSCDECL *OSMallocFunc ) (OSSIZE size);
00246 typedef void *(OSCDECL *OSReallocFunc) (void *ptr, OSSIZE size);
00247 typedef void (OSCDECL *OSFreeFunc ) (void *ptr);
00248
00249 #ifdef __cplusplus
00250 extern "C" {
00251 #endif
00252
00277 #ifndef rtxInitContext
00278 EXTERNRT int rtxInitContext (OSCTXT* pctxt);
00279 #endif
00280
00295 EXTERNRT int rtxInitContextExt (OSCTXT* pctxt,
00296 OSMallocFunc malloc_func,
00297 OSReallocFunc realloc_func,
00298 OSFreeFunc free_func);
00299
00320 EXTERNRT int rtxInitThreadContext (OSCTXT* pctxt, const OSCTXT* pSrcCtxt);
00321
00340 EXTERNRT int rtxInitContextBuffer
00341 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00342
00366 EXTERNRT int rtxCtxtSetBufPtr
00367 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00368
00380 #define rtxCtxtGetMsgPtr(pctxt) (pctxt)->buffer.data
00381
00391 #define rtxCtxtGetMsgLen(pctxt) (pctxt)->buffer.byteIndex
00392
00400 EXTERNRT OSSIZE rtxCtxtGetBitOffset (OSCTXT* pctxt);
00401
00411 EXTERNRT int rtxCtxtSetBitOffset (OSCTXT* pctxt, OSSIZE offset);
00412
00420 EXTERNRT OSSIZE rtxCtxtGetIOByteCount (OSCTXT* pctxt);
00421
00431 EXTERNRT int rtxCheckContext (OSCTXT* pctxt);
00432
00440 EXTERNRT void rtxFreeContext (OSCTXT* pctxt);
00441
00451 EXTERNRT void rtxCopyContext (OSCTXT* pdest, OSCTXT* psrc);
00452
00459 EXTERNRT void rtxCtxtSetFlag (OSCTXT* pctxt, OSUINT32 mask);
00460
00468 EXTERNRT void rtxCtxtClearFlag (OSCTXT* pctxt, OSUINT32 mask);
00469
00476 #define rtxCtxtTestFlag(pctxt,mask) (((pctxt)->flags & mask) != 0)
00477
00492 EXTERNRT int rtxCtxtPushArrayElemName
00493 (OSCTXT* pctxt, const OSUTF8CHAR* elemName, OSSIZE idx);
00494
00507 EXTERNRT int rtxCtxtPushElemName (OSCTXT* pctxt, const OSUTF8CHAR* elemName);
00508
00523 EXTERNRT int rtxCtxtPushTypeName (OSCTXT* pctxt, const OSUTF8CHAR* typeName);
00524
00535 EXTERNRT OSBOOL rtxCtxtPopArrayElemName (OSCTXT* pctxt);
00536
00544 EXTERNRT const OSUTF8CHAR* rtxCtxtPopElemName (OSCTXT* pctxt);
00545
00554 EXTERNRT const OSUTF8CHAR* rtxCtxtPopTypeName (OSCTXT* pctxt);
00555
00563 #define rtxCtxtPeekElemName(pctxt) \
00564 (((pctxt)->elemNameStack.count > 0) ? \
00565 (const OSUTF8CHAR*)(pctxt)->elemNameStack.tail->data : (const OSUTF8CHAR*)0)
00566
00567 EXTERNRT int rtxPreInitContext (OSCTXT* pctxt);
00568
00578 EXTERNRT void rtxMemHeapSetFlags (OSCTXT* pctxt, OSUINT32 flags);
00579
00588 EXTERNRT void rtxMemHeapClearFlags (OSCTXT* pctxt, OSUINT32 flags);
00589
00593 #define rtxByteAlign(pctxt) \
00594 if ((pctxt)->buffer.bitOffset != 8) { \
00595 (pctxt)->buffer.byteIndex++; (pctxt)->buffer.bitOffset = 8; }
00596
00606 EXTERNRT int rtxMarkPos (OSCTXT* pctxt, OSSIZE* ppos);
00607
00617 EXTERNRT int rtxResetToPos (OSCTXT* pctxt, OSSIZE pos);
00618
00633 #define rtxCtxtSetProtocolVersion(pctxt,value) (pctxt)->version = value
00634
00635 #define rtxMarkBitPos(pctxt,ppos,pbitoff) \
00636 (*(pbitoff) = (OSUINT8) (pctxt)->buffer.bitOffset, rtxMarkPos (pctxt, ppos))
00637
00638 #define rtxResetToBitPos(pctxt,pos,bitoff) \
00639 ((pctxt)->buffer.bitOffset = (OSUINT8) bitoff, rtxResetToPos (pctxt, pos))
00640
00641 #ifndef _COMPACT
00642 #define RTXCTXTPUSHARRAYELEMNAME(pctxt,name,idx) \
00643 rtxCtxtPushArrayElemName(pctxt,OSUTF8(name),idx)
00644
00645 #define RTXCTXTPOPARRAYELEMNAME(pctxt) \
00646 rtxCtxtPopArrayElemName(pctxt)
00647
00648 #define RTXCTXTPUSHELEMNAME(pctxt,name) \
00649 rtxCtxtPushElemName(pctxt,OSUTF8(name))
00650
00651 #define RTXCTXTPOPELEMNAME(pctxt) \
00652 rtxCtxtPopElemName(pctxt)
00653
00654 #define RTXCTXTPUSHTYPENAME(pctxt,name) \
00655 rtxCtxtPushTypeName(pctxt,OSUTF8(name))
00656
00657 #define RTXCTXTPOPTYPENAME(pctxt) \
00658 rtxCtxtPopTypeName(pctxt)
00659 #else
00660 #define RTXCTXTPUSHARRAYELEMNAME(pctxt,name,idx)
00661 #define RTXCTXTPOPARRAYELEMNAME(pctxt)
00662 #define RTXCTXTPUSHELEMNAME(pctxt,name)
00663 #define RTXCTXTPOPELEMNAME(pctxt)
00664 #define RTXCTXTPUSHTYPENAME(pctxt,name)
00665 #define RTXCTXTPOPTYPENAME(pctxt)
00666 #endif
00667
00668 #ifdef __cplusplus
00669 }
00670 #endif
00671
00674 #endif