コード例 #1
0
ファイル: ext_xmlreader.cpp プロジェクト: bjori/hhvm
Variant HHVM_METHOD(XMLReader, getAttributeNs,
                    const String& name,
                    const String& namespaceURI) {
  auto* data = Native::data<XMLReader>(this_);
  SYNC_VM_REGS_SCOPED();
  if (name.empty() || namespaceURI.empty()) {
    raise_warning("Attribute Name and Namespace URI cannot be empty");
    return false;
  }

  char *retchar = nullptr;
  if (data->m_ptr) {
    retchar = (char *)xmlTextReaderGetAttributeNs(data->m_ptr,
                                                  (xmlChar *)name.data(),
                                                  (xmlChar *)namespaceURI.data());
  }

  if (retchar) {
    String ret((const char*)retchar, CopyString);
    xmlFree(retchar);
    return ret;
  } else {
    return init_null();
  }
}
コード例 #2
0
ファイル: php_xmlreader.c プロジェクト: LTD-Beget/php-src
/* {{{ proto string XMLReader::getAttributeNs(string name, string namespaceURI)
Get value of a attribute via name and namespace from current element */
PHP_METHOD(xmlreader, getAttributeNs)
{
	zval *id;
	size_t name_len = 0, ns_uri_len = 0;
	xmlreader_object *intern;
	char *name, *ns_uri, *retchar = NULL;

	if (zend_parse_parameters(ZEND_NUM_ARGS(), "ss", &name, &name_len, &ns_uri, &ns_uri_len) == FAILURE) {
		return;
	}

	if (name_len == 0 || ns_uri_len == 0) {
		php_error_docref(NULL, E_WARNING, "Attribute Name and Namespace URI cannot be empty");
		RETURN_FALSE;
	}

	id = getThis();

	intern = Z_XMLREADER_P(id);
	if (intern && intern->ptr) {
		retchar = (char *)xmlTextReaderGetAttributeNs(intern->ptr, (xmlChar *)name, (xmlChar *)ns_uri);
	}
	if (retchar) {
		RETVAL_STRING(retchar);
		xmlFree(retchar);
	}
}
コード例 #3
0
ファイル: xmlreader.c プロジェクト: matsuu/konoha
/* @method String XmlReader.getAttributeNs(String ns, String name) */
METHOD XmlReader_getAttributeNs(Ctx *ctx, knh_sfp_t *sfp)
{
    xmlTextReaderPtr reader = (xmlTextReaderPtr) p_cptr(sfp[0]);
    xmlChar* ns   = (xmlChar*) p_char(sfp[1]);
    xmlChar* name = (xmlChar*) p_char(sfp[2]);
    char* ret = (char*) xmlTextReaderGetAttributeNs(reader,ns,name);
    KNH_RETURN(ctx,sfp,new_String(ctx,B(ret),NULL));
}
コード例 #4
0
ファイル: xml_glue.c プロジェクト: Kouhei-Moriya/konoha3
//## @Native String XmlReader.getAttributeNs(String ns, String name);
static KMETHOD XmlReader_getAttributeNs(KonohaContext *kctx, KonohaStack *sfp)
{
	xmlTextReaderPtr reader = getRawXmlReader(sfp[0]);
	xmlChar* ns = (xmlChar *)kString_text(sfp[1].asString);
	xmlChar* name = (xmlChar *)kString_text(sfp[2].asString);
	char* ret = (reader != NULL) ? (char *) xmlTextReaderGetAttributeNs(reader,ns,name) : NULL;
	KReturn(KLIB new_kString(kctx, GcUnsafe, ret, strlen(ret), 0));
}
コード例 #5
0
ファイル: oval_entity.c プロジェクト: swizzley/openscap
//typedef void (*oval_entity_consumer)(struct oval_entity_node*, void*);
int oval_entity_parse_tag(xmlTextReaderPtr reader,
			  struct oval_parser_context *context, oscap_consumer_func consumer, void *user)
{
	__attribute__nonnull__(context);

	struct oval_entity *entity = oval_entity_new(context->definition_model);
	int return_code = 0;
	oval_datatype_t datatype = oval_datatype_parse(reader, "datatype", OVAL_DATATYPE_STRING);
	oval_operation_t operation = oval_operation_parse(reader, "operation", OVAL_OPERATION_EQUALS);
	int mask = oval_parser_boolean_attribute(reader, "mask", 0);

	char *nil_attr = (char *) xmlTextReaderGetAttributeNs(reader, BAD_CAST "nil", OSCAP_XMLNS_XSI);
	int xsi_nil = oscap_streq(nil_attr, "true") != 0;
	xmlFree(nil_attr);

	oval_entity_type_t type = OVAL_ENTITY_TYPE_UNKNOWN;
	//The value of the type field vs. the complexity of extracting type is arguable
	char *varref = (char *)xmlTextReaderGetAttribute(reader, BAD_CAST "var_ref");
	struct oval_value *value = NULL;
	struct oval_variable *variable;
	char *name = (char *)xmlTextReaderLocalName(reader);
	oval_entity_varref_type_t varref_type;
	if (strcmp(name, "var_ref") == 0) {	//special case for <var_ref>
		if (varref == NULL) {
			struct oval_definition_model *model = context->definition_model;
			varref_type = OVAL_ENTITY_VARREF_ELEMENT;
			struct oval_consume_varref_context ctx = {.model = model, .variable = &variable, .value = &value};
			return_code = oscap_parser_text_value(reader, &oval_consume_varref, &ctx);
		} else {
			varref_type = OVAL_ENTITY_VARREF_ATTRIBUTE;
			struct oval_definition_model *model = context->definition_model;
			oval_schema_version_t version = oval_definition_model_get_core_schema_version(model);
			if (oval_schema_version_cmp(version, OVAL_SCHEMA_VERSION(5.6)) > 0) {
				oscap_seterr(OSCAP_EFAMILY_OVAL, "The var_ref attribute for the var_ref entity "
						"of a variable_object is prohibited since OVAL 5.6. Use plain "
						"var_ref instead.");
			}
			variable = oval_definition_model_get_variable(model, varref);
			if (variable == NULL) {
				oscap_seterr(OSCAP_EFAMILY_OVAL,
						"Could not found variable '%s' referenced by var_ref element.", varref);
				return_code = 1;
			} else {
				oscap_free(varref);
				varref = NULL;
				value = NULL;
			}
		}
	} else if (varref == NULL) {
コード例 #6
0
ファイル: xmlreader.c プロジェクト: anhk/lua-xmlreader
/* reader:get_attribute_ns(nsuri) */
static int xmlreader_get_attribute_ns(lua_State *L)
{
  xmlreader xr = check_xmlreader(L, 1);
  const xmlChar *localname = (xmlChar*)luaL_checkstring(L, 2);
  const xmlChar *namespaceuri = (xmlChar*)luaL_checkstring(L, 3);

  char *attr = (char*)xmlTextReaderGetAttributeNs(xr, localname, namespaceuri);
  if (attr) {
    lua_pushstring(L, attr);
    xmlFree(attr);
    return 1;
  } else {
    lua_pushnil(L);
    xmlreader_pusherror(L);
    return 2;
  }
}
コード例 #7
0
ファイル: ext_xmlreader.cpp プロジェクト: Alienfeel/hhvm
Variant c_XMLReader::t_getattributens(const String& name, const String& namespaceURI) {
  if (name.empty() || namespaceURI.empty()) {
    raise_warning("Attribute Name and Namespace URI cannot be empty");
    return false;
  }

  char *retchar = NULL;
  if (m_ptr) {
    retchar = (char *)xmlTextReaderGetAttributeNs(m_ptr,
                                                  (xmlChar *)name.data(),
                                                  (xmlChar *)namespaceURI.data());
  }

  if (retchar) {
    String ret((const char*)retchar, CopyString);
    xmlFree(retchar);
    return ret;
  } else {
    return uninit_null();
  }
}
コード例 #8
0
String c_XMLReader::t_getattributens(CStrRef name, CStrRef namespaceURI) {
  INSTANCE_METHOD_INJECTION_BUILTIN(XMLReader, XMLReader::getattributens);
  if (name.empty() || namespaceURI.empty()) {
    raise_warning("Attribute Name and Namespace URI cannot be empty");
    return false;
  }

  char *retchar = NULL;
  if (m_ptr) {
    retchar = (char *)xmlTextReaderGetAttributeNs(m_ptr,
                                                  (xmlChar *)name.data(),
                                                  (xmlChar *)namespaceURI.data());
  }

  if (retchar) {
    String ret((const char*)retchar, CopyString);
    xmlFree(retchar);
    return ret;
  } else {
    return String("");
  }
}