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 #include "rtxsrc/rtxStack.h"
00033
00034 #define OSRTENCBUFSIZ 1024
00035
00040
00041
00042 #define OSRTERRSTKSIZ 8
00043 #define OSRTMAXERRPRM 5
00044
00052 typedef struct {
00053 const OSUTF8CHAR* module;
00054 OSINT32 lineno;
00055 } OSRTErrLocn;
00056
00067 typedef struct {
00068 OSRTErrLocn stack[OSRTERRSTKSIZ];
00069 OSINT16 status;
00070 OSUINT8 stkx;
00071 OSUINT8 parmcnt;
00072 OSUTF8CHAR* parms[OSRTMAXERRPRM];
00073 OSUTF8CHAR* elemName;
00074 } OSRTErrInfo;
00075
00076 typedef struct {
00077 OSRTDList list;
00078 OSRTErrInfo reserved;
00079 OSRTDListNode reservedNode;
00080 } OSRTErrInfoList;
00081
00090 typedef struct {
00091 OSOCTET* data;
00092 OSSIZE byteIndex;
00093 OSSIZE size;
00094 OSINT16 bitOffset;
00095 OSBOOL dynamic;
00096 OSBOOL aligned;
00097 } OSRTBuffer;
00098
00099 typedef OSUINT32 OSRTFLAGS;
00100
00107 typedef struct {
00108 OSSIZE byteIndex;
00109 OSINT16 bitOffset;
00110 OSRTFLAGS flags;
00111 } OSRTBufSave;
00112
00113
00117 typedef struct {
00118 OSSIZE byteIndex;
00119 OSINT16 bitOffset;
00120 } OSBufferIndex;
00121
00122
00123
00124
00125
00126 #define OSDIAG 0x80000000
00127 #define OSTRACE 0x40000000
00128 #define OSDISSTRM 0x20000000
00129 #define OSNOSTRMBACKOFF 0x08000000
00130 #define OS3GMOBORIG 0x04000000
00131
00132
00133
00134
00135
00136
00137 #define OSCONTCLOSED 0x02000000
00138 #define OSRESERVED1 0x01000000
00139 #define OSBUFSYSALLOC 0x00800000
00140
00141 struct OSCTXT;
00148 typedef int (*OSFreeCtxtAppInfoPtr)(struct OSCTXT* pctxt);
00149
00156 typedef int (*OSResetCtxtAppInfoPtr)(struct OSCTXT* pctxt);
00157
00165 typedef void (*OSFreeCtxtGlobalPtr)(struct OSCTXT* pctxt);
00166
00167
00168
00169
00170 #if !defined(OSCDECL)
00171 #if defined(_MSC_VER) || defined(__BORLANDC__)
00172 #define OSCDECL __cdecl
00173 #else
00174 #define OSCDECL
00175 #endif
00176 #endif
00177
00185 typedef struct OSCTXT {
00186 void* pMemHeap;
00187 OSRTBuffer buffer;
00188 OSRTBufSave savedInfo;
00189 OSRTErrInfoList errInfo;
00190 OSUINT32 initCode;
00191 OSRTFLAGS flags;
00192 OSOCTET level;
00193 OSOCTET state;
00194 OSOCTET diagLevel;
00195 OSOCTET lastChar;
00196 #ifndef _NO_STREAM
00197 struct OSRTSTREAM* pStream;
00198 #else
00199 void* pStream;
00200 #endif
00201 struct OSRTPrintStream *pPrintStrm;
00202 OSRTDList elemNameStack;
00203 #ifndef _OS_NOPATTERN
00204 OSRTDList regExpCache;
00205 #endif
00206
00214 OSRTStack containerEndIndexStack;
00215
00216 const OSOCTET* key;
00217 OSSIZE keylen;
00218 OSVoidPtr pXMLInfo;
00219 OSVoidPtr pASN1Info;
00220 OSVoidPtr pLicInfo;
00221 OSVoidPtr pUserData;
00222 OSVoidPtr pGlobalData;
00223 struct OS3GPPSecParams* p3gppSec;
00224 OSFreeCtxtGlobalPtr gblFreeFunc;
00225 OSVoidPtr ssl;
00226 struct OSRTDiagBitFieldList* pBitFldList;
00227 OSUINT16 indent;
00228 OSUINT16 version;
00229 } OSCTXT;
00230
00231 #define OSRT_GET_FIRST_ERROR_INFO(pctxt) \
00232 (((pctxt)->errInfo.list.head == 0) ? (OSRTErrInfo*)0 : \
00233 (OSRTErrInfo*)((pctxt)->errInfo.list.head->data))
00234
00235 #define OSRT_GET_LAST_ERROR_INFO(pctxt) \
00236 (((pctxt)->errInfo.list.tail == 0) ? (OSRTErrInfo*)0 : \
00237 (OSRTErrInfo*)((pctxt)->errInfo.list.tail->data))
00238
00242 #ifndef _NO_STREAM
00243
00244 #define OSRTISSTREAM(pctxt) \
00245 ((pctxt)->pStream != 0 && !((pctxt)->flags & OSDISSTRM))
00246
00247 #define OSRTISBUFSTREAM(pctxt) \
00248 (OSRTISSTREAM(pctxt) && (0 != ((pctxt)->pStream->flags & OSRTSTRMF_BUFFERED)))
00249
00250 #else
00251
00252 #define OSRTISSTREAM(pctxt) FALSE
00253 #define OSRTISBUFSTREAM(pctxt) FALSE
00254
00255 #endif
00256
00257 #define OSRTBUFCUR(pctxt) (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00258 #define OSRTBUFPTR(pctxt) &(pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00259 #define OSRTBUFFER(pctxt) (pctxt)->buffer.data
00260 #define OSRTBUFSIZE(pctxt) (pctxt)->buffer.size
00261
00262 #define OSRTBUFSAVE(pctxt) { \
00263 (pctxt)->savedInfo.byteIndex = (pctxt)->buffer.byteIndex; \
00264 (pctxt)->savedInfo.flags = (pctxt)->flags; }
00265
00266 #define OSRTBUFSAVE2(pctxt,pSavedBuf) { \
00267 (pSavedBuf)->byteIndex = (pctxt)->buffer.byteIndex; \
00268 (pSavedBuf)->bitOffset = (pctxt)->buffer.bitOffset; \
00269 (pSavedBuf)->flags = (pctxt)->flags; }
00270
00271 #define OSRTBUFRESTORE(pctxt) { \
00272 (pctxt)->buffer.byteIndex = (pctxt)->savedInfo.byteIndex; \
00273 (pctxt)->flags = (pctxt)->savedInfo.flags; }
00274
00275 #define OSRTBUFRESTORE2(pctxt,pSavedBuf) { \
00276 (pctxt)->buffer.byteIndex = (pSavedBuf)->byteIndex; \
00277 (pctxt)->buffer.bitOffset = (pSavedBuf)->bitOffset; \
00278 (pctxt)->flags = (pSavedBuf)->flags; }
00279
00280 #define OSRTBYTEALIGNED(pctxt) \
00281 ((pctxt)->buffer.bitOffset == 8 || (pctxt)->buffer.bitOffset == 0)
00282
00283
00284
00285 typedef void *(OSCDECL *OSMallocFunc ) (OSSIZE size);
00286 typedef void *(OSCDECL *OSReallocFunc) (void *ptr, OSSIZE size);
00287 typedef void (OSCDECL *OSFreeFunc ) (void *ptr);
00288
00289 #ifdef __cplusplus
00290 extern "C" {
00291 #endif
00292
00317 #ifndef rtxInitContext
00318 EXTERNRT int rtxInitContext (OSCTXT* pctxt);
00319 #endif
00320
00335 EXTERNRT int rtxInitContextExt (OSCTXT* pctxt,
00336 OSMallocFunc malloc_func,
00337 OSReallocFunc realloc_func,
00338 OSFreeFunc free_func);
00339
00360 EXTERNRT int rtxInitThreadContext (OSCTXT* pctxt, const OSCTXT* pSrcCtxt);
00361
00376 EXTERNRT int rtxInitContextUsingKey
00377 (OSCTXT* pctxt, const OSOCTET* key, OSSIZE keylen);
00378
00397 EXTERNRT int rtxInitContextBuffer
00398 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00399
00423 EXTERNRT int rtxCtxtSetBufPtr
00424 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00425
00437 #define rtxCtxtGetMsgPtr(pctxt) (pctxt)->buffer.data
00438
00448 #define rtxCtxtGetMsgLen(pctxt) (pctxt)->buffer.byteIndex
00449
00457 EXTERNRT OSSIZE rtxCtxtGetBitOffset (OSCTXT* pctxt);
00458
00468 EXTERNRT int rtxCtxtSetBitOffset (OSCTXT* pctxt, OSSIZE offset);
00469
00477 EXTERNRT OSSIZE rtxCtxtGetIOByteCount (OSCTXT* pctxt);
00478
00488 EXTERNRT int rtxCheckContext (OSCTXT* pctxt);
00489
00497 EXTERNRT void rtxFreeContext (OSCTXT* pctxt);
00498
00508 EXTERNRT void rtxCopyContext (OSCTXT* pdest, OSCTXT* psrc);
00509
00516 EXTERNRT void rtxCtxtSetFlag (OSCTXT* pctxt, OSUINT32 mask);
00517
00525 EXTERNRT void rtxCtxtClearFlag (OSCTXT* pctxt, OSUINT32 mask);
00526
00533 #define rtxCtxtTestFlag(pctxt,mask) (((pctxt)->flags & mask) != 0)
00534
00549 EXTERNRT int rtxCtxtPushArrayElemName
00550 (OSCTXT* pctxt, const OSUTF8CHAR* elemName, OSSIZE idx);
00551
00564 EXTERNRT int rtxCtxtPushElemName (OSCTXT* pctxt, const OSUTF8CHAR* elemName);
00565
00580 EXTERNRT int rtxCtxtPushTypeName (OSCTXT* pctxt, const OSUTF8CHAR* typeName);
00581
00592 EXTERNRT OSBOOL rtxCtxtPopArrayElemName (OSCTXT* pctxt);
00593
00601 EXTERNRT const OSUTF8CHAR* rtxCtxtPopElemName (OSCTXT* pctxt);
00602
00611 EXTERNRT const OSUTF8CHAR* rtxCtxtPopTypeName (OSCTXT* pctxt);
00612
00620 #define rtxCtxtPeekElemName(pctxt) \
00621 (((pctxt)->elemNameStack.count > 0) ? \
00622 (const OSUTF8CHAR*)(pctxt)->elemNameStack.tail->data : (const OSUTF8CHAR*)0)
00623
00624
00633 EXTERNRT OSBOOL rtxCtxtContainerHasRemBits(OSCTXT* pctxt);
00634
00643 EXTERNRT OSSIZE rtxCtxtGetContainerRemBits(OSCTXT* pctxt);
00644
00658 EXTERNRT int rtxCtxtPushContainerBytes(OSCTXT* pctxt, OSSIZE bytes);
00659
00673 EXTERNRT int rtxCtxtPushContainerBits(OSCTXT* pctxt, OSSIZE bits);
00674
00675
00685 EXTERNRT void rtxCtxtPopContainer(OSCTXT* pctxt);
00686
00694 EXTERNRT void rtxCtxtPopAllContainers(OSCTXT* pctxt);
00695
00696 EXTERNRT int rtxPreInitContext (OSCTXT* pctxt);
00697 EXTERNRT void rtxCtxtSetMemHeap (OSCTXT* pctxt, OSCTXT* pSrcCtxt);
00698
00708 EXTERNRT void rtxMemHeapSetFlags (OSCTXT* pctxt, OSUINT32 flags);
00709
00718 EXTERNRT void rtxMemHeapClearFlags (OSCTXT* pctxt, OSUINT32 flags);
00719
00723 #define rtxByteAlign(pctxt) \
00724 if ((pctxt)->buffer.bitOffset != 8) { \
00725 (pctxt)->buffer.byteIndex++; (pctxt)->buffer.bitOffset = 8; }
00726
00736 EXTERNRT int rtxMarkPos (OSCTXT* pctxt, OSSIZE* ppos);
00737
00747 EXTERNRT int rtxResetToPos (OSCTXT* pctxt, OSSIZE pos);
00748
00762 #define rtxCtxtSetProtocolVersion(pctxt,value) (pctxt)->version = value
00763
00764 #define rtxMarkBitPos(pctxt,ppos,pbitoff) \
00765 (*(pbitoff) = (OSUINT8) (pctxt)->buffer.bitOffset, rtxMarkPos (pctxt, ppos))
00766
00767 #define rtxResetToBitPos(pctxt,pos,bitoff) \
00768 ((pctxt)->buffer.bitOffset = (OSUINT8) bitoff, rtxResetToPos (pctxt, pos))
00769
00770 #ifndef _COMPACT
00771 #define RTXCTXTPUSHARRAYELEMNAME(pctxt,name,idx) \
00772 rtxCtxtPushArrayElemName(pctxt,OSUTF8(name),idx)
00773
00774 #define RTXCTXTPOPARRAYELEMNAME(pctxt) \
00775 rtxCtxtPopArrayElemName(pctxt)
00776
00777 #define RTXCTXTPUSHELEMNAME(pctxt,name) \
00778 rtxCtxtPushElemName(pctxt,OSUTF8(name))
00779
00780 #define RTXCTXTPOPELEMNAME(pctxt) \
00781 rtxCtxtPopElemName(pctxt)
00782
00783 #define RTXCTXTPUSHTYPENAME(pctxt,name) \
00784 rtxCtxtPushTypeName(pctxt,OSUTF8(name))
00785
00786 #define RTXCTXTPOPTYPENAME(pctxt) \
00787 rtxCtxtPopTypeName(pctxt)
00788 #else
00789 #define RTXCTXTPUSHARRAYELEMNAME(pctxt,name,idx)
00790 #define RTXCTXTPOPARRAYELEMNAME(pctxt)
00791 #define RTXCTXTPUSHELEMNAME(pctxt,name)
00792 #define RTXCTXTPOPELEMNAME(pctxt)
00793 #define RTXCTXTPUSHTYPENAME(pctxt,name)
00794 #define RTXCTXTPOPTYPENAME(pctxt)
00795 #endif
00796
00797 #ifdef __cplusplus
00798 }
00799 #endif
00800
00803 #endif