Exemple #1
0
int userdiff_config(const char *k, const char *v)
{
	struct userdiff_driver *drv;

	if ((drv = parse_driver(k, v, "funcname")))
		return parse_funcname(&drv->funcname, k, v, 0);
	if ((drv = parse_driver(k, v, "xfuncname")))
		return parse_funcname(&drv->funcname, k, v, REG_EXTENDED);
	if ((drv = parse_driver(k, v, "binary")))
		return parse_tristate(&drv->binary, k, v);
	if ((drv = parse_driver(k, v, "command")))
		return parse_string(&drv->external, k, v);
	if ((drv = parse_driver(k, v, "textconv")))
		return parse_string(&drv->textconv, k, v);

	return 0;
}
Exemple #2
0
int parse_manifest(plugin_manifest_t m, xmlNode * root, iconv_t conv)
{
	int rv;
	xmlAttr * attr;
	xmlNode * cur;

	/* Initialize Version Information */
	m->plugin_info.plugin_major_version = 0;
	m->plugin_info.plugin_minor_version = 0;
	m->plugin_info.plugin_patch_version = 0;

	/* Parse Attributes */
	for (attr = root->properties ; attr ; attr = attr->next)
	{
		if (xmlStrcmp(attr->name, BAD_CAST("name")) == 0)
		{
			m->plugin_name = conv_xmlstr(attr->children->content, conv);
		}
		else if (xmlStrcmp(attr->name, BAD_CAST("library")) == 0)
		{
			m->plugin_library = conv_xmlstr(attr->children->content, conv);
		}
		else if (xmlStrcmp(attr->name, BAD_CAST("version")) == 0)
		{
			std::string verstr = conv_xmlstr(attr->children->content, conv);

			rv = sscanf(verstr.c_str(), "%hhu.%hhu.%hhu",
				& m->plugin_info.plugin_major_version,
				& m->plugin_info.plugin_minor_version,
				& m->plugin_info.plugin_patch_version);

			if (rv < 0)
			{
				g_parser_errmsg = "Invalid version string: '" + verstr + "'";
				return MANIFEST_ERR_PARSER;
			}
		}
		else
		{
			g_parser_errmsg = "Unsupported Attribute: '" + conv_xmlstr(attr->name, conv) + "' within <plugin>";
			return MANIFEST_ERR_PARSER;
		}
	}

	/* Check Name and Library */
	if (m->plugin_name.empty())
		return MANIFEST_ERR_NONAME;
	if (m->plugin_library.empty())
		return MANIFEST_ERR_NOLIB;

	/* Parse Drivers */
	for (cur = root->children ; cur ; cur = cur->next)
	{
		if (cur->type != XML_ELEMENT_NODE)
			continue;

		if (xmlStrcmp(cur->name, BAD_CAST("driver")) == 0)
		{
			rv = parse_driver(m, cur, conv);
			if (rv != 0)
				return rv;
		}
		else
		{
			g_parser_errmsg = "Unsupported node <" + conv_xmlstr(cur->name, conv) + "> within <plugin>";
			return MANIFEST_ERR_PARSER;
		}
	}

	/* Setup String Pointers */
	setup_pointers(m);

	/* Success */
	return 0;
}