Exemplo n.º 1
0
bool __xmlcontext::set_attr(const char *name, const char *value)
{
	return xml_set_attr(xml_node_, name, value);
}
Exemplo n.º 2
0
bool_t console_stdio_save(char * file)
{
	struct xml * root;
	struct xml * in, * out, * err;
	char * str;
	s32_t fd;

	root = xml_new("console");
	if(!root)
		return FALSE;

	in = xml_add_child(root, "stdin", 0);
	if(!in)
	{
		xml_free(root);
		return FALSE;
	}

	if(console_stdin && console_stdin->name)
		xml_set_attr(in, "name", console_stdin->name);

	out = xml_add_child(root, "stdout", 1);
	if(!out)
	{
		xml_free(root);
		return FALSE;
	}

	if(console_stdout && console_stdout->name)
		xml_set_attr(out, "name", console_stdout->name);

	err = xml_add_child(root, "stderr", 1);
	if(!err)
	{
		xml_free(root);
		return FALSE;
	}

	if(console_stderr && console_stderr->name)
		xml_set_attr(err, "name", console_stderr->name);

	str = xml_toxml(root);
	if(!str)
	{
		xml_free(root);
		return FALSE;
	}

	fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH));
	if(fd < 0)
	{
		free(str);
		xml_free(root);
		return FALSE;
	}

	write(fd, str, strlen((const char *)str));
	close(fd);

	free(str);
	xml_free(root);

	return TRUE;
}