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 struct OSRTPrintStream *pPrintStrm;
00199 #endif
00200 OSRTDList elemNameStack;
00201 OSRTDList regExpCache;
00202
00211 OSRTStack containerEndIndexStack;
00212
00213 const OSOCTET* key;
00214 OSSIZE keylen;
00215 OSVoidPtr pXMLInfo;
00216 OSVoidPtr pASN1Info;
00217 OSVoidPtr pLicInfo;
00218 OSVoidPtr pUserData;
00219 OSVoidPtr pGlobalData;
00220 struct OS3GPPSecParams* p3gppSec;
00221 OSFreeCtxtGlobalPtr gblFreeFunc;
00222 OSVoidPtr ssl;
00223 struct OSRTDiagBitFieldList* pBitFldList;
00224 OSUINT16 indent;
00225 OSUINT16 version;
00226 } OSCTXT;
00227
00228 #define OSRT_GET_FIRST_ERROR_INFO(pctxt) \
00229 (((pctxt)->errInfo.list.head == 0) ? (OSRTErrInfo*)0 : \
00230 (OSRTErrInfo*)((pctxt)->errInfo.list.head->data))
00231
00232 #define OSRT_GET_LAST_ERROR_INFO(pctxt) \
00233 (((pctxt)->errInfo.list.tail == 0) ? (OSRTErrInfo*)0 : \
00234 (OSRTErrInfo*)((pctxt)->errInfo.list.tail->data))
00235
00239 #ifndef _NO_STREAM
00240
00241 #define OSRTISSTREAM(pctxt) \
00242 ((pctxt)->pStream != 0 && !((pctxt)->flags & OSDISSTRM))
00243
00244 #define OSRTISBUFSTREAM(pctxt) \
00245 (OSRTISSTREAM(pctxt) && (0 != ((pctxt)->pStream->flags & OSRTSTRMF_BUFFERED)))
00246
00247 #else
00248
00249 #define OSRTISSTREAM(pctxt) FALSE
00250 #define OSRTISBUFSTREAM(pctxt) FALSE
00251
00252 #endif
00253
00254 #define OSRTBUFCUR(pctxt) (pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00255 #define OSRTBUFPTR(pctxt) &(pctxt)->buffer.data[(pctxt)->buffer.byteIndex]
00256 #define OSRTBUFFER(pctxt) (pctxt)->buffer.data
00257 #define OSRTBUFSIZE(pctxt) (pctxt)->buffer.size
00258
00259 #define OSRTBUFSAVE(pctxt) { \
00260 (pctxt)->savedInfo.byteIndex = (pctxt)->buffer.byteIndex; \
00261 (pctxt)->savedInfo.flags = (pctxt)->flags; }
00262
00263 #define OSRTBUFSAVE2(pctxt,pSavedBuf) { \
00264 (pSavedBuf)->byteIndex = (pctxt)->buffer.byteIndex; \
00265 (pSavedBuf)->bitOffset = (pctxt)->buffer.bitOffset; \
00266 (pSavedBuf)->flags = (pctxt)->flags; }
00267
00268 #define OSRTBUFRESTORE(pctxt) { \
00269 (pctxt)->buffer.byteIndex = (pctxt)->savedInfo.byteIndex; \
00270 (pctxt)->flags = (pctxt)->savedInfo.flags; }
00271
00272 #define OSRTBUFRESTORE2(pctxt,pSavedBuf) { \
00273 (pctxt)->buffer.byteIndex = (pSavedBuf)->byteIndex; \
00274 (pctxt)->buffer.bitOffset = (pSavedBuf)->bitOffset; \
00275 (pctxt)->flags = (pSavedBuf)->flags; }
00276
00277 #define OSRTBYTEALIGNED(pctxt) \
00278 ((pctxt)->buffer.bitOffset == 8 || (pctxt)->buffer.bitOffset == 0)
00279
00280
00281
00282 typedef void *(OSCDECL *OSMallocFunc ) (OSSIZE size);
00283 typedef void *(OSCDECL *OSReallocFunc) (void *ptr, OSSIZE size);
00284 typedef void (OSCDECL *OSFreeFunc ) (void *ptr);
00285
00286 #ifdef __cplusplus
00287 extern "C" {
00288 #endif
00289
00314 #ifndef rtxInitContext
00315 EXTERNRT int rtxInitContext (OSCTXT* pctxt);
00316 #endif
00317
00332 EXTERNRT int rtxInitContextExt (OSCTXT* pctxt,
00333 OSMallocFunc malloc_func,
00334 OSReallocFunc realloc_func,
00335 OSFreeFunc free_func);
00336
00357 EXTERNRT int rtxInitThreadContext (OSCTXT* pctxt, const OSCTXT* pSrcCtxt);
00358
00373 EXTERNRT int rtxInitContextUsingKey
00374 (OSCTXT* pctxt, const OSOCTET* key, OSSIZE keylen);
00375
00394 EXTERNRT int rtxInitContextBuffer
00395 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00396
00420 EXTERNRT int rtxCtxtSetBufPtr
00421 (OSCTXT* pctxt, OSOCTET* bufaddr, OSSIZE bufsiz);
00422
00434 #define rtxCtxtGetMsgPtr(pctxt) (pctxt)->buffer.data
00435
00445 #define rtxCtxtGetMsgLen(pctxt) (pctxt)->buffer.byteIndex
00446
00454 EXTERNRT OSSIZE rtxCtxtGetBitOffset (OSCTXT* pctxt);
00455
00465 EXTERNRT int rtxCtxtSetBitOffset (OSCTXT* pctxt, OSSIZE offset);
00466
00474 EXTERNRT OSSIZE rtxCtxtGetIOByteCount (OSCTXT* pctxt);
00475
00485 EXTERNRT int rtxCheckContext (OSCTXT* pctxt);
00486
00494 EXTERNRT void rtxFreeContext (OSCTXT* pctxt);
00495
00505 EXTERNRT void rtxCopyContext (OSCTXT* pdest, OSCTXT* psrc);
00506
00513 EXTERNRT void rtxCtxtSetFlag (OSCTXT* pctxt, OSUINT32 mask);
00514
00522 EXTERNRT void rtxCtxtClearFlag (OSCTXT* pctxt, OSUINT32 mask);
00523
00530 #define rtxCtxtTestFlag(pctxt,mask) (((pctxt)->flags & mask) != 0)
00531
00546 EXTERNRT int rtxCtxtPushArrayElemName
00547 (OSCTXT* pctxt, const OSUTF8CHAR* elemName, OSSIZE idx);
00548
00561 EXTERNRT int rtxCtxtPushElemName (OSCTXT* pctxt, const OSUTF8CHAR* elemName);
00562
00577 EXTERNRT int rtxCtxtPushTypeName (OSCTXT* pctxt, const OSUTF8CHAR* typeName);
00578
00589 EXTERNRT OSBOOL rtxCtxtPopArrayElemName (OSCTXT* pctxt);
00590
00598 EXTERNRT const OSUTF8CHAR* rtxCtxtPopElemName (OSCTXT* pctxt);
00599
00608 EXTERNRT const OSUTF8CHAR* rtxCtxtPopTypeName (OSCTXT* pctxt);
00609
00617 #define rtxCtxtPeekElemName(pctxt) \
00618 (((pctxt)->elemNameStack.count > 0) ? \
00619 (const OSUTF8CHAR*)(pctxt)->elemNameStack.tail->data : (const OSUTF8CHAR*)0)
00620
00621
00630 EXTERNRT OSBOOL rtxCtxtContainerHasRemBits(OSCTXT* pctxt);
00631
00640 EXTERNRT OSSIZE rtxCtxtGetContainerRemBits(OSCTXT* pctxt);
00641
00655 EXTERNRT int rtxCtxtPushContainerBytes(OSCTXT* pctxt, OSSIZE bytes);
00656
00670 EXTERNRT int rtxCtxtPushContainerBits(OSCTXT* pctxt, OSSIZE bits);
00671
00672
00682 EXTERNRT void rtxCtxtPopContainer(OSCTXT* pctxt);
00683
00691 EXTERNRT void rtxCtxtPopAllContainers(OSCTXT* pctxt);
00692
00693 EXTERNRT int rtxPreInitContext (OSCTXT* pctxt);
00694 EXTERNRT void rtxCtxtSetMemHeap (OSCTXT* pctxt, OSCTXT* pSrcCtxt);
00695
00705 EXTERNRT void rtxMemHeapSetFlags (OSCTXT* pctxt, OSUINT32 flags);
00706
00715 EXTERNRT void rtxMemHeapClearFlags (OSCTXT* pctxt, OSUINT32 flags);
00716
00720 #define rtxByteAlign(pctxt) \
00721 if ((pctxt)->buffer.bitOffset != 8) { \
00722 (pctxt)->buffer.byteIndex++; (pctxt)->buffer.bitOffset = 8; }
00723
00733 EXTERNRT int rtxMarkPos (OSCTXT* pctxt, OSSIZE* ppos);
00734
00744 EXTERNRT int rtxResetToPos (OSCTXT* pctxt, OSSIZE pos);
00745
00759 #define rtxCtxtSetProtocolVersion(pctxt,value) (pctxt)->version = value
00760
00761 #define rtxMarkBitPos(pctxt,ppos,pbitoff) \
00762 (*(pbitoff) = (OSUINT8) (pctxt)->buffer.bitOffset, rtxMarkPos (pctxt, ppos))
00763
00764 #define rtxResetToBitPos(pctxt,pos,bitoff) \
00765 ((pctxt)->buffer.bitOffset = (OSUINT8) bitoff, rtxResetToPos (pctxt, pos))
00766
00767 #ifndef _COMPACT
00768 #define RTXCTXTPUSHARRAYELEMNAME(pctxt,name,idx) \
00769 rtxCtxtPushArrayElemName(pctxt,OSUTF8(name),idx)
00770
00771 #define RTXCTXTPOPARRAYELEMNAME(pctxt) \
00772 rtxCtxtPopArrayElemName(pctxt)
00773
00774 #define RTXCTXTPUSHELEMNAME(pctxt,name) \
00775 rtxCtxtPushElemName(pctxt,OSUTF8(name))
00776
00777 #define RTXCTXTPOPELEMNAME(pctxt) \
00778 rtxCtxtPopElemName(pctxt)
00779
00780 #define RTXCTXTPUSHTYPENAME(pctxt,name) \
00781 rtxCtxtPushTypeName(pctxt,OSUTF8(name))
00782
00783 #define RTXCTXTPOPTYPENAME(pctxt) \
00784 rtxCtxtPopTypeName(pctxt)
00785 #else
00786 #define RTXCTXTPUSHARRAYELEMNAME(pctxt,name,idx)
00787 #define RTXCTXTPOPARRAYELEMNAME(pctxt)
00788 #define RTXCTXTPUSHELEMNAME(pctxt,name)
00789 #define RTXCTXTPOPELEMNAME(pctxt)
00790 #define RTXCTXTPUSHTYPENAME(pctxt,name)
00791 #define RTXCTXTPOPTYPENAME(pctxt)
00792 #endif
00793
00794 #ifdef __cplusplus
00795 }
00796 #endif
00797
00800 #endif