rtxContext.h
Go to the documentation of this file.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 16*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 spare[1];
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 OSRTBUFSAVE(pctxt) { \
00215 (pctxt)->savedInfo.byteIndex = (pctxt)->buffer.byteIndex; \
00216 (pctxt)->savedInfo.flags = (pctxt)->flags; }
00217
00218 #define OSRTBUFRESTORE(pctxt) { \
00219 (pctxt)->buffer.byteIndex = (pctxt)->savedInfo.byteIndex; \
00220 (pctxt)->flags = (pctxt)->savedInfo.flags; }
00221
00222
00223
00224 typedef void *(OSCDECL *OSMallocFunc ) (size_t size);
00225 typedef void *(OSCDECL *OSReallocFunc) (void *ptr, size_t size);
00226 typedef void (OSCDECL *OSFreeFunc ) (void *ptr);
00227
00228 #ifdef __cplusplus
00229 extern "C" {
00230 #endif
00231
00256 #ifndef rtxInitContext
00257 EXTERNRT int rtxInitContext (OSCTXT* pctxt);
00258 #endif
00259
00274 EXTERNRT int rtxInitContextExt (OSCTXT* pctxt,
00275 OSMallocFunc malloc_func,
00276 OSReallocFunc realloc_func,
00277 OSFreeFunc free_func);
00278
00299 EXTERNRT int rtxInitThreadContext (OSCTXT* pctxt, const OSCTXT* pSrcCtxt);
00300
00319 EXTERNRT int rtxInitContextBuffer
00320 (OSCTXT* pctxt, OSOCTET* bufaddr, size_t bufsiz);
00321
00345 EXTERNRT int rtxCtxtSetBufPtr
00346 (OSCTXT* pctxt, OSOCTET* bufaddr, size_t bufsiz);
00347
00359 #define rtxCtxtGetMsgPtr(pctxt) (pctxt)->buffer.data
00360
00370 #define rtxCtxtGetMsgLen(pctxt) (pctxt)->buffer.byteIndex
00371
00379 EXTERNRT size_t rtxCtxtGetBitOffset (OSCTXT* pctxt);
00380
00388 EXTERNRT size_t rtxCtxtGetIOByteCount (OSCTXT* pctxt);
00389
00399 EXTERNRT int rtxCheckContext (OSCTXT* pctxt);
00400
00408 EXTERNRT void rtxFreeContext (OSCTXT* pctxt);
00409
00419 EXTERNRT void rtxCopyContext (OSCTXT* pdest, OSCTXT* psrc);
00420
00427 EXTERNRT void rtxCtxtSetFlag (OSCTXT* pctxt, OSUINT32 mask);
00428
00436 EXTERNRT void rtxCtxtClearFlag (OSCTXT* pctxt, OSUINT32 mask);
00437
00444 #define rtxCtxtTestFlag(pctxt,mask) ((pctxt->flags & mask) != 0)
00445
00458 EXTERNRT int rtxCtxtPushElemName (OSCTXT* pctxt, const OSUTF8CHAR* elemName);
00459
00467 EXTERNRT const OSUTF8CHAR* rtxCtxtPopElemName (OSCTXT* pctxt);
00468
00476 #define rtxCtxtPeekElemName(pctxt) \
00477 (((pctxt)->elemNameStack.count > 0) ? \
00478 (const OSUTF8CHAR*)(pctxt)->elemNameStack.tail->data : (const OSUTF8CHAR*)0)
00479
00480 EXTERNRT int rtxPreInitContext (OSCTXT* pctxt);
00481 #if 0
00482 EXTERNRT void rtxResetContext (OSCTXT* pctxt);
00483 #endif
00484 EXTERNRT void rtxMemFreeOpenSeqExt
00485 (OSCTXT* pctxt, struct OSRTDList *pElemList);
00486
00496 EXTERNRT void rtxMemHeapSetFlags (OSCTXT* pctxt, OSUINT32 flags);
00497
00506 EXTERNRT void rtxMemHeapClearFlags (OSCTXT* pctxt, OSUINT32 flags);
00507
00516 EXTERNRT void rtxMemHeapSetDefBlkSize (OSCTXT* pctxt, OSUINT32 blkSize);
00517
00524 EXTERNRT OSUINT32 rtxMemHeapGetDefBlkSize (OSCTXT* pctxt);
00525
00529 #define rtxByteAlign(pctxt) \
00530 if ((pctxt)->buffer.bitOffset != 8) { \
00531 (pctxt)->buffer.byteIndex++; (pctxt)->buffer.bitOffset = 8; }
00532
00533 #ifdef __cplusplus
00534 }
00535 #endif
00536
00539 #endif