rtXmlCtxtAppInfo.h

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  *****************************************************************************/
00024 
00025 #ifndef INITCTXTAPPINFOFUNC
00026 #define INITCTXTAPPINFOFUNC rtXmlInitCtxtAppInfo
00027 #define FREECTXTAPPINFOFUNC rtXmlFreeCtxtAppInfo
00028 #define RESETCTXTAPPINFOFUNC rtXmlResetCtxtAppInfo
00029 #endif
00030 
00031 EXTXMLMETHOD int INITCTXTAPPINFOFUNC (OSCTXT* pctxt)
00032 {
00033    OSXMLCtxtInfo* pCtxtInfo;
00034    pctxt->pXMLInfo = (OSXMLCtxtInfo*)
00035       rtxMemSysAlloc (pctxt, sizeof(OSXMLCtxtInfo));
00036    if (pctxt->pXMLInfo == 0) return LOG_RTERRNEW (pctxt, RTERR_NOMEM);
00037    pCtxtInfo = (OSXMLCtxtInfo*)pctxt->pXMLInfo;
00038    pCtxtInfo->pFreeFunc = FREECTXTAPPINFOFUNC;
00039    pCtxtInfo->pResetFunc = RESETCTXTAPPINFOFUNC;
00040    pCtxtInfo->schemaLocation = 0;
00041    pCtxtInfo->noNSSchemaLoc = 0;
00042    pCtxtInfo->xsiTypeAttr = 0;
00043    pCtxtInfo->encoding = OSXMLUTF8;
00044    pCtxtInfo->mbCdataProcessed = FALSE;
00045    pCtxtInfo->mSaxLevel = pCtxtInfo->mSkipLevel = 0;
00046    pCtxtInfo->maxSaxErrors = pCtxtInfo->errorsCnt = 0;
00047    pCtxtInfo->facets.totalDigits = -1;
00048    pCtxtInfo->facets.fractionDigits = -1;
00049    pCtxtInfo->indent = OSXMLINDENT;
00050    pCtxtInfo->indentChar = ' ';
00051    pCtxtInfo->soapVersion = 12;
00052    pCtxtInfo->encodingStr = 0;
00053    rtxDListFastInit (&pCtxtInfo->namespaceList);
00054    rtxDListFastInit (&pCtxtInfo->encodedNSList);
00055    rtxDListFastInit (&pCtxtInfo->sortedAttrList);
00056    pCtxtInfo->nsPfxLinkStack.count = 0;
00057    pCtxtInfo->nsPfxLinkStack.top = 0;
00058    pCtxtInfo->nsURITable.nrows = 0;
00059    pCtxtInfo->nsURITable.data = 0;
00060    pCtxtInfo->byteOrderMark = OSXMLBOM_NO_BOM;
00061    rtxMemBufInit (pctxt, &pCtxtInfo->memBuf, OSRTMEMBUFSEG);
00062 
00063    pCtxtInfo->pXmlPPReader = 0;
00064    pCtxtInfo->attrsBuff = 0;
00065    pCtxtInfo->attrsBuffSize = 0;
00066    pCtxtInfo->attrStartPos = 0;
00067 
00068    /* Add XML error codes to global table */
00069 #ifndef XERCONTEXT /* to avoid an undefined symbol error */
00070    rtErrXmlInit ();
00071 #endif
00072 
00073    pctxt->state = OSXMLINIT;
00074 
00075    return 0;
00076 }
00077 
00078 EXTXMLMETHOD int FREECTXTAPPINFOFUNC (OSCTXT* pctxt)
00079 {
00080    if (0 != pctxt->pXMLInfo) {
00081       OSXMLCtxtInfo* pCtxtInfo = (OSXMLCtxtInfo*)pctxt->pXMLInfo;
00082       OSCTXT* pXMLInfoCtxt = pctxt;
00083       if (0 != pCtxtInfo->pFreeFunc) {
00084          /* Call free using the context used to allocate XML Info.
00085             It may be different from current context in the case
00086             where getAppInfo() and setAppInfo() are used. */
00087          if (0 != pCtxtInfo->memBuf.pctxt)
00088             pXMLInfoCtxt = pCtxtInfo->memBuf.pctxt;
00089          rtxMemBufFree (&pCtxtInfo->memBuf);
00090 #ifndef XERCONTEXT
00091          rtXmlNSRemoveAll (pctxt);
00092 #endif
00093          rtxMemFreeArray (pXMLInfoCtxt, pCtxtInfo->schemaLocation);
00094          rtxMemFreeArray (pXMLInfoCtxt, pCtxtInfo->noNSSchemaLoc);
00095          rtxMemFreeArray (pXMLInfoCtxt, pCtxtInfo->xsiTypeAttr);
00096          pCtxtInfo->pFreeFunc = 0;
00097          pCtxtInfo->noNSSchemaLoc = 0;
00098          pCtxtInfo->schemaLocation = 0;
00099          pCtxtInfo->nsURITable.nrows = 0;
00100          pCtxtInfo->nsURITable.data = 0;
00101 
00102          /* Free nodes in namespace lists (note: we can't free namespace
00103             record memory because they might be held in local lists) */
00104          rtxDListFreeNodes (pXMLInfoCtxt, &pCtxtInfo->namespaceList);
00105          rtxDListFreeNodes (pXMLInfoCtxt, &pCtxtInfo->encodedNSList);
00106          rtxDListFreeNodes (pXMLInfoCtxt, &pCtxtInfo->sortedAttrList);
00107 
00108          rtxMemFreeArray (pctxt, pCtxtInfo->attrsBuff);
00109          pCtxtInfo->attrsBuff = 0;
00110          pCtxtInfo->attrsBuffSize = 0;
00111          pCtxtInfo->attrStartPos = 0;
00112 
00113 #ifndef XERCONTEXT /* This is a missing symbol in the asn1xer library! */
00114          rtXmlpFreeReader (pctxt, pCtxtInfo);
00115 #endif
00116       }
00117       pctxt->pXMLInfo = 0;
00118       return 0;
00119    }
00120    return LOG_RTERRNEW (pctxt, RTERR_NOTINIT);
00121 }
00122 
00123 EXTXMLMETHOD int RESETCTXTAPPINFOFUNC (OSCTXT* pctxt)
00124 {
00125    if (0 != pctxt->pXMLInfo) {
00126       OSXMLCtxtInfo* pCtxtInfo = (OSXMLCtxtInfo*)pctxt->pXMLInfo;
00127       rtxMemBufReset (&pCtxtInfo->memBuf);
00128 #ifndef XERCONTEXT
00129       rtXmlNSRemoveAll (pctxt);
00130 #endif
00131       rtxMemFreeArray (pctxt, pCtxtInfo->schemaLocation);
00132       rtxMemFreeArray (pctxt, pCtxtInfo->noNSSchemaLoc);
00133       rtxMemFreeArray (pctxt, pCtxtInfo->xsiTypeAttr);
00134       pCtxtInfo->noNSSchemaLoc = 0;
00135       pCtxtInfo->schemaLocation = 0;
00136       pCtxtInfo->xsiTypeAttr = 0;
00137       pCtxtInfo->pFreeFunc = FREECTXTAPPINFOFUNC;
00138       pCtxtInfo->pResetFunc = RESETCTXTAPPINFOFUNC;
00139       pCtxtInfo->encoding = OSXMLUTF8;
00140       pCtxtInfo->indent = OSXMLINDENT;
00141       pCtxtInfo->indentChar = ' ';
00142       pCtxtInfo->encodingStr = 0;
00143       pCtxtInfo->nsURITable.nrows = 0;
00144       pCtxtInfo->nsURITable.data = 0;
00145       pCtxtInfo->pXmlPPReader = 0;
00146       rtxMemFreeArray (pctxt, pCtxtInfo->attrsBuff);
00147       rtxDListFastInit (&pCtxtInfo->sortedAttrList);
00148       pCtxtInfo->attrsBuff = 0;
00149       pCtxtInfo->attrsBuffSize = 0;
00150       pCtxtInfo->attrStartPos = 0;
00151       return 0;
00152    }
00153    return LOG_RTERRNEW (pctxt, RTERR_NOTINIT);
00154 }
00155 
00156