当前位置: 首页>>代码示例>>C++>>正文


C++ xml_free函数代码示例

本文整理汇总了C++中xml_free函数的典型用法代码示例。如果您正苦于以下问题:C++ xml_free函数的具体用法?C++ xml_free怎么用?C++ xml_free使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了xml_free函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: loadenv

/*
 * load environment variable
 */
bool_t loadenv(char * file)
{
	struct xml * root, * env;

	root = xml_parse_file(file);
	if(!root || !root->name)
		return FALSE;

	if(strcmp(root->name, "environment") != 0)
	{
		xml_free(root);
		return FALSE;
	}

	clearenv();

	for(env = xml_child(root, "env"); env; env = env->next)
	{
		if(env->txt)
			putenv(env->txt);
	}

	xml_free(root);
	return TRUE;
}
开发者ID:rharter,项目名称:xboot-clone,代码行数:28,代码来源:environ.c

示例2: fprintf

xml_node *xml_parse( const char *filename ) {
	int done = 0;
	FILE *xptr;
	XML_Parser p;
	static char buf[BUFSIZE];
	xml_node root, *ret;

	if( (xptr = fopen( filename, "r" )) == NULL ) {
		fprintf( stderr, "Unable to open file: %s\n", filename );
		return NULL;
	}

	root.child = NULL;
	if( (ret = xml_alloc(&root)) == NULL ) {
		fclose( xptr );
		fprintf( stderr, "Out of memory\n" );
		return NULL;
	}

	if( (p = XML_ParserCreate( NULL )) == NULL ) {
		fclose( xptr );
		fprintf( stderr, "Out of memory\n" );
		return NULL;
	}

	XML_SetUserData( p, &ret );
	XML_SetElementHandler( p, xml_el_start, xml_el_end );
	XML_SetCharacterDataHandler( p, xml_charhndl );

	while( !done ) {
		int len;

		len = fread( buf, 1, BUFSIZE, xptr );
		if( ferror( xptr ) ) {
			fprintf( stderr, "Read error\n" );
			xml_free( ret );
			ret = NULL;
			break;
		}
		done = feof( xptr );

		if( XML_Parse(p, buf, len, done) == 0 ) {
			fprintf( stderr, "Parse error at line %d:\n%s\n",
							 (int) XML_GetCurrentLineNumber(p),
							 XML_ErrorString( XML_GetErrorCode(p) ) );
			xml_free( ret );
			ret = NULL;
			break;
		}
	}

	if( ret != NULL )
		ret->parent = NULL;

	fclose( xptr );
	XML_ParserFree( p );
	return ret;
}
开发者ID:elementalvoid,项目名称:captagent,代码行数:58,代码来源:xmlread.c

示例3: xml_free

/* free a previously allocated XmlNode */
void xml_free(XmlNode *target)
{
	int i;
	for(i=0; i<target->nattrib*2; i++)
		if(target->attrib[i])
			free(target->attrib[i]);

	if(target->attrib)free(target->attrib);
	if(target->child)xml_free(target->child);
	if(target->next)xml_free(target->next);
	free(target->name);
	free(target);
}
开发者ID:atbrox,项目名称:ccan,代码行数:14,代码来源:ttxml.c

示例4: clicon_rpc_create_subscription

/*! Create a new notification subscription
 * @param[in]   h        Clicon handle
 * @param{in]   stream   name of notificatio/log stream (CLICON is predefined)
 * @param{in]   filter   message filter, eg xpath for xml notifications
 * @param[out]  s0       socket returned where notification mesages will appear
 * @retval      0        OK
 * @retval      -1       Error and logged to syslog

 * @note When using netconf create-subsrciption,status and format is not supported
 */
int
clicon_rpc_create_subscription(clicon_handle    h,
			       char            *stream, 
			       char            *filter, 
			       int             *s0)
{
    int                retval = -1;
    struct clicon_msg *msg = NULL;
    cxobj             *xret = NULL;
    cxobj             *xerr;
    char              *username;

    username = clicon_username_get(h);
    if ((msg = clicon_msg_encode("<rpc username=\"%s\"><create-subscription xmlns=\"urn:ietf:params:xml:ns:netmod:notification\">"
				 "<stream>%s</stream>"
				 "<filter type=\"xpath\" select=\"%s\" />"
				 "</create-subscription></rpc>", 
				 username?username:"",
				 stream?stream:"", filter?filter:"")) == NULL)
	goto done;
    if (clicon_rpc_msg(h, msg, &xret, s0) < 0)
	goto done;
    if ((xerr = xpath_first(xret, "//rpc-error")) != NULL){
	clicon_rpc_generate_error("Create subscription", xerr);
	goto done;
    }
    retval = 0;
  done:
    if (xret)
	xml_free(xret);
    if (msg)
	free(msg);
    return retval;
}
开发者ID:clicon,项目名称:clixon,代码行数:44,代码来源:clixon_proto_client.c

示例5: clicon_rpc_debug

/*! Send a debug request to backend server
 * @param[in] h        CLICON handle
 * @param[in] level    Debug level
 * @retval    0        OK
 * @retval   -1        Error and logged to syslog
 */
int
clicon_rpc_debug(clicon_handle h, 
		int           level)
{
    int                retval = -1;
    struct clicon_msg *msg = NULL;
    cxobj             *xret = NULL;
    cxobj             *xerr;
    char              *username;

    username = clicon_username_get(h);
    /* XXX: hardcoded example yang, should be clixon-config!!! */
    if ((msg = clicon_msg_encode("<rpc username=\"%s\"><debug xmlns=\"http://clicon.org/lib\"><level>%d</level></debug></rpc>", username?username:"", level)) == NULL)
	goto done;
    if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
	goto done;
    if ((xerr = xpath_first(xret, "//rpc-error")) != NULL){
	clicon_rpc_generate_error("Debug",xerr);
	goto done;
    }
    if (xpath_first(xret, "//rpc-reply/ok") == NULL){
	clicon_err(OE_XML, 0, "rpc error"); /* XXX extract info from rpc-error */
	goto done;
    }
    retval = 0;
 done:
    if (msg)
	free(msg);
    if (xret)
	xml_free(xret);
    return retval;
}
开发者ID:clicon,项目名称:clixon,代码行数:38,代码来源:clixon_proto_client.c

示例6: clicon_rpc_commit

/*! Commit changes send a commit request to backend daemon
 * @param[in] h          CLICON handle
 * @retval    0        OK
 * @retval   -1        Error and logged to syslog
 */
int
clicon_rpc_commit(clicon_handle h)
{
    int                retval = -1;
    struct clicon_msg *msg = NULL;
    cxobj             *xret = NULL;
    cxobj             *xerr;
    char              *username;

    username = clicon_username_get(h);
    if ((msg = clicon_msg_encode("<rpc username=\"%s\"><commit/></rpc>", username?username:"")) == NULL)
	goto done;
    if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
	goto done;
    if ((xerr = xpath_first(xret, "//rpc-error")) != NULL){
	clicon_rpc_generate_error(CLIXON_ERRSTR_COMMIT_FAILED, xerr);
	goto done;
    }
    retval = 0;
 done:
    if (xret)
	xml_free(xret);
    if (msg)
	free(msg);
    return retval;
}
开发者ID:clicon,项目名称:clixon,代码行数:31,代码来源:clixon_proto_client.c

示例7: clicon_rpc_discard_changes

/*! Discard all changes in candidate / revert to running
 * @param[in] h        CLICON handle
 * @retval    0        OK
 * @retval   -1        Error and logged to syslog
 */
int
clicon_rpc_discard_changes(clicon_handle h)
{
    int                retval = -1;
    struct clicon_msg *msg = NULL;
    cxobj             *xret = NULL;
    cxobj             *xerr;
    char              *username;

    username = clicon_username_get(h);
    if ((msg = clicon_msg_encode("<rpc username=\"%s\"><discard-changes/></rpc>", username?username:"")) == NULL)
	goto done;
    if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
	goto done;
    if ((xerr = xpath_first(xret, "//rpc-error")) != NULL){
	clicon_rpc_generate_error("Discard changes", xerr);
	goto done;
    }
    retval = 0;
 done:
    if (xret)
	xml_free(xret);
    if (msg)
	free(msg);
    return retval;
}
开发者ID:clicon,项目名称:clixon,代码行数:31,代码来源:clixon_proto_client.c

示例8: clicon_rpc_kill_session

/*! Kill other user sessions
 * @param[in] h           CLICON handle
 * @param[in] session_id  Session id of other user session
 * @retval    0        OK
 * @retval   -1        Error and logged to syslog
 */
int
clicon_rpc_kill_session(clicon_handle h,
			int           session_id)
{
    int                retval = -1;
    struct clicon_msg *msg = NULL;
    cxobj             *xret = NULL;
    cxobj             *xerr;
    char              *username;

    username = clicon_username_get(h);
    if ((msg = clicon_msg_encode("<rpc username=\"%s\"><kill-session><session-id>%d</session-id></kill-session></rpc>",
				 username?username:"", session_id)) == NULL)
	goto done;
    if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
	goto done;
    if ((xerr = xpath_first(xret, "//rpc-error")) != NULL){
	clicon_rpc_generate_error("Kill session", xerr);
	goto done;
    }
    retval = 0;
 done:
    if (xret)
	xml_free(xret);
    if (msg)
	free(msg);
    return retval;
}
开发者ID:clicon,项目名称:clixon,代码行数:34,代码来源:clixon_proto_client.c

示例9: clicon_rpc_validate

/*! Send validate request to backend daemon
 * @param[in] h        CLICON handle
 * @param[in] db       Name of database
 * @retval    0        OK
 * @retval   -1        Error and logged to syslog
 */
int
clicon_rpc_validate(clicon_handle h, 
		    char         *db)
{
    int                retval = -1;
    struct clicon_msg *msg = NULL;
    cxobj             *xret = NULL;
    cxobj             *xerr;
    char              *username;

    username = clicon_username_get(h);
    if ((msg = clicon_msg_encode("<rpc username=\"%s\"><validate><source><%s/></source></validate></rpc>", username?username:"", db)) == NULL)
	goto done;
    if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
	goto done;
    if ((xerr = xpath_first(xret, "//rpc-error")) != NULL){
	clicon_rpc_generate_error(CLIXON_ERRSTR_VALIDATE_FAILED, xerr);
	goto done;	
    }
    retval = 0;
 done:
    if (msg)
	free(msg);
    if (xret)
	xml_free(xret);
    return retval;
}
开发者ID:clicon,项目名称:clixon,代码行数:33,代码来源:clixon_proto_client.c

示例10: clicon_rpc_unlock

/*! Unlock a database
 * @param[in] h        CLICON handle
 * @param[in] db       database, eg "running"
 * @retval    0        OK
 * @retval   -1        Error and logged to syslog
 */
int
clicon_rpc_unlock(clicon_handle h, 
		  char         *db)
{
    int                retval = -1;
    struct clicon_msg *msg = NULL;
    cxobj             *xret = NULL;
    cxobj             *xerr;
    char              *username;

    username = clicon_username_get(h);
    if ((msg = clicon_msg_encode("<rpc username=\"%s\"><unlock><target><%s/></target></unlock></rpc>", username?username:"", db)) == NULL)
	goto done;
    if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
	goto done;
    if ((xerr = xpath_first(xret, "//rpc-error")) != NULL){
	clicon_rpc_generate_error("Configuration unlock", xerr);
	goto done;
    }
    retval = 0;
 done:
    if (xret)
	xml_free(xret);
    if (msg)
	free(msg);
    return retval;
}
开发者ID:clicon,项目名称:clixon,代码行数:33,代码来源:clixon_proto_client.c

示例11: clicon_rpc_delete_config

/*! Send a request to backend to delete a config database
 * @param[in] h        CLICON handle
 * @param[in] db       database, eg "running"
 * @retval    0        OK
 * @retval   -1        Error and logged to syslog
 * @code
 * if (clicon_rpc_delete_config(h, "startup") < 0)
 *    err;
 * @endcode
 */
int
clicon_rpc_delete_config(clicon_handle h, 
			 char         *db)
{
    int                retval = -1;
    struct clicon_msg *msg = NULL;
    cxobj             *xret = NULL;
    cxobj             *xerr;
    char              *username;

    username = clicon_username_get(h);
    if ((msg = clicon_msg_encode("<rpc username=\"%s\"><edit-config><target><%s/></target><default-operation>none</default-operation><config operation=\"delete\"/></edit-config></rpc>",
				 username?username:"", db)) == NULL)
	goto done;
    if (clicon_rpc_msg(h, msg, &xret, NULL) < 0)
	goto done;
    if ((xerr = xpath_first(xret, "//rpc-error")) != NULL){
	clicon_rpc_generate_error("Deleting configuration", xerr);
	goto done;
    }
    retval = 0;
 done:
    if (xret)
	xml_free(xret);
    if (msg)
	free(msg);
    return retval;
}
开发者ID:clicon,项目名称:clixon,代码行数:38,代码来源:clixon_proto_client.c

示例12: free_switches_structure

MODULE free_switches_structure (void)
{
    if (xml_switches)
        xml_free (xml_switches);

    xml_switches = NULL;
}
开发者ID:tempbottle,项目名称:openamq,代码行数:7,代码来源:gslgen.c

示例13: xml_el_start

void xml_el_start( void *data, const char *name, const char **attr ) {
	int i, nattr = 1;
	xml_node *node = xml_alloc( *((xml_node **) data) );

	if( node == NULL ) {
		fprintf( stderr, "Out of memory\n" );
		return;
	}

	node->key = strdup( name );

	for( i=0;attr[i];i++ )
		nattr++;

	if( (node->attr = (char **) malloc( sizeof( char * ) *nattr )) == NULL ) {
		fprintf( stderr, "Out of memory\n" );
		xml_free( node );
		return;
	}

	for( i=0;attr[i];i++ ) {
		node->attr[i] = strdup( attr[i] );
		//printf("ATTR: %s\n", attr[i]);
        }

	node->attr[i] = NULL;
		

	*((xml_node **) data) = node;
}
开发者ID:elementalvoid,项目名称:captagent,代码行数:30,代码来源:xmlread.c

示例14: fopen

char *test_read_input()
{
        FILE *f;

        /* open, read and parse some invalid xml */
        f = fopen("test.invalid.xml", "r");
        mu_assert("read invalid xml", read_input(f) == 0);
        fclose(f);
        mu_assert("parse invalid xml", xml_parse(buf) == XML_STATUS_INVALID);

        /* open, read and parse some valid xml */
        f = fopen("test.xml", "r");
        mu_assert("read valid xml", read_input(f) == 0);
        fclose(f);
        mu_assert("buffer contains request", strncmp(buf,"<request>", 9) == 0);
        mu_assert("parse some valid xml", xml_parse(buf) == XML_STATUS_OK);

        /* fetch value of an element */
        char *value = xml_element("//username");
        mu_assert("perform xpath search for element", value != NULL);
        mu_assert("get value of xml element", strcmp(value, "iamauser") == 0);
        xml_free(value);

        xml_cleanup();

        return 0;
}
开发者ID:brettsheffield,项目名称:gladd,代码行数:27,代码来源:tests.c

示例15: prepare_xml_file

void
prepare_xml_file (char *filename)
{
    int
    rc;

    rc = xml_load_file (& xml_root, PATH, filename, FALSE);
    if (rc == XML_NOERROR)
    {
        xml_source = xml_first_child (xml_root);
        if (xml_source)
        {
            xml_put_attr (xml_switches, "filename", filename);
            xml_put_attr (xml_switches, "template", "1");
        }
        else
            xml_free (xml_root);
    }
    else
    {
        coprintf ("%s E: Error processing %s...", me, filename);
        coprintf (xml_error ());
        raise_exception (anomaly_event);
    }
}
开发者ID:tempbottle,项目名称:openamq,代码行数:25,代码来源:gslgen.c


注:本文中的xml_free函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。