/** * xmlSecNodeSetAddList: * @nset: the pointer to currrent nodes set (or NULL). * @newNSet: the pointer to new nodes set. * @op: the operation type. * * Adds @newNSet to the @nset as child using operation @op. * * Returns the pointer to combined nodes set or NULL if an error * occurs. */ EXPORT_C xmlSecNodeSetPtr xmlSecNodeSetAddList(xmlSecNodeSetPtr nset, xmlSecNodeSetPtr newNSet, xmlSecNodeSetOp op) { xmlSecNodeSetPtr tmp1, tmp2; xmlSecAssert2(newNSet != NULL, NULL); tmp1 = xmlSecNodeSetCreate(newNSet->doc, NULL, xmlSecNodeSetList); if(tmp1 == NULL) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecNodeSetCreate", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); return(NULL); } tmp1->children = newNSet; tmp2 = xmlSecNodeSetAdd(nset, tmp1, op); if(tmp2 == NULL) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecNodeSetAdd", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); xmlSecNodeSetDestroy(tmp1); return(NULL); } return(tmp2); }
static xmlSecNodeSetPtr xmlSecXPathDataListExecute(xmlSecPtrListPtr dataList, xmlDocPtr doc, xmlNodePtr hereNode, xmlSecNodeSetPtr nodes) { xmlSecXPathDataPtr data; xmlSecNodeSetPtr res, tmp, tmp2; xmlSecSize pos; xmlSecAssert2(xmlSecPtrListCheckId(dataList, xmlSecXPathDataListId), NULL); xmlSecAssert2(xmlSecPtrListGetSize(dataList) > 0, NULL); xmlSecAssert2(doc != NULL, NULL); xmlSecAssert2(hereNode != NULL, NULL); res = nodes; for(pos = 0; pos < xmlSecPtrListGetSize(dataList); ++pos) { data = (xmlSecXPathDataPtr)xmlSecPtrListGetItem(dataList, pos); if(data == NULL) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecPtrListGetItem", XMLSEC_ERRORS_R_XMLSEC_FAILED, "pos=%d", pos); if((res != NULL) && (res != nodes)) { xmlSecNodeSetDestroy(res); } return(NULL); } tmp = xmlSecXPathDataExecute(data, doc, hereNode); if(tmp == NULL) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecXPathDataExecute", XMLSEC_ERRORS_R_XMLSEC_FAILED, XMLSEC_ERRORS_NO_MESSAGE); if((res != NULL) && (res != nodes)) { xmlSecNodeSetDestroy(res); } return(NULL); } tmp2 = xmlSecNodeSetAdd(res, tmp, data->nodeSetOp); if(tmp2 == NULL) { xmlSecError(XMLSEC_ERRORS_HERE, NULL, "xmlSecNodeSetAdd", XMLSEC_ERRORS_R_XMLSEC_FAILED, "xmlSecNodeSetIntersection"); if((res != NULL) && (res != nodes)) { xmlSecNodeSetDestroy(res); } xmlSecNodeSetDestroy(tmp); return(NULL); } res = tmp2; } return(res); }
static xmlSecNodeSetPtr xmlSecXPathDataListExecute(xmlSecPtrListPtr dataList, xmlDocPtr doc, xmlNodePtr hereNode, xmlSecNodeSetPtr nodes) { xmlSecXPathDataPtr data; xmlSecNodeSetPtr res, tmp, tmp2; xmlSecSize pos; xmlSecAssert2(xmlSecPtrListCheckId(dataList, xmlSecXPathDataListId), NULL); xmlSecAssert2(xmlSecPtrListGetSize(dataList) > 0, NULL); xmlSecAssert2(doc != NULL, NULL); xmlSecAssert2(hereNode != NULL, NULL); res = nodes; for(pos = 0; pos < xmlSecPtrListGetSize(dataList); ++pos) { data = (xmlSecXPathDataPtr)xmlSecPtrListGetItem(dataList, pos); if(data == NULL) { xmlSecInternalError2("xmlSecPtrListGetItem", NULL, "pos=%d", pos); if((res != NULL) && (res != nodes)) { xmlSecNodeSetDestroy(res); } return(NULL); } tmp = xmlSecXPathDataExecute(data, doc, hereNode); if(tmp == NULL) { xmlSecInternalError("xmlSecXPathDataExecute", NULL); if((res != NULL) && (res != nodes)) { xmlSecNodeSetDestroy(res); } return(NULL); } tmp2 = xmlSecNodeSetAdd(res, tmp, data->nodeSetOp); if(tmp2 == NULL) { xmlSecInternalError2("xmlSecNodeSetAdd", NULL, "nodeSetOp=%d", (int)data->nodeSetOp); if((res != NULL) && (res != nodes)) { xmlSecNodeSetDestroy(res); } xmlSecNodeSetDestroy(tmp); return(NULL); } res = tmp2; } return(res); }
PyObject *xmlsec_NodeSetAdd(PyObject *self, PyObject *args) { PyObject *nset_obj, *newNSet_obj; xmlSecNodeSetPtr nset; xmlSecNodeSetPtr newNSet; xmlSecNodeSetOp op; if (CheckArgs(args, "OOI:nodeSetAdd")) { if (!PyArg_ParseTuple(args, "OOi:nodeSetAdd", &nset_obj, &newNSet_obj, &op)) return NULL; } else return NULL; nset = xmlSecNodeSetPtr_get(nset_obj); newNSet = xmlSecNodeSetPtr_get(newNSet_obj); return (wrap_xmlSecNodeSetPtr(xmlSecNodeSetAdd(nset, newNSet, op))); }