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


C++ xmlSetProp函数代码示例

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


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

示例1: base_tool_output_result_to_string

/**
 * base_tool_output_result_to_string:
 * @res: a #ToolCommandResult
 * @format: a #ToolOutputFormat format specification
 * @stream: (allow-none): a stream which the returned string will be put to, or %NULL
 * @options: (allow-none): a #GdaSet containing options, or %NULL
 *
 * Converts @res to a string
 *
 * Returns: (transfer full): a new string
 */
gchar *
base_tool_output_result_to_string (ToolCommandResult *res, ToolOutputFormat format,
                                   FILE *stream, GdaSet *options)
{
    switch (res->type) {
    case BASE_TOOL_COMMAND_RESULT_DATA_MODEL:
        return base_tool_output_data_model_to_string (res->u.model, format, stream, options);

    case BASE_TOOL_COMMAND_RESULT_SET: {
        GSList *list;
        GString *string;
        xmlNodePtr node;
        xmlBufferPtr buffer;
        gchar *str;

        if (format & BASE_TOOL_OUTPUT_FORMAT_DEFAULT) {
            string = g_string_new ("");
            for (list = res->u.set->holders; list; list = list->next) {
                const GValue *value;
                gchar *tmp;
                const gchar *cstr;
                GdaHolder *h;
                h = GDA_HOLDER (list->data);

                cstr = gda_holder_get_id (h);
                value = gda_holder_get_value (h);
                if (!strcmp (cstr, "IMPACTED_ROWS")) {
                    g_string_append_printf (string, "%s: ",
                                            _("Number of rows impacted"));
                    tmp = gda_value_stringify (value);
                    g_string_append_printf (string, "%s", tmp);
                    g_free (tmp);
                }
                else if (!strcmp (cstr, "EXEC_DELAY")) {
                    g_string_append_printf (string, "%s: ",
                                            _("Execution delay"));
                    gdouble etime;
                    etime = g_value_get_double (value);
                    g_string_append_printf (string, "%.03f s", etime);
                }
                else {
                    tmp = g_markup_escape_text (cstr, -1);
                    g_string_append_printf (string, "%s: ", tmp);
                    g_free (tmp);

                    tmp = gda_value_stringify (value);
                    g_string_append_printf (string, "%s", tmp);
                    g_free (tmp);
                }
                g_string_append (string, "\n");
            }
            str = string->str;
            g_string_free (string, FALSE);
            return str;
        }
        else if (format & BASE_TOOL_OUTPUT_FORMAT_XML) {
            buffer = xmlBufferCreate ();
            node = xmlNewNode (NULL, BAD_CAST "parameters");
            for (list = res->u.set->holders; list; list = list->next) {
                const GValue *value;
                xmlNodePtr pnode, vnode;

                pnode = xmlNewNode (NULL, BAD_CAST "parameter");
                xmlAddChild (node, pnode);
                xmlSetProp (pnode, BAD_CAST "name",
                            BAD_CAST gda_holder_get_id (GDA_HOLDER (list->data)));
                value = gda_holder_get_value (GDA_HOLDER (list->data));
                vnode = gda_value_to_xml (value);
                xmlAddChild (pnode, vnode);
            }
            xmlNodeDump (buffer, NULL, node, 0, 1);
            str = g_strdup ((gchar *) xmlBufferContent (buffer));
            xmlBufferFree (buffer);
            xmlFreeNode (node);
            return str;
        }
        else if (format & BASE_TOOL_OUTPUT_FORMAT_HTML) {
            buffer = xmlBufferCreate ();
            node = xmlNewNode (NULL, BAD_CAST "ul");
            for (list = res->u.set->holders; list; list = list->next) {
                const GValue *value;
                xmlNodePtr pnode, vnode;

                pnode = xmlNewNode (NULL, BAD_CAST "li");
                xmlAddChild (node, pnode);
                xmlSetProp (pnode, BAD_CAST "name",
                            BAD_CAST gda_holder_get_id (GDA_HOLDER (list->data)));
                value = gda_holder_get_value (GDA_HOLDER (list->data));
                vnode = gda_value_to_xml (value);
//.........这里部分代码省略.........
开发者ID:arthurnn,项目名称:libgda,代码行数:101,代码来源:base-tool-output.c

示例2: command_manageauth

static void command_manageauth(client_t *client, source_t *source,
    int response)
{
    xmlDocPtr doc;
    xmlNodePtr node, srcnode, msgnode;
    const char *action = NULL;
    const char *username = NULL;
    char *message = NULL;
    int ret = AUTH_OK;
    ice_config_t *config = config_get_config ();
    mount_proxy *mountinfo = config_find_mount (config, source->mount);

    do
    {
        if (mountinfo == NULL || mountinfo->auth == NULL)
        {
            WARN1 ("manage auth request for %s but no facility available", source->mount);
            break;
        }
        COMMAND_OPTIONAL(client, "action", action);
        COMMAND_OPTIONAL (client, "username", username);

        if (action == NULL)
            action = "list";

        if (!strcmp(action, "add"))
        {
            const char *password = NULL;
            COMMAND_OPTIONAL (client, "password", password);

            if (username == NULL || password == NULL)
            {
                WARN1 ("manage auth request add for %s but no user/pass", source->mount);
                break;
            }
            ret = mountinfo->auth->adduser(mountinfo->auth, username, password);
            if (ret == AUTH_FAILED) {
                message = strdup("User add failed - check the icecast error log");
            }
            if (ret == AUTH_USERADDED) {
                message = strdup("User added");
            }
            if (ret == AUTH_USEREXISTS) {
                message = strdup("User already exists - not added");
            }
        }
        if (!strcmp(action, "delete"))
        {
            if (username == NULL)
            {
                WARN1 ("manage auth request delete for %s but no username", source->mount);
                break;
            }
            ret = mountinfo->auth->deleteuser(mountinfo->auth, username);
            if (ret == AUTH_FAILED) {
                message = strdup("User delete failed - check the icecast error log");
            }
            if (ret == AUTH_USERDELETED) {
                message = strdup("User deleted");
            }
        }

        doc = xmlNewDoc (XMLSTR("1.0"));
        node = xmlNewDocNode(doc, NULL, XMLSTR("icestats"), NULL);
        srcnode = xmlNewChild(node, NULL, XMLSTR("source"), NULL);
        xmlSetProp(srcnode, XMLSTR("mount"), XMLSTR(source->mount));

        if (message) {
            msgnode = xmlNewChild(node, NULL, XMLSTR("iceresponse"), NULL);
            xmlNewChild(msgnode, NULL, XMLSTR("message"), XMLSTR(message));
        }

        xmlDocSetRootElement(doc, node);

        if (mountinfo && mountinfo->auth && mountinfo->auth->listuser)
            mountinfo->auth->listuser (mountinfo->auth, srcnode);

        config_release_config ();

        admin_send_response(doc, client, response, 
                MANAGEAUTH_TRANSFORMED_REQUEST);
        free (message);
        xmlFreeDoc(doc);
        return;
    } while (0);

    config_release_config ();
    client_send_400 (client, "missing parameter");
}
开发者ID:krattai,项目名称:AEBL,代码行数:89,代码来源:admin.c

示例3: xmlSetProp

void XmlNode::property(std::string n, std::string v)
{
    ::cleanXml( n );
    ::cleanXml( v );
    xmlSetProp(node_, (xmlChar*) n.c_str(), (xmlChar*) v.c_str());
}
开发者ID:tdphong,项目名称:FrontEnd,代码行数:6,代码来源:xmlnode.cpp

示例4: send_sessions

int DEFAULT_CC
send_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,代码来源:sesman.c

示例5: send_logoff

int DEFAULT_CC
send_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,代码来源:sesman.c

示例6: xmlSetProp

void XmlNodo::setPropiedad(const std::string& nombre, const std::string& valor) {
	xmlSetProp(nodo, (const xmlChar*) nombre.c_str(), (const xmlChar*) valor.c_str());
}
开发者ID:pablomagnaghi,项目名称:tptaller2chimi,代码行数:3,代码来源:XmlNodo.cpp

示例7: invoice_dom_tree_create

static xmlNodePtr
invoice_dom_tree_create (GncInvoice* invoice)
{
    xmlNodePtr ret;
    Timespec ts;
    Transaction* txn;
    GNCLot* lot;
    Account* acc;
    GncBillTerm* term;
    GncOwner* billto;
    gnc_numeric amt;

    ret = xmlNewNode (NULL, BAD_CAST gnc_invoice_string);
    xmlSetProp (ret, BAD_CAST "version", BAD_CAST invoice_version_string);

    xmlAddChild (ret, guid_to_dom_tree (invoice_guid_string,
                                        qof_instance_get_guid (QOF_INSTANCE (invoice))));

    xmlAddChild (ret, text_to_dom_tree (invoice_id_string,
                                        gncInvoiceGetID (invoice)));

    xmlAddChild (ret, gnc_owner_to_dom_tree (invoice_owner_string,
                                             gncInvoiceGetOwner (invoice)));

    ts = gncInvoiceGetDateOpened (invoice);
    xmlAddChild (ret, timespec_to_dom_tree (invoice_opened_string, &ts));

    maybe_add_timespec (ret, invoice_posted_string,
                        gncInvoiceGetDatePosted (invoice));

    term = gncInvoiceGetTerms (invoice);
    if (term)
        xmlAddChild (ret, guid_to_dom_tree (invoice_terms_string,
                                            qof_instance_get_guid (QOF_INSTANCE (term))));

    maybe_add_string (ret, invoice_billing_id_string,
                      gncInvoiceGetBillingID (invoice));
    maybe_add_string (ret, invoice_notes_string, gncInvoiceGetNotes (invoice));

    xmlAddChild (ret, int_to_dom_tree (invoice_active_string,
                                       gncInvoiceGetActive (invoice)));

    txn = gncInvoiceGetPostedTxn (invoice);
    if (txn)
        xmlAddChild (ret, guid_to_dom_tree (invoice_posttxn_string,
                                            xaccTransGetGUID (txn)));

    lot = gncInvoiceGetPostedLot (invoice);
    if (lot)
        xmlAddChild (ret, guid_to_dom_tree (invoice_postlot_string,
                                            gnc_lot_get_guid (lot)));

    acc = gncInvoiceGetPostedAcc (invoice);
    if (acc)
        xmlAddChild (ret, guid_to_dom_tree (invoice_postacc_string,
                                            qof_instance_get_guid (QOF_INSTANCE (acc))));

    xmlAddChild
    (ret,
     commodity_ref_to_dom_tree (invoice_currency_string,
                                gncInvoiceGetCurrency (invoice)));

    billto = gncInvoiceGetBillTo (invoice);
    if (billto && billto->owner.undefined != NULL)
        xmlAddChild (ret, gnc_owner_to_dom_tree (invoice_billto_string, billto));

    amt = gncInvoiceGetToChargeAmount (invoice);
    if (! gnc_numeric_zero_p (amt))
        xmlAddChild (ret, gnc_numeric_to_dom_tree (invoice_tochargeamt_string, &amt));

    /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */
    xmlAddChild (ret, qof_instance_slots_to_dom_tree (invoice_slots_string,
                                                      QOF_INSTANCE (invoice)));
    return ret;
}
开发者ID:Bob-IT,项目名称:gnucash,代码行数:75,代码来源:gnc-invoice-xml-v2.cpp

示例8: build_mgmt_response

/*
 * build_mgmt_response -- sets an XML doc with a root and calls a porper
 *	    routine based on the request.  If the called routine constructed
 *	    the response doc with the result element, this routine fills up
 *	    response buffer with raw XML doc.
 *
 * reponse: ptr to response buffer
 * req: request to be processed.
 * size: ptr to the response doc buffer
 */
static int
build_mgmt_response(xmlChar **response, request_t req, int *size)
{

	int ret;
	xmlDocPtr	doc;
	xmlNodePtr	root;
	xmlXPathContextPtr ctext = NULL;
	xmlChar expr[ISNS_MAX_LABEL_LEN + 13];
	xmlXPathObjectPtr xpath_obj = NULL;

	isnslog(LOG_DEBUG, "build_mgmt_response", "entered");

	doc = xmlNewDoc((uchar_t *)"1.0");
	root = xmlNewNode(NULL, (xmlChar *)ISNSRESPONSE);
	(void) xmlDocSetRootElement(doc, root);
	if (xmlSetProp(root, (xmlChar *)XMLNSATTR, (xmlChar *)XMLNSATTRVAL) ==
	    NULL) {
	    return (ERR_XML_SETPROP_FAILED);
	}

	switch (req.op_info.op) {
	    case get_op:
		switch (req.op_info.obj) {
		    case Node:
			ret = get_node_op(&req, doc);
			break;
		    case DiscoveryDomain:
			ret = get_dd_op(&req, doc);
			break;
		    case DiscoveryDomainSet:
			ret = get_ddset_op(&req, doc);
			break;
		    case ServerConfig:
			ret = get_serverconfig_op(doc);
			break;
		    default:
			ret = ERR_INVALID_MGMT_REQUEST;
		}
		break;
	    case enumerate_op:
		isnslog(LOG_DEBUG, "build_mgmt_response", "enumerate_op");
		switch (req.op_info.obj) {
		    case Node:
			ret = enumerate_node_op(doc);
			break;
		    case DiscoveryDomain:
			ret = enumerate_dd_op(doc);
			break;
		    case DiscoveryDomainSet:
			ret = enumerate_ddset_op(doc);
			break;
		    default:
			ret = ERR_INVALID_MGMT_REQUEST;
		}
		break;
	    case getAssociated_op:
		switch (req.op_info.obj) {
		    case DiscoveryDomainMember:
			if (req.assoc_req == container_to_member) {
			    ret = getAssociated_dd_to_node_op(&req, doc);
			} else {
			    ret = getAssociated_node_to_dd_op(&req, doc);
			}
			break;
		    case DiscoveryDomainSetMember:
			if (req.assoc_req == container_to_member) {
			    ret = getAssociated_ddset_to_dd_op(&req, doc);
			} else {
			    ret = getAssociated_dd_to_ddset_op(&req, doc);
			}
			break;
		    default:
			ret = ERR_INVALID_MGMT_REQUEST;
		}
		break;
	    case createModify_op:
		switch (req.op_info.obj) {
		    case DiscoveryDomain:
		    case DiscoveryDomainSet:
			ret = createModify_dd_ddset_op(&req, doc);
			break;
		    case DiscoveryDomainMember:
		    case DiscoveryDomainSetMember:
			ret = create_ddmember_ddsetmember_op(&req, doc,
			    req.op_info.obj);
			break;
		    default:
			ret = ERR_INVALID_MGMT_REQUEST;
		}
//.........这里部分代码省略.........
开发者ID:bahamas10,项目名称:openzfs,代码行数:101,代码来源:door.c

示例9: loadThesaurus


//.........这里部分代码省略.........
										// build a link to cterms
										snprintf(strbuff, 1000, "|    searching cbranch ' %s ' in cterms \n", indexer->tStructField[i].cbranch);
										cstr += strbuff;

										// check if cterms has a branch '...field='..zfname..'...
										xmlXPathObjectPtr  xpathObj_cterms = NULL;

										xpathObj_cterms = xmlXPathEvalExpression((const xmlChar*)(indexer->tStructField[i].cbranch), indexer->XPathCtx_cterms);
										if(xpathObj_cterms != NULL)
										{
											if(!xpathObj_cterms->nodesetval || xpathObj_cterms->nodesetval->nodeNr == 0)
											{
												// the branch does not exists, create it

												cstr += "|    -> node not found, creating \n";

												xmlNodePtr root = xmlDocGetRootElement(indexer->DocCterms);

												// get nextid
												xmlChar *nextid;
												if( (nextid = xmlGetProp(root, (const xmlChar *)"nextid")) )
												{
													int l = strlen((const char *)nextid);
													if(l > 32)
														l = 32;
													xmlNodePtr te;
													if((te = xmlNewChild(root, NULL, (const xmlChar*)"te", NULL)) != NULL)
													{
														char ibuff[33];

														// prop 'id'
														ibuff[0] = 'C';
														memcpy(ibuff+1, nextid, l+1);
														xmlSetProp(te, (const xmlChar*)"id", (const xmlChar *)ibuff);

														// prop 'field'
														xmlSetProp(te, (const xmlChar*)"field", (const xmlChar *)(indexer->tStructField[i].name));

														// prop 'nextid'
														xmlSetProp(te, (const xmlChar*)"nextid", (const xmlChar *)"0");

														// inc nextid
														sprintf(ibuff, "%d", atoi((const char *)nextid) + 1);
														xmlSetProp(root, (const xmlChar*)"nextid", (const xmlChar *)ibuff );

														// put a xpathcontext into the field
														indexer->tStructField[i].xmlNodeCterms = te;
														indexer->tStructField[i].XPathCtxCterms = xmlXPathNewContext((xmlDocPtr)te);
													}
													xmlFree(nextid);

													time(&cterms_moddate);
												}
											}
											else
											{
												xmlNodeSetPtr nodes_cterms = xpathObj_cterms->nodesetval;

												snprintf(strbuff, 1000, "|    -> found %d node%s (keeping the first) \n", nodes_cterms->nodeNr, (nodes_cterms->nodeNr==1 ? "s":""));
												cstr += strbuff;

												// in the field, keep the first xpathcontext
												indexer->tStructField[i].xmlNodeCterms = nodes_cterms->nodeTab[0];
												indexer->tStructField[i].XPathCtxCterms = xmlXPathNewContext((xmlDocPtr)(nodes_cterms->nodeTab[0]));
											}
开发者ID:alchemy-fr,项目名称:Phraseanet-Indexer,代码行数:66,代码来源:thesaurus.cpp

示例10: osync_group_save

/*! @brief Saves the group to disc
 * 
 * Saves the group to disc possibly creating the configdirectory
 * 
 * @param group The group
 * @param error Pointer to an error struct
 * @returns TRUE on success, FALSE otherwise
 * 
 */
osync_bool osync_group_save(OSyncGroup *group, OSyncError **error)
{
  char *filename = NULL;
  int i;
  xmlDocPtr doc;
  char *tmstr = NULL;
  char *version_str = NULL;
	
  osync_trace(TRACE_ENTRY, "%s(%p, %p)", __func__, group, error);
  osync_assert(group);
  osync_assert(group->configdir);
	
  osync_trace(TRACE_INTERNAL, "Trying to open configdirectory %s to save group %s", group->configdir, group->name);
	
  if (!g_file_test(group->configdir, G_FILE_TEST_IS_DIR)) {
    osync_trace(TRACE_INTERNAL, "Creating group configdirectory %s", group->configdir);
    if (g_mkdir(group->configdir, 0700)) {
      osync_error_set(error, OSYNC_ERROR_IO_ERROR, "Unable to create directory for group %s\n", group->name);
      goto error;
    }
  }
	
  filename = g_strdup_printf ("%s%csyncgroup.conf", group->configdir, G_DIR_SEPARATOR);
  osync_trace(TRACE_INTERNAL, "Saving group to file %s", filename);
	
  doc = xmlNewDoc((xmlChar*)"1.0");
  doc->children = xmlNewDocNode(doc, NULL, (xmlChar*)"syncgroup", NULL);

  version_str = g_strdup_printf("%u.%u", OSYNC_GROUP_MAJOR_VERSION, OSYNC_GROUP_MINOR_VERSION);
  xmlSetProp(doc->children, (const xmlChar*)"version", (const xmlChar *)version_str);	
  g_free(version_str);
	
  // TODO: reimplement the filter!
  //The filters
  /*GList *f;
    for (f = group->filters; f; f = f->next) {
    OSyncFilter *filter = f->data;
    xmlNodePtr child = xmlNewChild(doc->children, NULL, (xmlChar*)"filter", NULL);
		
    if (filter->sourcememberid) {
    char *sourcememberid = g_strdup_printf("%lli", filter->sourcememberid);
    xmlNewChild(child, NULL, (xmlChar*)"sourcemember", (xmlChar*)sourcememberid);
    g_free(sourcememberid);
    }
    if (filter->destmemberid) {
    char *destmemberid = g_strdup_printf("%lli", filter->destmemberid);
    xmlNewChild(child, NULL, (xmlChar*)"destmember", (xmlChar*)destmemberid);
    g_free(destmemberid);
    }
    if (filter->sourceobjtype)
    xmlNewChild(child, NULL, (xmlChar*)"sourceobjtype", (xmlChar*)filter->sourceobjtype);
    if (filter->destobjtype)
    xmlNewChild(child, NULL, (xmlChar*)"destobjtype", (xmlChar*)filter->destobjtype);
    if (filter->detectobjtype)
    xmlNewChild(child, NULL, (xmlChar*)"detectobjtype", (xmlChar*)filter->detectobjtype);
    if (filter->action) {
    char *action = g_strdup_printf("%i", filter->action);
    xmlNewChild(child, NULL, (xmlChar*)"action", (xmlChar*)action);
    g_free(action);
    }
    if (filter->function_name)
    xmlNewChild(child, NULL, (xmlChar*)"function_name", (xmlChar*)filter->function_name);
    if (filter->config)
    xmlNewChild(child, NULL, (xmlChar*)"config", (xmlChar*)filter->config);
    }*/

  xmlNewChild(doc->children, NULL, (xmlChar*)"groupname", (xmlChar*)group->name);

  tmstr = g_strdup_printf("%i", (int)group->last_sync);
  xmlNewChild(doc->children, NULL, (xmlChar*)"last_sync", (xmlChar*)tmstr);
  g_free(tmstr);

  xmlNewChild(doc->children, NULL, (xmlChar*)"merger_enabled", (xmlChar*) (group->merger_enabled ? "true" : "false"));
  xmlNewChild(doc->children, NULL, (xmlChar*)"converter_enabled", (xmlChar*) (group->converter_enabled ? "true" : "false"));


  xmlSaveFormatFile(filename, doc, 1);
  osync_xml_free_doc(doc);
  g_free(filename);

  for (i = 0; i < osync_group_num_members(group); i++) {
    OSyncMember *member = osync_group_nth_member(group, i);
    if (!osync_member_save(member, error))
      goto error;
  }
	
  osync_trace(TRACE_EXIT, "%s", __func__);
  return TRUE;

 error:
  osync_trace(TRACE_EXIT_ERROR, "%s: %s", __func__, osync_error_print(error));
//.........这里部分代码省略.........
开发者ID:ianmartin,项目名称:autoimportopensync,代码行数:101,代码来源:opensync_group.c

示例11: add_kvp_value_node

static void
add_kvp_value_node(xmlNodePtr node, gchar *tag, kvp_value* val)
{
    xmlNodePtr val_node;
    gchar *tmp_str1;
    kvp_value_t kvp_type;

    kvp_type = kvp_value_get_type(val);

    if (kvp_type == KVP_TYPE_STRING)
        val_node = xmlNewTextChild(node, NULL, BAD_CAST tag, BAD_CAST kvp_value_get_string(val));
    else if (kvp_type == KVP_TYPE_TIMESPEC)
        val_node = NULL;
    else if (kvp_type == KVP_TYPE_GDATE)
    {
        GDate d = kvp_value_get_gdate(val);
        val_node = gdate_to_dom_tree(tag, &d);
        xmlAddChild (node, val_node);
    }
    else
        val_node = xmlNewTextChild(node, NULL, BAD_CAST tag, NULL);

    switch (kvp_value_get_type(val))
    {
    case KVP_TYPE_GINT64:
        add_text_to_node(val_node, "integer",
                         g_strdup_printf("%" G_GINT64_FORMAT,
                                         kvp_value_get_gint64(val)));
        break;
    case KVP_TYPE_DOUBLE:
        add_text_to_node(val_node, "double",
                         double_to_string(kvp_value_get_double(val)));
        break;
    case KVP_TYPE_NUMERIC:
        add_text_to_node(val_node, "numeric",
                         gnc_numeric_to_string(kvp_value_get_numeric(val)));
        break;
    case KVP_TYPE_STRING:
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "string");
        break;
    case KVP_TYPE_GUID:
        /* THREAD-UNSAFE */
        add_text_to_node(val_node, "guid",
                         g_strdup(guid_to_string(kvp_value_get_guid(val))));
        break;
    case KVP_TYPE_TIMESPEC:
    {
        Timespec ts = kvp_value_get_timespec (val);

        val_node = timespec_to_dom_tree (tag, &ts);
        xmlSetProp (val_node, BAD_CAST "type", BAD_CAST "timespec");
        xmlAddChild (node, val_node);
    }
    break;
    case KVP_TYPE_GDATE:
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "gdate");
        break;
    case KVP_TYPE_BINARY:
    {
        guint64 size;
        void *binary_data = kvp_value_get_binary(val, &size);
        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "binary");
        g_return_if_fail(binary_data);
        tmp_str1 = binary_to_string(binary_data, size);
        xmlNodeSetContent(val_node, BAD_CAST tmp_str1);
        g_free(tmp_str1);
    }
    break;
    case KVP_TYPE_GLIST:
    {
        GList *cursor;

        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "list");
        for (cursor = kvp_value_get_glist(val); cursor; cursor = cursor->next)
        {
            kvp_value *val = (kvp_value*)cursor->data;
            add_kvp_value_node(val_node, "slot:value", val);
        }
    }

    break;
    case KVP_TYPE_FRAME:
    {
        kvp_frame *frame;

        xmlSetProp(val_node, BAD_CAST "type", BAD_CAST "frame");

        frame = kvp_value_get_frame (val);
        if (!frame || !kvp_frame_get_hash (frame))
            break;

        g_hash_table_foreach_sorted(kvp_frame_get_hash(frame),
                                    add_kvp_slot, val_node, (GCompareFunc)strcmp);
    }
    break;

    }
}
开发者ID:iulianu,项目名称:gnucash-butchered,代码行数:98,代码来源:sixtp-dom-generators.cpp

示例12: draw_object

/* 
 * renderer methods 
 */ 
static void 
draw_object(DiaRenderer *self,
            DiaObject   *object,
	    DiaMatrix   *matrix)
{
  DrsRenderer *renderer = DRS_RENDERER (self);
  DiaMatrix *m = g_queue_peek_tail (renderer->matrices);
  xmlNodePtr node;

  g_queue_push_tail (renderer->parents, renderer->root);
  renderer->root = node = xmlNewChild(renderer->root, NULL, (const xmlChar *)"object", NULL);
  xmlSetProp(node, (const xmlChar *)"type", (xmlChar *)object->type->name);
  /* if it looks like intdata store it as well */
  if ((int)object->type->default_user_data > 0 && (int)object->type->default_user_data < 0xFF) {
    gchar buffer[30];
    g_snprintf(buffer, sizeof(buffer), "%d", (int)object->type->default_user_data);
    xmlSetProp(node, (const xmlChar *)"intdata", (xmlChar *)buffer);
  }
  if (renderer->save_props) {
    xmlNodePtr props_node;

    props_node = xmlNewChild(node, NULL, (const xmlChar *)"properties", NULL);
    object_save_props (object, props_node, renderer->ctx);
  }
  if (matrix) {
    DiaMatrix *m2 = g_new (DiaMatrix, 1);
    if (m)
      dia_matrix_multiply (m2, matrix, m);
    else
      *m2 = *matrix;
    g_queue_push_tail (renderer->matrices, m2);
    /* lazy creation of our transformer */
    if (!renderer->transformer)
      renderer->transformer = dia_transform_renderer_new (self);
  }
  /* special handling for group objects:
   *  - for the render branch use DiaTransformRenderer, but not it's draw_object,
   *    to see all the children's draw_object ourself
   *  - for the object branch we rely on this draw_object being called so need
   *    to inline group_draw here
   *  - to maintain the correct transform build our own queue of matrices like
   *    the DiaTransformRenderer would do through it's draw_object
   */
  {
    g_queue_push_tail (renderer->parents, renderer->root);
    renderer->root = node = xmlNewChild(renderer->root, NULL, (const xmlChar *)"render", NULL);
    if (renderer->transformer) {
      DiaMatrix *m = g_queue_peek_tail (renderer->matrices);

      if (IS_GROUP (object)) {
	/* reimplementation of group_draw to use this draw_object method */
	GList *list;
	DiaObject *obj;

	list = group_objects (object);
	while (list != NULL) {
	  obj = (DiaObject *) list->data;

	  DIA_RENDERER_GET_CLASS(self)->draw_object(self, obj, m);
	  list = g_list_next(list);
	}
      } else {
	/* just the leaf */
	DIA_RENDERER_GET_CLASS(renderer->transformer)->draw_object(renderer->transformer, object, m);
      }
    } else {
      object->ops->draw(object, DIA_RENDERER (renderer));
    }
    renderer->root = g_queue_pop_tail (renderer->parents);
  }
  renderer->root = g_queue_pop_tail (renderer->parents);

  if (matrix)
    g_queue_pop_tail (renderer->matrices);
  /* one lost demand destruction */
  if (renderer->transformer && g_queue_is_empty (renderer->matrices)) {
    g_object_unref (renderer->transformer);
    renderer->transformer = NULL;
  }
}
开发者ID:UIKit0,项目名称:dia,代码行数:83,代码来源:dia-render-script-renderer.c

示例13: rest_set_filter

static int
rest_set_filter(noit_http_rest_closure_t *restc,
                int npats, char **pats) {
  noit_http_session_ctx *ctx = restc->http_ctx;
  xmlDocPtr doc = NULL, indoc = NULL;
  xmlNodePtr node, parent, root, newfilter;
  char xpath[1024];
  int error_code = 500, complete = 0, mask = 0;
  const char *error = "internal error";

  if(npats != 2) goto error;

  indoc = rest_get_xml_upload(restc, &mask, &complete);
  if(!complete) return mask;
  if(indoc == NULL) FAIL("xml parse error");

  snprintf(xpath, sizeof(xpath), "//filtersets%sfilterset[@name=\"%s\"]",
           pats[0], pats[1]);
  node = noit_conf_get_section(NULL, xpath);
  if(!node && noit_filter_exists(pats[1])) {
    /* It's someone else's */
    error_code = 403;
    goto error;
  }

  if((newfilter = validate_filter_post(indoc)) == NULL) goto error;
  xmlSetProp(newfilter, (xmlChar *)"name", (xmlChar *)pats[1]);

  parent = make_conf_path(pats[0]);
  if(!parent) FAIL("invalid path");
  if(node) {
    xmlUnlinkNode(node);
    xmlFreeNode(node);
  }
  xmlUnlinkNode(newfilter);
  xmlAddChild(parent, newfilter);
  CONF_DIRTY(newfilter);

  noit_conf_mark_changed();
  if(noit_conf_write_file(NULL) != 0)
    noitL(noit_error, "local config write failed\n");
  noit_filter_compile_add(newfilter);
  if(restc->call_closure_free) restc->call_closure_free(restc->call_closure);
  restc->call_closure_free = NULL;
  restc->call_closure = NULL;
  restc->fastpath = rest_show_filter;
  return restc->fastpath(restc, restc->nparams, restc->params);

 error:
  noit_http_response_standard(ctx, error_code, "ERROR", "text/html");
  doc = xmlNewDoc((xmlChar *)"1.0");
  root = xmlNewDocNode(doc, NULL, (xmlChar *)"error", NULL);
  xmlDocSetRootElement(doc, root);
  xmlNodeAddContent(root, (xmlChar *)error);
  noit_http_response_xml(ctx, doc);
  noit_http_response_end(ctx);
  goto cleanup;

 cleanup:
  if(doc) xmlFreeDoc(doc);
  return 0;
}
开发者ID:ahpeterson,项目名称:reconnoiter,代码行数:62,代码来源:noit_filters_rest.c

示例14: base_tool_output_data_model_to_string

/**
 * base_tool_output_data_model_to_string:
 */
gchar *
base_tool_output_data_model_to_string (GdaDataModel *model, ToolOutputFormat format, FILE *stream, GdaSet *options)
{
    if (!GDA_IS_DATA_MODEL (model))
        return NULL;

    if (format & BASE_TOOL_OUTPUT_FORMAT_DEFAULT) {
        gchar *tmp;
        GdaSet *local_options;
        gint width;
        base_tool_input_get_size (&width, NULL);
        local_options = gda_set_new_inline (6, "NAME", G_TYPE_BOOLEAN, TRUE,
                                            "NULL_AS_EMPTY", G_TYPE_BOOLEAN, TRUE,
                                            "MAX_WIDTH", G_TYPE_INT, width,
                                            "COLUMN_SEPARATORS", G_TYPE_BOOLEAN, TRUE,
                                            "SEPARATOR_LINE", G_TYPE_BOOLEAN, TRUE,
                                            "NAMES_ON_FIRST_LINE", G_TYPE_BOOLEAN, TRUE);
        if (options)
            gda_set_merge_with_set (local_options, options);
        tmp = gda_data_model_export_to_string (model, GDA_DATA_MODEL_IO_TEXT_TABLE, NULL, 0, NULL, 0,
                                               local_options);
        g_object_unref (local_options);
        if (GDA_IS_DATA_SELECT (model)) {
            gchar *tmp2, *tmp3;
            gdouble etime;
            g_object_get ((GObject*) model, "execution-delay", &etime, NULL);
            tmp2 = g_strdup_printf ("%s: %.03f s", _("Execution delay"), etime);
            tmp3 = g_strdup_printf ("%s\n%s", tmp, tmp2);
            g_free (tmp);
            g_free (tmp2);
            return tmp3;
        }
        else
            return tmp;
    }
    else if (format & BASE_TOOL_OUTPUT_FORMAT_XML)
        return gda_data_model_export_to_string (model, GDA_DATA_MODEL_IO_DATA_ARRAY_XML,
                                                NULL, 0,
                                                NULL, 0, NULL);
    else if (format & BASE_TOOL_OUTPUT_FORMAT_CSV) {
        gchar *retval;
        GdaSet *optexp;
        optexp = make_options_set_from_string ("csv", options);
        retval = gda_data_model_export_to_string (model, GDA_DATA_MODEL_IO_TEXT_SEPARATED,
                 NULL, 0,
                 NULL, 0, optexp);
        if (optexp)
            g_object_unref (optexp);
        return retval;
    }
    else if (format & BASE_TOOL_OUTPUT_FORMAT_HTML) {
        xmlBufferPtr buffer;
        xmlNodePtr top, div, table, node, row_node, col_node, header, meta;
        gint ncols, nrows, i, j;
        gchar *str;

        top = xmlNewNode (NULL, BAD_CAST "html");
        header = xmlNewChild (top, NULL, BAD_CAST "head", NULL);
        meta = xmlNewChild (header, NULL, BAD_CAST "meta", NULL);
        xmlSetProp (meta, BAD_CAST "http-equiv", BAD_CAST "content-type");
        xmlSetProp (meta, BAD_CAST "content", BAD_CAST "text/html; charset=UTF-8");
        div = xmlNewChild (top, NULL, BAD_CAST "body", NULL);
        table = xmlNewChild (div, NULL, BAD_CAST "table", NULL);
        xmlSetProp (table, BAD_CAST "border", BAD_CAST "1");

        if (g_object_get_data (G_OBJECT (model), "name"))
            xmlNewTextChild (table, NULL, BAD_CAST "caption", g_object_get_data (G_OBJECT (model), "name"));

        ncols = gda_data_model_get_n_columns (model);
        nrows = gda_data_model_get_n_rows (model);

        row_node = xmlNewChild (table, NULL, BAD_CAST "tr", NULL);
        for (j = 0; j < ncols; j++) {
            const gchar *cstr;
            cstr = gda_data_model_get_column_title (model, j);
            col_node = xmlNewTextChild (row_node, NULL, BAD_CAST "th", BAD_CAST cstr);
            xmlSetProp (col_node, BAD_CAST "align", BAD_CAST "center");
        }

        for (i = 0; i < nrows; i++) {
            row_node = xmlNewChild (table, NULL, BAD_CAST "tr", NULL);
            xmlSetProp (row_node, BAD_CAST "valign", BAD_CAST "top");
            for (j = 0; j < ncols; j++) {
                const GValue *value;
                value = gda_data_model_get_value_at (model, j, i, NULL);
                if (!value) {
                    col_node = xmlNewChild (row_node, NULL, BAD_CAST "td", BAD_CAST "ERROR");
                    xmlSetProp (col_node, BAD_CAST "align", BAD_CAST "left");
                }
                else {
                    str = gda_value_stringify (value);
                    col_node = xmlNewTextChild (row_node, NULL, BAD_CAST "td", BAD_CAST str);
                    xmlSetProp (col_node, BAD_CAST "align", BAD_CAST "left");
                    g_free (str);
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:arthurnn,项目名称:libgda,代码行数:101,代码来源:base-tool-output.c

示例15: xmlSetProp

	xmlNodePtr CGroupModal::serialize( xmlNodePtr parentNode, const char *type ) const
	{
		xmlNodePtr node = CGroupFrame::serialize( parentNode, type );
		if( node == NULL )
			return NULL;

		xmlSetProp( node, BAD_CAST "type", BAD_CAST "modal" );
		xmlSetProp( node, BAD_CAST "mouse_pos", BAD_CAST NLMISC::toString( SpawnOnMousePos ).c_str() );
		xmlSetProp( node, BAD_CAST "exit_click_out", BAD_CAST NLMISC::toString( ExitClickOut ).c_str() );
		xmlSetProp( node, BAD_CAST "exit_click_l", BAD_CAST NLMISC::toString( ExitClickL ).c_str() );
		xmlSetProp( node, BAD_CAST "exit_click_r", BAD_CAST NLMISC::toString( ExitClickR ).c_str() );
		
		if( ExitClickL == ExitClickR )
			xmlSetProp( node, BAD_CAST "exit_click_b", BAD_CAST NLMISC::toString( ExitClickL ).c_str() );

		xmlSetProp( node, BAD_CAST "force_inside_screen", BAD_CAST NLMISC::toString( ForceInsideScreen ).c_str() );
		xmlSetProp( node, BAD_CAST "category", BAD_CAST Category.c_str() );
		xmlSetProp( node, BAD_CAST "onclick_out", BAD_CAST OnClickOut.c_str() );
		xmlSetProp( node, BAD_CAST "onclick_out_params", BAD_CAST OnClickOutParams.c_str() );
		xmlSetProp( node, BAD_CAST "onpostclick_out", BAD_CAST OnPostClickOut.c_str() );
		xmlSetProp( node, BAD_CAST "onpostclick_out_params", BAD_CAST OnPostClickOutParams.c_str() );
		xmlSetProp( node, BAD_CAST "exit_key_pushed", BAD_CAST NLMISC::toString( ExitKeyPushed ).c_str() );

		return node;
	}
开发者ID:CCChaos,项目名称:RyzomCore,代码行数:25,代码来源:group_modal.cpp


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