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 pEXIInfo;
00187 OSVoidPtr pUserData;
00188 OSVoidPtr pGlobalData;
00189 struct OS3GPPSecParams* p3gppSec;
00190 OSFreeCtxtGlobalPtr gblFreeFunc;
00191 OSVoidPtr ssl;
00192 struct OSRTDiagBitFieldList* pBitFldList;
00193 OSUINT16 indent;
00194 OSUINT16 version;
00195 } OSCTXT;
00196
00197 #define OSRT_GET_FIRST_ERROR_INFO(pctxt) \
00198 (((pctxt)->errInfo.list.head == 0) ? (OSRTErrInfo*)0 : \
00199 (OSRTErrInfo*)((pctxt)->errInfo.list.head->data))
00200
00201 #define OSRT_GET_LAST_ERROR_INFO(pctxt) \
00202 (((pctxt)->errInfo.list.tail == 0) ? (OSRTErrInfo*)0 : \
00203 (OSRTErrInfo*)((pctxt)->errInfo.list.tail->data))
00204
00208 #ifndef _NO_STREAM
00209
00210 #define OSRTISSTREAM(pctxt) \
00211 ((pctxt)->pStream != 0 && !((pctxt)->flags & OSDISSTRM))
00212
00213 #else
00214
00215 #define OSRTISSTREAM(pctxt) FALSE
00216
00217 #endif
00218
00219 #define OSRTBUFCUR(pctxt) (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00220 #define OSRTBUFPTR(pctxt) &(pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00221 #define OSRTBUFFER(pctxt) (pctxt)->buffer.data
00222 #define OSRTBUFSIZE(pctxt) (pctxt)->buffer.size
00223
00224 #define OSRTBUFSAVE(pctxt) { \
00225 (pctxt)->savedInfo.byteIndex = (pctxt)->buffer.byteIndex; \
00226 (pctxt)->savedInfo.flags = (pctxt)->flags; }
00227
00228 #define OSRTBUFSAVE2(pctxt,pSavedBuf) { \
00229 (pSavedBuf)->byteIndex = (pctxt)->buffer.byteIndex; \
00230 (pSavedBuf)->bitOffset = (pctxt)->buffer.bitOffset; \
00231 (pSavedBuf)->flags = (pctxt)->flags; }
00232
00233 #define OSRTBUFRESTORE(pctxt) { \
00234 (pctxt)->buffer.byteIndex = (pctxt)->savedInfo.byteIndex; \
00235 (pctxt)->flags = (pctxt)->savedInfo.flags; }
00236
00237 #define OSRTBUFRESTORE2(pctxt,pSavedBuf) { \
00238 (pctxt)->buffer.byteIndex = (pSavedBuf)->byteIndex; \
00239 (pctxt)->buffer.bitOffset = (pSavedBuf)->bitOffset; \
00240 (pctxt)->flags = (pSavedBuf)->flags; }
00241
00242 #define OSRTBYTEALIGNED(pctxt) \
00243 ((pctxt)->buffer.bitOffset == 8 || (pctxt)->buffer.bitOffset == 0)
00244
00245
00246
00247 typedef void *(OSCDECL *OSMallocFunc ) (OSSIZE size);
00248 typedef void *(OSCDECL *OSReallocFunc) (void *ptr, OSSIZE size);
00249 typedef void (OSCDECL *OSFreeFunc ) (void *ptr);
00250
00251 #ifdef __cplusplus
00252 extern "C" {
00253 #endif
00254
00279 #ifndef rtxInitContext
00280 EXTERNRT int rtxInitContext (OSCTXT* pctxt);
00281 #endif
00282
00297 EXTERNRT int rtxInitContextExt (OSCTXT* pctxt,
00298 OSMallocFunc malloc_func,
00299 OSReallocFunc realloc_func,
00300 OSFreeFunc free_func);
00301
00322 EXTERNRT int rtxInitThreadContext (OSCTXT* pctxt, const OSCTXT* pSrcCtxt);
00323
00342 EXTERNRT int rtxInitContextBuffer
00343 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00344
00368 EXTERNRT int rtxCtxtSetBufPtr
00369 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00370
00382 #define rtxCtxtGetMsgPtr(pctxt) (pctxt)->buffer.data
00383
00393 #define rtxCtxtGetMsgLen(pctxt) (pctxt)->buffer.byteIndex
00394
00402 EXTERNRT OSSIZE rtxCtxtGetBitOffset (OSCTXT* pctxt);
00403
00413 EXTERNRT int rtxCtxtSetBitOffset (OSCTXT* pctxt, OSSIZE offset);
00414
00422 EXTERNRT OSSIZE rtxCtxtGetIOByteCount (OSCTXT* pctxt);
00423
00433 EXTERNRT int rtxCheckContext (OSCTXT* pctxt);
00434
00442 EXTERNRT void rtxFreeContext (OSCTXT* pctxt);
00443
00453 EXTERNRT void rtxCopyContext (OSCTXT* pdest, OSCTXT* psrc);
00454
00461 EXTERNRT void rtxCtxtSetFlag (OSCTXT* pctxt, OSUINT32 mask);
00462
00470 EXTERNRT void rtxCtxtClearFlag (OSCTXT* pctxt, OSUINT32 mask);
00471
00478 #define rtxCtxtTestFlag(pctxt,mask) (((pctxt)->flags & mask) != 0)
00479
00494 EXTERNRT int rtxCtxtPushArrayElemName
00495 (OSCTXT* pctxt, const OSUTF8CHAR* elemName, OSSIZE idx);
00496
00509 EXTERNRT int rtxCtxtPushElemName (OSCTXT* pctxt, const OSUTF8CHAR* elemName);
00510
00525 EXTERNRT int rtxCtxtPushTypeName (OSCTXT* pctxt, const OSUTF8CHAR* typeName);
00526
00537 EXTERNRT OSBOOL rtxCtxtPopArrayElemName (OSCTXT* pctxt);
00538
00546 EXTERNRT const OSUTF8CHAR* rtxCtxtPopElemName (OSCTXT* pctxt);
00547
00556 EXTERNRT const OSUTF8CHAR* rtxCtxtPopTypeName (OSCTXT* pctxt);
00557
00565 #define rtxCtxtPeekElemName(pctxt) \
00566 (((pctxt)->elemNameStack.count > 0) ? \
00567 (const OSUTF8CHAR*)(pctxt)->elemNameStack.tail->data : (const OSUTF8CHAR*)0)
00568
00569 EXTERNRT int rtxPreInitContext (OSCTXT* pctxt);
00570
00580 EXTERNRT void rtxMemHeapSetFlags (OSCTXT* pctxt, OSUINT32 flags);
00581
00590 EXTERNRT void rtxMemHeapClearFlags (OSCTXT* pctxt, OSUINT32 flags);
00591
00595 #define rtxByteAlign(pctxt) \
00596 if ((pctxt)->buffer.bitOffset != 8) { \
00597 (pctxt)->buffer.byteIndex++; (pctxt)->buffer.bitOffset = 8; }
00598
00608 EXTERNRT int rtxMarkPos (OSCTXT* pctxt, OSSIZE* ppos);
00609
00619 EXTERNRT int rtxResetToPos (OSCTXT* pctxt, OSSIZE pos);
00620
00634 #define rtxCtxtSetProtocolVersion(pctxt,value) (pctxt)->version = value
00635
00636 #define rtxMarkBitPos(pctxt,ppos,pbitoff) \
00637 (*(pbitoff) = (OSUINT8) (pctxt)->buffer.bitOffset, rtxMarkPos (pctxt, ppos))
00638
00639 #define rtxResetToBitPos(pctxt,pos,bitoff) \
00640 ((pctxt)->buffer.bitOffset = (OSUINT8) bitoff, rtxResetToPos (pctxt, pos))
00641
00642 #ifndef _COMPACT
00643 #define RTXCTXTPUSHARRAYELEMNAME(pctxt,name,idx) \
00644 rtxCtxtPushArrayElemName(pctxt,OSUTF8(name),idx)
00645
00646 #define RTXCTXTPOPARRAYELEMNAME(pctxt) \
00647 rtxCtxtPopArrayElemName(pctxt)
00648
00649 #define RTXCTXTPUSHELEMNAME(pctxt,name) \
00650 rtxCtxtPushElemName(pctxt,OSUTF8(name))
00651
00652 #define RTXCTXTPOPELEMNAME(pctxt) \
00653 rtxCtxtPopElemName(pctxt)
00654
00655 #define RTXCTXTPUSHTYPENAME(pctxt,name) \
00656 rtxCtxtPushTypeName(pctxt,OSUTF8(name))
00657
00658 #define RTXCTXTPOPTYPENAME(pctxt) \
00659 rtxCtxtPopTypeName(pctxt)
00660 #else
00661 #define RTXCTXTPUSHARRAYELEMNAME(pctxt,name,idx)
00662 #define RTXCTXTPOPARRAYELEMNAME(pctxt)
00663 #define RTXCTXTPUSHELEMNAME(pctxt,name)
00664 #define RTXCTXTPOPELEMNAME(pctxt)
00665 #define RTXCTXTPUSHTYPENAME(pctxt,name)
00666 #define RTXCTXTPOPTYPENAME(pctxt)
00667 #endif
00668
00669 #ifdef __cplusplus
00670 }
00671 #endif
00672
00675 #endif