rtxContext.h
Go to the documentation of this file.00001 /* 00002 * Copyright (c) 2003-2010 Objective Systems, Inc. 00003 * 00004 * This software is furnished under a license and may be used and copied 00005 * only in accordance with the terms of such license and with the 00006 * inclusion of the above copyright notice. This software or any other 00007 * copies thereof may not be provided or otherwise made available to any 00008 * other person. No title to and ownership of the software is hereby 00009 * transferred. 00010 * 00011 * The information in this software is subject to change without notice 00012 * and should not be construed as a commitment by Objective Systems, Inc. 00013 * 00014 * PROPRIETARY NOTICE 00015 * 00016 * This software is an unpublished work subject to a confidentiality agreement 00017 * and is protected by copyright and trade secret law. Unauthorized copying, 00018 * redistribution or other use of this work is prohibited. 00019 * 00020 * The above notice of copyright on this source code product does not indicate 00021 * any actual or intended publication of such source code. 00022 * 00023 *****************************************************************************/ 00028 #ifndef _RTXCONTEXT_H_ 00029 #define _RTXCONTEXT_H_ 00030 00031 #include "rtxsrc/rtxDList.h" 00032 00033 #define OSRTENCBUFSIZ 1024 /* dynamic encode buffer extent size */ 00034 00039 /* run-time error info structures */ 00040 00041 #define OSRTERRSTKSIZ 8 /* error stack size */ 00042 #define OSRTMAXERRPRM 5 /* maximum error parameters */ 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; /* list of errors */ 00077 OSRTErrInfo reserved; /* error info elem, used if nomem to alloc */ 00078 OSRTDListNode reservedNode; /* node placeholder for errInfo elem */ 00079 } OSRTErrInfoList; 00080 00089 typedef struct { 00090 OSOCTET* data; /* pointer to start of data buffer */ 00091 size_t byteIndex; /* byte index */ 00092 size_t size; /* current buffer size */ 00093 OSINT16 bitOffset; /* current bit offset (8 - 1) */ 00094 OSBOOL dynamic; /* is buffer dynamic? */ 00095 OSBOOL aligned; /* is buffer byte aligned? */ 00096 } OSRTBuffer; 00097 00098 typedef OSUINT32 OSRTFLAGS; 00099 00106 typedef struct { 00107 size_t byteIndex; /* byte index */ 00108 OSINT16 bitOffset; /* current bit offset (8 - 1) */ 00109 OSRTFLAGS flags; /* flag bits */ 00110 } OSRTBufSave; 00111 00112 /* OSRTCTXT flag mask values : bits 32 - 16 are for common flags, bits */ 00113 /* 15 - 0 are reserved for application specific flags */ 00114 00115 #define OSDIAG 0x80000000 /* diagnostic tracing enabled */ 00116 #define OSTRACE 0x40000000 /* tracing enabled */ 00117 #define OSDISSTRM 0x20000000 /* disable stream encode/decode */ 00118 #define OSNOSTRMBACKOFF 0x8000000 /* stream mark/reset funcs is not used */ 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 /* Alias for __cdecl modifier; if __cdecl keyword is not supported, 00147 * redefine it as empty macro. */ 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 /* OSCDECL */ 00156 00164 typedef struct OSCTXT { /* run-time context block */ 00165 void* pMemHeap; /* internal message memory heap */ 00166 OSRTBuffer buffer; /* data buffer */ 00167 OSRTBufSave savedInfo; /* saved buffer info */ 00168 OSRTErrInfoList errInfo; /* run-time error info */ 00169 OSUINT32 initCode; /* code double word to indicate init */ 00170 OSRTFLAGS flags; /* flag bits */ 00171 OSOCTET level; /* nesting level */ 00172 OSOCTET state; /* encode/decode process state */ 00173 OSOCTET diagLevel; /* diagnostic trace level */ 00174 OSOCTET lastChar; /* last char/byte written or read */ 00175 #ifndef _NO_STREAM 00176 struct OSRTSTREAM* pStream; /* Stream */ 00177 struct OSRTPrintStream *pPrintStrm; /* Print Stream */ 00178 #endif /* _NO_STREAM */ 00179 OSRTDList elemNameStack; /* element name stack */ 00180 OSRTDList regExpCache; /* compiled regular expression cache */ 00181 const OSOCTET* key; /* pointer to run-time key data */ 00182 size_t keylen; /* run-time key length */ 00183 OSVoidPtr pXMLInfo; /* XML specific info */ 00184 OSVoidPtr pASN1Info; /* ASN.1 specific info */ 00185 OSVoidPtr pEXIInfo; /* EXI specific info */ 00186 OSVoidPtr pUserData; /* User defined data */ 00187 OSVoidPtr pGlobalData; /* Global constant data */ 00188 OSFreeCtxtGlobalPtr gblFreeFunc; /* Global free function */ 00189 OSVoidPtr ssl; /* SSL stack endpoint */ 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 /* _NO_STREAM */ 00209 00210 #define OSRTISSTREAM(pctxt) FALSE 00211 00212 #endif /* _NO_STREAM */ 00213 00214 #define OSRTBUFCUR(pctxt) (pctxt)->buffer.data[(pctxt)->buffer.byteIndex] 00215 #define OSRTBUFPTR(pctxt) &(pctxt)->buffer.data[(pctxt)->buffer.byteIndex] 00216 #define OSRTBUFFER(pctxt) (pctxt)->buffer.data 00217 #define OSRTBUFSIZE(pctxt) (pctxt)->buffer.size 00218 00219 #define OSRTBUFSAVE(pctxt) { \ 00220 (pctxt)->savedInfo.byteIndex = (pctxt)->buffer.byteIndex; \ 00221 (pctxt)->savedInfo.flags = (pctxt)->flags; } 00222 00223 #define OSRTBUFRESTORE(pctxt) { \ 00224 (pctxt)->buffer.byteIndex = (pctxt)->savedInfo.byteIndex; \ 00225 (pctxt)->flags = (pctxt)->savedInfo.flags; } 00226 00227 /* Pointers to C Run-Time memory allocation functions */ 00228 00229 typedef void *(OSCDECL *OSMallocFunc ) (size_t size); 00230 typedef void *(OSCDECL *OSReallocFunc) (void *ptr, size_t size); 00231 typedef void (OSCDECL *OSFreeFunc ) (void *ptr); 00232 00233 #ifdef __cplusplus 00234 extern "C" { 00235 #endif 00236 00261 #ifndef rtxInitContext 00262 EXTERNRT int rtxInitContext (OSCTXT* pctxt); 00263 #endif 00264 00279 EXTERNRT int rtxInitContextExt (OSCTXT* pctxt, 00280 OSMallocFunc malloc_func, 00281 OSReallocFunc realloc_func, 00282 OSFreeFunc free_func); 00283 00304 EXTERNRT int rtxInitThreadContext (OSCTXT* pctxt, const OSCTXT* pSrcCtxt); 00305 00324 EXTERNRT int rtxInitContextBuffer 00325 (OSCTXT* pctxt, OSOCTET* bufaddr, size_t bufsiz); 00326 00350 EXTERNRT int rtxCtxtSetBufPtr 00351 (OSCTXT* pctxt, OSOCTET* bufaddr, size_t bufsiz); 00352 00364 #define rtxCtxtGetMsgPtr(pctxt) (pctxt)->buffer.data 00365 00375 #define rtxCtxtGetMsgLen(pctxt) (pctxt)->buffer.byteIndex 00376 00384 EXTERNRT size_t rtxCtxtGetBitOffset (OSCTXT* pctxt); 00385 00393 EXTERNRT size_t rtxCtxtGetIOByteCount (OSCTXT* pctxt); 00394 00404 EXTERNRT int rtxCheckContext (OSCTXT* pctxt); 00405 00413 EXTERNRT void rtxFreeContext (OSCTXT* pctxt); 00414 00424 EXTERNRT void rtxCopyContext (OSCTXT* pdest, OSCTXT* psrc); 00425 00432 EXTERNRT void rtxCtxtSetFlag (OSCTXT* pctxt, OSUINT32 mask); 00433 00441 EXTERNRT void rtxCtxtClearFlag (OSCTXT* pctxt, OSUINT32 mask); 00442 00449 #define rtxCtxtTestFlag(pctxt,mask) ((pctxt->flags & mask) != 0) 00450 00463 EXTERNRT int rtxCtxtPushElemName (OSCTXT* pctxt, const OSUTF8CHAR* elemName); 00464 00479 EXTERNRT int rtxCtxtPushTypeName (OSCTXT* pctxt, const OSUTF8CHAR* typeName); 00480 00488 EXTERNRT const OSUTF8CHAR* rtxCtxtPopElemName (OSCTXT* pctxt); 00489 00498 EXTERNRT const OSUTF8CHAR* rtxCtxtPopTypeName (OSCTXT* pctxt); 00499 00507 #define rtxCtxtPeekElemName(pctxt) \ 00508 (((pctxt)->elemNameStack.count > 0) ? \ 00509 (const OSUTF8CHAR*)(pctxt)->elemNameStack.tail->data : (const OSUTF8CHAR*)0) 00510 00511 EXTERNRT int rtxPreInitContext (OSCTXT* pctxt); 00512 #if 0 00513 EXTERNRT void rtxResetContext (OSCTXT* pctxt); 00514 #endif 00515 EXTERNRT void rtxMemFreeOpenSeqExt 00516 (OSCTXT* pctxt, struct OSRTDList *pElemList); 00517 00527 EXTERNRT void rtxMemHeapSetFlags (OSCTXT* pctxt, OSUINT32 flags); 00528 00537 EXTERNRT void rtxMemHeapClearFlags (OSCTXT* pctxt, OSUINT32 flags); 00538 00547 EXTERNRT void rtxMemHeapSetDefBlkSize (OSCTXT* pctxt, OSUINT32 blkSize); 00548 00555 EXTERNRT OSUINT32 rtxMemHeapGetDefBlkSize (OSCTXT* pctxt); 00556 00560 #define rtxByteAlign(pctxt) \ 00561 if ((pctxt)->buffer.bitOffset != 8) { \ 00562 (pctxt)->buffer.byteIndex++; (pctxt)->buffer.bitOffset = 8; } 00563 00573 EXTERNRT int rtxMarkPos (OSCTXT* pctxt, size_t* ppos); 00574 00584 EXTERNRT int rtxResetToPos (OSCTXT* pctxt, size_t pos); 00585 00586 #define rtxMarkBitPos(pctxt,ppos,pbitoff) \ 00587 (*(pbitoff) = (OSUINT8) (pctxt)->buffer.bitOffset, rtxMarkPos (pctxt, ppos)) 00588 00589 #define rtxResetToBitPos(pctxt,pos,bitoff) \ 00590 ((pctxt)->buffer.bitOffset = (OSUINT8) bitoff, rtxResetToPos (pctxt, pos)) 00591 00592 #ifdef __cplusplus 00593 } 00594 #endif 00595 00598 #endif
©Copyright 2010. Objective Systems, Inc. All Rights Reserved.
