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 OSSAVEBUF 0x10000000
00119 #define OSNOSTRMBACKOFF 0x8000000
00120
00121 struct OSCTXT;
00122
00123
00124
00125
00126
00127
00128 typedef int (*OSFreeCtxtAppInfoPtr)(struct OSCTXT* pctxt);
00129
00130
00131
00132
00133
00134
00135
00136 typedef int (*OSResetCtxtAppInfoPtr)(struct OSCTXT* pctxt);
00137
00138
00139
00140
00141
00142
00143
00144
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
00158
00159 typedef void *(OSCDECL *OSMallocFunc ) (size_t size);
00160 typedef void *(OSCDECL *OSReallocFunc) (void *ptr, size_t size);
00161 typedef void (OSCDECL *OSFreeFunc ) (void *ptr);
00162
00170 typedef struct OSCTXT {
00171 void* pMemHeap;
00172 OSRTBuffer buffer;
00173 OSRTBufSave savedInfo;
00174 OSRTErrInfoList errInfo;
00175 OSUINT32 initCode;
00176 OSRTFLAGS flags;
00177 OSOCTET level;
00178 OSOCTET state;
00179 OSOCTET diagLevel;
00180 OSOCTET spare[1];
00181 struct OSRTSTREAM* pStream;
00182 struct OSRTPrintStream *pPrintStrm;
00183 OSRTDList elemNameStack;
00184 OSRTDList regExpCache;
00185 const OSOCTET* key;
00186 size_t keylen;
00187 OSVoidPtr pXMLInfo;
00188 OSVoidPtr pASN1Info;
00189 OSVoidPtr pEXIInfo;
00190 OSVoidPtr pUserData;
00191 OSVoidPtr pGlobalData;
00192 OSFreeCtxtGlobalPtr gblFreeFunc;
00193 } OSCTXT;
00194
00195 #define OSRT_GET_FIRST_ERROR_INFO(pctxt) \
00196 (((pctxt)->errInfo.list.head == 0) ? (OSRTErrInfo*)0 : \
00197 (OSRTErrInfo*)((pctxt)->errInfo.list.head->data))
00198
00199 #define OSRT_GET_LAST_ERROR_INFO(pctxt) \
00200 (((pctxt)->errInfo.list.tail == 0) ? (OSRTErrInfo*)0 : \
00201 (OSRTErrInfo*)((pctxt)->errInfo.list.tail->data))
00202
00206 #define OSRTISSTREAM(pctxt) \
00207 ((pctxt)->pStream != 0 && !((pctxt)->flags & OSDISSTRM))
00208
00209 #define OSRTBUFSAVE(pctxt) { \
00210 (pctxt)->savedInfo.byteIndex = (pctxt)->buffer.byteIndex; \
00211 (pctxt)->savedInfo.flags = (pctxt)->flags; }
00212
00213 #define OSRTBUFRESTORE(pctxt) { \
00214 (pctxt)->buffer.byteIndex = (pctxt)->savedInfo.byteIndex; \
00215 (pctxt)->flags = (pctxt)->savedInfo.flags; }
00216
00217 #ifdef __cplusplus
00218 extern "C" {
00219 #endif
00220
00247 EXTERNRT int rtxInitContextUsingKey
00248 (OSCTXT* pctxt, const OSOCTET* key, size_t keylen);
00249
00250 #define rtxInitContextUsingKeyExt
00251
00263 #ifndef rtxInitContext
00264 EXTERNRT int rtxInitContext (OSCTXT* pctxt);
00265 #endif
00266
00281 EXTERNRT int rtxInitContextExt (OSCTXT* pctxt,
00282 OSMallocFunc malloc_func,
00283 OSReallocFunc realloc_func,
00284 OSFreeFunc free_func);
00285
00306 EXTERNRT int rtxInitThreadContext (OSCTXT* pctxt, const OSCTXT* pSrcCtxt);
00307
00326 EXTERNRT int rtxInitContextBuffer
00327 (OSCTXT* pctxt, OSOCTET* bufaddr, size_t bufsiz);
00328
00352 EXTERNRT int rtxCtxtSetBufPtr
00353 (OSCTXT* pctxt, OSOCTET* bufaddr, size_t bufsiz);
00354
00366 #define rtxCtxtGetMsgPtr(pctxt) (pctxt)->buffer.data
00367
00377 #define rtxCtxtGetMsgLen(pctxt) (pctxt)->buffer.byteIndex
00378
00386 EXTERNRT size_t rtxCtxtGetIOByteCount (OSCTXT* pctxt);
00387
00397 EXTERNRT int rtxCheckContext (OSCTXT* pctxt);
00398
00406 EXTERNRT void rtxFreeContext (OSCTXT* pctxt);
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417 EXTERNRT void rtxCopyContext (OSCTXT* pdest, OSCTXT* psrc);
00418
00425 EXTERNRT void rtxCtxtSetFlag (OSCTXT* pctxt, OSUINT32 mask);
00426
00434 EXTERNRT void rtxCtxtClearFlag (OSCTXT* pctxt, OSUINT32 mask);
00435
00442 #define rtxCtxtTestFlag(pctxt,mask) ((pctxt->flags & mask) != 0)
00443
00456 EXTERNRT int rtxCtxtPushElemName (OSCTXT* pctxt, const OSUTF8CHAR* elemName);
00457
00465 EXTERNRT const OSUTF8CHAR* rtxCtxtPopElemName (OSCTXT* pctxt);
00466
00467 EXTERNRT int rtxPreInitContext (OSCTXT* pctxt);
00468 #if 0
00469 EXTERNRT void rtxResetContext (OSCTXT* pctxt);
00470 #endif
00471 EXTERNRT void rtxMemFreeOpenSeqExt
00472 (OSCTXT* pctxt, struct OSRTDList *pElemList);
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483 EXTERNRT void rtxMemHeapSetFlags (OSCTXT* pctxt, OSUINT32 flags);
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493 EXTERNRT void rtxMemHeapClearFlags (OSCTXT* pctxt, OSUINT32 flags);
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503 EXTERNRT void rtxMemHeapSetDefBlkSize (OSCTXT* pctxt, OSUINT32 blkSize);
00504
00505
00506
00507
00508
00509
00510
00511 EXTERNRT OSUINT32 rtxMemHeapGetDefBlkSize (OSCTXT* pctxt);
00512
00516 #define rtxByteAlign(pctxt) \
00517 if ((pctxt)->buffer.bitOffset != 8) { \
00518 (pctxt)->buffer.byteIndex++; (pctxt)->buffer.bitOffset = 8; }
00519
00520 #ifdef __cplusplus
00521 }
00522 #endif
00523
00526 #endif