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
00140 struct OSCTXT;
00147 typedef int (*OSFreeCtxtAppInfoPtr)(struct OSCTXT* pctxt);
00148
00155 typedef int (*OSResetCtxtAppInfoPtr)(struct OSCTXT* pctxt);
00156
00164 typedef void (*OSFreeCtxtGlobalPtr)(struct OSCTXT* pctxt);
00165
00166
00167
00168
00169 #if !defined(OSCDECL)
00170 #if defined(_MSC_VER) || defined(__BORLANDC__)
00171 #define OSCDECL __cdecl
00172 #else
00173 #define OSCDECL
00174 #endif
00175 #endif
00176
00184 typedef struct OSCTXT {
00185 void* pMemHeap;
00186 OSRTBuffer buffer;
00187 OSRTBufSave savedInfo;
00188 OSRTErrInfoList errInfo;
00189 OSUINT32 initCode;
00190 OSRTFLAGS flags;
00191 OSOCTET level;
00192 OSOCTET state;
00193 OSOCTET diagLevel;
00194 OSOCTET lastChar;
00195 #ifndef _NO_STREAM
00196 struct OSRTSTREAM* pStream;
00197 struct OSRTPrintStream *pPrintStrm;
00198 #endif
00199 OSRTDList elemNameStack;
00200 OSRTDList regExpCache;
00201
00210 OSRTStack containerEndIndexStack;
00211
00212 const OSOCTET* key;
00213 OSSIZE keylen;
00214 OSVoidPtr pXMLInfo;
00215 OSVoidPtr pASN1Info;
00216 OSVoidPtr pLicInfo;
00217 OSVoidPtr pUserData;
00218 OSVoidPtr pGlobalData;
00219 struct OS3GPPSecParams* p3gppSec;
00220 OSFreeCtxtGlobalPtr gblFreeFunc;
00221 OSVoidPtr ssl;
00222 struct OSRTDiagBitFieldList* pBitFldList;
00223 OSUINT16 indent;
00224 OSUINT16 version;
00225 } OSCTXT;
00226
00227 #define OSRT_GET_FIRST_ERROR_INFO(pctxt) \
00228 (((pctxt)->errInfo.list.head == 0) ? (OSRTErrInfo*)0 : \
00229 (OSRTErrInfo*)((pctxt)->errInfo.list.head->data))
00230
00231 #define OSRT_GET_LAST_ERROR_INFO(pctxt) \
00232 (((pctxt)->errInfo.list.tail == 0) ? (OSRTErrInfo*)0 : \
00233 (OSRTErrInfo*)((pctxt)->errInfo.list.tail->data))
00234
00238 #ifndef _NO_STREAM
00239
00240 #define OSRTISSTREAM(pctxt) \
00241 ((pctxt)->pStream != 0 && !((pctxt)->flags & OSDISSTRM))
00242
00243 #else
00244
00245 #define OSRTISSTREAM(pctxt) FALSE
00246
00247 #endif
00248
00249 #define OSRTBUFCUR(pctxt) (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00250 #define OSRTBUFPTR(pctxt) &(pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00251 #define OSRTBUFFER(pctxt) (pctxt)->buffer.data
00252 #define OSRTBUFSIZE(pctxt) (pctxt)->buffer.size
00253
00254 #define OSRTBUFSAVE(pctxt) { \
00255 (pctxt)->savedInfo.byteIndex = (pctxt)->buffer.byteIndex; \
00256 (pctxt)->savedInfo.flags = (pctxt)->flags; }
00257
00258 #define OSRTBUFSAVE2(pctxt,pSavedBuf) { \
00259 (pSavedBuf)->byteIndex = (pctxt)->buffer.byteIndex; \
00260 (pSavedBuf)->bitOffset = (pctxt)->buffer.bitOffset; \
00261 (pSavedBuf)->flags = (pctxt)->flags; }
00262
00263 #define OSRTBUFRESTORE(pctxt) { \
00264 (pctxt)->buffer.byteIndex = (pctxt)->savedInfo.byteIndex; \
00265 (pctxt)->flags = (pctxt)->savedInfo.flags; }
00266
00267 #define OSRTBUFRESTORE2(pctxt,pSavedBuf) { \
00268 (pctxt)->buffer.byteIndex = (pSavedBuf)->byteIndex; \
00269 (pctxt)->buffer.bitOffset = (pSavedBuf)->bitOffset; \
00270 (pctxt)->flags = (pSavedBuf)->flags; }
00271
00272 #define OSRTBYTEALIGNED(pctxt) \
00273 ((pctxt)->buffer.bitOffset == 8 || (pctxt)->buffer.bitOffset == 0)
00274
00275
00276
00277 typedef void *(OSCDECL *OSMallocFunc ) (OSSIZE size);
00278 typedef void *(OSCDECL *OSReallocFunc) (void *ptr, OSSIZE size);
00279 typedef void (OSCDECL *OSFreeFunc ) (void *ptr);
00280
00281 #ifdef __cplusplus
00282 extern "C" {
00283 #endif
00284
00309 #ifndef rtxInitContext
00310 EXTERNRT int rtxInitContext (OSCTXT* pctxt);
00311 #endif
00312
00327 EXTERNRT int rtxInitContextExt (OSCTXT* pctxt,
00328 OSMallocFunc malloc_func,
00329 OSReallocFunc realloc_func,
00330 OSFreeFunc free_func);
00331
00352 EXTERNRT int rtxInitThreadContext (OSCTXT* pctxt, const OSCTXT* pSrcCtxt);
00353
00372 EXTERNRT int rtxInitContextBuffer
00373 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00374
00398 EXTERNRT int rtxCtxtSetBufPtr
00399 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00400
00412 #define rtxCtxtGetMsgPtr(pctxt) (pctxt)->buffer.data
00413
00423 #define rtxCtxtGetMsgLen(pctxt) (pctxt)->buffer.byteIndex
00424
00432 EXTERNRT OSSIZE rtxCtxtGetBitOffset (OSCTXT* pctxt);
00433
00443 EXTERNRT int rtxCtxtSetBitOffset (OSCTXT* pctxt, OSSIZE offset);
00444
00452 EXTERNRT OSSIZE rtxCtxtGetIOByteCount (OSCTXT* pctxt);
00453
00463 EXTERNRT int rtxCheckContext (OSCTXT* pctxt);
00464
00472 EXTERNRT void rtxFreeContext (OSCTXT* pctxt);
00473
00483 EXTERNRT void rtxCopyContext (OSCTXT* pdest, OSCTXT* psrc);
00484
00491 EXTERNRT void rtxCtxtSetFlag (OSCTXT* pctxt, OSUINT32 mask);
00492
00500 EXTERNRT void rtxCtxtClearFlag (OSCTXT* pctxt, OSUINT32 mask);
00501
00508 #define rtxCtxtTestFlag(pctxt,mask) (((pctxt)->flags & mask) != 0)
00509
00524 EXTERNRT int rtxCtxtPushArrayElemName
00525 (OSCTXT* pctxt, const OSUTF8CHAR* elemName, OSSIZE idx);
00526
00539 EXTERNRT int rtxCtxtPushElemName (OSCTXT* pctxt, const OSUTF8CHAR* elemName);
00540
00555 EXTERNRT int rtxCtxtPushTypeName (OSCTXT* pctxt, const OSUTF8CHAR* typeName);
00556
00567 EXTERNRT OSBOOL rtxCtxtPopArrayElemName (OSCTXT* pctxt);
00568
00576 EXTERNRT const OSUTF8CHAR* rtxCtxtPopElemName (OSCTXT* pctxt);
00577
00586 EXTERNRT const OSUTF8CHAR* rtxCtxtPopTypeName (OSCTXT* pctxt);
00587
00595 #define rtxCtxtPeekElemName(pctxt) \
00596 (((pctxt)->elemNameStack.count > 0) ? \
00597 (const OSUTF8CHAR*)(pctxt)->elemNameStack.tail->data : (const OSUTF8CHAR*)0)
00598
00599
00608 EXTERNRT OSBOOL rtxCtxtContainerHasRemBits(OSCTXT* pctxt);
00609
00618 EXTERNRT OSSIZE rtxCtxtGetContainerRemBits(OSCTXT* pctxt);
00619
00633 EXTERNRT int rtxCtxtPushContainerBytes(OSCTXT* pctxt, OSSIZE bytes);
00634
00648 EXTERNRT int rtxCtxtPushContainerBits(OSCTXT* pctxt, OSSIZE bits);
00649
00650
00660 EXTERNRT void rtxCtxtPopContainer(OSCTXT* pctxt);
00661
00669 EXTERNRT void rtxCtxtPopAllContainers(OSCTXT* pctxt);
00670
00671
00672 EXTERNRT int rtxPreInitContext (OSCTXT* pctxt);
00673
00683 EXTERNRT void rtxMemHeapSetFlags (OSCTXT* pctxt, OSUINT32 flags);
00684
00693 EXTERNRT void rtxMemHeapClearFlags (OSCTXT* pctxt, OSUINT32 flags);
00694
00698 #define rtxByteAlign(pctxt) \
00699 if ((pctxt)->buffer.bitOffset != 8) { \
00700 (pctxt)->buffer.byteIndex++; (pctxt)->buffer.bitOffset = 8; }
00701
00711 EXTERNRT int rtxMarkPos (OSCTXT* pctxt, OSSIZE* ppos);
00712
00722 EXTERNRT int rtxResetToPos (OSCTXT* pctxt, OSSIZE pos);
00723
00737 #define rtxCtxtSetProtocolVersion(pctxt,value) (pctxt)->version = value
00738
00739 #define rtxMarkBitPos(pctxt,ppos,pbitoff) \
00740 (*(pbitoff) = (OSUINT8) (pctxt)->buffer.bitOffset, rtxMarkPos (pctxt, ppos))
00741
00742 #define rtxResetToBitPos(pctxt,pos,bitoff) \
00743 ((pctxt)->buffer.bitOffset = (OSUINT8) bitoff, rtxResetToPos (pctxt, pos))
00744
00745 #ifndef _COMPACT
00746 #define RTXCTXTPUSHARRAYELEMNAME(pctxt,name,idx) \
00747 rtxCtxtPushArrayElemName(pctxt,OSUTF8(name),idx)
00748
00749 #define RTXCTXTPOPARRAYELEMNAME(pctxt) \
00750 rtxCtxtPopArrayElemName(pctxt)
00751
00752 #define RTXCTXTPUSHELEMNAME(pctxt,name) \
00753 rtxCtxtPushElemName(pctxt,OSUTF8(name))
00754
00755 #define RTXCTXTPOPELEMNAME(pctxt) \
00756 rtxCtxtPopElemName(pctxt)
00757
00758 #define RTXCTXTPUSHTYPENAME(pctxt,name) \
00759 rtxCtxtPushTypeName(pctxt,OSUTF8(name))
00760
00761 #define RTXCTXTPOPTYPENAME(pctxt) \
00762 rtxCtxtPopTypeName(pctxt)
00763 #else
00764 #define RTXCTXTPUSHARRAYELEMNAME(pctxt,name,idx)
00765 #define RTXCTXTPOPARRAYELEMNAME(pctxt)
00766 #define RTXCTXTPUSHELEMNAME(pctxt,name)
00767 #define RTXCTXTPOPELEMNAME(pctxt)
00768 #define RTXCTXTPUSHTYPENAME(pctxt,name)
00769 #define RTXCTXTPOPTYPENAME(pctxt)
00770 #endif
00771
00772 #ifdef __cplusplus
00773 }
00774 #endif
00775
00778 #endif