您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ xmlNewNode函数代码示例

51自学网 2021-06-03 11:46:12
  C++
这篇教程C++ xmlNewNode函数代码示例写得很实用,希望能帮到您。

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

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

示例1: xupl_parse

//.........这里部分代码省略.........						if (tkndx >= 1) p = tk[tkndx - 1];						unsigned char* m = NULL;						unsigned int tklen = tkndx + 1;						unsigned char* t = tk;						IF(COMMENT) {							if ('/n' == c && IS(LINE_COMMENT)) {								if (tkndx + 1 < tksize) {									tk[tkndx++] = ' ';									tk[tkndx] = 0;								}							} else if ('*' == p && '/' == c && IS(MULTI_COMMENT)) {								tk[tkndx - 1] = 0;							} else break;							DISABLE(COMMENT);							m = tk + 2;						} else if ('/' == p && '*' == c) {							ALLOW(MULTI_COMMENT);							break;						// Single-line comments can be #! #* #/ ##						} else if ('#' == p && ('!' == c || '*' == c || '/' == c || '#' == c)) {							ALLOW(LINE_COMMENT);							break;						// If these characters were in the token and not part of a comment,						// then continue as if they are normal characters of a token.						} else if ('!' == c || '/' == c || '*' == c || '#' == c) break;						if (!xc) {							if (m) {								xroot = xmlNewDocComment(xdoc, m);								xmlDocSetRootElement(xdoc, xroot);							} else {								xc = xmlNewNode(NULL, tk);								xmlDocSetRootElement(xdoc, xc);								if (!xroot) xroot = xc;							}						} else if (m) {							xmlAddChild(xc, xmlNewComment(m));						} else {							char *attr = NULL;							xmlAttrPtr closed = xmlHasProp(xc, xuplAttr);							switch (tk[0]) {								case '/'':								case '"':									t += 1;									xmlAddChild(xc, xmlNewText(t));									break;									// TODO make this parameterized, characters and names.								case '.': attr = "class";    break;								case '#': attr = "id";       break;								case '@': attr = "project";  break;								case '/': attr = "href";     break;								case '[': attr = "data";     break;								case '~': attr = "duration"; break;								case '=': attr = "location"; break;								case '^': attr = "at";       break;								case ':': attr = "type";     break;								case '!': attr = "priority"; break;								default:								{									regmatch_t pmatch[1];									unsigned int isword = 0 == regexec(&re_word, (char*) tk, 1, pmatch, 0);									if (closed) {										if (isword) {
开发者ID:xupl,项目名称:xupl,代码行数:67,


示例2: build_dialoginfo

str* build_dialoginfo(char *state, struct to_body *entity, struct to_body *peer,		str *callid, unsigned int initiator, str *localtag, str *remotetag){	xmlDocPtr  doc = NULL;	xmlNodePtr root_node = NULL;	xmlNodePtr dialog_node = NULL;	xmlNodePtr state_node = NULL;	xmlNodePtr remote_node = NULL;	xmlNodePtr local_node = NULL;	xmlNodePtr tag_node = NULL;	xmlNodePtr id_node = NULL;	str *body= NULL;	char buf[MAX_URI_SIZE+1];	if (entity->uri.len > MAX_URI_SIZE) {		LM_ERR("entity URI '%.*s' too long, maximum=%d/n",entity->uri.len,				entity->uri.s, MAX_URI_SIZE);		return NULL;	}    memcpy(buf, entity->uri.s, entity->uri.len);	buf[entity->uri.len]= '/0';	/* create the Publish body  */	doc = xmlNewDoc(BAD_CAST "1.0");	if(doc==0)		return NULL;    root_node = xmlNewNode(NULL, BAD_CAST "dialog-info");	if(root_node==0)		goto error;	xmlDocSetRootElement(doc, root_node);	xmlNewProp(root_node, BAD_CAST "xmlns", BAD_CAST "urn:ietf:params:xml:ns:dialog-info");	xmlNewProp(root_node, BAD_CAST  "state", BAD_CAST "partial" );	xmlNewProp(root_node, BAD_CAST "entity", BAD_CAST buf);    /* version is set by dialoginfo_process_body() */	/* RFC 3245 differs between id and call-id. For example if a call	   is forked and 2 early dialogs are established, we should send 2	    PUBLISH requests, both have the same call-id but different id.	    Thus, id could be for example derived from the totag.	    Currently the dialog module does not support multiple dialogs.	    Thus, it does no make sense to differ here between multiple dialog.	    Thus, id and call-id will be populated identically */	/* dialog tag */	dialog_node =xmlNewChild(root_node, NULL, BAD_CAST "dialog", NULL) ;	if( dialog_node ==NULL)	{		LM_ERR("while adding child/n");		goto error;	}	if (callid->len > MAX_URI_SIZE) {		LM_ERR("call-id '%.*s' too long, maximum=%d/n", callid->len, callid->s, MAX_URI_SIZE);		return NULL;	}    memcpy(buf, callid->s, callid->len);	buf[callid->len]= '/0';	xmlNewProp(dialog_node, BAD_CAST "id", BAD_CAST buf);	if (include_callid) {		xmlNewProp(dialog_node, BAD_CAST "call-id", BAD_CAST buf);	}	if (include_tags) {		if (localtag && localtag->s) {			if (localtag->len > MAX_URI_SIZE) {				LM_ERR("localtag '%.*s' too long, maximum=%d/n", localtag->len, localtag->s, MAX_URI_SIZE);				return NULL;			}		    memcpy(buf, localtag->s, localtag->len);			buf[localtag->len]= '/0';			xmlNewProp(dialog_node, BAD_CAST "local-tag", BAD_CAST buf);		}		if (remotetag && remotetag->s) {			if (remotetag->len > MAX_URI_SIZE) {				LM_ERR("remotetag '%.*s' too long, maximum=%d/n", remotetag->len, remotetag->s, MAX_URI_SIZE);				return NULL;			}		    memcpy(buf, remotetag->s, remotetag->len);			buf[remotetag->len]= '/0';			xmlNewProp(dialog_node, BAD_CAST "remote-tag", BAD_CAST buf);		}	}	if (initiator) {		xmlNewProp(dialog_node, BAD_CAST "direction", BAD_CAST "initiator");	}else {		xmlNewProp(dialog_node, BAD_CAST "direction", BAD_CAST "recipient");	}	/* state tag */	state_node = xmlNewChild(dialog_node, NULL, BAD_CAST "state", BAD_CAST state) ;	if( state_node ==NULL)	{		LM_ERR("while adding child/n");		goto error;//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:opensips,代码行数:101,


示例3: xml_result

static xmlNodePtrxml_result(freesasa_node *result,           int options){    xmlNodePtr xml_result_node = NULL, xml_structure = NULL, xml_param = NULL;    freesasa_node *child = NULL;    const freesasa_parameters *parameters;    int exclude_type = FREESASA_NODE_NONE;    assert(freesasa_node_type(result) == FREESASA_NODE_RESULT);    parameters = freesasa_node_result_parameters(result);    if (options & FREESASA_OUTPUT_STRUCTURE) exclude_type = FREESASA_NODE_CHAIN;    if (options & FREESASA_OUTPUT_CHAIN) exclude_type = FREESASA_NODE_RESIDUE;    if (options & FREESASA_OUTPUT_RESIDUE) exclude_type = FREESASA_NODE_ATOM;    xml_result_node = xmlNewNode(NULL, BAD_CAST "result");    if (xml_result_node == NULL) {        fail_msg("");        return NULL;    }    xml_param = parameters2xml(parameters);    if (xml_param == NULL) {        fail_msg("");        goto cleanup;    }    if (xmlAddChild(xml_result_node, xml_param) == NULL) {        fail_msg("");        xmlFreeNode(xml_param);        goto cleanup;    }    if (xmlNewProp(xml_result_node, BAD_CAST "classifier",                   BAD_CAST freesasa_node_classified_by(result)) == NULL) {        fail_msg("");        goto cleanup;    }    if (xmlNewProp(xml_result_node, BAD_CAST "input",                   BAD_CAST freesasa_node_name(result)) == NULL) {        fail_msg("");        goto cleanup;    }    child = freesasa_node_children(result);    assert(child);    while(child) {        if (node2xml(&xml_structure, child, exclude_type, options) == FREESASA_FAIL) {            fail_msg("");            goto cleanup;        }        if (xmlAddChild(xml_result_node, xml_structure) == NULL) {            fail_msg("");            goto cleanup;        }        child = freesasa_node_next(child);    };    return xml_result_node; cleanup:    xmlFreeNode(xml_structure);    xmlFreeNode(xml_result_node);    return NULL;}
开发者ID:mittinatten,项目名称:freesasa,代码行数:68,


示例4: main

intmain (G_GNUC_UNUSED int argc, G_GNUC_UNUSED char** argv){        xmlDocPtr doc;        xmlNodePtr node;        gchar *fname;	xmlNodePtr out_top_node;	xmlBufferPtr buf;        fname = g_build_filename (ROOT_DIR, "libgda", FILE_NAME, NULL);	if (! g_file_test (fname, G_FILE_TEST_EXISTS)) {		g_free (fname);		fname = gda_gbr_get_file_path (GDA_DATA_DIR, LIBGDA_ABI_NAME, FILE_NAME, NULL);		if (! g_file_test (fname, G_FILE_TEST_EXISTS)) {			g_print ("Could not find '%s'./n", FILE_NAME);			exit (1);		}	}	doc = xmlParseFile (fname);	if (!doc) {		g_print ("Missing or malformed file '%s', check your installation", fname);		g_free (fname);		exit (1);        }		node = xmlDocGetRootElement (doc);	g_free (fname);	if (strcmp ((gchar *) node->name, "schema")) {		g_print ("Root node should be <schema>, got <%s>/n", (gchar *) node->name);		xmlFreeDoc (doc);		exit (1);	}	out_top_node = xmlNewNode (NULL, BAD_CAST "sect2");	xmlAddChild (out_top_node, xmlNewComment (BAD_CAST 						  "File generated by the tools/information-schema-doc program from the/n"						  "libgda/information-schema.xml file,/ndo not modify"));	xmlNewChild (out_top_node, NULL, BAD_CAST "title", BAD_CAST "Individual table description");	xmlNewChild (out_top_node, NULL, BAD_CAST "para", BAD_CAST "This section individually describes each table.");		for (node = node->children; node; node = node->next) {		if (!strcmp ((gchar *) node->name, "table")) {			xmlNodePtr snode, child, table, row, ref = NULL;			xmlChar *prop;			snode = xmlNewChild (out_top_node, NULL, BAD_CAST "sect3", NULL);			prop = xmlGetProp (node, BAD_CAST "name");			if (prop) {				gchar *str;				str = g_strdup_printf ("is:%s", (gchar *) prop);				xmlSetProp (snode, BAD_CAST "id", BAD_CAST str);				g_free (str);				str = g_strdup_printf ("%s table", (gchar *) prop);				xmlNewTextChild (snode, NULL, BAD_CAST "title", BAD_CAST str);				g_free (str);				xmlFree (prop);			}			else				xmlNewChild (snode, NULL, BAD_CAST "title", BAD_CAST "FIXME: table not named");			prop = xmlGetProp (node, BAD_CAST "descr");			if (prop) {				xmlNewTextChild (snode, NULL, BAD_CAST "para", prop);				xmlFree (prop);			}			table = xmlNewChild (snode, NULL, BAD_CAST "para", BAD_CAST "The following table describes the columns:");			table = xmlNewChild (table, NULL, BAD_CAST "informaltable", NULL);			xmlSetProp (table, BAD_CAST "frame", BAD_CAST "all");			table = xmlNewChild (table, NULL, BAD_CAST "tgroup", NULL);			xmlSetProp (table, BAD_CAST "cols", BAD_CAST "5");			xmlSetProp (table, BAD_CAST "colsep", BAD_CAST "1");			xmlSetProp (table, BAD_CAST "rowsep", BAD_CAST "1");			xmlSetProp (table, BAD_CAST "align", BAD_CAST "justify");						child = xmlNewChild (table, NULL, BAD_CAST "thead", NULL);			row = xmlNewChild (child, NULL, BAD_CAST "row", NULL);			xmlNewChild (row, NULL, BAD_CAST "entry", BAD_CAST "Column name");			xmlNewChild (row, NULL, BAD_CAST "entry", BAD_CAST "Type");			xmlNewChild (row, NULL, BAD_CAST "entry", BAD_CAST "Key");			xmlNewChild (row, NULL, BAD_CAST "entry", BAD_CAST "Can be NULL");			xmlNewChild (row, NULL, BAD_CAST "entry", BAD_CAST "description");			table = xmlNewChild (table, NULL, BAD_CAST "tbody", NULL);				for (child = node->children; child; child = child->next) {				if (!strcmp ((gchar *) child->name, "column")) {					row = xmlNewChild (table, NULL, BAD_CAST "row", NULL);										prop = xmlGetProp (child, BAD_CAST "name");					xmlNewChild (row, NULL, BAD_CAST "entry", prop ? prop : BAD_CAST "FIXME");					if (prop) xmlFree (prop);										prop = xmlGetProp (child, BAD_CAST "type");					xmlNewChild (row, NULL, BAD_CAST "entry", prop ? prop : BAD_CAST "string");					if (prop) xmlFree (prop);										prop = xmlGetProp (child, BAD_CAST "pkey");					xmlNewChild (row, NULL, BAD_CAST "entry", 						     prop && ((*prop == 't') || (*prop == 'T')) ? 						     BAD_CAST "Yes" : BAD_CAST "");					if (prop) xmlFree (prop);//.........这里部分代码省略.........
开发者ID:arthurnn,项目名称:libgda,代码行数:101,


示例5: xmlNewChild

HRESULT CTSExecutorLIB::GetConfigurationData(xmlNodePtr pxmlNodePtr){    const char* omcVarChar ;    //<Test_Suite_Name />    omcVarChar = m_omstrTestSuiteName.GetBuffer(MAX_PATH);    xmlNodePtr pTSName = xmlNewChild(pxmlNodePtr, NULL, BAD_CAST DEF_TS_NAME, BAD_CAST omcVarChar);    xmlAddChild(pxmlNodePtr, pTSName);    // <IsEnable />    CString csIsEnabled;    csIsEnabled.Format("%d", m_bTestSuiteStatus);    omcVarChar = csIsEnabled;    xmlNodePtr pIsEnabled = xmlNewChild(pxmlNodePtr, NULL, BAD_CAST DEF_IS_ENABLE, BAD_CAST omcVarChar);    xmlAddChild(pxmlNodePtr, pIsEnabled);    INT nFileCount = (INT)m_ouTestSetupEntityList.GetCount();    for(int iCnt = 0; iCnt < nFileCount; iCnt++)    {        //<TEST_SUITE>        xmlNodePtr pTestSuite = xmlNewNode(NULL, BAD_CAST DEF_TEST_SUITE);        xmlAddChild(pxmlNodePtr, pTestSuite);        //<Test_Suite_Name />        POSITION pos = m_ouTestSetupEntityList.FindIndex(iCnt);        CTestSetupEntity& ouTestSetupEntity = m_ouTestSetupEntityList.GetAt(pos);        string omPath, omStrConfigFolder;        char configPath[MAX_PATH];        AfxGetMainWnd()->SendMessage(MSG_GET_CONFIGPATH, (WPARAM)configPath, 0);        CUtilFunctions::nGetBaseFolder(configPath, omStrConfigFolder );        CUtilFunctions::MakeRelativePath(omStrConfigFolder.c_str(), (char*)ouTestSetupEntity.m_omstrCurrentTSFile.GetBuffer(MAX_PATH), omPath);        omcVarChar = omPath.c_str();        xmlNodePtr pFilePath = xmlNewChild(pTestSuite, NULL, BAD_CAST DEF_FILE_PATH, BAD_CAST omcVarChar);        xmlAddChild(pTestSuite, pFilePath);        //<IsEnable />        CString csIsEnabled;        csIsEnabled.Format("%d", ouTestSetupEntity.bGetEnableStatus());        omcVarChar = csIsEnabled;        xmlNodePtr pIsEnabled = xmlNewChild(pTestSuite, NULL, BAD_CAST DEF_IS_ENABLE, BAD_CAST omcVarChar);        xmlAddChild(pTestSuite, pIsEnabled);        //<Testcases_Selected>        xmlNodePtr pTestCasesSel = xmlNewNode(NULL, BAD_CAST DEF_TEST_CASES_SEL);        xmlAddChild(pTestSuite, pTestCasesSel);        // <Index>1</Index>        CString csIndex;        bool    bStatus;        UINT    unCount;        ouTestSetupEntity.GetSubEntryCount(unCount);        for(UINT j=0; j<unCount; j++)        {            CBaseEntityTA* pTCEntity;            ouTestSetupEntity.GetSubEntityObj(j, &pTCEntity);            bStatus = FALSE;            if(pTCEntity != NULL)            {                bStatus = pTCEntity->bGetEnableStatus();            }            if( bStatus == true )            {                csIndex.Format("%d", j);                omcVarChar = csIndex;                xmlNodePtr pIndex = xmlNewChild(pTestCasesSel, NULL, BAD_CAST DEF_INDEX, BAD_CAST omcVarChar);                xmlAddChild(pTestCasesSel, pIndex);            }        }    }    return true;}
开发者ID:bagge,项目名称:busmaster,代码行数:76,


示例6: noit_console_rule_configure

static intnoit_console_rule_configure(noit_console_closure_t ncct,                            int argc, char **argv,                            noit_console_state_t *state,                            void *closure) {  xmlNodePtr fsnode = NULL;  noit_conf_t_userdata_t *info;  char xpath[1024];  info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA);  snprintf(xpath, sizeof(xpath), "/%s",           info->path);  fsnode = noit_conf_get_section(NULL, xpath);  if(!fsnode) {    nc_printf(ncct, "internal error");    return -1;  }  if(closure) {    int rulenum;    xmlNodePtr byebye;    /* removing a rule */    if(argc != 1) {      nc_printf(ncct, "requires one argument/n");      return -1;    }    rulenum = atoi(argv[0]);    snprintf(xpath, sizeof(xpath), "rule[%d]", rulenum);    byebye = noit_conf_get_section(fsnode, xpath);    if(!byebye) {      nc_printf(ncct, "cannot find rule/n");      return -1;    }    xmlUnlinkNode(byebye);    xmlFreeNode(byebye);    nc_printf(ncct, "removed/n");  }  else {    xmlNodePtr (*add_func)(xmlNodePtr, xmlNodePtr);    xmlNodePtr add_arg, new_rule;    int i, needs_type = 1;    if(argc < 1 || argc % 2) {      nc_printf(ncct, "even number of arguments required/n");      return -1;    }    if(!strcmp(argv[0], "before") || !strcmp(argv[0], "after")) {      int rulenum = atoi(argv[1]);      snprintf(xpath, sizeof(xpath), "rule[%d]", rulenum);      add_arg = noit_conf_get_section(fsnode, xpath);      if(!add_arg) {        nc_printf(ncct, "%s rule not found/n", xpath);        return -1;      }      if(*argv[0] == 'b') add_func = xmlAddPrevSibling;      else add_func = xmlAddNextSibling;      argc -= 2;      argv += 2;    }    else {      add_func = xmlAddChild;      add_arg = fsnode;    }    for(i=0;i<argc;i+=2) {      if(!strcmp(argv[i], "type")) needs_type = 0;      else if(strcmp(argv[i], "target") && strcmp(argv[i], "module") &&              strcmp(argv[i], "name") && strcmp(argv[i], "metric")) {        nc_printf(ncct, "unknown attribute '%s'/n", argv[i]);        return -1;      }    }    if(needs_type) {      nc_printf(ncct, "type <allow|deny> is required/n");      return -1;    }    new_rule = xmlNewNode(NULL, (xmlChar *)"rule");    for(i=0;i<argc;i+=2)      xmlSetProp(new_rule, (xmlChar *)argv[i], (xmlChar *)argv[i+1]);    add_func(add_arg, new_rule);    noit_filter_compile_add((noit_conf_section_t *)fsnode);  }  return 0;}
开发者ID:Kami,项目名称:reconnoiter,代码行数:81,


示例7: msWFSDumpLayer11

static xmlNodePtr msWFSDumpLayer11(mapObj *map, layerObj *lp, xmlNsPtr psNsOws){  rectObj ext;  xmlNodePtr psRootNode, psNode;  const char *value    = NULL;  const char *encoding = NULL;  char *encoded=NULL;  char *valueToFree;  char **tokens;  int n=0,i=0;  encoding = msOWSLookupMetadata(&(map->web.metadata), "FO", "encoding");  if (!encoding)    encoding = "ISO-8859-1";  psRootNode = xmlNewNode(NULL, BAD_CAST "FeatureType");  /* add namespace to layer name */  value = msOWSLookupMetadata(&(map->web.metadata), "FO", "namespace_prefix");  if(value) {    n = strlen(value)+strlen(lp->name)+1+1;    valueToFree = (char *) msSmallMalloc(sizeof(char*)*n);    snprintf(valueToFree, n, "%s%s%s", (value ? value : ""), (value ? ":" : ""), lp->name);    /*if there is an encoding using it on some of the items*/    psNode = msOWSCommonxmlNewChildEncoded(psRootNode, NULL, "Name", valueToFree, encoding);    msFree(valueToFree);  } else {    psNode = msOWSCommonxmlNewChildEncoded(psRootNode, NULL, "Name", lp->name, encoding);  }  if (lp->name && strlen(lp->name) > 0 &&      (msIsXMLTagValid(lp->name) == MS_FALSE || isdigit(lp->name[0])))    xmlAddSibling(psNode,                  xmlNewComment(BAD_CAST "WARNING: The layer name '%s' might contain spaces or "                                "invalid characters or may start with a number. This could lead to potential problems"));  value = msOWSLookupMetadata(&(lp->metadata), "FO", "title");  if (!value)    value =(const char*)lp->name;  psNode = msOWSCommonxmlNewChildEncoded(psRootNode, NULL, "Title", value, encoding);  value = msOWSLookupMetadata(&(lp->metadata), "FO", "abstract");  if (value)    psNode = msOWSCommonxmlNewChildEncoded(psRootNode, NULL, "Abstract", value, encoding);  value = msOWSLookupMetadata(&(lp->metadata), "FO", "keywordlist");  if (value) {    encoded = msGetEncodedString(value, encoding);    msLibXml2GenerateList(      xmlNewChild(psRootNode, psNsOws, BAD_CAST "Keywords", NULL),      NULL, "Keyword", encoded, ',' );    msFree(encoded);  }  /*support DefaultSRS and OtherSRS*/  valueToFree = msOWSGetProjURN(&(map->projection),&(map->web.metadata),"FO",MS_FALSE);  if (!valueToFree)    valueToFree = msOWSGetProjURN(&(lp->projection), &(lp->metadata), "FO", MS_FALSE);  if (valueToFree) {    tokens = msStringSplit(valueToFree, ' ', &n);    if (tokens && n > 0) {      psNode = xmlNewChild(psRootNode, NULL, BAD_CAST "DefaultSRS", BAD_CAST tokens[0]);      for (i=1; i<n; i++)        psNode = xmlNewChild(psRootNode, NULL, BAD_CAST "OtherSRS", BAD_CAST tokens[i]);      msFreeCharArray(tokens, n);    }  } else    xmlAddSibling(psNode,                  xmlNewComment(BAD_CAST "WARNING: Mandatory mapfile parameter: (at least one of) MAP.PROJECTION, LAYER.PROJECTION or wfs/ows_srs metadata was missing in this context."));  free(valueToFree);  valueToFree = NULL;  /*TODO: adevertize only gml3?*/  psNode = xmlNewNode(NULL, BAD_CAST "OutputFormats");  xmlAddChild(psRootNode, psNode);  {    char *formats_list = msWFSGetOutputFormatList( map, lp, "1.1.0" );    int iformat, n;    char **tokens;    n = 0;    tokens = msStringSplit(formats_list, ',', &n);    for( iformat = 0; iformat < n; iformat++ )      xmlNewChild(psNode, NULL, BAD_CAST "Format",                  BAD_CAST tokens[iformat] );    msFree( formats_list );    msFreeCharArray( tokens, n );  }//.........这里部分代码省略.........
开发者ID:lydonchandra,项目名称:MapServer-SpeedUp,代码行数:101,


示例8: build_pidf

str* build_pidf(ucontact_t* c){	xmlDocPtr  doc = NULL;	xmlNodePtr root_node = NULL;	xmlNodePtr tuple_node = NULL;	xmlNodePtr status_node = NULL;	xmlNodePtr basic_node = NULL;	str *body= NULL;	str pres_uri= {NULL, 0};	char buf[BUF_LEN];	char* at= NULL;	if(c->expires< (int)time(NULL))	{		LM_DBG("found expired /n/n");		return NULL;	}	pres_uri.s = buf;	if(pres_prefix.s)	{		memcpy(pres_uri.s, pres_prefix.s, pres_prefix.len);		pres_uri.len+= pres_prefix.len;		memcpy(pres_uri.s+ pres_uri.len, ":", 1);		pres_uri.len+= 1;	}	if(pres_uri.len + c->aor->len+ 1 > BUF_LEN)	{		LM_ERR("buffer size overflown/n");		return NULL;	}	memcpy(pres_uri.s+ pres_uri.len, c->aor->s, c->aor->len);	pres_uri.len+= c->aor->len;	at = memchr(c->aor->s, '@', c->aor->len);	if(!at)	{		if(pres_uri.len + 2 + default_domain.len > BUF_LEN)		{			LM_ERR("buffer size overflown/n");			return NULL;		}		pres_uri.s[pres_uri.len++]= '@';		memcpy(pres_uri.s+ pres_uri.len, default_domain.s, default_domain.len);		pres_uri.len+= default_domain.len;	}	pres_uri.s[pres_uri.len]= '/0';	/* create the Publish body  */	doc = xmlNewDoc(BAD_CAST "1.0");	if(doc==0)		return NULL;	root_node = xmlNewNode(NULL, BAD_CAST "presence");	if(root_node==0)		goto error;	xmlDocSetRootElement(doc, root_node);	xmlNewProp(root_node, BAD_CAST "xmlns",			BAD_CAST "urn:ietf:params:xml:ns:pidf");	xmlNewProp(root_node, BAD_CAST "xmlns:dm",			BAD_CAST "urn:ietf:params:xml:ns:pidf:data-model");	xmlNewProp(root_node, BAD_CAST  "xmlns:rpid",			BAD_CAST "urn:ietf:params:xml:ns:pidf:rpid" );	xmlNewProp(root_node, BAD_CAST "xmlns:c",			BAD_CAST "urn:ietf:params:xml:ns:pidf:cipid");	xmlNewProp(root_node, BAD_CAST "entity", BAD_CAST pres_uri.s);	tuple_node =xmlNewChild(root_node, NULL, BAD_CAST "tuple", NULL) ;	if( tuple_node ==NULL)	{		LM_ERR("while adding child/n");		goto error;	}	status_node = xmlNewChild(tuple_node, NULL, BAD_CAST "status", NULL) ;	if( status_node ==NULL)	{		LM_ERR("while adding child/n");		goto error;	}	basic_node = xmlNewChild(status_node, NULL, BAD_CAST "basic",		BAD_CAST "open") ;	if( basic_node ==NULL)	{		LM_ERR("while adding child/n");		goto error;	}	body = (str*)pkg_malloc(sizeof(str));	if(body == NULL)	{		LM_ERR("while allocating memory/n");		return NULL;	}//.........这里部分代码省略.........
开发者ID:GreenfieldTech,项目名称:kamailio,代码行数:101,


示例9: xmlNewDoc

xmlDoc *marcmap_apply(struct marcmap *marcmap, xmlDoc *xml_in){    char mergekey[1024];    char medium[32];    char *s;    NMEM nmem;    xmlNsPtr ns_pz;    xmlDocPtr xml_out;    xmlNodePtr xml_out_root;    xmlNodePtr rec_node;    xmlNodePtr meta_node;     struct marchash *marchash;    struct marcfield *field;    struct marcsubfield *subfield;    struct marcmap *mmcur;         xml_out = xmlNewDoc(BAD_CAST "1.0");    xml_out->encoding = xmlCharStrdup("UTF-8");    xml_out_root = xmlNewNode(NULL, BAD_CAST "record");    xmlDocSetRootElement(xml_out, xml_out_root);    ns_pz = xmlNewNs(xml_out_root, BAD_CAST "http://www.indexdata.com/pazpar2/1.0", BAD_CAST "pz");     xmlSetNs(xml_out_root, ns_pz);    nmem = nmem_create();    rec_node = xmlDocGetRootElement(xml_in);    marchash = marchash_create(nmem);    marchash_ingest_marcxml(marchash, rec_node);    mmcur = marcmap;    while (mmcur != NULL)    {        field = 0;        while ((field = marchash_get_field(marchash, mmcur->field, field)) != 0)        {            // field value            if ((mmcur->subfield == '$') && (s = field->val))            {                meta_node = xmlNewChild(xml_out_root, ns_pz, BAD_CAST "metadata", BAD_CAST s);                xmlSetProp(meta_node, BAD_CAST "type", BAD_CAST mmcur->pz);             }            // catenate all subfields            else if ((mmcur->subfield == '*') && (s = marchash_catenate_subfields(field, " ", nmem)))            {                meta_node = xmlNewChild(xml_out_root, ns_pz, BAD_CAST "metadata", BAD_CAST s);                xmlSetProp(meta_node, BAD_CAST "type", BAD_CAST mmcur->pz);            }            // subfield value            else if (mmcur->subfield)             {                subfield = 0;                while ((subfield =                         marchash_get_subfield(mmcur->subfield,                                              field, subfield)) != 0)                {                    if ((s = subfield->val) != 0)                    {                        meta_node = xmlNewChild(xml_out_root, ns_pz, BAD_CAST "metadata", BAD_CAST s);                        xmlSetProp(meta_node, BAD_CAST "type", BAD_CAST mmcur->pz);                    }                }            }                    }        mmcur = mmcur->next;    }    // hard coded mappings    // medium    if ((field = marchash_get_field(marchash, "245", NULL)) && (subfield = marchash_get_subfield('h', field, NULL)))    {       strncpy(medium, subfield->val, 32);    }    else if ((field = marchash_get_field(marchash, "900", NULL)) && (subfield = marchash_get_subfield('a', field, NULL)))       strcpy(medium, "electronic resource");    else if ((field = marchash_get_field(marchash, "900", NULL)) && (subfield = marchash_get_subfield('b', field, NULL)))       strcpy(medium, "electronic resource");    else if ((field = marchash_get_field(marchash, "773", NULL)) && (subfield = marchash_get_subfield('t', field, NULL)))       strcpy(medium, "article");    else       strcpy(medium, "book");    meta_node = xmlNewChild(xml_out_root, ns_pz, BAD_CAST "metadata", BAD_CAST medium);    xmlSetProp(meta_node, BAD_CAST "type", BAD_CAST "medium");    // merge key    memset(mergekey, 0, 1024);    strcpy(mergekey, "title ");    if ((field = marchash_get_field(marchash, "245", NULL)) && (subfield = marchash_get_subfield('a', field, NULL)))        strncat(mergekey, subfield->val, 1023 - strlen(mergekey));    strncat(mergekey, " author ", 1023 - strlen(mergekey));    if ((field = marchash_get_field(marchash, "100", NULL)) && (subfield = marchash_get_subfield('a', field, NULL)))        strncat(mergekey, subfield->val, 1023 - strlen(mergekey));    strncat(mergekey, " medium ", 1023 - strlen(mergekey));    strncat(mergekey, medium, 1023 - strlen(mergekey));//    xmlSetProp(xml_out_root, BAD_CAST "mergekey", BAD_CAST mergekey);    nmem_destroy(nmem);    return xml_out;}
开发者ID:saiful76,项目名称:pazpar2,代码行数:100,


示例10: mate_wp_xml_save_list

void mate_wp_xml_save_list (AppearanceData *data) {    xmlDoc * wplist;    xmlNode * root, * wallpaper, * item;    GSList * list = NULL;    gchar * wpfile;    g_hash_table_foreach (data->wp_hash,                          (GHFunc) mate_wp_list_flatten, &list);    g_hash_table_destroy (data->wp_hash);    list = g_slist_reverse (list);    wpfile = g_build_filename (g_get_home_dir (),                               "/.mate2",                               "backgrounds.xml",                               NULL);    xmlKeepBlanksDefault (0);    wplist = xmlNewDoc ((xmlChar *)"1.0");    xmlCreateIntSubset (wplist, (xmlChar *)"wallpapers", NULL, (xmlChar *)"mate-wp-list.dtd");    root = xmlNewNode (NULL, (xmlChar *)"wallpapers");    xmlDocSetRootElement (wplist, root);    while (list != NULL) {        MateWPItem * wpitem = list->data;        const char * none = "(none)";        gchar * filename;        const gchar * scale, * shade;        gchar * pcolor, * scolor;        if (!strcmp (wpitem->filename, none) ||                (g_utf8_validate (wpitem->filename, -1, NULL) &&                 g_file_test (wpitem->filename, G_FILE_TEST_EXISTS)))            filename = g_strdup (wpitem->filename);        else            filename = g_filename_to_utf8 (wpitem->filename, -1, NULL, NULL, NULL);        pcolor = gdk_color_to_string (wpitem->pcolor);        scolor = gdk_color_to_string (wpitem->scolor);        scale = wp_item_option_to_string (wpitem->options);        shade = wp_item_shading_to_string (wpitem->shade_type);        wallpaper = xmlNewChild (root, NULL, (xmlChar *)"wallpaper", NULL);        mate_wp_xml_set_bool (wallpaper, (xmlChar *)"deleted", wpitem->deleted);        item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"name", (xmlChar *)wpitem->name);        item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"filename", (xmlChar *)filename);        item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"options", (xmlChar *)scale);        item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"shade_type", (xmlChar *)shade);        item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"pcolor", (xmlChar *)pcolor);        item = xmlNewTextChild (wallpaper, NULL, (xmlChar *)"scolor", (xmlChar *)scolor);        g_free (pcolor);        g_free (scolor);        g_free (filename);        list = g_slist_delete_link (list, list);        mate_wp_item_free (wpitem);    }    xmlSaveFormatFile (wpfile, wplist, 1);    xmlFreeDoc (wplist);    g_free (wpfile);}
开发者ID:TheCoffeMaker,项目名称:Mate-Desktop-Environment,代码行数:61,


示例11: status_presets_file_save

static gbooleanstatus_presets_file_save (void){    xmlDocPtr   doc;    xmlNodePtr  root;    GList      *l;    gchar      *dir;    gchar      *file;    gint        count[TP_NUM_CONNECTION_PRESENCE_TYPES];    gint        i;    for (i = 0; i < TP_NUM_CONNECTION_PRESENCE_TYPES; i++) {        count[i] = 0;    }    dir = g_build_filename (g_get_user_config_dir (), PACKAGE_NAME, NULL);    g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);    file = g_build_filename (dir, STATUS_PRESETS_XML_FILENAME, NULL);    g_free (dir);    doc = xmlNewDoc ((const xmlChar *) "1.0");    root = xmlNewNode (NULL, (const xmlChar *) "presets");    xmlDocSetRootElement (doc, root);    if (default_preset) {        xmlNodePtr  subnode;        xmlChar    *state;        state = (xmlChar *) empathy_presence_to_str (default_preset->state);        subnode = xmlNewTextChild (root, NULL, (const xmlChar *) "default",                                   (const xmlChar *) default_preset->status);        xmlNewProp (subnode, (const xmlChar *) "presence", state);    }    for (l = presets; l; l = l->next) {        StatusPreset *sp;        xmlNodePtr    subnode;        xmlChar      *state;        sp = l->data;        state = (xmlChar *) empathy_presence_to_str (sp->state);        count[sp->state]++;        if (count[sp->state] > STATUS_PRESETS_MAX_EACH) {            continue;        }        subnode = xmlNewTextChild (root, NULL,                                   (const xmlChar *) "status", (const xmlChar *) sp->status);        xmlNewProp (subnode, (const xmlChar *) "presence", state);    }    /* Make sure the XML is indented properly */    xmlIndentTreeOutput = 1;    DEBUG ("Saving file:'%s'", file);    xmlSaveFormatFileEnc (file, doc, "utf-8", 1);    xmlFreeDoc (doc);    g_free (file);    return TRUE;}
开发者ID:JorgeRdg,项目名称:empathy,代码行数:64,


示例12: send_logoff

int DEFAULT_CCsend_logoff(int client, int session_id){	struct session_item* sess;	xmlNodePtr node, node2;	xmlDocPtr doc;	xmlChar* version;	xmlChar* response;	xmlChar* session;	xmlChar* username;	xmlChar* username_value;	xmlChar* id;	xmlChar* id_value;	xmlChar* status;	xmlChar* status_value;	char prop[128];	int display;	if (session_id == 0) {		log_message(&(g_cfg->log), LOG_LEVEL_WARNING, "sesman[send_logoff]: "				"%i is not a valid session id", session_id);		return 1;	}	log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "sesman[send_logoff]: "			"request session %i logoff", session_id);	lock_chain_acquire();	sess = session_get_by_display(session_id);	lock_chain_release();	if( sess == NULL)	{		log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "sesman[send_logoff]: "				"The session %i did not exist", session_id);		xml_send_error(client, "the session id of the request did not exist");		return 1;	}	session_update_status_by_user(sess->name, SESMAN_SESSION_STATUS_TO_DESTROY);	version = xmlCharStrdup("1.0");	doc = xmlNewDoc(version);	if (doc == NULL)	{		log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "sesman[send_logoff]: "				"Unable to create the document");		g_free(sess);		xmlFree(version);		xmlFreeDoc(doc);		return 1;	}	doc->encoding = xmlCharStrdup("UTF-8");	response = xmlCharStrdup("response");	session = xmlCharStrdup("session");	node = xmlNewNode(NULL, response);	node2 = xmlNewNode(NULL, session);	sprintf(prop, "%i", display);	id = xmlCharStrdup("id");	id_value = xmlCharStrdup(prop);	username = xmlCharStrdup("username");	username_value = xmlCharStrdup(sess->name);	status = xmlCharStrdup("status");	status_value = xmlCharStrdup("CLOSED");	xmlSetProp(node2, id, id_value);	xmlSetProp(node2, username, username_value);	xmlSetProp(node2, status, status_value);	xmlAddChild(node, node2);	xmlDocSetRootElement(doc, node);	xml_send_info(client, doc);	xmlFreeDoc(doc);	xmlFree(version);	xmlFree(response);	xmlFree(session);	xmlFree(username);	xmlFree(username_value);	xmlFree(id);	xmlFree(id_value);	xmlFree(status);	xmlFree(status_value);	g_free(sess);	return 0;}
开发者ID:Oyatsumi,项目名称:ulteo4Kode4kids,代码行数:86,


示例13: send_session

int DEFAULT_CCsend_session(int client, int session_id, char* user){	struct session_item* sess = NULL;	xmlNodePtr node, node2;	xmlDocPtr doc;	xmlChar* version;	xmlChar* response;	xmlChar* session;	xmlChar* id;	xmlChar* id_value;	xmlChar* username;	xmlChar* username_value;	xmlChar* status;	xmlChar* status_value;	log_message(&(g_cfg->log), LOG_LEVEL_DEBUG_PLUS, "sesman[send_session]: "			"request for session/n");	lock_chain_acquire();	if (user == NULL || user[0] == '/0')	{		sess = session_get_by_display(session_id);	}	else	{		sess = session_get_bydata(user);	}	lock_chain_release();	if( sess == NULL && session_id != 0)	{		log_message(&(g_cfg->log), LOG_LEVEL_DEBUG, "sesman[send_session]: "				"the session %i did not exist",session_id);		sess = g_malloc(sizeof(struct session_item), 1);		sess->display = session_id;		sess->status = SESMAN_SESSION_STATUS_UNKNOWN;		g_snprintf(sess->name, sizeof(sess->name), "UNKNOW");	}	version = xmlCharStrdup("1.0");	doc = xmlNewDoc(version);	if (doc == NULL)	{		log_message(&(g_cfg->log), LOG_LEVEL_DEBUG_PLUS, "sesman[send_session]: "				"Unable to create the document");		if (sess != NULL)		{			g_free(sess);		}		return 1;	}	doc->encoding = xmlCharStrdup("UTF-8");	response = xmlCharStrdup("response");	session = xmlCharStrdup("session");	node = xmlNewNode(NULL, response);	node2 = xmlNewNode(NULL, session);	if (sess != NULL)	{		char prop[128] = {0};		g_sprintf(prop, "%i", sess->display);		id = xmlCharStrdup("id");		id_value = xmlCharStrdup(prop);		username = xmlCharStrdup("username");		username_value = xmlCharStrdup(sess->name);		status = xmlCharStrdup("status");		status_value = xmlCharStrdup(session_get_status_string(sess->status));		xmlSetProp(node2, id, id_value);		xmlSetProp(node2, username, username_value);		xmlSetProp(node2, status, status_value );		xmlAddChild(node, node2);	}	xmlDocSetRootElement(doc, node);	xml_send_info(client, doc);	xmlFree(response);	xmlFree(session);	xmlFree(version);	xmlFreeDoc(doc);	if (sess != NULL)	{		xmlFree(id);		xmlFree(id_value);		xmlFree(username);		xmlFree(username_value);		xmlFree(status);		xmlFree(status_value);		g_free(sess);	}	return 0;}
开发者ID:Oyatsumi,项目名称:ulteo4Kode4kids,代码行数:95,


示例14: send_sessions

int DEFAULT_CCsend_sessions(int client){	struct session_item* sess;	xmlNodePtr node, node2, node3;	xmlDocPtr doc;	int count, i;	xmlChar* version;	xmlChar* encoding;	xmlChar* s_node;	xmlChar* s_node2;	log_message(&(g_cfg->log), LOG_LEVEL_DEBUG_PLUS, "sesman[send_sessions]: "			"request for sessions list");	lock_chain_acquire();	sess = (struct session_item*)session_list_session(&count);	lock_chain_release();	log_message(&(g_cfg->log), LOG_LEVEL_DEBUG_PLUS, "sesman[send_sessions]: "			"%i count sessions",count);	version = xmlCharStrdup("1.0");	doc = xmlNewDoc(version);	if (doc ==NULL)	{		log_message(&(g_cfg->log), LOG_LEVEL_DEBUG_PLUS, "sesman[send_sessions]: "				"Unable to create the document");		return 1;	}	doc->encoding = xmlCharStrdup("UTF-8");	s_node = xmlCharStrdup("response");	node = xmlNewNode(NULL, s_node);	s_node2 = xmlCharStrdup("sessions");	node2 = xmlNewNode(NULL, s_node2);	xmlAddChild(node, node2);	char prop[128];	for ( i=0 ; i<count ; i++)	{		g_sprintf(prop, "%i", sess[i].display);		xmlChar* s_session = xmlCharStrdup("session");		xmlChar* s_id = xmlCharStrdup("id");		xmlChar* s_id_value = xmlCharStrdup(prop);		xmlChar* s_username = xmlCharStrdup("username");		xmlChar* s_username_value = xmlCharStrdup(sess[i].name);		xmlChar* s_status = xmlCharStrdup("status");		xmlChar* s_status_value = xmlCharStrdup(session_get_status_string(sess[i].status));		node3 = xmlNewNode(NULL, s_session);		xmlSetProp(node3, s_id, s_id_value );		xmlSetProp(node3, s_username,	s_username_value);		xmlSetProp(node3, s_status, s_status_value );		xmlAddChild(node2, node3);		xmlFree(s_session);		xmlFree(s_id);		xmlFree(s_id_value);		xmlFree(s_username);		xmlFree(s_username_value);		xmlFree(s_status);		xmlFree(s_status_value);	}	xmlAddChild(node, node2);	xmlDocSetRootElement(doc, node);	xml_send_info(client, doc);	xmlFree(version);	xmlFree(s_node);	xmlFree(s_node2);	g_free(sess);	xmlFreeDoc(doc);	return 0;}
开发者ID:Oyatsumi,项目名称:ulteo4Kode4kids,代码行数:72,


示例15: xml_gal_write

/* * Create xml content for the gallery ready to be written to disk. */guchar *xml_gal_write(struct data *data, gsize *len){    xmlDocPtr doc;    xmlNodePtr gallery, settings, pages, page, page_settings;    xmlChar *xmlbuff;    gchar tmp_setting[256];    int bufsize;    GSList *list;    g_assert(data != NULL);    g_assert(len != NULL);    g_debug("in xml_gal_write");    /* CHECKME: extra block to help emacs with indenting.. */    { LIBXML_TEST_VERSION }    /* create new xml with pwgallery as the root element */    doc = xmlNewDoc(BAD_CAST "1.0");    gallery = xmlNewNode(NULL, BAD_CAST "pwgallery");    xmlDocSetRootElement(doc, gallery);    /* add settings node under pwgallery node */    settings = xmlNewNode(NULL, BAD_CAST "settings");    xmlAddChild(gallery, settings);    /* add settings under the settings node */    xmlNewChild(settings, NULL, BAD_CAST "version",                BAD_CAST VERSION);    xmlNewTextChild(settings, NULL, BAD_CAST "name",                BAD_CAST data->gal->name);    xmlNewTextChild(settings, NULL, BAD_CAST "dir_name",                BAD_CAST data->gal->dir_name);    xmlNewTextChild(settings, NULL, BAD_CAST "desc",                BAD_CAST data->gal->desc);    xmlNewChild(settings, NULL, BAD_CAST "output_dir",                BAD_CAST data->gal->base_dir);    xmlNewChild(settings, NULL, BAD_CAST "page_gen_prog",                BAD_CAST data->gal->page_gen_prog);    xmlNewChild(settings, NULL, BAD_CAST "templ_index",                BAD_CAST data->gal->templ_index);    xmlNewChild(settings, NULL, BAD_CAST "templ_indeximg",                BAD_CAST data->gal->templ_indeximg);    xmlNewChild(settings, NULL, BAD_CAST "templ_indexgen",                BAD_CAST data->gal->templ_indexgen);    xmlNewChild(settings, NULL, BAD_CAST "templ_image",                BAD_CAST data->gal->templ_image);    xmlNewChild(settings, NULL, BAD_CAST "templ_gen",                BAD_CAST data->gal->templ_gen);        g_snprintf(tmp_setting, 256, "%d", data->gal->page_gen);    xmlNewChild(settings, NULL, BAD_CAST "page_gen", BAD_CAST tmp_setting);    g_snprintf(tmp_setting, 256, "%d", data->gal->thumb_w);    xmlNewChild(settings, NULL, BAD_CAST "thumb_w", BAD_CAST tmp_setting);    g_snprintf(tmp_setting, 256, "%d", data->gal->image_h);    xmlNewChild(settings, NULL, BAD_CAST "image_h", BAD_CAST tmp_setting);    g_snprintf(tmp_setting, 256, "%d", data->gal->image_h2);    xmlNewChild(settings, NULL, BAD_CAST "image_h2", BAD_CAST tmp_setting);    g_snprintf(tmp_setting, 256, "%d", data->gal->image_h3);    xmlNewChild(settings, NULL, BAD_CAST "image_h3", BAD_CAST tmp_setting);    g_snprintf(tmp_setting, 256, "%d", data->gal->image_h4);    xmlNewChild(settings, NULL, BAD_CAST "image_h4", BAD_CAST tmp_setting);    xmlNewChild(settings, NULL, BAD_CAST "edited",                 BAD_CAST (data->gal->edited ? "true" : "false"));    xmlNewChild(settings, NULL, BAD_CAST "remove_exif",                 BAD_CAST (data->gal->remove_exif ? "true" : "false"));    xmlNewChild(settings, NULL, BAD_CAST "rename",                 BAD_CAST (data->gal->rename ? "true" : "false"));        /* add pages node under pwgallery node */    pages = xmlNewNode(NULL, BAD_CAST "pages");    xmlAddChild(gallery, pages);    /* add pages (images/generic) under the pages node */    list = data->gal->images;    while(list != NULL)    {        struct image *img = list->data;        /* FIXME: how to support generic pages here? */        page = xmlNewNode(NULL, BAD_CAST "image");        xmlAddChild(pages, page);                /* add page settings node under page node */        page_settings = xmlNewNode(NULL, BAD_CAST "settings");//.........这里部分代码省略.........
开发者ID:kulve,项目名称:pwgallery,代码行数:101,


示例16: xmlNewTextChild

xmlNode *oval_definition_model_to_dom(struct oval_definition_model *definition_model, xmlDocPtr doc, xmlNode * parent){	xmlNodePtr root_node = NULL;	if (parent) { /* result file */		root_node = xmlNewTextChild(parent, NULL, BAD_CAST OVAL_ROOT_ELM_DEFINITIONS, NULL);	} else {      /* definitions file, we are the root */		root_node = xmlNewNode(NULL, BAD_CAST OVAL_ROOT_ELM_DEFINITIONS);		xmlDocSetRootElement(doc, root_node);	}	xmlNewNsProp(root_node, lookup_xsi_ns(doc), BAD_CAST "schemaLocation", BAD_CAST definition_model->schema);	xmlNs *ns_common = xmlNewNs(root_node, OVAL_COMMON_NAMESPACE, BAD_CAST "oval");	xmlNs *ns_unix = xmlNewNs(root_node, OVAL_DEFINITIONS_UNIX_NS, BAD_CAST "unix-def");	xmlNs *ns_ind = xmlNewNs(root_node, OVAL_DEFINITIONS_IND_NS, BAD_CAST "ind-def");	xmlNs *ns_lin = xmlNewNs(root_node, OVAL_DEFINITIONS_LIN_NS, BAD_CAST "lin-def");	xmlNs *ns_defntns = xmlNewNs(root_node, OVAL_DEFINITIONS_NAMESPACE, NULL);	xmlSetNs(root_node, ns_common);	xmlSetNs(root_node, ns_unix);	xmlSetNs(root_node, ns_ind);	xmlSetNs(root_node, ns_lin);	xmlSetNs(root_node, ns_defntns);	/* Always report the generator */	oval_generator_to_dom(definition_model->generator, doc, root_node);	/* Report definitions */	struct oval_definition_iterator *definitions = oval_definition_model_get_definitions(definition_model);	if (oval_definition_iterator_has_more(definitions)) {		xmlNode *definitions_node = NULL;		while(oval_definition_iterator_has_more(definitions)) {			struct oval_definition *definition = oval_definition_iterator_next(definitions);			if (definitions_node == NULL) {				definitions_node = xmlNewTextChild(root_node, ns_defntns, BAD_CAST "definitions", NULL);			}			oval_definition_to_dom(definition, doc, definitions_node);		}	}        oval_definition_iterator_free(definitions);	/* Report tests */	struct oval_test_iterator *tests = oval_definition_model_get_tests(definition_model);	if (oval_test_iterator_has_more(tests)) {		xmlNode *tests_node = xmlNewTextChild(root_node, ns_defntns, BAD_CAST "tests", NULL);		while (oval_test_iterator_has_more(tests)) {			struct oval_test *test = oval_test_iterator_next(tests);			oval_test_to_dom(test, doc, tests_node);		}	}	oval_test_iterator_free(tests);	/* Report objects */	struct oval_object_iterator *objects = oval_definition_model_get_objects(definition_model);	if (oval_object_iterator_has_more(objects)) {		xmlNode *objects_node = xmlNewTextChild(root_node, ns_defntns, BAD_CAST "objects", NULL);		while(oval_object_iterator_has_more(objects)) {			struct oval_object *object = oval_object_iterator_next(objects);			if (oval_object_get_base_obj(object))				/* Skip internal objects */				continue;			oval_object_to_dom(object, doc, objects_node);		}	}	oval_object_iterator_free(objects);	/* Report states */	struct oval_state_iterator *states = oval_definition_model_get_states(definition_model);	if (oval_state_iterator_has_more(states)) {		xmlNode *states_node = xmlNewTextChild(root_node, ns_defntns, BAD_CAST "states", NULL);		while (oval_state_iterator_has_more(states)) {			struct oval_state *state = oval_state_iterator_next(states);			oval_state_to_dom(state, doc, states_node);		}	}	oval_state_iterator_free(states);	/* Report variables */	struct oval_variable_iterator *variables = oval_definition_model_get_variables(definition_model);	if (oval_variable_iterator_has_more(variables)) {		xmlNode *variables_node = xmlNewTextChild(root_node, ns_defntns, BAD_CAST "variables", NULL);		while (oval_variable_iterator_has_more(variables)) {			struct oval_variable *variable = oval_variable_iterator_next(variables);			oval_variable_to_dom(variable, doc, variables_node);		}	}	oval_variable_iterator_free(variables);	return root_node;}
开发者ID:galaris,项目名称:openscap,代码行数:91,


示例17: XLALInferenceVariablesArray2VOTTable

/** * /brief Serializes an array of /c LALInferenceVariables into a VOTable XML %node * * This function takes a /c LALInferenceVariables structure and serializes it into a VOTable * /c RESOURCE %node identified by the given name. The returned /c xmlNode can then be * embedded into an existing %node hierarchy or turned into a full VOTable document. * A VOTable Table element is returned, with fixed variables as PARAMs and the varying ones as FIELDs. * * /param varsArray [in] Pointer to an array of /c LALInferenceVariables structures to be serialized * /param N [in] Number of items in the array * /param tablename UNDOCUMENTED * * /return A pointer to a /c xmlNode that holds the VOTable fragment that represents * the /c LALInferenceVariables array. * In case of an error, a null-pointer is returned./n * /b Important: the caller is responsible to free the allocated memory (when the * fragment isn't needed anymore) using /c xmlFreeNode. Alternatively, /c xmlFreeDoc * can be used later on when the returned fragment has been embedded in a XML document. * * /sa XLALCreateVOTParamNode * /sa XLALCreateVOTResourceNode * * /author John Veitch * */xmlNodePtr XLALInferenceVariablesArray2VOTTable(LALInferenceVariables * const *const varsArray, UINT4 N, const char *tablename){  xmlNodePtr fieldNodeList=NULL;  xmlNodePtr paramNodeList=NULL;  xmlNodePtr xmlTABLEDATAnode=NULL;  xmlNodePtr VOTtableNode=NULL;  xmlNodePtr tmpNode=NULL;  xmlNodePtr field_ptr,param_ptr;  LALInferenceVariableItem *varitem=NULL;  UINT4 Nfields=0;  UINT4 bufsize=1024;  int err;	/* Sanity check input */	if(!varsArray) {		XLALPrintError("Received null varsArray pointer");		XLAL_ERROR_NULL(XLAL_EFAULT);	}	if(N==0) return(NULL);	field_ptr=fieldNodeList;	param_ptr=paramNodeList;    char *field_names[varsArray[0]->dimension];    /* Build a list of PARAM and FIELD elements */    for(varitem=varsArray[0]->head;varitem;varitem=varitem->next)	{		tmpNode=NULL;		switch(varitem->vary){			case LALINFERENCE_PARAM_LINEAR:			case LALINFERENCE_PARAM_CIRCULAR:			case LALINFERENCE_PARAM_OUTPUT:			{				tmpNode=LALInferenceVariableItem2VOTFieldNode(varitem);				if(!tmpNode) {					XLALPrintWarning ("%s: xmlAddNextSibling() failed to add field node for %s./n", __func__, varitem->name );					//XLAL_ERROR_NULL(XLAL_EFAILED);					continue;				}				if(field_ptr) field_ptr=xmlAddNextSibling(field_ptr,tmpNode);				else {field_ptr=tmpNode; fieldNodeList=field_ptr;}				field_names[Nfields]=varitem->name;				Nfields++;				break;			}			case LALINFERENCE_PARAM_FIXED:			{				tmpNode=LALInferenceVariableItem2VOTParamNode(varitem);				if(!tmpNode) {					XLALPrintWarning ("%s: xmlAddNextSibling() failed to add param node for %s./n", __func__, varitem->name );					//XLAL_ERROR_NULL(XLAL_EFAILED);					continue;				}				if(param_ptr) param_ptr=xmlAddNextSibling(param_ptr,tmpNode);				else {param_ptr=tmpNode; paramNodeList=param_ptr;}				break;			}			default:			{				XLALPrintWarning("Unknown param vary type");			}		}	}	if(Nfields>0)	{			UINT4 row,col;			/* create TABLEDATA node */			if ( ( xmlTABLEDATAnode = xmlNewNode ( NULL, CAST_CONST_XMLCHAR("TABLEDATA") ))== NULL ) {					XLALPrintError ("%s: xmlNewNode() failed to create 'TABLEDATA' node./n", __func__ );					err = XLAL_ENOMEM;					goto failed;			}			/* ---------- loop over data-arrays and generate each table-row *///.........这里部分代码省略.........
开发者ID:cpankow,项目名称:lalsuite,代码行数:101,


示例18: create_program_list

static gbooleancreate_program_list(IRAPISession *session, GList **list, SynceAppManBusyFunc busy_func, gpointer busy_data, GError **error){  GList *prog_list = NULL;  xmlDocPtr doc = NULL;  xmlDocPtr reply_doc = NULL;  xmlNodePtr parent = NULL;  xmlNodePtr root_node = NULL, node = NULL, reply_node = NULL;  xmlChar *doc_string = NULL;  gint doc_size;  LPWSTR config_w = NULL;  LPWSTR reply_w = NULL;  HRESULT result;  gchar *reply = NULL;  gchar *prop = NULL;  doc = xmlNewDoc((xmlChar *)"1.0");  root_node = xmlNewNode(NULL, (xmlChar *)"wap-provisioningdoc");  xmlDocSetRootElement(doc, root_node);  parent = root_node;  node = xmlNewNode(NULL, (xmlChar *)"characteristic-query");  xmlNewProp(node, (xmlChar *)"recursive", (xmlChar *)"false");  xmlNewProp(node, (xmlChar *)"type", (xmlChar *)"UnInstall");  xmlAddChild(parent, node);  xmlDocDumpMemoryEnc(doc, &doc_string, &doc_size, "utf-8");  g_debug("%s: CeProcessConfig request is /n%s", G_STRFUNC, doc_string);  config_w = wstr_from_utf8((char *)doc_string);  xmlFree(doc_string);  xmlFreeDoc(doc);  result = IRAPISession_CeProcessConfig(session, config_w, CONFIG_PROCESS_DOCUMENT, &reply_w);  wstr_free_string(config_w);  if (result != 0) {    g_set_error(error,		SYNCE_APP_MAN_ERROR,		SYNCE_APP_MAN_ERROR_RAPI,		_("Unable to obtain application list: %s"),		synce_strerror(result));    return FALSE;  }  reply = wstr_to_utf8(reply_w);  wstr_free_string(reply_w);  reply_doc = xmlReadMemory(reply, strlen(reply), "reply.xml", NULL, 0);  xmlDocDumpMemoryEnc(reply_doc, &doc_string, &doc_size, "utf-8");  g_debug("%s: CeProcessConfig response is /n%s", G_STRFUNC, doc_string);  xmlFree(doc_string);  reply_node = NULL;  node = xmlDocGetRootElement(reply_doc);  node = node->children;  while(node)    {      if (node->type == XML_ELEMENT_NODE)	{	  reply_node = node;	}      node = node->next;    }  if (!reply_node) {    xmlFreeDoc(reply_doc);    g_set_error(error,		SYNCE_APP_MAN_ERROR,		SYNCE_APP_MAN_ERROR_RAPI,		_("Unable to obtain application list: Unexpected reply XML structure"));    return FALSE;  }  node = reply_node->children;  while (node) {    prop = (gchar *)xmlGetProp(node, (xmlChar *)"type");    g_strstrip(prop);    prog_list = g_list_append(prog_list, prop);    node = node->next;  }  xmlFreeDoc(reply_doc);  *list = prog_list;  return TRUE;}
开发者ID:asmblur,项目名称:SynCE,代码行数:93,


示例19: noit_console_filter_configure

static intnoit_console_filter_configure(noit_console_closure_t ncct,                              int argc, char **argv,                              noit_console_state_t *state,                              void *closure) {  xmlNodePtr parent, fsnode = NULL;  int rv = -1;  noit_conf_t_userdata_t *info;  char xpath[1024];  info = noit_console_userdata_get(ncct, NOIT_CONF_T_USERDATA);  if(!info) {    nc_printf(ncct, "internal error/n");    goto cleanup;  }  if(strncmp(info->path, "/filtersets/", strlen("/filtersets/")) &&     strcmp(info->path, "/filtersets")) {    nc_printf(ncct, "filterset only allows inside /filtersets (not %s)/n",              info->path);    goto cleanup;  }  if(argc != 1) {    nc_printf(ncct, "filterset requires one argument/n");    goto cleanup;  }  snprintf(xpath, sizeof(xpath), "/%s", info->path);  parent = noit_conf_get_section(NULL, xpath);  if(!parent) {    nc_printf(ncct, "internal error, can't final current working path/n");    goto cleanup;  }  snprintf(xpath, sizeof(xpath), "filterset[@name=/"%s/"]", argv[0]);  fsnode = noit_conf_get_section(parent, xpath);  if(closure) {    int removed;    removed = noit_filter_remove(fsnode);    nc_printf(ncct, "%sremoved filterset '%s'/n",              removed ? "" : "failed to ", argv[0]);    if(removed) {      xmlUnlinkNode(fsnode);      xmlFreeNode(fsnode);    }    rv = !removed;    goto cleanup;  }  if(!fsnode) {    void *vfs;    nc_printf(ncct, "Cannot find filterset '%s'/n", argv[0]);    LOCKFS();    if(noit_hash_retrieve(filtersets, argv[0], strlen(argv[0]), &vfs)) {      UNLOCKFS();      nc_printf(ncct, "filter of the same name already exists/n");      goto cleanup;    }    UNLOCKFS();    /* Fine the parent path */    fsnode = xmlNewNode(NULL, (xmlChar *)"filterset");    xmlSetProp(fsnode, (xmlChar *)"name", (xmlChar *)argv[0]);    xmlAddChild(parent, fsnode);    nc_printf(ncct, "created new filterset/n");  }  if(info) {    char *xmlpath = NULL;    if(info->path) free(info->path);    xmlpath = (char *)xmlGetNodePath(fsnode);    info->path = strdup(xmlpath + strlen("/noit"));    free(xmlpath);    strlcpy(info->filter_name, argv[0], sizeof(info->filter_name));    if(state) {      noit_console_state_push_state(ncct, state);      noit_console_state_init(ncct);    }  } cleanup:  return rv;}
开发者ID:Kami,项目名称:reconnoiter,代码行数:77,


示例20: hip_xmlrpc_getput

//.........这里部分代码省略.........        {          dv = insert_dht_val(key);        }      strncpy(dv->app, app, sizeof(dv->app));      dv->value_hash_len = SHA_DIGEST_LENGTH;      memcpy(dv->value_hash, value_hash, SHA_DIGEST_LENGTH);      dv->secret_len = secret_len;      memcpy(dv->secret, secret, secret_len);      dv->expire_time.tv_usec = now.tv_usec;      dv->expire_time.tv_sec = now.tv_sec + ttl;      pthread_mutex_unlock(&dht_vals_lock);    }  switch (mode & 0x000F)    {    case XMLRPC_MODE_PUT:      sprintf(oper, "put_removable");      break;    case XMLRPC_MODE_GET:      sprintf(oper, "get");      break;    case XMLRPC_MODE_RM:      sprintf(oper, "rm");      break;    default:      log_(WARN, "Invalid XMLRPC mode given to DHT./n");      return(-1);    }  /*   * create a new XML document   */  doc = xmlNewDoc(BAD_CAST "1.0");  root_node = xmlNewNode(NULL, BAD_CAST "methodCall");  xmlDocSetRootElement(doc, root_node);  node = xmlNewChild(root_node, NULL, BAD_CAST "methodName",                     BAD_CAST oper);  node = xmlNewChild(root_node, NULL, BAD_CAST "params", NULL);  memset(tmp, 0, sizeof(tmp));  memcpy(tmp, key, key_len);  EVP_EncodeBlock(key64, tmp, key_len);  xml_new_param(node, "base64", (char *)key64);                 /* key */  /* log_(NORM, "Doing %s using key(%d)=",   *    ((mode & 0x000F)==XMLRPC_MODE_PUT) ? "PUT":"GET", key_len);   *  print_hex(key, key_len);   *  log_(NORM, " [%s]/n", key64); // */  switch (mode & 0x000F)    {    case XMLRPC_MODE_PUT:      memset(tmp, 0, sizeof(tmp));      memcpy(tmp, value, *value_len);      EVP_EncodeBlock(val64, tmp, *value_len);      xml_new_param(node, "base64", (char *)val64);             /* value */      xml_new_param(node, "string", "SHA");                     /* hash type */      memset(tmp, 0, sizeof(tmp));      memcpy(tmp, secret_hash, SHA_DIGEST_LENGTH);      EVP_EncodeBlock(val64, tmp, SHA_DIGEST_LENGTH);      xml_new_param(node, "base64", (char *)val64);            /* secret_hash */      sprintf((char *)tmp, "%d", ttl);      xml_new_param(node, "int", (char *)tmp);                  /* lifetime */      break;    case XMLRPC_MODE_GET:      xml_new_param(node, "int", "10");                 /* maxvals */      xml_new_param(node, "base64", "");                /* placemark */      memset(value, 0, *value_len);      break;
开发者ID:carriercomm,项目名称:openhip,代码行数:67,


示例21: msWFSGetCapabilities11

int msWFSGetCapabilities11(mapObj *map, wfsParamsObj *params,                           cgiRequestObj *req, owsRequestObj *ows_request){  xmlDocPtr psDoc = NULL;       /* document pointer */  xmlNodePtr psRootNode, psMainNode, psNode, psFtNode;  const char *updatesequence=NULL;  xmlNsPtr psNsOws, psNsXLink, psNsOgc;  char *schemalocation = NULL;  char *xsi_schemaLocation = NULL;  const char *user_namespace_prefix = NULL;  const char *user_namespace_uri = NULL;  gmlNamespaceListObj *namespaceList=NULL; /* for external application schema support */  char *script_url=NULL, *formats_list;  const char *value = NULL;  const char *encoding;  xmlChar *buffer = NULL;  int size = 0, i;  msIOContext *context = NULL;  int ows_version = OWS_1_0_0;  /* -------------------------------------------------------------------- */  /*      Handle updatesequence                                           */  /* -------------------------------------------------------------------- */  updatesequence = msOWSLookupMetadata(&(map->web.metadata), "FO", "updatesequence");  encoding = msOWSLookupMetadata(&(map->web.metadata), "FO", "encoding");  if (params->pszUpdateSequence != NULL) {    i = msOWSNegotiateUpdateSequence(params->pszUpdateSequence, updatesequence);    if (i == 0) { /* current */      msSetError(MS_WFSERR, "UPDATESEQUENCE parameter (%s) is equal to server (%s)", "msWFSGetCapabilities11()", params->pszUpdateSequence, updatesequence);      return msWFSException11(map, "updatesequence", "CurrentUpdateSequence", params->pszVersion);    }    if (i > 0) { /* invalid */      msSetError(MS_WFSERR, "UPDATESEQUENCE parameter (%s) is higher than server (%s)", "msWFSGetCapabilities11()", params->pszUpdateSequence, updatesequence);      return msWFSException11(map, "updatesequence", "InvalidUpdateSequence", params->pszVersion);    }  }  /* -------------------------------------------------------------------- */  /*      Create document.                                                */  /* -------------------------------------------------------------------- */  psDoc = xmlNewDoc(BAD_CAST "1.0");  psRootNode = xmlNewNode(NULL, BAD_CAST "WFS_Capabilities");  xmlDocSetRootElement(psDoc, psRootNode);  /* -------------------------------------------------------------------- */  /*      Name spaces                                                     */  /* -------------------------------------------------------------------- */  /*default name space*/  xmlNewProp(psRootNode, BAD_CAST "xmlns", BAD_CAST "http://www.opengis.net/wfs");  xmlSetNs(psRootNode, xmlNewNs(psRootNode, BAD_CAST "http://www.opengis.net/gml", BAD_CAST "gml"));  xmlSetNs(psRootNode, xmlNewNs(psRootNode, BAD_CAST "http://www.opengis.net/wfs", BAD_CAST "wfs"));  psNsOws = xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_PREFIX);  psNsXLink = xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_W3C_XLINK_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_W3C_XLINK_NAMESPACE_PREFIX);  xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_W3C_XSI_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_W3C_XSI_NAMESPACE_PREFIX);  xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OGC_NAMESPACE_PREFIX );  value = msOWSLookupMetadata(&(map->web.metadata), "FO", "namespace_uri");  if(value) user_namespace_uri = value;  value = msOWSLookupMetadata(&(map->web.metadata), "FO", "namespace_prefix");  if(value) user_namespace_prefix = value;  if(user_namespace_prefix != NULL && msIsXMLTagValid(user_namespace_prefix) == MS_FALSE)    msIO_printf("<!-- WARNING: The value '%s' is not valid XML namespace. -->/n", user_namespace_prefix);  else    xmlNewNs(psRootNode, BAD_CAST user_namespace_uri, BAD_CAST user_namespace_prefix);  /* any additional namespaces */  namespaceList = msGMLGetNamespaces(&(map->web), "G");  for(i=0; i<namespaceList->numnamespaces; i++) {    if(namespaceList->namespaces[i].uri) {      xmlNewNs(psRootNode, BAD_CAST namespaceList->namespaces[i].uri, BAD_CAST namespaceList->namespaces[i].prefix);    }  }  msGMLFreeNamespaces(namespaceList);    xmlNewProp(psRootNode, BAD_CAST "version", BAD_CAST params->pszVersion );  updatesequence = msOWSLookupMetadata(&(map->web.metadata), "FO", "updatesequence");  if (updatesequence)    xmlNewProp(psRootNode, BAD_CAST "updateSequence", BAD_CAST updatesequence);  /*schema*/  schemalocation = msEncodeHTMLEntities( msOWSGetSchemasLocation(map) );  xsi_schemaLocation = msStrdup("http://www.opengis.net/wfs");  xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, " ");  xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, schemalocation);  xsi_schemaLocation = msStringConcatenate(xsi_schemaLocation, "/wfs/1.1.0/wfs.xsd");  xmlNewNsProp(psRootNode, NULL, BAD_CAST "xsi:schemaLocation", BAD_CAST xsi_schemaLocation);//.........这里部分代码省略.........
开发者ID:lydonchandra,项目名称:MapServer-SpeedUp,代码行数:101,


示例22: dns_getconfig

xmlNodePtr dns_getconfig(xmlNsPtr ns, char** msg){	int i, done;	char* path, *content = NULL;	const char* value;	xmlNodePtr dns_node, server, aux_node;	assert(sysaugeas);	/* dns-resolver */	dns_node = xmlNewNode(ns, BAD_CAST "dns-resolver");	/* dns-resolver/search[] */	for (i = 1, done = 0; !done; i++) {		path = NULL;		asprintf(&path, "/files/"AUGEAS_DNS_CONF"/search/domain[%d]", i);		switch (aug_match(sysaugeas, path, NULL)) {		case -1:			asprintf(msg, "Augeas match for /"%s/" failed: %s", path, aug_error_message(sysaugeas));			free(path);			xmlFreeNode(dns_node);			return (NULL);		case 0:			/* index out of bounds, continue with next server type */			free(path);			done = 1;			break;		default: /* 1 */			/* dns-resolver/search */			aug_get(sysaugeas, path, &value);			xmlNewChild(dns_node, dns_node->ns, BAD_CAST "search", BAD_CAST value);			free(path); path = NULL;			break;		}	}	/* dns-resolver/server[] */	for (i = 1, done = 0; !done; i++) {		path = NULL;		asprintf(&path, "/files/"AUGEAS_DNS_CONF"/nameserver[%d]", i);		switch (aug_match(sysaugeas, path, NULL)) {		case -1:			asprintf(msg, "Augeas match for /"%s/" failed: %s", path, aug_error_message(sysaugeas));			free(path);			xmlFreeNode(dns_node);			return (NULL);		case 0:			/* index out of bounds, continue with next server type */			free(path);			done = 1;			break;		default: /* 1 */			/* dns-resolver/server */			server = xmlNewChild(dns_node, dns_node->ns, BAD_CAST "server", NULL);			/* dns-resolver/server/name */			asprintf(&content, "nameserver-%d", i);			xmlNewChild(server, server->ns, BAD_CAST "name", BAD_CAST content);			free(content);			/* dns-resolver/server/udp-and-tcp/address */			aug_get(sysaugeas, path, &value);			aux_node = xmlNewChild(server, server->ns, BAD_CAST "udp-and-tcp", NULL);			xmlNewChild(aux_node, aux_node->ns, BAD_CAST "address", BAD_CAST value);			free(path);			/* port specification is not supported by Linux dns resolver implementation */			break;		}	}	/* dns-resolver/options */	switch (aug_match(sysaugeas, "/files/"AUGEAS_DNS_CONF"/options", NULL)) {	case -1:		asprintf(msg, "Augeas match for /"%s/" failed: %s", path, aug_error_message(sysaugeas));		free(path);		xmlFreeNode(dns_node);		return (NULL);	case 0:		/* No options specified */		break;	default: /* 1 */		aux_node = xmlNewChild(dns_node, dns_node->ns, BAD_CAST "options", NULL);		/* dns-resolver/options/timeout */		value = NULL;		aug_get(sysaugeas, "/files/"AUGEAS_DNS_CONF"/options/timeout", &value);		if (value != NULL) {			xmlNewChild(aux_node, aux_node->ns, BAD_CAST "timeout", BAD_CAST value);		}		/* dns-resolver/options/attempts */		value = NULL;		aug_get(sysaugeas, "/files/"AUGEAS_DNS_CONF"/options/attempts", &value);		if (value != NULL) {			xmlNewChild(aux_node, aux_node->ns, BAD_CAST "attempts", BAD_CAST value);		}//.........这里部分代码省略.........
开发者ID:billleblanc,项目名称:netopeer,代码行数:101,


示例23: xmlNewDoc

char *uwsgi_format_airbrake_backtrace(struct uwsgi_thread *ut) {	struct uwsgi_airbrake_config *uacc = (struct uwsgi_airbrake_config *) ut->data;	xmlChar *xmlbuff;	int buffersize;	xmlDocPtr doc = NULL;	xmlNodePtr notice_node = NULL, node = NULL, line_node = NULL, errnode = NULL;	char *msg = NULL;	doc = xmlNewDoc(BAD_CAST "1.0");	notice_node = xmlNewNode(NULL, BAD_CAST "notice");	xmlNewProp(notice_node, BAD_CAST "version", BAD_CAST "2.3");	xmlDocSetRootElement(doc, notice_node);	xmlNewChild(notice_node, NULL, BAD_CAST "api-key", BAD_CAST uacc->apikey);	node = xmlNewChild(notice_node, NULL, BAD_CAST "notifier", NULL);	xmlNewChild(node, NULL, BAD_CAST "name", BAD_CAST "uWSGI");	xmlNewChild(node, NULL, BAD_CAST "version", BAD_CAST UWSGI_VERSION);	xmlNewChild(node, NULL, BAD_CAST "url", BAD_CAST "https://github.com/unbit/uwsgi");	// request env	node = xmlNewChild(notice_node, NULL, BAD_CAST "request", NULL);	node = xmlNewChild(node, NULL, BAD_CAST "cgi-data", NULL);	line_node = xmlNewChild(node, NULL, BAD_CAST "var", BAD_CAST UWSGI_VERSION);	xmlNewProp(line_node, BAD_CAST "key", BAD_CAST "uwsgi_version");	line_node = xmlNewChild(node, NULL, BAD_CAST "var", BAD_CAST __VERSION__);	xmlNewProp(line_node, BAD_CAST "key", BAD_CAST "compiled_with_version");	struct utsname uuts;#ifdef __sun__	if (uname(&uuts) < 0) {#else	if (uname(&uuts)) {#endif		uwsgi_error("uname()");	}	else {		line_node = xmlNewChild(node, NULL, BAD_CAST "var", BAD_CAST uuts.sysname);		xmlNewProp(line_node, BAD_CAST "key", BAD_CAST "os_sysname");		char *os_version = uwsgi_concat3(uuts.release, "-", uuts.version);		line_node = xmlNewChild(node, NULL, BAD_CAST "var", BAD_CAST os_version);		xmlNewProp(line_node, BAD_CAST "key", BAD_CAST "os_version");		free(os_version);		line_node = xmlNewChild(node, NULL, BAD_CAST "var", BAD_CAST uuts.machine);		xmlNewProp(line_node, BAD_CAST "key", BAD_CAST "machine");		line_node = xmlNewChild(node, NULL, BAD_CAST "var", BAD_CAST uuts.nodename);		xmlNewProp(line_node, BAD_CAST "key", BAD_CAST "nodename");	}	// end request env	node = xmlNewChild(notice_node, NULL, BAD_CAST "server-environment", NULL);	xmlNewChild(node, NULL, BAD_CAST "app-version", BAD_CAST UWSGI_VERSION);	if (uacc->env) {		xmlNewChild(node, NULL, BAD_CAST "environment-name", BAD_CAST uacc->env);	}	else {		xmlNewChild(node, NULL, BAD_CAST "environment-name", BAD_CAST UWSGI_VERSION);	}	errnode = xmlNewChild(notice_node, NULL, BAD_CAST "error", NULL);	xmlNewChild(errnode, NULL, BAD_CAST "class", BAD_CAST "RuntimeError");	node = xmlNewChild(errnode, NULL, BAD_CAST "backtrace", NULL);	char *ctx = NULL;	char *text = uwsgi_str(ut->buf);	char *p = strtok_r(text, "/n", &ctx);	while (p) {		// skip log messages		if (!uwsgi_startswith(p, "***", 3))			goto next;		// backtrace line looks like this: uwsgi(simple_loop_run+0xc5) [0x451555]		// we take binary/lib as filename		// and extract method name from remaining string		char *n = strchr(p, '(');		if (n) {			*n = 0;			char *pls = strchr(n+1, '+');			if (pls) {				*pls = 0;			}			if (!strcmp("uwsgi_backtrace", n+1) || !strcmp("what_i_am_doing", n+1)) {				goto next;			}			else if (!strcmp("uwsgi_fpe", n+1)) {				msg = uwsgi_concat4("uWSGI FPE at ", n+1, " in ", p);				goto next;			}			if (!msg) {				if (strlen(n+1)) {//.........这里部分代码省略.........
开发者ID:IsCoolEntertainment,项目名称:debpkg_uwsgi,代码行数:101,


示例24: xccdf_tailoring_to_dom

xmlNodePtr xccdf_tailoring_to_dom(struct xccdf_tailoring *tailoring, xmlDocPtr doc, xmlNodePtr parent, const struct xccdf_version_info *version_info){	xmlNs *ns_xccdf = xmlSearchNsByHref(doc, parent,				BAD_CAST xccdf_version_info_get_namespace_uri(version_info));	xmlNs *ns_tailoring = NULL;	xmlNode *tailoring_node = xmlNewNode(ns_xccdf, BAD_CAST "Tailoring");	const char *xccdf_version = xccdf_version_info_get_version(version_info);#ifdef __USE_GNU	if (strverscmp(xccdf_version, "1.1") >= 0 && strverscmp(xccdf_version, "1.2") < 0) {#else	if (strcmp(xccdf_version, "1.1") >= 0 && strcmp(xccdf_version, "1.2") < 0) {#endif		// XCCDF 1.1 does not support Tailoring!		// However we will allow Tailoring export if it is done to an external		// file. The namespace will be our custom xccdf-1.1-tailoring extension		// namespace.		if (parent != NULL) {			oscap_seterr(OSCAP_EFAMILY_XML, "XCCDF 1.1 does not support embedded Tailoring elements!");			xmlFreeNode(tailoring_node);			return NULL;		}		ns_tailoring = xmlNewNs(tailoring_node,			BAD_CAST "http://open-scap.org/page/Xccdf-1.1-tailoring",			BAD_CAST "cdf-11-tailoring"		);	}#ifdef __USE_GNU	else if (strverscmp(xccdf_version, "1.1") < 0) {#else	else if (strcmp(xccdf_version, "1.1") < 0) {#endif		oscap_seterr(OSCAP_EFAMILY_XML, "XCCDF Tailoring isn't supported in XCCDF version '%s',"			"nor does openscap have a custom extension for this scenario. "			"XCCDF Tailoring requires XCCDF 1.1 and higher, 1.2 is recommended.");		xmlFreeNode(tailoring_node);		return NULL;	}	if (!ns_xccdf) {		// In cases where tailoring ends up being the root node we have to create		// a namespace at the node itself.		ns_xccdf = xmlNewNs(tailoring_node,			BAD_CAST xccdf_version_info_get_namespace_uri(version_info),			BAD_CAST "xccdf");	}	if (!ns_tailoring)		ns_tailoring = ns_xccdf;	// We intentionally set the wrong namespace here since children of tailoring	// will reuse it and we want them to have the xccdf namespace, the namespace	// is set to the proper namespace before returning the tailoring.	xmlSetNs(tailoring_node, ns_xccdf);	if (parent)		xmlAddChild(parent, tailoring_node);	else		xmlDocSetRootElement(doc, tailoring_node);	if (tailoring->id) {		xmlNewProp(tailoring_node, BAD_CAST "id", BAD_CAST tailoring->id);	}	if (tailoring->benchmark_ref || tailoring->benchmark_ref_version) {		xmlNodePtr benchmark_ref_node = xmlNewChild(tailoring_node, ns_tailoring, BAD_CAST "benchmark", NULL);		if (tailoring->benchmark_ref)			xmlNewProp(benchmark_ref_node, BAD_CAST "href", BAD_CAST tailoring->benchmark_ref);		if (tailoring->benchmark_ref_version)			xmlNewProp(benchmark_ref_node, BAD_CAST "version", BAD_CAST tailoring->benchmark_ref_version);	}	struct xccdf_status_iterator *statuses = xccdf_tailoring_get_statuses(tailoring);	while (xccdf_status_iterator_has_more(statuses)) {		struct xccdf_status *status = xccdf_status_iterator_next(statuses);		xccdf_status_to_dom(status, doc, tailoring_node, version_info);	}	xccdf_status_iterator_free(statuses);	struct oscap_reference_iterator *dc_statuses = xccdf_tailoring_get_dc_statuses(tailoring);	while (oscap_reference_iterator_has_more(dc_statuses)) {		struct oscap_reference *ref = oscap_reference_iterator_next(dc_statuses);		oscap_reference_to_dom(ref, tailoring_node, doc, "dc-status");	}	oscap_reference_iterator_free(dc_statuses);	/* version and attributes */	const char *version = xccdf_tailoring_get_version(tailoring);	if (version) {		xmlNode* version_node = xmlNewTextChild(tailoring_node, ns_tailoring, BAD_CAST "version", BAD_CAST version);		const char *version_update = xccdf_tailoring_get_version_update(tailoring);		if (version_update)//.........这里部分代码省略.........
开发者ID:GovReady,项目名称:openscap,代码行数:101,


示例25: EBC_Provider_MkEuZipDoc_A004

int EBC_Provider_MkEuZipDoc_A004(AB_PROVIDER *pro,				 AB_USER *u,				 const char *requestType,				 const uint8_t *pMsg,				 uint32_t lMsg,				 GWEN_BUFFER *sbuf) {  int rv;  xmlDocPtr doc;  xmlNodePtr root_node;  xmlNodePtr node;  xmlNsPtr ns;  GWEN_BUFFER *tbuf;  GWEN_BUFFER *bbuf;  tbuf=GWEN_Buffer_new(0, 256, 0, 1);  rv=EBC_Provider_EuSign_A004(pro, u, requestType, pMsg, lMsg, tbuf);  if (rv) {    DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv);    GWEN_Buffer_free(tbuf);    return rv;  }  bbuf=GWEN_Buffer_new(0, (GWEN_Buffer_GetUsedBytes(tbuf)*3)/2, 0, 1);  rv=GWEN_Base64_Encode((const uint8_t*)GWEN_Buffer_GetStart(tbuf),			GWEN_Buffer_GetUsedBytes(tbuf),			bbuf, 0);  if (rv<0) {    DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv);    GWEN_Buffer_free(bbuf);    GWEN_Buffer_free(tbuf);    return rv;  }  GWEN_Buffer_free(tbuf);  doc=xmlNewDoc(BAD_CAST "1.0");  root_node=xmlNewNode(NULL, BAD_CAST "UserSignatureData");  xmlDocSetRootElement(doc, root_node);  ns=xmlNewNs(root_node,	      BAD_CAST "http://www.ebics.org/H002",	      NULL);  assert(ns);  ns=xmlNewNs(root_node,	      BAD_CAST "http://www.w3.org/2001/XMLSchema-instance",	      BAD_CAST "xsi");  xmlNewNsProp(root_node,	       ns,	       BAD_CAST "schemaLocation", /* xsi:schemaLocation */	       BAD_CAST "http://www.ebics.org/H002 "	       "http://www.ebics.org/H002/ebics_orders.xsd");  node=xmlNewTextChild(root_node, NULL,		       BAD_CAST "OrderSignature",		       BAD_CAST GWEN_Buffer_GetStart(bbuf));  GWEN_Buffer_free(bbuf);  xmlNewProp(node,	     BAD_CAST "PartnerID",	     BAD_CAST AB_User_GetCustomerId(u));  rv=EB_Xml_CompressDoc(doc, sbuf);  if (rv<0) {    DBG_INFO(AQEBICS_LOGDOMAIN, "here (%d)", rv);    xmlFreeDoc(doc);    return rv;  }  xmlFreeDoc(doc);  return 0;}
开发者ID:Zauberstuhl,项目名称:aqbanking,代码行数:73,


示例26: residue2xml

static xmlNodePtrresidue2xml(const freesasa_node *node,            int options){    xmlNodePtr xml_node = NULL, xml_area = NULL, xml_relarea = NULL;    const char *name, *number;    const freesasa_nodearea *abs, *reference;    char *trim_number, *trim_name;    freesasa_nodearea rel;    assert(node);    name = freesasa_node_name(node);    number = freesasa_node_residue_number(node);    abs = freesasa_node_area(node);    reference = freesasa_node_residue_reference(node);    trim_number = malloc(strlen(number) + 1);    trim_name = malloc(strlen(name) + 1);    if (!trim_number || ! trim_name) {        mem_fail();        goto cleanup;    }    sscanf(number, "%s", trim_number);    sscanf(name, "%s", trim_name);    xml_node = xmlNewNode(NULL, BAD_CAST "residue");    if (xml_node == NULL) {        fail_msg("");        return NULL;    }    if (xmlNewProp(xml_node, BAD_CAST "name", BAD_CAST trim_name) == NULL ||        xmlNewProp(xml_node, BAD_CAST "number", BAD_CAST trim_number) == NULL) {        fail_msg("");        goto cleanup;    }    xml_area = nodearea2xml(abs, "area");    if (xml_area == NULL) {        fail_msg("");        goto cleanup;    }    if (xmlAddChild(xml_node, xml_area) == NULL) {        xmlFreeNode(xml_area);        fail_msg("");        goto cleanup;    }    if ((reference != NULL) && !(options & FREESASA_OUTPUT_SKIP_REL)) {        freesasa_residue_rel_nodearea(&rel, abs, reference);        xml_relarea = nodearea2xml(&rel, "relativeArea");        if (xml_relarea == NULL) {            fail_msg("");            goto cleanup;        }        if (xmlAddChild(xml_node, xml_relarea) == NULL) {            xmlFreeNode(xml_relarea);            fail_msg("");            goto cleanup;        }    }    free(trim_name);    free(trim_number);    return xml_node; cleanup:    free(trim_name);    free(trim_number);    xmlFreeNode(xml_node);    return NULL;}
开发者ID:mittinatten,项目名称:freesasa,代码行数:75,


示例27: xmlNewNode

xmlNode* CXBindingsObjectHandler::DoWriteResource(){	CXBindingsObject* object = dynamic_cast<CXBindingsObject*>(m_instance);	xmlNode* node = xmlNewNode( NULL , (const xmlChar*) "object" );		xmlNewProp( node , (const xmlChar*) "type" , cxxU2C( object->GetName() ) );		CXBindingsArrayGrammarChild& childs = object->GetChilds();	for( unsigned int i = 0; i < childs.size() ; ++i )	{		xmlNode* child = CXBindingsXmlReader::Get()->WriteResource( &(childs[i]) );		if( child != NULL )			xmlAddChild( node , child );	}	CXBindingsArrayGrammarRule& rules = object->GetRules();	for( unsigned int i = 0; i < rules.size() ; ++i )	{		xmlNode* childnode = CXBindingsXmlReader::Get()->WriteResource( &(rules[i]) );		if( childnode != NULL )			xmlAddChild( node , childnode );	}	CXBindingsArrayGrammarProperty& properties = object->GetProperties();	for( unsigned int i = 0; i < properties.size() ; ++i )	{		xmlNode* childnode = CXBindingsXmlReader::Get()->WriteResource( &(properties[i]) );		if( childnode != NULL )			xmlAddChild( node , childnode );	}		CXBindingsArrayGrammarForEachChild& childRules = object->GetChildRules();	for( unsigned int i = 0; i < childRules.size() ; ++i )	{		xmlNode* childnode = CXBindingsXmlReader::Get()->WriteResource( &(childRules[i]) );		if( childnode != NULL )			xmlAddChild( node , childnode );	}	CXBindingsArrayGrammarCategory& categories = object->GetCategories();	for( unsigned int i = 0; i < categories.size() ; ++i )	{		xmlNode* childnode = CXBindingsXmlReader::Get()->WriteResource( &(categories[i]) );		if( childnode != NULL )			xmlAddChild( node , childnode );	}	CXBindingsArrayGrammarChildContainer& childcontainers = object->GetChildContainers();	for( unsigned int i = 0; i < childcontainers.size() ; ++i )	{		xmlNode* childnode = CXBindingsXmlReader::Get()->WriteResource( &(childcontainers[i]) );		if( childnode != NULL )			xmlAddChild( node , childnode );	}	CXBindingsArrayGrammarInherits& inherits = object->GetModels();	for( unsigned int i = 0; i < inherits.size() ; ++i )	{		xmlNode* childnode = CXBindingsXmlReader::Get()->WriteResource( &(inherits[i]) );		if( childnode != NULL )			xmlAddChild( node , childnode );	}	return node;}
开发者ID:nmacherey,项目名称:cxbindings,代码行数:73,


示例28: freesasa_write_xml

intfreesasa_write_xml(FILE *output,                   freesasa_node *root,                   int options){    freesasa_node *child = NULL;    xmlDocPtr doc = NULL;    xmlNodePtr xml_root = NULL, xml_result_node = NULL;    xmlNsPtr ns = NULL;    xmlBufferPtr buf = NULL;    xmlTextWriterPtr writer = NULL;    int ret = FREESASA_FAIL;    assert(freesasa_node_type(root) == FREESASA_NODE_ROOT);    doc = xmlNewDoc(BAD_CAST "1.0");    if (doc == NULL) {        fail_msg("");        goto cleanup;    }    xml_root = xmlNewNode(NULL, BAD_CAST "results");    if (xml_root == NULL) {        fail_msg("");        goto cleanup;    }    ns = xmlNewNs(xml_root, BAD_CAST FREESASA_XMLNS, NULL);    if (ns == NULL) {        fail_msg("");        xmlFreeNode(xml_root);        goto cleanup;    }    xmlDocSetRootElement(doc, xml_root);    /* global attributes */    if (xmlNewProp(xml_root, BAD_CAST "source", BAD_CAST freesasa_string) == NULL) {        fail_msg("");        goto cleanup;    }    if (xmlNewProp(xml_root, BAD_CAST "lengthUnit", BAD_CAST "
C++ xmlNewNs函数代码示例
C++ xmlNewDocNode函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。