Exemple #1
0
/** Add rectangle data to an attribute node.
 * @param attr The attribute node.
 * @param rect The value to set.
 */
void
data_add_rectangle(AttributeNode attr, const Rectangle *rect)
{
  DataNode data_node;
  gchar *buffer;
  gchar rl_buf[G_ASCII_DTOSTR_BUF_SIZE];
  gchar rr_buf[G_ASCII_DTOSTR_BUF_SIZE];
  gchar rt_buf[G_ASCII_DTOSTR_BUF_SIZE];
  gchar rb_buf[G_ASCII_DTOSTR_BUF_SIZE];

  g_ascii_formatd(rl_buf, sizeof(rl_buf), "%g", rect->left);
  g_ascii_formatd(rr_buf, sizeof(rr_buf), "%g", rect->right);
  g_ascii_formatd(rt_buf, sizeof(rt_buf), "%g", rect->top);
  g_ascii_formatd(rb_buf, sizeof(rb_buf), "%g", rect->bottom);

  buffer = g_strconcat(rl_buf, ",", rt_buf, ";", rr_buf, ",", rb_buf, NULL);

  data_node = xmlNewChild(attr, NULL, (const xmlChar *)"rectangle", NULL);
  xmlSetProp(data_node, (const xmlChar *)"val", (xmlChar *)buffer);

  g_free(buffer);
}
Exemple #2
0
xmlNodePtr msOWSCommonOperationsMetadataDomainType(int version, xmlNsPtr psNsOws, char *elname, char *name, char *values)
{
  xmlNodePtr psRootNode = NULL;
  xmlNodePtr psNode = NULL;

  if (_validateNamespace(psNsOws) == MS_FAILURE)
    psNsOws = xmlNewNs(psRootNode, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_URI, BAD_CAST MS_OWSCOMMON_OWS_NAMESPACE_PREFIX);

  psRootNode = xmlNewNode(psNsOws, BAD_CAST elname);

  xmlNewProp(psRootNode, BAD_CAST "name", BAD_CAST name);

  if (version == OWS_1_0_0) {
    msLibXml2GenerateList(psRootNode, psNsOws, "Value", values, ',');
  }
  if (version == OWS_1_1_0 || version == OWS_2_0_0) {
    psNode = xmlNewChild(psRootNode, psNsOws, BAD_CAST "AllowedValues", NULL);
    msLibXml2GenerateList(psNode, psNsOws, "Value", values, ',');
  }

  return psRootNode;
}
Exemple #3
0
void add_systemp(xmlNodePtr node)
{
  char buffer[24];
  int systemp = 0;

  if (HAVE_OPT(SYSTEMP_COMMAND)) {
    char cmd[1024];
    FILE *in;

    sprintf(cmd, "%s > /tmp/.uw_sysstat.tmp", OPT_ARG(SYSTEMP_COMMAND));
    uw_setproctitle("running %s", OPT_ARG(SYSTEMP_COMMAND));
    system(cmd);
    in = fopen("/tmp/.uw_sysstat.tmp", "r");
    if (in) {
      fscanf(in, "%d", &systemp);
      fclose(in);
    }
    unlink("tmp/.uw_sysstat.tmp");
  }
  sprintf(buffer, "%d", systemp);
  xmlNewChild(node, NULL, "systemp", buffer);
}
Exemple #4
0
bool DomTree::write(const std::string& file, bool indent) {
	xmlDocPtr doc;
	xmlNodePtr cur;
	//xmlAttrPtr attr;
	
	doc = xmlNewDoc((const xmlChar *)version.c_str());
	doc->children = xmlNewDocNode(doc, NULL,(const xmlChar *)name.c_str(), NULL);
	
	for(unsigned int i = 0; i < attributes.size() ; i++) {
		xmlSetProp(doc->children,(const xmlChar *)attributes[i]->getName().c_str(),(const xmlChar *)attributes[i]->getValue().c_str());
	}
	
	for(unsigned int i = 0; i < elements.size() ; i++) {
		cur = xmlNewChild(doc->children,NULL,(const xmlChar *)elements[i]->getName().c_str(),(xmlChar *)elements[i]->getValue().c_str());
		if(elements[i]->getAttributes().size() > 0) {
			for(unsigned int a = 0; a < elements[i]->getAttributes().size() ; a++) {
				xmlSetProp(cur,(const xmlChar *)elements[i]->getAttributes()[a]->getName().c_str(),(const xmlChar *)elements[i]->getAttributes()[a]->getValue().c_str());
			}
		}
		if ( elements[i]->getChildren().size() > 0 ) {	
			for(unsigned int b = 0; b < elements[i]->getChildren().size() ; b++) {
				dumpXmlChild(cur,elements[i]->getChildren()[b]);
			}
		}
	}
	
	if((xmlSaveFormatFile((const char *)file.c_str(),doc,indent)) < 1) {
		
		std::cout << "Error writing to file" << std::endl;
		
		xmlFreeDoc(doc);
		xmlCleanupParser();
		return(false);
	}
		
	xmlFreeDoc(doc);
	xmlCleanupParser();
	return(true);
}	
Exemple #5
0
/**
 * Add a directory to the HTML tree for saving.
 *
 * \param  directory  hotlist directory to add
 * \param  node       node to add ul to
 * \return  true on success, false on memory exhaustion
 */
static bool tree_url_save_directory(struct node *directory, xmlNode *node)
{
	struct node *child;
	xmlNode *ul, *h4;
	const char *text;

	ul = xmlNewChild(node, NULL, (const xmlChar *)"ul", NULL);
	if (ul == NULL)
		return false;
	if (tree_node_is_default(directory) == true)
		xmlSetProp(ul, (const xmlChar *) "id",
				(const xmlChar *) "default");

	for (child = tree_node_get_child(directory); child;
	     child = tree_node_get_next(child)) {
		if (!tree_node_is_folder(child)) {
			/* entry */
			if (!tree_url_save_entry(child, ul))
				return false;
		} else {
			/* directory */
			/* invalid HTML */

			text = tree_url_node_get_title(child);
			if (text == NULL)
				return false;

			h4 = xmlNewTextChild(ul, NULL,
					     (const xmlChar *) "h4",
					     (const xmlChar *) text);
			if (h4 == NULL)
				return false;

			if (!tree_url_save_directory(child, ul))
				return false;
		}	}

	return true;
}
static void
_arc(DiaRenderer *self, 
	 Point *center,
	 real width, real height,
	 real angle1, real angle2,
	 Color *color,
	 gboolean fill)
{
  DrsRenderer *renderer = DRS_RENDERER (self);
  xmlNodePtr node;
  
  node = xmlNewChild(renderer->root, NULL, (const xmlChar *)(fill ? "fill-arc" : "draw-arc"), NULL);
  _node_set_point (node, "center", center);
  _node_set_real (node, "width", width);
  _node_set_real (node, "height", height);
  _node_set_real (node, "angle1", angle1);
  _node_set_real (node, "angle2", angle2);
  if (fill)
    _node_set_color (node, "fill", color);
  else
    _node_set_color (node, "stroke", color);
}
Exemple #7
0
static void xmlCloneTree(void* Pool,PXMLNode x,PXMLNode nx)
{
  nx->eType=x->eType;
  if(x->szCont)nx->szCont=xstrdup(Pool,x->szCont);

  if(x->tAttrs)
  {
    pchar k,v;
    tableFirst(x->tAttrs);
    nx->tAttrs=tableNew(Pool,TABLE_FLAG_ALLOCNAME);
    while(tableNext(x->tAttrs,&k,&v))
    {
      tableSet(nx->tAttrs,k,v);
    }
  }
  if(x->hChildren)
  {
    PXMLNode p=x->pChildren;
    PXMLNode np=NULL,c;
    PHashLink l;
    nx->hChildren=hashNewEx(Pool,x->hChildren->iCount);
    while(p)
    {
      c=xmlNewChild(Pool,nx,p->eType);
      if(np)np->pNext=c;
      else nx->pChildren=c;
      np=c;
      //c->pParent=nx;
      if(p->szName)
      {
        l=hashAdd(nx->hChildren,p->szName,c);
        c->szName=l->szKey;
      }
      xmlCloneTree(Pool,p,c);
      p=p->pNext;
    }
  }
}
Exemple #8
0
void KmlRenderer::renderLine(imageObj*, shapeObj *p, strokeStyleObj *style)
{
    if (p->numlines == 0)
      return;

    if (PlacemarkNode == NULL)
      PlacemarkNode = createPlacemarkNode(LayerNode, NULL);

    if (!PlacemarkNode)
      return;

    addLineStyleToList(style);    
    SymbologyFlag[Line] = 1;

    /*p->index > CurrentDrawnShapeIndexneed to be reviewd. Added since the hight
      level code caches shapes when rendering lines*/
    if (CurrentDrawnShapeIndex == -1 || p->index > CurrentDrawnShapeIndex)
    {
        xmlNodePtr geomNode = getGeomParentNode("LineString");
        addAddRenderingSpecifications(geomNode);
        addCoordsNode(geomNode, p->line[0].point, p->line[0].numpoints);
          
        /* more than one line => MultiGeometry*/
        if (p->numlines > 1)
        {
            geomNode = getGeomParentNode("LineString"); // returns MultiGeom Node
            for (int i=1; i<p->numlines; i++)
            {
                xmlNodePtr lineStringNode = xmlNewChild(geomNode, NULL, BAD_CAST "LineString", NULL);
                addAddRenderingSpecifications(lineStringNode);
                addCoordsNode(lineStringNode, p->line[i].point, p->line[i].numpoints);
            }
        }
      
        CurrentDrawnShapeIndex = p->index;
    }
      
}
Exemple #9
0
static void
draw_arc(DiaRenderer *self, 
	 Point *center,
	 real width, real height,
	 real angle1, real angle2,
	 Color *colour)
{
  DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
  xmlNodePtr node;
  char buf[512];
  real rx = width / 2, ry = height / 2;
  real sx=center->x + rx*cos(angle1*G_PI/180);
  real sy=center->y - ry*sin(angle1*G_PI/180);
  real ex=center->x + rx*cos(angle2*G_PI/180);
  real ey=center->y - ry*sin(angle2*G_PI/180);
  int swp = (angle2 > angle1) ? 0 : 1; /* not always drawing negative direction anymore */
  int large_arc;
  gchar sx_buf[DTOSTR_BUF_SIZE];
  gchar sy_buf[DTOSTR_BUF_SIZE];
  gchar rx_buf[DTOSTR_BUF_SIZE];
  gchar ry_buf[DTOSTR_BUF_SIZE];
  gchar ex_buf[DTOSTR_BUF_SIZE];
  gchar ey_buf[DTOSTR_BUF_SIZE];

  large_arc = (fabs(angle2 - angle1) >= 180);

  node = xmlNewChild(renderer->root, renderer->svg_name_space, (const xmlChar *)"path", NULL);
  
  xmlSetProp(node, (const xmlChar *)"style", (xmlChar *) get_draw_style(renderer, NULL, colour));

  g_snprintf(buf, sizeof(buf), "M %s,%s A %s,%s 0 %d %d %s,%s",
	     dia_svg_dtostr(sx_buf, sx), dia_svg_dtostr(sy_buf, sy),
	     dia_svg_dtostr(rx_buf, rx), dia_svg_dtostr(ry_buf, ry),
	     large_arc, swp,
	     dia_svg_dtostr(ex_buf, ex), dia_svg_dtostr(ey_buf, ey) );

  xmlSetProp(node, (const xmlChar *)"d", (xmlChar *) buf);
}
static void
set_linejoin(DiaRenderer *self, LineJoin mode)
{
  DrsRenderer *renderer = DRS_RENDERER (self);
  xmlNodePtr node;
  gchar *value = NULL;

  switch(mode) {
  case LINEJOIN_MITER:
    value = "miter";
    break;
  case LINEJOIN_ROUND:
    value = "round";
    break;
  case LINEJOIN_BEVEL:
    value = "bevel";
    break;
  /* intentionally no default to let 'good' compilers warn about new constants*/
  }
  node =  xmlNewChild(renderer->root, NULL, (const xmlChar *)"set-linejoin", NULL);
  xmlSetProp(node, (const xmlChar *)"mode", 
             value ? (xmlChar *)value : (xmlChar *)"?");
}
static void
set_linecaps(DiaRenderer *self, LineCaps mode)
{
  DrsRenderer *renderer = DRS_RENDERER (self);
  xmlNodePtr node;
  gchar *value = NULL;

  switch(mode) {
  case LINECAPS_BUTT:
    value = "butt";
    break;
  case LINECAPS_ROUND:
    value = "round";
    break;
  case LINECAPS_PROJECTING:
    value = "projecting";
    break;
  /* intentionally no default to let 'good' compilers warn about new constants*/
  }
  node =  xmlNewChild(renderer->root, NULL, (const xmlChar *)"set-linecaps", NULL);
  xmlSetProp(node, (const xmlChar *)"mode", 
             value ? (xmlChar *)value : (xmlChar *)"?");
}
Exemple #12
0
static xmlNodePtr
bt_wavelevel_persistence_save (const BtPersistence * const persistence,
    xmlNodePtr const parent_node)
{
  const BtWavelevel *const self = BT_WAVELEVEL (persistence);
  xmlNodePtr node = NULL;

  GST_DEBUG ("PERSISTENCE::wavelevel");

  if ((node =
          xmlNewChild (parent_node, NULL, XML_CHAR_PTR ("wavelevel"), NULL))) {
    // only serialize customizable properties
    xmlNewProp (node, XML_CHAR_PTR ("root-note"),
        XML_CHAR_PTR (bt_str_format_uchar (self->priv->root_note)));
    xmlNewProp (node, XML_CHAR_PTR ("rate"),
        XML_CHAR_PTR (bt_str_format_ulong (self->priv->rate)));
    xmlNewProp (node, XML_CHAR_PTR ("loop-start"),
        XML_CHAR_PTR (bt_str_format_long (self->priv->loop_start)));
    xmlNewProp (node, XML_CHAR_PTR ("loop-end"),
        XML_CHAR_PTR (bt_str_format_long (self->priv->loop_end)));
  }
  return node;
}
void KmlRenderer::addCoordsNode(xmlNodePtr parentNode, pointObj *pts, int numPts)
{
  char lineBuf[128];

  xmlNodePtr coordsNode = xmlNewChild(parentNode, NULL, BAD_CAST "coordinates", NULL);
  xmlNodeAddContent(coordsNode, BAD_CAST "\n");

  for (int i=0; i<numPts; i++) {
    if( mElevationFromAttribute ) {
      sprintf(lineBuf, "\t%.8f,%.8f,%.8f\n", pts[i].x, pts[i].y, mCurrentElevationValue);
    } else if (AltitudeMode == relativeToGround || AltitudeMode == absolute) {
#ifdef USE_POINT_Z_M
      sprintf(lineBuf, "\t%.8f,%.8f,%.8f\n", pts[i].x, pts[i].y, pts[i].z);
#else
      msSetError(MS_MISCERR, "Z coordinates support not available  (mapserver not compiled with USE_POINT_Z_M option)", "KmlRenderer::addCoordsNode()");
#endif
    } else
      sprintf(lineBuf, "\t%.8f,%.8f\n", pts[i].x, pts[i].y);

    xmlNodeAddContent(coordsNode, BAD_CAST lineBuf);
  }
  xmlNodeAddContent(coordsNode, BAD_CAST "\t");
}
Exemple #14
0
static void
draw_text_line(DiaRenderer *self, TextLine *text_line,
	       Point *pos, Alignment alignment, Color *colour)
{
  DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
  xmlNodePtr node;
  DiaFont *font = text_line_get_font(text_line); /* no reference? */
  real font_height = text_line_get_height(text_line);
  gchar d_buf[G_ASCII_DTOSTR_BUF_SIZE];
  
  node = xmlNewChild(renderer->root, renderer->svg_name_space, (const xmlChar *)"text", 
		     (xmlChar *) text_line_get_string(text_line));

  /* not using the renderers font but the textlines */
  node_set_text_style(node, renderer, font, font_height, alignment, colour);

  dia_svg_dtostr(d_buf, pos->x);
  xmlSetProp(node, (const xmlChar *)"x", (xmlChar *) d_buf);
  dia_svg_dtostr(d_buf, pos->y);
  xmlSetProp(node, (const xmlChar *)"y", (xmlChar *) d_buf);
  dia_svg_dtostr(d_buf, text_line_get_width(text_line));
  xmlSetProp(node, (const xmlChar*)"textLength", (xmlChar *) d_buf);
}
Exemple #15
0
/* Create a new element with string value */
int ermXmlNewString(const erManifest *pCtx, const char *parentExpress, const char *name, const char *content)
{
    xmlXPathObjectPtr xpathObj = LocateTo(parentExpress, pCtx);
    if (NULL == xpathObj)
        return RET_ERR;

    xmlNodeSetPtr nodes = xpathObj->nodesetval;

    /* MvdW: we need to encode special chars in the input */
    xmlChar *xmlString = xmlEncodeSpecialChars(pCtx->pDoc, (xmlChar *) content);

    if (nodes && nodes->nodeTab[0])
    {
        /*xmlNodePtr node = */ xmlNewChild(nodes->nodeTab[0],
                                           NULL, BAD_CAST name, // MvdW: this should ALSO be encoded!
                                           xmlString);
        xmlFree(xmlString);
        xmlXPathFreeObject(xpathObj);
        return RET_OK;
    }
    xmlXPathFreeObject(xpathObj);
    return RET_ERR;
}
Exemple #16
0
static void
mpp_write_overridden_date (MrpParser      *parser,
			   xmlNodePtr      parent,
			   MrpDateWithDay *dd)
{
	NodeEntry  *entry;
	xmlNodePtr  child;
	gchar      *str;

	entry = g_hash_table_lookup (parser->day_hash, dd->day);
	if (entry) {
		child = xmlNewChild (parent, NULL, "day", NULL);

		str = mrp_time_format ("%Y%m%d", dd->date);
		xmlSetProp (child, "date", str);
		g_free (str);

		xmlSetProp (child, "type", "day-type");
 		mpp_xml_set_int (child, "id", entry->id);
	}

 	g_free (dd);
}
Exemple #17
0
static void
draw_ellipse(DiaRenderer *self, 
	     Point *center,
	     real width, real height,
	     Color *fill, Color *stroke)
{
  DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
  xmlNodePtr node;
  gchar d_buf[DTOSTR_BUF_SIZE];

  node = xmlNewChild(renderer->root, renderer->svg_name_space, (const xmlChar *)"ellipse", NULL);

  xmlSetProp(node, (const xmlChar *)"style", (xmlChar *) get_draw_style (renderer, fill, stroke));

  dia_svg_dtostr(d_buf, center->x);
  xmlSetProp(node, (const xmlChar *)"cx", (xmlChar *) d_buf);
  dia_svg_dtostr(d_buf, center->y);
  xmlSetProp(node, (const xmlChar *)"cy", (xmlChar *) d_buf);
  dia_svg_dtostr(d_buf, width / 2);
  xmlSetProp(node, (const xmlChar *)"rx", (xmlChar *) d_buf);
  dia_svg_dtostr(d_buf, height / 2);
  xmlSetProp(node, (const xmlChar *)"ry", (xmlChar *) d_buf);
}
Exemple #18
0
xmlNodePtr add_resouce_list_attribute(
    const char *nodeTag,     /* I tag to use on the resouce head-node */
    xmlNodePtr *attr_node,   /* M attribute head-node */ 
    xmlNodePtr *res_node,    /* M Resource_List/resources_used head-node */ 
    svrattrl   *pal)         /* I encoded attribute structure */

  {
  xmlNodePtr attributeHeadNode = *attr_node;
  xmlNodePtr resourceHeadNode = *res_node;
  xmlNodePtr resourceNode = NULL;

  if (!resourceHeadNode)
    if ((resourceHeadNode = xmlNewNode(NULL, (xmlChar *)nodeTag)))
      {
      xmlAddChild(attributeHeadNode, resourceHeadNode);
      *res_node = resourceHeadNode;
      }

  if (pal->al_atopl.resource)
    resourceNode = xmlNewChild(resourceHeadNode, NULL, (xmlChar *)pal->al_atopl.resource, (xmlChar *)pal->al_atopl.value);

  return resourceNode;
  }
Exemple #19
0
static xmlNodePtr _find_xml_node(char *mount, source_xml_t **list, xmlNodePtr root)
{
    source_xml_t *node, *node2;
    int found = 0;

    /* search for existing node */
    node = *list;
    while (node) {
        if (strcmp(node->mount, mount) == 0) {
            found = 1;
            break;
        }
        node = node->next;
    }

    if (found) return node->node;

    /* if we didn't find it, we must build it and add it to the list */

    /* build node */
    node = (source_xml_t *)malloc(sizeof(source_xml_t));
    node->mount = strdup(mount);
    node->node = xmlNewChild(root, NULL, "source", NULL);
    xmlSetProp(node->node, "mount", mount);
    node->next = NULL;

    /* add node */
    if (*list == NULL) {
        *list = node;
    } else {
        node2 = *list;
        while (node2->next) node2 = node2->next;
        node2->next = node;
    }

    return node->node;
}
Exemple #20
0
bool create_jpeg( const char *filename, xmlNodePtr parent ) {
	char *name = get_name_from_filename( filename );

	// parse thru the jpeg to find width and height
	FILE *fp = fopen( filename, "rb" );
	char tmp[TMP_STRLEN];
	if( !fp ) return false;
		
	int width=-1, height=-1;
	while( !feof( fp ) ) { // could do a && width==-1 here, but that captures preview imgs...
		if( fgetc(fp) == 0xff ) {
			if( fgetc(fp) == 0xc0 ) {
				// StartOfFrame
				// skip length and precision (UGLY, eh?)
				fgetc(fp); fgetc(fp); fgetc(fp);
				
				// read height, width
				height = getJpegWord( fp );
				width = getJpegWord( fp );
			}
		}
	}
	
	xmlNodePtr node = xmlNewChild( parent, NULL, (const xmlChar *)"jpeg", NULL );

	snprintf(tmp,TMP_STRLEN,"%i", width);
	xmlSetProp( node, (const xmlChar *)"width", (const xmlChar *)&tmp );

	snprintf(tmp,TMP_STRLEN,"%i", height);
	xmlSetProp( node, (const xmlChar *)"height", (const xmlChar *)&tmp );

	xmlSetProp( node, (const xmlChar *)"file", (const xmlChar *)filename );
	xmlSetProp( node, (const xmlChar *)"name", (const xmlChar *)name );
	if( name ) delete name;
		
	return true;
}
Exemple #21
0
static void uwsgi_webdav_do_prop_update(struct wsgi_request *wsgi_req, xmlNode *prop, xmlNode *response, char *filename, uint8_t action) {
	xmlNode *node;
        // search for "prop"
        for (node = prop->children; node; node = node->next) {
		if (node->type == XML_ELEMENT_NODE) {
			xmlNode *propstat = xmlNewChild(response, NULL, BAD_CAST "propstat", NULL);
			xmlNode *r_prop = xmlNewChild(propstat, NULL, BAD_CAST "prop" , NULL);
			xmlNode *new_prop = xmlNewChild(r_prop, NULL, node->name, NULL);
			if (node->ns) {
				xmlNsPtr xattr_ns = xmlNewNs(new_prop, node->ns->href, NULL);
                                xmlSetNs(new_prop, xattr_ns);
			}
			if (action == 0) {
				if (uwsgi_webdav_prop_set(filename, (char *) node->name, node->ns ? (char *) node->ns->href : NULL, node->children ? (char *) node->children->content : "")) {
					char *r_status = uwsgi_concat2n(wsgi_req->protocol, wsgi_req->protocol_len, " 403 Forbidden", 14);
					xmlNewChild(r_prop, NULL, BAD_CAST "status", BAD_CAST r_status);
					free(r_status);
				}
				else {
					char *r_status = uwsgi_concat2n(wsgi_req->protocol, wsgi_req->protocol_len, " 200 OK", 7);
					xmlNewChild(r_prop, NULL, BAD_CAST "status", BAD_CAST r_status);
					free(r_status);
				}
			}
			else if (action == 1) {
				if (uwsgi_webdav_prop_del(filename, (char *) node->name, node->ns ? (char *) node->ns->href : NULL)) {
					char *r_status = uwsgi_concat2n(wsgi_req->protocol, wsgi_req->protocol_len, " 403 Forbidden", 14);
					xmlNewChild(r_prop, NULL, BAD_CAST "status", BAD_CAST r_status);
					free(r_status);
				}
				else {
					char *r_status = uwsgi_concat2n(wsgi_req->protocol, wsgi_req->protocol_len, " 200 OK", 7);
					xmlNewChild(r_prop, NULL, BAD_CAST "status", BAD_CAST r_status);
					free(r_status);
				}
			}
		}
	}
}
Exemple #22
0
static void
mpp_write_string_list (xmlNodePtr   node,
		       MrpProperty *property,
		       MrpObject   *object)
{
	xmlNodePtr   child;
	GArray      *array;
	GValue      *value;
	gint         i;

	mrp_object_get (object, mrp_property_get_name (property), &array, NULL);
	if (!array) {
		return;
	}

	for (i = 0; i < array->len; i++) {
		value = g_array_index (array, GValue *, i);

		child = xmlNewChild (node, NULL, "list-item", NULL);
		xmlSetProp (child, "value", g_value_get_string (value));
	}

	g_array_free (array, TRUE);
}
Exemple #23
0
static void op_history_insert(xmlNode *resource_xml,
	struct operation_history *oh)
{
	xmlNode *op;
	char key[255];
	char magic[255];

	qb_enter();

	op = xmlNewChild(resource_xml, NULL, BAD_CAST "lrm_rsc_op", NULL);

	xmlNewProp(op, BAD_CAST "id", BAD_CAST oh->rsc_id);
	xmlNewProp(op, BAD_CAST "operation", BAD_CAST oh->operation);
	xml_new_int_prop(op, "call-id", oh->call_id);
	xml_new_int_prop(op, "rc-code", oh->rc);
	xml_new_int_prop(op, "interval", oh->interval);
	xml_new_time_prop(op, "last-run", oh->last_run);
	xml_new_time_prop(op, "last-rc-change", oh->last_rc_change);

	snprintf(key, 255, "%d:%d:%d:%s",
		oh->action_id, oh->graph_id, oh->target_outcome, crmd_uuid);

	xmlNewProp(op, BAD_CAST "transition-key", BAD_CAST key);

	snprintf(magic, 255, "0:%d:%s", oh->rc, key);
	xmlNewProp(op, BAD_CAST "transition-magic", BAD_CAST magic);

	xmlNewProp(op, BAD_CAST "op-digest", BAD_CAST oh->op_digest);
	xmlNewProp(op, BAD_CAST "crm-debug-origin", BAD_CAST __func__);
	xmlNewProp(op, BAD_CAST "crm_feature_set", BAD_CAST PE_CRM_VERSION);
	xmlNewProp(op, BAD_CAST "op-status", BAD_CAST "0");
	xmlNewProp(op, BAD_CAST "exec-time", BAD_CAST "0");
	xmlNewProp(op, BAD_CAST "queue-time", BAD_CAST "0");

	qb_leave();
}
Exemple #24
0
static void
draw_polyline(DiaRenderer *self, 
	      Point *points, int num_points, 
	      Color *line_colour)
{
  DiaSvgRenderer *renderer = DIA_SVG_RENDERER (self);
  int i;
  xmlNodePtr node;
  GString *str;
  gchar px_buf[DTOSTR_BUF_SIZE];
  gchar py_buf[DTOSTR_BUF_SIZE];

  node = xmlNewChild(renderer->root, renderer->svg_name_space, (const xmlChar *)"polyline", NULL);

  xmlSetProp(node, (const xmlChar *)"style", (xmlChar *) get_draw_style(renderer, NULL, line_colour));

  str = g_string_new(NULL);
  for (i = 0; i < num_points; i++)
    g_string_append_printf(str, "%s,%s ",
		      dia_svg_dtostr(px_buf, points[i].x),
		      dia_svg_dtostr(py_buf, points[i].y) );
  xmlSetProp(node, (const xmlChar *)"points", (xmlChar *) str->str);
  g_string_free(str, TRUE);
}
static xmlNodePtr
taxtable_dom_tree_create (GncTaxTable *table)
{
    xmlNodePtr ret, entries;
    GList *list;

    ret = xmlNewNode(NULL, BAD_CAST gnc_taxtable_string);
    xmlSetProp(ret, BAD_CAST "version", BAD_CAST taxtable_version_string);

    maybe_add_guid(ret, taxtable_guid_string, table);
    xmlAddChild(ret, text_to_dom_tree (taxtable_name_string,
                                       gncTaxTableGetName (table)));

    xmlAddChild(ret, int_to_dom_tree (taxtable_refcount_string,
                                      gncTaxTableGetRefcount (table)));
    xmlAddChild(ret, int_to_dom_tree (taxtable_invisible_string,
                                      gncTaxTableGetInvisible (table)));

    /* We should not be our own child */
    if (gncTaxTableGetChild(table) != table)
        maybe_add_guid(ret, taxtable_child_string, gncTaxTableGetChild (table));

    maybe_add_guid(ret, taxtable_parent_string, gncTaxTableGetParent (table));

    entries = xmlNewChild (ret, NULL, BAD_CAST taxtable_entries_string, NULL);
    for (list = gncTaxTableGetEntries (table); list; list = list->next)
    {
        GncTaxTableEntry *entry = static_cast<decltype(entry)>(list->data);
        xmlAddChild(entries, ttentry_dom_tree_create (entry));
    }

    /* xmlAddChild won't do anything with a NULL, so tests are superfluous. */
    xmlAddChild(ret, qof_instance_slots_to_dom_tree(taxtable_slots_string,
                                                    QOF_INSTANCE(table)));
    return ret;
}
static void
inf_adopted_session_to_xml_sync_foreach_user_func(InfUser* user,
                                                  gpointer user_data)
{
  InfAdoptedRequestLog* log;
  InfAdoptedSessionToXmlSyncForeachData* data;
  InfAdoptedSessionClass* session_class;
  guint i;
  guint end;
  xmlNodePtr xml;
  InfAdoptedRequest* request;

  g_assert(INF_ADOPTED_IS_USER(user));

  data = (InfAdoptedSessionToXmlSyncForeachData*)user_data;
  log = inf_adopted_user_get_request_log(INF_ADOPTED_USER(user));
  end = inf_adopted_request_log_get_end(log);
  session_class = INF_ADOPTED_SESSION_GET_CLASS(data->session);
  g_assert(session_class->request_to_xml != NULL);

  for(i = inf_adopted_request_log_get_begin(log); i < end; ++ i)
  {
    request = inf_adopted_request_log_get_request(log, i);

    xml = xmlNewChild(
      data->parent_xml,
      NULL,
      (const xmlChar*)"sync-request",
      NULL
    );

    /* TODO: Diff to previous request? */
    session_class->request_to_xml(data->session, xml, request, NULL, TRUE);
    xmlAddChild(data->parent_xml, xml);
  }
}
Exemple #27
0
static void
mpp_write_group (MrpParser *parser, xmlNodePtr parent, MrpGroup *group)
{
	NodeEntry  *entry;
	xmlNodePtr  node;
	gchar      *name, *admin_name, *admin_phone, *admin_email;

	g_return_if_fail (MRP_IS_GROUP (group));

	node = xmlNewChild (parent,
                            NULL,
			    "group",
			    NULL);

	entry = g_hash_table_lookup (parser->group_hash, group);
	entry->node = node;

	mpp_xml_set_int (node, "id", entry->id);

	g_object_get (group,
		      "name", &name,
		      "manager-name", &admin_name,
		      "manager-phone", &admin_phone,
		      "manager-email", &admin_email,
		      NULL);

	xmlSetProp (node, "name", name);
	xmlSetProp (node, "admin-name", admin_name);
	xmlSetProp (node, "admin-phone", admin_phone);
	xmlSetProp (node, "admin-email", admin_email);

	g_free (name);
	g_free (admin_name);
	g_free (admin_phone);
	g_free (admin_email);
}
Exemple #28
0
static void
vfolder_export (nodePtr node,
                xmlNodePtr cur,
                gboolean trusted)
{
	vfolderPtr	vfolder = (vfolderPtr) node->data;
	xmlNodePtr	ruleNode;
	rulePtr		rule;
	GSList		*iter;

	debug_enter ("vfolder_export");
	
	g_assert (TRUE == trusted);
	
	xmlNewProp (cur, BAD_CAST"matchType", BAD_CAST (vfolder->itemset->anyMatch?"any":"all"));

	iter = vfolder->itemset->rules;
	while (iter) {
		rule = iter->data;
		ruleNode = xmlNewChild (cur, NULL, BAD_CAST"outline", NULL);
		xmlNewProp (ruleNode, BAD_CAST"type", BAD_CAST "rule");
		xmlNewProp (ruleNode, BAD_CAST"text", BAD_CAST rule->ruleInfo->title);
		xmlNewProp (ruleNode, BAD_CAST"rule", BAD_CAST rule->ruleInfo->ruleId);
		xmlNewProp (ruleNode, BAD_CAST"value", BAD_CAST rule->value);
		if (rule->additive)
			xmlNewProp (ruleNode, BAD_CAST"additive", BAD_CAST "true");
		else
			xmlNewProp (ruleNode, BAD_CAST"additive", BAD_CAST "false");

		iter = g_slist_next (iter);
	}
	
	debug1 (DEBUG_CACHE, "adding vfolder: title=%s", node_get_title (node));

	debug_exit ("vfolder_export");
}
xmlNodePtr
create_param_node (xmlDocPtr doc,
                   SoupSoapParam *param,
                   xmlNodePtr parent_node)
{
	xmlNodePtr node = xmlNewChild (parent_node, NULL,
	                               BAD_CAST soup_soap_param_get_name (param),
	                               NULL);

	SoupSoapParam *param_child;

	if (SOUP_SOAP_IS_PARAM_GROUP (param))
	{
		GList *elements =
			soup_soap_param_group_get_elements (SOUP_SOAP_PARAM_GROUP (param));
		GList *curr_element = elements;

		while (curr_element)
		{
			param_child = curr_element->data;

			create_param_node (doc, param_child, node);

			curr_element = g_list_next (curr_element);
		}
	}
	else
	{
		xmlChar *content = xmlEncodeEntitiesReentrant (doc,
		                                               BAD_CAST soup_soap_param_get_value (param));
		xmlNodeSetContent (node, content);
		xmlFree (content);
	}

	return node;
}
/**
 * rb_playlist_source_save_to_xml:
 * @source: the playlist source to save
 * @parent_node: libxml node below which to save the playlist
 *
 * Converts the playlist to XML format, below the specified
 * parent node.
 */
void
rb_playlist_source_save_to_xml (RBPlaylistSource *source,
				xmlNodePtr parent_node)
{
	xmlNodePtr node;
	xmlChar *name;
	GSettings *settings;
	RBPlaylistSourceClass *klass = RB_PLAYLIST_SOURCE_GET_CLASS (source);

	g_return_if_fail (RB_IS_PLAYLIST_SOURCE (source));

	node = xmlNewChild (parent_node, NULL, RB_PLAYLIST_PLAYLIST, NULL);
	g_object_get (source, "name", &name, NULL);
	xmlSetProp (node, RB_PLAYLIST_NAME, name);
	g_free (name);

	g_object_get (source, "settings", &settings, NULL);
	if (settings) {
		char *p;
		xmlSetProp (node,
			    RB_PLAYLIST_SHOW_BROWSER,
			    (xmlChar *)(g_settings_get_boolean (settings, "show-browser") ? "true" : "false"));

		p = g_strdup_printf ("%d", g_settings_get_int (settings, "paned-position"));
		xmlSetProp (node, RB_PLAYLIST_BROWSER_POSITION, (xmlChar *)p);
		g_free (p);

		xmlSetProp (node, RB_PLAYLIST_SEARCH_TYPE, (xmlChar *)g_settings_get_string (settings, "search-type"));
		g_object_unref (settings);
	}


	klass->impl_save_contents_to_xml (source, node);

	source->priv->dirty = FALSE;
}