Ejemplo n.º 1
0
void cg_upnpav_content_copy(CgUpnpAvContent* destContent, CgUpnpAvContent* srcContent)
{
  CgXmlAttribute* attr;
  CgUpnpAvContent* destNode;
  CgUpnpAvContent* srcNode;

  cg_xml_node_setname(destContent, cg_xml_node_getname(srcContent));
  cg_xml_node_setvalue(destContent, cg_xml_node_getvalue(srcContent));
  for (attr = cg_xml_node_getattributes(srcContent); attr; attr = cg_xml_attribute_next(attr))
    cg_xml_node_setattribute(destContent, cg_xml_attribute_getname(attr), cg_xml_attribute_getvalue(attr));

  for (srcNode = cg_xml_node_getchildnodes(srcContent); srcNode; srcNode = cg_xml_node_next(srcNode)) {
    if (cg_upnpav_content_gettype(srcNode) != CG_UPNPAV_CONTENT_NONE)
      continue;
    if (cg_streq(cg_xml_node_getname(srcNode), CG_UPNPAV_RESOURCE_NAME)) {
      destNode = cg_upnpav_resource_new();
      cg_upnpav_resource_copy(destNode, srcNode);
    }
    else {
      destNode = cg_upnpav_content_new();
      cg_xml_node_setname(destNode, cg_xml_node_getname(srcNode));
      cg_xml_node_setvalue(destNode, cg_xml_node_getvalue(srcNode));
      for (attr = cg_xml_node_getattributes(srcNode); attr; attr = cg_xml_attribute_next(attr))
        cg_xml_node_setattribute(destNode, cg_xml_attribute_getname(attr), cg_xml_attribute_getvalue(attr));
    }
    cg_xml_node_addchildnode(destContent, destNode);
  }
}
Ejemplo n.º 2
0
static CgUpnpProperty *cg_upnp_property_createfromnode(CgXmlNode *varNode)
{
    CgUpnpProperty *prop;
    char *varName;
    char *varValue;
    ssize_t colonIdx;

    cg_log_debug_l4("Entering...\n");

    prop = cg_upnp_property_new();
    if (varNode == NULL)
        return prop;

    // remove the event namespace
    varName = cg_xml_node_getname(varNode);
    colonIdx = cg_strstr(varName, ":");
    if (0 <= colonIdx)
        varName = varName + colonIdx + 1;
    varValue = cg_xml_node_getvalue(varNode);
    cg_upnp_property_setname(prop, varName);
    cg_upnp_property_setvalue(prop, varValue);

    cg_log_debug_l4("Leaving...\n");

    return prop;
}
Ejemplo n.º 3
0
void cg_xml_node_copy(CgXmlNode *dstNode, CgXmlNode *srcNode)
{
	CgXmlAttribute *attr;
	CgXmlNode *dstChildNode;
	CgXmlNode *srcChildNode;
	
	cg_log_debug_l4("Entering...\n");
	
	if (!dstNode || !srcNode)
		return;

	cg_xml_node_setname(dstNode, cg_xml_node_getname(srcNode));
	cg_xml_node_setvalue(dstNode, cg_xml_node_getvalue(srcNode));
	
	for (attr = cg_xml_node_getattributes(srcNode); attr != NULL; attr = cg_xml_attribute_next(attr))
		cg_xml_node_setattribute(dstNode, cg_xml_attribute_getname(attr), cg_xml_attribute_getvalue(attr));
	
	for (srcChildNode = cg_xml_node_getchildnodes(srcNode); srcChildNode != NULL; srcChildNode = cg_xml_node_next(srcChildNode)) {
		dstChildNode = cg_xml_node_new();
		cg_xml_node_copy(dstChildNode, srcChildNode);
		cg_xml_node_addchildnode(dstNode, dstChildNode);
	}
	
	 cg_log_debug_l4("Leaving...\n");
}
Ejemplo n.º 4
0
void cg_upnpav_resource_copy(CgUpnpAvResource *destRes, CgUpnpAvResource *srcRes)
{
    CgXmlAttribute *attr;

    cg_xml_node_setname(destRes, cg_xml_node_getname(srcRes));
    cg_xml_node_setvalue(destRes, cg_xml_node_getvalue(srcRes));
    for (attr=cg_xml_node_getattributes(srcRes); attr; attr=cg_xml_attribute_next(attr))
        cg_xml_node_setattribute(destRes, cg_xml_attribute_getname(attr), cg_xml_attribute_getvalue(attr));
    cg_upnpav_resource_data_copy((CgUpnpAvResourceData *)cg_xml_node_getuserdata(destRes), (CgUpnpAvResourceData *)cg_xml_node_getuserdata(srcRes));
}
Ejemplo n.º 5
0
char *cg_upnp_control_query_response_getreturnvalue(CgUpnpQueryResponse *queryRes)
{
	CgXmlNode *returnNode;
	
	cg_log_debug_l4("Entering...\n");

	returnNode = cg_upnp_control_query_response_getreturnnode(queryRes);
	if (returnNode == NULL)
		return "";
	return cg_xml_node_getvalue(returnNode);

	cg_log_debug_l4("Leaving...\n");
}
Ejemplo n.º 6
0
char *cg_xml_node_getchildnodevalue(CgXmlNode *node, char *name)
{
	CgXmlNode *childNode;

	cg_log_debug_l4("Entering...\n");

	childNode = cg_xml_node_getchildnode(node, name);
	if (childNode != NULL)
		return cg_xml_node_getvalue(childNode);

	cg_log_debug_l4("Leaving...\n");

	return NULL;
}
Ejemplo n.º 7
0
static char *cg_xml_node_tostring_indent(CgXmlNode *node, int indentLevel, BOOL withChildNode, CgString *str)
{
	char *name;
	char *value;
	CgString *valueStr;
	CgXmlNode *childNode;
	
	cg_log_debug_l4("Entering...\n");

	name = cg_xml_node_getname(node);
	value = cg_xml_node_getvalue(node);

	if (cg_xml_node_haschildnodes(node) == FALSE || withChildNode == FALSE) {
		cg_string_addrepvalue(str, CG_XML_INDENT_STRING, indentLevel);
		if (!cg_string_naddvalue(str, "<", 1) ||
		    !cg_string_addvalue(str, name) ||
		    !cg_xml_node_attribute_tostring(node, str))
			/* Memory allocation failed */
			return NULL;
		
		valueStr = cg_string_new();
		if (!valueStr)
			/* Memory allocation failed */
			return NULL;
		
		cg_string_setvalue(valueStr, value);
		cg_xml_escapechars(valueStr);

		if (!cg_string_naddvalue(str, ">", 1) ||
		    !cg_string_addvalue(str, cg_string_getvalue(valueStr)) ||
		    !cg_string_naddvalue(str, "</", 2) ||
		    !cg_string_addvalue(str, name) ||
		    !cg_string_naddvalue(str, ">", 1) ||
		    !cg_string_addvalue(str, "\n"))
		{
			/* Memory allocation failed */
			cg_string_delete(valueStr);
			return NULL;
		}

		cg_string_delete(valueStr);
		
		return cg_string_getvalue(str);
	}

	cg_string_addrepvalue(str, CG_XML_INDENT_STRING, indentLevel);
	if (!cg_string_naddvalue(str, "<", 1) ||
	    !cg_string_addvalue(str, name) ||
	    !cg_xml_node_attribute_tostring(node, str) ||
	    !cg_string_naddvalue(str, ">", 1) ||
	    !cg_string_addvalue(str, "\n"))
		/* Memory allocation failed */
		return NULL;

	for (childNode = cg_xml_node_getchildnodes(node); childNode != NULL; childNode = cg_xml_node_next(childNode))
		if (!cg_xml_node_tostring_indent(childNode, indentLevel+1, TRUE, str))
			/* Memory allocation failed */
			return NULL;

	cg_string_addrepvalue(str, CG_XML_INDENT_STRING, indentLevel);
	if (!cg_string_naddvalue(str, "</", 2) ||
	    !cg_string_addvalue(str, name) ||
	    !cg_string_naddvalue(str, ">", 1) ||
	    !cg_string_addvalue(str, "\n"))
		/* Memory allocation failed */
		return NULL;

	cg_log_debug_l4("Leaving...\n");
	
	return cg_string_getvalue(str);
}