EXTERN int asn1PD_HnbPrivateMessage (OSCTXT* pctxt, HnbPrivateMessage* pvalue) { int stat = 0; OSCTXT lctxt; ASN1OpenType openType; ASN1OpenType* pOpenType; OSUINT32 bitcnt; OSUINT32 i; OSBOOL optbit = FALSE; OSBOOL extbit = FALSE; /* extension bit */ stat = PD_BIT (pctxt, &extbit); if (stat != 0) return LOG_RTERR (pctxt, stat); rtxDListInit (&pvalue->extElem1); /* decode privateIEs */ asn1Init_PrivateIE_Container (&pvalue->privateIEs); stat = asn1PD_PrivateIE_Container (pctxt, &pvalue->privateIEs); if (stat != 0) return LOG_RTERR (pctxt, stat); if (extbit) { /* decode extension optional bits length */ stat = pd_SmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != 0) return LOG_RTERR (pctxt, stat); bitcnt += 1; rtxPreInitContext (&lctxt); rtxCopyContext (&lctxt, pctxt); stat = pd_moveBitCursor (pctxt, bitcnt); if (stat != 0) return LOG_RTERR (pctxt, stat); for (i = 0; i < bitcnt; i++) { PD_BIT (&lctxt, &optbit); if (optbit) { stat = pd_OpenType (pctxt, &openType.data, &openType.numocts); if (stat != 0) return LOG_RTERR (pctxt, stat); pOpenType = rtxMemAllocType (pctxt, ASN1OpenType); pOpenType->numocts = openType.numocts; pOpenType->data = openType.data; rtxDListAppend (pctxt, &pvalue->extElem1, pOpenType); } else { /* unknown element */ rtxDListAppend (pctxt, &pvalue->extElem1, 0); } } } return (stat); }
int XmlDec_Math (OSCTXT* pctxt, Math* pvalue) { int stat = 0; /* decode attributes */ if (rtXmlpHasAttributes (pctxt)) { size_t i, nAttrs = 0; const OSUTF8CHAR* attrStr; stat = rtXmlpGetAttributeCount (pctxt); if (stat < 0) return LOG_RTERR (pctxt, stat); else nAttrs = (size_t)stat; for (i = 0; i < nAttrs; i++) { stat = rtXmlpDecAnyAttrStr (pctxt, &attrStr, i); if (stat != 0) return LOG_RTERR (pctxt, stat); rtxDListAppend (pctxt, &pvalue->attr, (void*)attrStr); } } { OSXSDAny* pdata1; OSXMLElemDescr elemDescr; const OSUTF8CHAR* pxmlstr; for (;;) { stat = rtXmlpGetNextElem (pctxt, &elemDescr, -1); if (0 != stat) break; stat = rtXmlpDecAnyElem (pctxt, &pxmlstr); if (0 != stat) break; stat = rtXmlpMatchEndTag (pctxt, -1); if (stat < 0) return LOG_RTERR (pctxt, stat); pdata1 = rtxMemAllocType (pctxt, OSXSDAny); if (0 == pdata1) return LOG_RTERR (pctxt, RTERR_NOMEM); pdata1->t = OSXSDAny_xmlText; pdata1->u.xmlText = pxmlstr; if (0 == rtxDListAppend (pctxt, &pvalue->element446_list, pdata1)) return LOG_RTERR (pctxt, RTERR_NOMEM); } if (stat == XML_OK_EOB) stat = 0; else return LOG_RTERR (pctxt, stat); } return (stat); }
EXTRTMETHOD OSBOOL rtCopyOpenTypeExt (OSCTXT* pctxt, OSRTDList* srcList, OSRTDList* dstList) { OSRTDListNode* pnode; if (srcList == NULL || dstList == NULL) return FALSE; pnode = srcList->head; rtxDListInit (dstList); /* Check all the octets are equal */ while (0 != pnode) { if (0 != pnode->data) { ASN1OpenType* pSrcOT = (ASN1OpenType*) pnode->data; ASN1OpenType* pDestOT = (ASN1OpenType*) rtxMemAlloc (pctxt, sizeof (ASN1OpenType)); if (pDestOT == NULL) return FALSE; if (!rtCopyOpenType (pctxt, pSrcOT, pDestOT)) return FALSE; rtxDListAppend (pctxt, dstList, pDestOT); } pnode = pnode->next; } return TRUE; }
void asn1DOMTest_OrderCancellationType_orderReference_list (OSCTXT* pctxt, OrderCancellationType_orderReference_list* pvalue, xmlNodePtr pXmlNode, OSBOOL setChild) { OrderReference* pdata = rtxMemAllocTypeZ (pctxt, OrderReference); asn1DOMTest_OrderReference (pctxt, pdata, pXmlNode, setChild); if (0 != pdata) rtxDListAppend (pctxt, pvalue, (void*)pdata); }
int DOMTest_Config_item_map_entry (OSCTXT* pctxt, Config_item_map_entry* pvalue, xmlNodePtr pXmlNode, OSBOOL setChild) { xmlAttrPtr pXmlAttr = pXmlNode->properties; /* Populate attributes */ for ( ; 0 != pXmlAttr; pXmlAttr = pXmlAttr->next) { if (pXmlAttr->type == XML_ATTRIBUTE_NODE) { if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("name"))) { pvalue->m.namePresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->name = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->name = (const OSUTF8CHAR*)""; } } } } /* Populate elements */ if (setChild) pXmlNode = pXmlNode->children; for ( ; 0 != pXmlNode; pXmlNode = pXmlNode->next) { if (pXmlNode->type == XML_ELEMENT_NODE) { if (rtxUTF8StrEqual (pXmlNode->name, OSUTF8("config-item")) || rtxUTF8StrEqual (pXmlNode->name, OSUTF8("config-item-set")) || rtxUTF8StrEqual (pXmlNode->name, OSUTF8("config-item-map-named")) || rtxUTF8StrEqual (pXmlNode->name, OSUTF8("config-item-map-indexed"))) { { Config_item_map_entry_element* pdata2; pdata2 = rtxMemAllocType (pctxt, Config_item_map_entry_element); if (pdata2 == NULL) return LOG_RTERR (pctxt, RTERR_NOMEM); asn1Init_Config_item_map_entry_element (pdata2); DOMTest_Config_item_map_entry_element (pctxt, pdata2, pXmlNode, FALSE); if (0 != pdata2) rtxDListAppend (pctxt, &pvalue->choice_list, (void*)pdata2); } } } } return 0; }
/* * Returns namespace count if successful or negative status code on failure. */ EXTXMLMETHOD int rtSaxParseNSAttrs (OSCTXT* pctxt, const OSUTF8CHAR* const* attrs, OSRTDList* pNSAttrs, const OSUTF8CHAR* nsTable[], OSUINT32 nsTableRowCount) { int count = 0, stat; if (0 != attrs) { size_t i; const OSUTF8CHAR* nsPrefix; for (i = 0; 0 != attrs[i]; i += 2) { if (rtXmlStrnCmpAsc (attrs[i], "xmlns", 5)) { if (0 == count++) { /* Push new namespace level onto stack */ rtXmlNSPush (pctxt); } nsPrefix = (attrs[i][5] == ':') ? &attrs[i][6] : 0; stat = rtXmlNSAddPrefixLink (pctxt, nsPrefix, attrs[i+1], nsTable, nsTableRowCount); if (0 != stat) return LOG_RTERR (pctxt, stat); /* If output namespace list pointer provided, add a record */ /* to this list.. */ if (0 != pNSAttrs) { OSXMLNamespace* pNS = rtxMemAllocType (pctxt, OSXMLNamespace); if (0 == pNS) return LOG_RTERR (pctxt, RTERR_NOMEM); pNS->prefix = (0 != nsPrefix) ? rtxUTF8Strdup (pctxt, nsPrefix) : 0; pNS->uri = rtxUTF8Strdup (pctxt, attrs[i+1]); rtxDListAppend (pctxt, pNSAttrs, (void*)pNS); } } } } return count; }
EXTERN int asn1PD_RUA_CriticalityDiagnostics (OSCTXT* pctxt, RUA_CriticalityDiagnostics* pvalue) { int stat = 0; OSCTXT lctxt; ASN1OpenType openType; ASN1OpenType* pOpenType; OSUINT32 bitcnt; OSUINT32 i; OSBOOL optbit = FALSE; OSBOOL extbit = FALSE; /* extension bit */ stat = PD_BIT (pctxt, &extbit); if (stat != 0) return LOG_RTERR (pctxt, stat); /* optional bits */ memset (&pvalue->m, 0, sizeof(pvalue->m)); rtxDListInit (&pvalue->extElem1); stat = PD_BIT (pctxt, &optbit); if (stat != 0) return LOG_RTERR (pctxt, stat); pvalue->m.procedureCodePresent = optbit; stat = PD_BIT (pctxt, &optbit); if (stat != 0) return LOG_RTERR (pctxt, stat); pvalue->m.triggeringMessagePresent = optbit; stat = PD_BIT (pctxt, &optbit); if (stat != 0) return LOG_RTERR (pctxt, stat); pvalue->m.procedureCriticalityPresent = optbit; stat = PD_BIT (pctxt, &optbit); if (stat != 0) return LOG_RTERR (pctxt, stat); pvalue->m.iEsCriticalityDiagnosticsPresent = optbit; stat = PD_BIT (pctxt, &optbit); if (stat != 0) return LOG_RTERR (pctxt, stat); pvalue->m.iE_ExtensionsPresent = optbit; /* decode procedureCode */ if (pvalue->m.procedureCodePresent) { stat = asn1PD_RUA_ProcedureCode (pctxt, &pvalue->procedureCode); if (stat != 0) return LOG_RTERR (pctxt, stat); } /* decode triggeringMessage */ if (pvalue->m.triggeringMessagePresent) { stat = asn1PD_RUA_TriggeringMessage (pctxt, &pvalue->triggeringMessage); if (stat != 0) return LOG_RTERR (pctxt, stat); } /* decode procedureCriticality */ if (pvalue->m.procedureCriticalityPresent) { stat = asn1PD_RUA_Criticality (pctxt, &pvalue->procedureCriticality); if (stat != 0) return LOG_RTERR (pctxt, stat); } /* decode iEsCriticalityDiagnostics */ if (pvalue->m.iEsCriticalityDiagnosticsPresent) { asn1Init_RUA_CriticalityDiagnostics_IE_List (&pvalue->iEsCriticalityDiagnostics); stat = asn1PD_RUA_CriticalityDiagnostics_IE_List (pctxt, &pvalue->iEsCriticalityDiagnostics); if (stat != 0) return LOG_RTERR (pctxt, stat); } /* decode iE_Extensions */ if (pvalue->m.iE_ExtensionsPresent) { asn1Init_RUA_ProtocolExtensionContainer (&pvalue->iE_Extensions); stat = asn1PD_RUA_ProtocolExtensionContainer (pctxt, &pvalue->iE_Extensions); if (stat != 0) return LOG_RTERR (pctxt, stat); } if (extbit) { /* decode extension optional bits length */ stat = pd_SmallNonNegWholeNumber (pctxt, &bitcnt); if (stat != 0) return LOG_RTERR (pctxt, stat); bitcnt += 1; rtxPreInitContext (&lctxt); rtxCopyContext (&lctxt, pctxt); stat = pd_moveBitCursor (pctxt, bitcnt); if (stat != 0) return LOG_RTERR (pctxt, stat); for (i = 0; i < bitcnt; i++) { PD_BIT (&lctxt, &optbit); if (optbit) { stat = pd_OpenType (pctxt, &openType.data, &openType.numocts); if (stat != 0) return LOG_RTERR (pctxt, stat); pOpenType = rtxMemAllocType (pctxt, ASN1OpenType); pOpenType->numocts = openType.numocts; pOpenType->data = openType.data; rtxDListAppend (pctxt, &pvalue->extElem1, pOpenType); } else { /* unknown element */ rtxDListAppend (pctxt, &pvalue->extElem1, 0); } } } return (stat); }
int DOMTest_Ns7_Scene (OSCTXT* pctxt, Ns7_Scene* pvalue, xmlNodePtr pXmlNode, OSBOOL setChild) { xmlAttrPtr pXmlAttr = pXmlNode->properties; /* Populate attributes */ for ( ; 0 != pXmlAttr; pXmlAttr = pXmlAttr->next) { if (pXmlAttr->type == XML_ATTRIBUTE_NODE) { if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("ambient-color"))) { pvalue->m.ambient_colorPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->ambient_color = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->ambient_color = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("distance"))) { pvalue->m.distancePresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->distance = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->distance = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("focal-length"))) { pvalue->m.focal_lengthPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->focal_length = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->focal_length = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("lighting-mode"))) { pvalue->m.lighting_modePresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { Ns7_Lighting_mode_ToEnum (pctxt, ((xmlNodePtr)pXmlAttr)->children->content, &pvalue->lighting_mode); } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("projection"))) { pvalue->m.projectionPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { Ns7_Projection_ToEnum (pctxt, ((xmlNodePtr)pXmlAttr)->children->content, &pvalue->projection); } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("shade-mode"))) { pvalue->m.shade_modePresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { Ns7_Shade_mode_ToEnum (pctxt, ((xmlNodePtr)pXmlAttr)->children->content, &pvalue->shade_mode); } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("shadow-slant"))) { pvalue->m.shadow_slantPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->shadow_slant = atoi ((const char*)((xmlNodePtr)pXmlAttr)->children->content); } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("transform"))) { pvalue->m.transformPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->transform = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->transform = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("vpn"))) { pvalue->m.vpnPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->vpn = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->vpn = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("vrp"))) { pvalue->m.vrpPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->vrp = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->vrp = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("vup"))) { pvalue->m.vupPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->vup = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->vup = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("class-names"))) { pvalue->m.class_namesPresent = 1; DOMTest_Ns3_Class_names (pctxt, (Ns3_Class_names*)&pvalue->class_names, pXmlAttr, FALSE); } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("id"))) { pvalue->m.idPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->id = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->id = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("layer"))) { pvalue->m.layerPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->layer = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->layer = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("style-name"))) { pvalue->m.style_namePresent = 1; pvalue->style_name = rtxMemAllocType (pctxt, Ns3_Style_name); if (pvalue->style_name == NULL) return LOG_RTERR (pctxt, RTERR_NOMEM); asn1Init_Ns3_Style_name ((Ns3_Style_name*)pvalue->style_name); DOMTest_Ns3_Style_name (pctxt, (Ns3_Style_name*)pvalue->style_name, pXmlAttr, FALSE); } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("z-index"))) { pvalue->m.z_indexPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->z_index = atoi ((const char*)((xmlNodePtr)pXmlAttr)->children->content); } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("class-names"))) { pvalue->m.class_names_1Present = 1; DOMTest_Ns3_Class_names (pctxt, (Ns3_Class_names*)&pvalue->class_names_1, pXmlAttr, FALSE); } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("style-name"))) { pvalue->m.style_name_1Present = 1; pvalue->style_name_1 = rtxMemAllocType (pctxt, Ns3_Style_name); if (pvalue->style_name_1 == NULL) return LOG_RTERR (pctxt, RTERR_NOMEM); asn1Init_Ns3_Style_name ((Ns3_Style_name*)pvalue->style_name_1); DOMTest_Ns3_Style_name (pctxt, (Ns3_Style_name*)pvalue->style_name_1, pXmlAttr, FALSE); } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("height"))) { pvalue->m.heightPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->height = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->height = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("width"))) { pvalue->m.widthPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->width = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->width = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("x"))) { pvalue->m.xPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->x = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->x = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("y"))) { pvalue->m.yPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->y = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->y = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("end-cell-address"))) { pvalue->m.end_cell_addressPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->end_cell_address = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->end_cell_address = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("end-x"))) { pvalue->m.end_xPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->end_x = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->end_x = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("end-y"))) { pvalue->m.end_yPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->end_y = ((xmlNodePtr)pXmlAttr)->children->content; } else { pvalue->end_y = (const OSUTF8CHAR*)""; } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("table-background"))) { pvalue->m.table_backgroundPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { Table_background_ToEnum (pctxt, ((xmlNodePtr)pXmlAttr)->children->content, &pvalue->table_background); } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("anchor-page-number"))) { pvalue->m.anchor_page_numberPresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { pvalue->anchor_page_number = atoi ((const char*)((xmlNodePtr)pXmlAttr)->children->content); } } else if (rtxUTF8StrEqual (pXmlAttr->name, OSUTF8("anchor-type"))) { pvalue->m.anchor_typePresent = 1; if (0 != ((xmlNodePtr)pXmlAttr)->children) { Odf_Anchor_type_ToEnum (pctxt, ((xmlNodePtr)pXmlAttr)->children->content, &pvalue->anchor_type); } } } } /* Populate elements */ if (setChild) pXmlNode = pXmlNode->children; for ( ; 0 != pXmlNode; pXmlNode = pXmlNode->next) { if (pXmlNode->type == XML_ELEMENT_NODE) { if (rtxUTF8StrEqual (pXmlNode->name, OSUTF8("light"))) { { Ns7_Light* pdata2; pdata2 = rtxMemAllocType (pctxt, Ns7_Light); if (pdata2 == NULL) return LOG_RTERR (pctxt, RTERR_NOMEM); asn1Init_Ns7_Light (pdata2); DOMTest_Ns7_Light (pctxt, pdata2, pXmlNode, FALSE); if (0 != pdata2) rtxDListAppend (pctxt, &pvalue->light_list, (void*)pdata2); } } else if (rtxUTF8StrEqual (pXmlNode->name, OSUTF8("scene")) || rtxUTF8StrEqual (pXmlNode->name, OSUTF8("extrude")) || rtxUTF8StrEqual (pXmlNode->name, OSUTF8("sphere")) || rtxUTF8StrEqual (pXmlNode->name, OSUTF8("rotate")) || rtxUTF8StrEqual (pXmlNode->name, OSUTF8("cube"))) { { Ns7_Scene_element* pdata2; pdata2 = rtxMemAllocType (pctxt, Ns7_Scene_element); if (pdata2 == NULL) return LOG_RTERR (pctxt, RTERR_NOMEM); asn1Init_Ns7_Scene_element (pdata2); DOMTest_Ns7_Scene_element (pctxt, pdata2, pXmlNode, FALSE); if (0 != pdata2) rtxDListAppend (pctxt, &pvalue->choice_list, (void*)pdata2); } } } } return 0; }
int XmlDec_InvoiceType (OSCTXT* pctxt, InvoiceType* pvalue) { int stat = 0; { int elemID; static const OSXMLElemIDRec elemtab[] = { {{{OSUTF8("Header"), 6}, 0}, 0 }, {{{OSUTF8("LineItem"), 8}, 0}, 1 }, {{{OSUTF8("Summary"), 7}, 0}, 2 } } ; static const struct { int row; int num; int anyCase; } groupDesc[] = { {0, 1, -1}, {1, 2, -1}, {3, 0, -1}}; int group = 0; int i; for (i = 0; i < 3; i++) { int fromrow = groupDesc[group].row; int rows = groupDesc[group].num; int anyCase = groupDesc[group].anyCase; elemID = rtXmlpGetNextElemID (pctxt, elemtab + fromrow, rows, -1, FALSE); if (elemID == RTERR_UNEXPELEM && anyCase >= 0 && i == anyCase) elemID = anyCase; else if (elemID < 0) return LOG_RTERR (pctxt, elemID); else if (elemID == XML_OK_EOB) break; else if (elemID == elemtab[fromrow + rows - 1].id) group++; switch (elemID) { case 0: { /* Header */ stat = XmlDec_InvoiceHeaderType (pctxt, &pvalue->header); if (stat != 0) return LOG_RTERR (pctxt, stat); stat = rtXmlpMatchEndTag (pctxt, -1); if (stat < 0) return LOG_RTERR (pctxt, stat); break; } case 1: { InvoiceLineItemType* pdata1; do { pdata1 = rtxMemAllocType (pctxt, InvoiceLineItemType); if (pdata1 == NULL) return LOG_RTERR (pctxt, RTERR_NOMEM); asn1Init_InvoiceLineItemType (pdata1); stat = XmlDec_InvoiceLineItemType (pctxt, pdata1); if (stat != 0) return LOG_RTERR (pctxt, stat); stat = rtXmlpMatchEndTag (pctxt, -1); if (stat < 0) return LOG_RTERR (pctxt, stat); rtxDListAppend (pctxt, &pvalue->lineItem_list, (void*)pdata1); stat = rtXmlpGetNextElemID (pctxt, elemtab + 1, 1, -1, FALSE); if (stat < 0 && stat != RTERR_UNEXPELEM) return LOG_RTERR (pctxt, stat); } while (stat == 1); rtXmlpMarkLastEventActive (pctxt); stat = 0; break; } case 2: { /* Summary */ stat = XmlDec_InvoiceSummaryType (pctxt, &pvalue->summary); if (stat != 0) return LOG_RTERR (pctxt, stat); stat = rtXmlpMatchEndTag (pctxt, -1); if (stat < 0) return LOG_RTERR (pctxt, stat); break; } } i = elemID; } } return (stat); }
int XmlDec_InvoiceSummaryType (OSCTXT* pctxt, InvoiceSummaryType* pvalue) { int stat = 0; memset (&pvalue->m, 0, sizeof(pvalue->m)); { int elemID; static const OSXMLElemIDRec elemtab[] = { {{{OSUTF8("LineItemCountValue"), 18}, 0}, 0 }, {{{OSUTF8("SubtotalAmount"), 14}, 0}, 1 }, {{{OSUTF8("PricingVariation"), 16}, 0}, 2 }, {{{OSUTF8("TotalTax"), 8}, 0}, 3 }, {{{OSUTF8("PriceAmount"), 11}, 0}, 4 }, {{{OSUTF8("PackingSlipIdentifier"), 21}, 0}, 5 }, {{{OSUTF8("SummaryNote"), 11}, 0}, 6 } } ; static const struct { int row; int num; int anyCase; } groupDesc[] = { {0, 2, -1}, {2, 3, -1}, {5, 2, -1}}; int group = 0; int i; for (i = 0; i < 7; i++) { int fromrow = groupDesc[group].row; int rows = groupDesc[group].num; int anyCase = groupDesc[group].anyCase; elemID = rtXmlpGetNextElemID (pctxt, elemtab + fromrow, rows, -1, FALSE); if (elemID == RTERR_UNEXPELEM && anyCase >= 0 && i == anyCase) elemID = anyCase; else if (elemID < 0) return LOG_RTERR (pctxt, elemID); else if (elemID == XML_OK_EOB) break; else if (elemID == elemtab[fromrow + rows - 1].id) group++; switch (elemID) { case 0: { /* LineItemCountValue */ stat = XmlDec_CCT_NumericType (pctxt, &pvalue->lineItemCountValue); if (stat != 0) return LOG_RTERR (pctxt, stat); stat = rtXmlpMatchEndTag (pctxt, -1); if (stat < 0) return LOG_RTERR (pctxt, stat); pvalue->m.lineItemCountValuePresent = TRUE; break; } case 1: { /* SubtotalAmount */ stat = XmlDec_CCT_AmountType (pctxt, &pvalue->subtotalAmount); if (stat != 0) return LOG_RTERR (pctxt, stat); stat = rtXmlpMatchEndTag (pctxt, -1); if (stat < 0) return LOG_RTERR (pctxt, stat); break; } case 2: { PricingVariationType* pdata1; do { pdata1 = rtxMemAllocType (pctxt, PricingVariationType); if (pdata1 == NULL) return LOG_RTERR (pctxt, RTERR_NOMEM); asn1Init_PricingVariationType (pdata1); stat = XmlDec_PricingVariationType (pctxt, pdata1); if (stat != 0) return LOG_RTERR (pctxt, stat); stat = rtXmlpMatchEndTag (pctxt, -1); if (stat < 0) return LOG_RTERR (pctxt, stat); rtxDListAppend (pctxt, &pvalue->pricingVariation_list , (void*)pdata1); stat = rtXmlpGetNextElemID (pctxt, elemtab + 2, 1, -1, FALSE); if (stat < 0 && stat != RTERR_UNEXPELEM) return LOG_RTERR (pctxt, stat); } while (stat == 2); rtXmlpMarkLastEventActive (pctxt); stat = 0; break; } case 3: { /* TotalTax */ stat = XmlDec_TaxType (pctxt, &pvalue->totalTax); if (stat != 0) return LOG_RTERR (pctxt, stat); stat = rtXmlpMatchEndTag (pctxt, -1); if (stat < 0) return LOG_RTERR (pctxt, stat); pvalue->m.totalTaxPresent = TRUE; break; } case 4: { /* PriceAmount */ stat = XmlDec_CCT_AmountType (pctxt, &pvalue->priceAmount); if (stat != 0) return LOG_RTERR (pctxt, stat); stat = rtXmlpMatchEndTag (pctxt, -1); if (stat < 0) return LOG_RTERR (pctxt, stat); break; } case 5: { /* PackingSlipIdentifier */ stat = XmlDec_CCT_IdentifierType (pctxt, &pvalue-> packingSlipIdentifier); if (stat != 0) return LOG_RTERR (pctxt, stat); stat = rtXmlpMatchEndTag (pctxt, -1); if (stat < 0) return LOG_RTERR (pctxt, stat); pvalue->m.packingSlipIdentifierPresent = TRUE; break; } case 6: { /* SummaryNote */ stat = XmlDec_NoteType (pctxt, &pvalue->summaryNote); if (stat != 0) return LOG_RTERR (pctxt, stat); stat = rtXmlpMatchEndTag (pctxt, -1); if (stat < 0) return LOG_RTERR (pctxt, stat); pvalue->m.summaryNotePresent = TRUE; break; } } i = elemID; } } return (stat); }
// Appends new list node with data EXTRTMETHOD void ASN1CSeqOfList::append(void* data) { if (getCtxtPtr () == 0) return; //check the context rtxDListAppend(getCtxtPtr (), pList, data); modCount++; }
EXTXMLMETHOD int rtXmlEncStartElement (OSCTXT* pctxt, const OSUTF8CHAR* elemName, OSXMLNamespace* pNS, OSRTDList* pNSAttrs, OSBOOL terminate) { int stat = 0; if (0 != elemName && 0 != *elemName) { size_t elemLen = rtxUTF8LenBytes (elemName); size_t nsPrefixLen; size_t specChars; /* Push null entry onto namespace stack */ stat = rtXmlNSPush (pctxt); if (stat != 0) return LOG_RTERR (pctxt, stat); /* Set namespace URI/prefix links */ stat = rtXmlSetNSPrefixLinks (pctxt, pNSAttrs); if (stat != 0) return LOG_RTERR (pctxt, stat); /* Set namespace prefix in passed namespace structure */ if (0 != pNS) { if (0 == pNS->prefix) { pNS->prefix = rtXmlNSGetPrefix (pctxt, pNS->uri); } nsPrefixLen = OSUTF8LEN (pNS->prefix); } else nsPrefixLen = 0; specChars = (0 != nsPrefixLen) ? 3 : 2; /* Terminate previous element if still open */ stat = rtXmlEncTermStartElement (pctxt); if (stat != 0) return LOG_RTERR (pctxt, stat); stat = rtXmlEncIndent (pctxt); if (stat != 0) return LOG_RTERR (pctxt, stat); pctxt->level++; pctxt->state = OSXMLSTART; /* Verify element will fit in encode buffer */ stat = rtxCheckBuffer (pctxt, elemLen + nsPrefixLen + specChars); if (stat != 0) return LOG_RTERR (pctxt, stat); /* Copy data to buffer */ OSRTPUTCHAR (pctxt, '<'); if (0 != nsPrefixLen) { OSRTMEMCPY (pctxt, pNS->prefix, nsPrefixLen); OSRTPUTCHAR (pctxt, ':'); } OSRTMEMCPY (pctxt, elemName, elemLen); if (terminate) { OSRTPUTCHAR (pctxt, '>'); pctxt->flags &= ~OSTERMSTART; } else /* set flag in context indicating terminator needed */ pctxt->flags |= OSTERMSTART; #ifndef _COMPACT /* Add name to element name stack in context */ rtxDListAppend (pctxt, &pctxt->elemNameStack, (void*)elemName); #endif if (!terminate && rtxCtxtTestFlag (pctxt, OSXMLC14N)) stat = rtXmlEncStartAttrC14N (pctxt); } else if (terminate) { stat = rtXmlEncTermStartElement (pctxt); } if (stat < 0) return LOG_RTERR (pctxt, stat); return 0; }
/* * This function should work only inside the current level. * Once the start or end tag parsed is out of scope of current level * this function returns. */ EXTXMLMETHOD int rtXmlpGetNextElemID (OSCTXT* pctxt, const OSXMLElemIDRec* tab, size_t nrows, OSINT32 level, OSBOOL continueParse) { struct OSXMLReader* pXmlReader; OSXMLStrFragment localName; OSINT16 nsIndex; OSINT32 curLevel; int stat = 0; size_t i; OSXMLEvent event; pXmlReader = rtXmlpGetReader (pctxt); if (0 == pXmlReader) return LOG_RTERR (pctxt, RTERR_NOTINIT); if (level == -1) level = pXmlReader->mDecodeLevel; curLevel = rtXmlpGetCurrentLevel (pctxt); if (curLevel < level) { return XML_OK_EOB; } event = rtXmlRdGetLastEvent (pXmlReader); if (event.mId == OSXMLEVT_END_TAG) { if (event.mLevel == level) { return XML_OK_EOB; } } do { if (event.mId != OSXMLEVT_START_TAG) { stat = rtXmlRdNextEvent (pXmlReader, OSXMLEVT_START_TAG | OSXMLEVT_END_TAG, level, &event); if (stat < 0) return LOG_RTERR (pctxt, stat); } if (event.mId == OSXMLEVT_END_TAG) { if (event.mLevel == level) { return XML_OK_EOB; } } if (event.mId == OSXMLEVT_START_TAG) { if (event.mLevel != level + 1) { rtXmlRdGetTagName (pXmlReader, &localName, 0); rtxErrAddStrnParm (pctxt, (const char*)localName.value, localName.length); rtXmlRdErrAddSrcPos (pXmlReader, FALSE); return LOG_RTERRNEW (pctxt, XML_E_UNEXPSTARTTAG); } } else { rtXmlRdGetTagName (pXmlReader, &localName, 0); rtxErrAddStrnParm (pctxt, (const char*)localName.value, localName.length); rtXmlRdErrAddSrcPos (pXmlReader, FALSE); return LOG_RTERRNEW (pctxt, XML_E_UNEXPENDTAG); } rtXmlRdGetTagName (pXmlReader, &localName, &nsIndex); #ifdef XMLPTRACE RTDIAG4 (pctxt, "rtXmlpGetNextElemID: localName = '%-*.*s'\n", localName.length, localName.length, localName.value); #endif /* first pass: check named elements */ for (i = 0; i < nrows; i++) { if (tab[i].descr.localName.length == 0) continue; /* nsidx == -1 - check element name only */ /*??? relax namespace index check for local elements */ /*if ((tab[i].descr.nsidx == -1 || nsIndex == tab[i].descr.nsidx) && */ if ((tab[i].descr.nsidx == -1 || nsIndex == tab[i].descr.nsidx || tab[i].descr.nsidx == 0) && (tab[i].descr.localName.length == 0 || OSXMLFRAGSEQUAL (localName, tab[i].descr.localName))) { rtXmlRdMarkLastEventDone (pXmlReader); #ifndef _COMPACT /* Add name to element name stack in context */ rtxDListAppend (pctxt, &pctxt->elemNameStack, (void*)tab[i].descr.localName.value); #endif return tab[i].id; } } /* second pass: check any elements by namespace */ for (i = 0; i < nrows; i++) { OSBOOL found; if (tab[i].descr.localName.length != 0) continue; /* ##other - length == 0 and localName is not empty */ found = FALSE; if (tab[i].descr.localName.value && tab[i].descr.localName.value[0] != 0) { /* ##other */ if (nsIndex != 0 && nsIndex != tab[i].descr.nsidx) found = TRUE; } else if (nsIndex == tab[i].descr.nsidx) { found = TRUE; } if (found) { rtXmlRdMarkLastEventDone (pXmlReader); #ifndef _COMPACT /* Add name to element name stack in context */ rtxDListAppend (pctxt, &pctxt->elemNameStack, "*"); #endif return tab[i].id; } } /* not found! skip whole level and log warning here */ if (continueParse) { rtxErrAddStrnParm (pctxt, (const char*)localName.value, localName.length); rtXmlRdErrAddSrcPos (pXmlReader, FALSE); LOG_RTERRNEW (pctxt, RTERR_UNEXPELEM); stat = rtXmlRdSkipCurrentLevel (pXmlReader); event = rtXmlRdGetLastEvent (pXmlReader); } else { stat = RTERR_UNEXPELEM; #ifndef _COMPACT /* Add dummy name to element name stack in context */ rtxDListAppend (pctxt, &pctxt->elemNameStack, (void*)"<unknown>"); #endif } } while (stat == 0); return stat; }