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
00120 struct OSCTXT;
00127 typedef int (*OSFreeCtxtAppInfoPtr)(struct OSCTXT* pctxt);
00128
00135 typedef int (*OSResetCtxtAppInfoPtr)(struct OSCTXT* pctxt);
00136
00144 typedef void (*OSFreeCtxtGlobalPtr)(struct OSCTXT* pctxt);
00145
00146
00147
00148
00149 #if !defined(OSCDECL)
00150 #if defined(_MSC_VER) || defined(__BORLANDC__)
00151 #define OSCDECL __cdecl
00152 #else
00153 #define OSCDECL
00154 #endif
00155 #endif
00156
00164 typedef struct OSCTXT {
00165 void* pMemHeap;
00166 OSRTBuffer buffer;
00167 OSRTBufSave savedInfo;
00168 OSRTErrInfoList errInfo;
00169 OSUINT32 initCode;
00170 OSRTFLAGS flags;
00171 OSOCTET level;
00172 OSOCTET state;
00173 OSOCTET diagLevel;
00174 OSOCTET lastChar;
00175 #ifndef _NO_STREAM
00176 struct OSRTSTREAM* pStream;
00177 struct OSRTPrintStream *pPrintStrm;
00178 #endif
00179 OSRTDList elemNameStack;
00180 OSRTDList regExpCache;
00181 const OSOCTET* key;
00182 OSSIZE keylen;
00183 OSVoidPtr pXMLInfo;
00184 OSVoidPtr pASN1Info;
00185 OSVoidPtr pEXIInfo;
00186 OSVoidPtr pUserData;
00187 OSVoidPtr pGlobalData;
00188 OSFreeCtxtGlobalPtr gblFreeFunc;
00189 OSVoidPtr ssl;
00190 struct OSRTDiagBitFieldList* pBitFldList;
00191 OSUINT16 indent;
00192 } OSCTXT;
00193
00194 #define OSRT_GET_FIRST_ERROR_INFO(pctxt) \
00195 (((pctxt)->errInfo.list.head == 0) ? (OSRTErrInfo*)0 : \
00196 (OSRTErrInfo*)((pctxt)->errInfo.list.head->data))
00197
00198 #define OSRT_GET_LAST_ERROR_INFO(pctxt) \
00199 (((pctxt)->errInfo.list.tail == 0) ? (OSRTErrInfo*)0 : \
00200 (OSRTErrInfo*)((pctxt)->errInfo.list.tail->data))
00201
00205 #ifndef _NO_STREAM
00206
00207 #define OSRTISSTREAM(pctxt) \
00208 ((pctxt)->pStream != 0 && !((pctxt)->flags & OSDISSTRM))
00209
00210 #else
00211
00212 #define OSRTISSTREAM(pctxt) FALSE
00213
00214 #endif
00215
00216 #define OSRTBUFCUR(pctxt) (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00217 #define OSRTBUFPTR(pctxt) &(pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00218 #define OSRTBUFFER(pctxt) (pctxt)->buffer.data
00219 #define OSRTBUFSIZE(pctxt) (pctxt)->buffer.size
00220
00221 #define OSRTBUFSAVE(pctxt) { \
00222 (pctxt)->savedInfo.byteIndex = (pctxt)->buffer.byteIndex; \
00223 (pctxt)->savedInfo.flags = (pctxt)->flags; }
00224
00225 #define OSRTBUFRESTORE(pctxt) { \
00226 (pctxt)->buffer.byteIndex = (pctxt)->savedInfo.byteIndex; \
00227 (pctxt)->flags = (pctxt)->savedInfo.flags; }
00228
00229
00230
00231 typedef void *(OSCDECL *OSMallocFunc ) (OSSIZE size);
00232 typedef void *(OSCDECL *OSReallocFunc) (void *ptr, OSSIZE size);
00233 typedef void (OSCDECL *OSFreeFunc ) (void *ptr);
00234
00235 #ifdef __cplusplus
00236 extern "C" {
00237 #endif
00238
00263 #ifndef rtxInitContext
00264 EXTERNRT int rtxInitContext (OSCTXT* pctxt);
00265 #endif
00266
00281 EXTERNRT int rtxInitContextExt (OSCTXT* pctxt,
00282 OSMallocFunc malloc_func,
00283 OSReallocFunc realloc_func,
00284 OSFreeFunc free_func);
00285
00306 EXTERNRT int rtxInitThreadContext (OSCTXT* pctxt, const OSCTXT* pSrcCtxt);
00307
00326 EXTERNRT int rtxInitContextBuffer
00327 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00328
00352 EXTERNRT int rtxCtxtSetBufPtr
00353 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00354
00366 #define rtxCtxtGetMsgPtr(pctxt) (pctxt)->buffer.data
00367
00377 #define rtxCtxtGetMsgLen(pctxt) (pctxt)->buffer.byteIndex
00378
00386 EXTERNRT OSSIZE rtxCtxtGetBitOffset (OSCTXT* pctxt);
00387
00395 EXTERNRT OSSIZE rtxCtxtGetIOByteCount (OSCTXT* pctxt);
00396
00406 EXTERNRT int rtxCheckContext (OSCTXT* pctxt);
00407
00415 EXTERNRT void rtxFreeContext (OSCTXT* pctxt);
00416
00426 EXTERNRT void rtxCopyContext (OSCTXT* pdest, OSCTXT* psrc);
00427
00434 EXTERNRT void rtxCtxtSetFlag (OSCTXT* pctxt, OSUINT32 mask);
00435
00443 EXTERNRT void rtxCtxtClearFlag (OSCTXT* pctxt, OSUINT32 mask);
00444
00451 #define rtxCtxtTestFlag(pctxt,mask) ((pctxt->flags & mask) != 0)
00452
00467 EXTERNRT int rtxCtxtPushArrayElemName
00468 (OSCTXT* pctxt, const OSUTF8CHAR* elemName, OSSIZE idx);
00469
00482 EXTERNRT int rtxCtxtPushElemName (OSCTXT* pctxt, const OSUTF8CHAR* elemName);
00483
00498 EXTERNRT int rtxCtxtPushTypeName (OSCTXT* pctxt, const OSUTF8CHAR* typeName);
00499
00510 EXTERNRT OSBOOL rtxCtxtPopArrayElemName (OSCTXT* pctxt);
00511
00519 EXTERNRT const OSUTF8CHAR* rtxCtxtPopElemName (OSCTXT* pctxt);
00520
00529 EXTERNRT const OSUTF8CHAR* rtxCtxtPopTypeName (OSCTXT* pctxt);
00530
00538 #define rtxCtxtPeekElemName(pctxt) \
00539 (((pctxt)->elemNameStack.count > 0) ? \
00540 (const OSUTF8CHAR*)(pctxt)->elemNameStack.tail->data : (const OSUTF8CHAR*)0)
00541
00542 EXTERNRT int rtxPreInitContext (OSCTXT* pctxt);
00543
00553 EXTERNRT void rtxMemHeapSetFlags (OSCTXT* pctxt, OSUINT32 flags);
00554
00563 EXTERNRT void rtxMemHeapClearFlags (OSCTXT* pctxt, OSUINT32 flags);
00564
00568 #define rtxByteAlign(pctxt) \
00569 if ((pctxt)->buffer.bitOffset != 8) { \
00570 (pctxt)->buffer.byteIndex++; (pctxt)->buffer.bitOffset = 8; }
00571
00581 EXTERNRT int rtxMarkPos (OSCTXT* pctxt, OSSIZE* ppos);
00582
00592 EXTERNRT int rtxResetToPos (OSCTXT* pctxt, OSSIZE pos);
00593
00594 #define rtxMarkBitPos(pctxt,ppos,pbitoff) \
00595 (*(pbitoff) = (OSUINT8) (pctxt)->buffer.bitOffset, rtxMarkPos (pctxt, ppos))
00596
00597 #define rtxResetToBitPos(pctxt,pos,bitoff) \
00598 ((pctxt)->buffer.bitOffset = (OSUINT8) bitoff, rtxResetToPos (pctxt, pos))
00599
00600 #ifndef _COMPACT
00601 #define RTXCTXTPUSHARRAYELEMNAME(pctxt,name,idx) \
00602 rtxCtxtPushArrayElemName(pctxt,OSUTF8(name),idx)
00603
00604 #define RTXCTXTPOPARRAYELEMNAME(pctxt) \
00605 rtxCtxtPopArrayElemName(pctxt)
00606
00607 #define RTXCTXTPUSHELEMNAME(pctxt,name) \
00608 rtxCtxtPushElemName(pctxt,OSUTF8(name))
00609
00610 #define RTXCTXTPOPELEMNAME(pctxt) \
00611 rtxCtxtPopElemName(pctxt)
00612
00613 #define RTXCTXTPUSHTYPENAME(pctxt,name) \
00614 rtxCtxtPushTypeName(pctxt,OSUTF8(name))
00615
00616 #define RTXCTXTPOPTYPENAME(pctxt) \
00617 rtxCtxtPopTypeName(pctxt)
00618 #else
00619 #define RTXCTXTPUSHELEMNAME(pctxt,name)
00620 #define RTXCTXTPOPELEMNAME(pctxt)
00621 #define RTXCTXTPUSHTYPENAME(pctxt,name)
00622 #define RTXCTXTPOPTYPENAME(pctxt)
00623 #endif
00624
00625 #ifdef __cplusplus
00626 }
00627 #endif
00628
00631 #endif