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 size_t byteIndex;
00092 size_t size;
00093 OSINT16 bitOffset;
00094 OSBOOL dynamic;
00095 OSBOOL aligned;
00096 } OSRTBuffer;
00097
00098 typedef OSUINT32 OSRTFLAGS;
00099
00106 typedef struct {
00107 size_t 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 size_t keylen;
00183 OSVoidPtr pXMLInfo;
00184 OSVoidPtr pASN1Info;
00185 OSVoidPtr pEXIInfo;
00186 OSVoidPtr pUserData;
00187 OSVoidPtr pGlobalData;
00188 OSFreeCtxtGlobalPtr gblFreeFunc;
00189 OSVoidPtr ssl;
00190 } OSCTXT;
00191
00192 #define OSRT_GET_FIRST_ERROR_INFO(pctxt) \
00193 (((pctxt)->errInfo.list.head == 0) ? (OSRTErrInfo*)0 : \
00194 (OSRTErrInfo*)((pctxt)->errInfo.list.head->data))
00195
00196 #define OSRT_GET_LAST_ERROR_INFO(pctxt) \
00197 (((pctxt)->errInfo.list.tail == 0) ? (OSRTErrInfo*)0 : \
00198 (OSRTErrInfo*)((pctxt)->errInfo.list.tail->data))
00199
00203 #ifndef _NO_STREAM
00204
00205 #define OSRTISSTREAM(pctxt) \
00206 ((pctxt)->pStream != 0 && !((pctxt)->flags & OSDISSTRM))
00207
00208 #else
00209
00210 #define OSRTISSTREAM(pctxt) FALSE
00211
00212 #endif
00213
00214 #define OSRTBUFCUR(pctxt) (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00215 #define OSRTBUFPTR(pctxt) &(pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00216 #define OSRTBUFFER(pctxt) (pctxt)->buffer.data
00217 #define OSRTBUFSIZE(pctxt) (pctxt)->buffer.size
00218
00219 #define OSRTBUFSAVE(pctxt) { \
00220 (pctxt)->savedInfo.byteIndex = (pctxt)->buffer.byteIndex; \
00221 (pctxt)->savedInfo.flags = (pctxt)->flags; }
00222
00223 #define OSRTBUFRESTORE(pctxt) { \
00224 (pctxt)->buffer.byteIndex = (pctxt)->savedInfo.byteIndex; \
00225 (pctxt)->flags = (pctxt)->savedInfo.flags; }
00226
00227
00228
00229 typedef void *(OSCDECL *OSMallocFunc ) (size_t size);
00230 typedef void *(OSCDECL *OSReallocFunc) (void *ptr, size_t size);
00231 typedef void (OSCDECL *OSFreeFunc ) (void *ptr);
00232
00233 #ifdef __cplusplus
00234 extern "C" {
00235 #endif
00236
00261 #ifndef rtxInitContext
00262 EXTERNRT int rtxInitContext (OSCTXT* pctxt);
00263 #endif
00264
00279 EXTERNRT int rtxInitContextExt (OSCTXT* pctxt,
00280 OSMallocFunc malloc_func,
00281 OSReallocFunc realloc_func,
00282 OSFreeFunc free_func);
00283
00304 EXTERNRT int rtxInitThreadContext (OSCTXT* pctxt, const OSCTXT* pSrcCtxt);
00305
00324 EXTERNRT int rtxInitContextBuffer
00325 (OSCTXT* pctxt, OSOCTET* bufaddr, size_t bufsiz);
00326
00350 EXTERNRT int rtxCtxtSetBufPtr
00351 (OSCTXT* pctxt, OSOCTET* bufaddr, size_t bufsiz);
00352
00364 #define rtxCtxtGetMsgPtr(pctxt) (pctxt)->buffer.data
00365
00375 #define rtxCtxtGetMsgLen(pctxt) (pctxt)->buffer.byteIndex
00376
00384 EXTERNRT size_t rtxCtxtGetBitOffset (OSCTXT* pctxt);
00385
00393 EXTERNRT size_t rtxCtxtGetIOByteCount (OSCTXT* pctxt);
00394
00404 EXTERNRT int rtxCheckContext (OSCTXT* pctxt);
00405
00413 EXTERNRT void rtxFreeContext (OSCTXT* pctxt);
00414
00424 EXTERNRT void rtxCopyContext (OSCTXT* pdest, OSCTXT* psrc);
00425
00432 EXTERNRT void rtxCtxtSetFlag (OSCTXT* pctxt, OSUINT32 mask);
00433
00441 EXTERNRT void rtxCtxtClearFlag (OSCTXT* pctxt, OSUINT32 mask);
00442
00449 #define rtxCtxtTestFlag(pctxt,mask) ((pctxt->flags & mask) != 0)
00450
00463 EXTERNRT int rtxCtxtPushElemName (OSCTXT* pctxt, const OSUTF8CHAR* elemName);
00464
00479 EXTERNRT int rtxCtxtPushTypeName (OSCTXT* pctxt, const OSUTF8CHAR* typeName);
00480
00488 EXTERNRT const OSUTF8CHAR* rtxCtxtPopElemName (OSCTXT* pctxt);
00489
00498 EXTERNRT const OSUTF8CHAR* rtxCtxtPopTypeName (OSCTXT* pctxt);
00499
00507 #define rtxCtxtPeekElemName(pctxt) \
00508 (((pctxt)->elemNameStack.count > 0) ? \
00509 (const OSUTF8CHAR*)(pctxt)->elemNameStack.tail->data : (const OSUTF8CHAR*)0)
00510
00511 EXTERNRT int rtxPreInitContext (OSCTXT* pctxt);
00512 #if 0
00513 EXTERNRT void rtxResetContext (OSCTXT* pctxt);
00514 #endif
00515 EXTERNRT void rtxMemFreeOpenSeqExt
00516 (OSCTXT* pctxt, struct OSRTDList *pElemList);
00517
00527 EXTERNRT void rtxMemHeapSetFlags (OSCTXT* pctxt, OSUINT32 flags);
00528
00537 EXTERNRT void rtxMemHeapClearFlags (OSCTXT* pctxt, OSUINT32 flags);
00538
00547 EXTERNRT void rtxMemHeapSetDefBlkSize (OSCTXT* pctxt, OSUINT32 blkSize);
00548
00555 EXTERNRT OSUINT32 rtxMemHeapGetDefBlkSize (OSCTXT* pctxt);
00556
00560 #define rtxByteAlign(pctxt) \
00561 if ((pctxt)->buffer.bitOffset != 8) { \
00562 (pctxt)->buffer.byteIndex++; (pctxt)->buffer.bitOffset = 8; }
00563
00573 EXTERNRT int rtxMarkPos (OSCTXT* pctxt, size_t* ppos);
00574
00584 EXTERNRT int rtxResetToPos (OSCTXT* pctxt, size_t pos);
00585
00586 #define rtxMarkBitPos(pctxt,ppos,pbitoff) \
00587 (*(pbitoff) = (OSUINT8) (pctxt)->buffer.bitOffset, rtxMarkPos (pctxt, ppos))
00588
00589 #define rtxResetToBitPos(pctxt,pos,bitoff) \
00590 ((pctxt)->buffer.bitOffset = (OSUINT8) bitoff, rtxResetToPos (pctxt, pos))
00591
00592 #ifdef __cplusplus
00593 }
00594 #endif
00595
00598 #endif