Esempio n. 1
0
static int
xmlconfig_load_timer( xmlTextReaderPtr reader )
{
	int ret;
	const xmlChar *name;
        
	ret = xmlTextReaderRead( reader );
	while ( ret == 1 ) {
		name = xmlTextReaderConstName( reader );
		if ( name &&
                    (XML_READER_TYPE_END_ELEMENT != xmlTextReaderNodeType( reader )) &&
                    ( 0 == xmlStrncmp( name, (const xmlChar *)"Timer", 7 ) ) )
		{
			const xmlChar *nodeid = xmlTextReaderGetAttribute( reader, (const xmlChar*)"node" );
			const xmlChar *tname = xmlTextReaderGetAttribute( reader, (const xmlChar*)"name" );
			const xmlChar *on = xmlTextReaderGetAttribute( reader, (const xmlChar*)"on" );
			const xmlChar *off = xmlTextReaderGetAttribute( reader, (const xmlChar*)"off" );
                        
			SYSLOG_DEBUG( "xmlconfig_load_timer: Name=%s Id=%s ON=%s, OFF=%s",
                                     tname, nodeid, on, off );
                }
		if ( (XML_READER_TYPE_END_ELEMENT == xmlTextReaderNodeType( reader )) &&
			(0 == xmlStrncmp(name, (const xmlChar *)"TimerConfig", 11)))
			break;

		ret = xmlTextReaderRead( reader );
	}
	return ret;
}
Esempio n. 2
0
MANSCDP_xml_type get_xml_type(char* xml_type_string)
{
    if(NULL == xml_type_string)
    {
        return MANSCDP_xml_Unknown;
    }

    if(0 == xmlStrncmp(xml_type_string, "Control", xmlStrlen("Control")))
    {
        return MANSCDP_xml_Control;
    }
    if(0 == xmlStrncmp(xml_type_string, "Query", xmlStrlen("Query")))
    {
        return MANSCDP_xml_Query;
    }
    if(0 == xmlStrncmp(xml_type_string, "Notify", xmlStrlen("Notify")))
    {
        return MANSCDP_xml_Notify;
    }
    if(0 == xmlStrncmp(xml_type_string, "Response", xmlStrlen("Response")))
    {
        return MANSCDP_xml_Response;
    }

    return MANSCDP_xml_Unknown;
}
Esempio n. 3
0
static int
xmlconfig_load_node( xmlTextReaderPtr reader )
{
	int ret;
	const xmlChar *name;
        
	ret = xmlTextReaderRead( reader );
	while ( ret == 1 ) {
		name = xmlTextReaderConstName( reader );
		if ( name &&
                    (XML_READER_TYPE_END_ELEMENT != xmlTextReaderNodeType( reader )) &&
                    ( 0 == xmlStrncmp( name, (const xmlChar *)"Node", 7 ) ) )
		{
			const xmlChar *id = xmlTextReaderGetAttribute( reader, (const xmlChar*)"id" );
			const xmlChar *nname = xmlTextReaderGetAttribute( reader, (const xmlChar*)"name" );
			const xmlChar *type = xmlTextReaderGetAttribute( reader, (const xmlChar*)"type" );
                        
			SYSLOG_DEBUG( "xmlconfig_load_node: Name=%s Id=%s Type=%s",
                                     	nname, id, type );
                        
                        ret = zw_node_set_label( atoi((const char*)id), (char *)nname );
                        if ( ret )
                                SYSLOG_DEBUG( "xmlconfig_load_node: set label for node(%d) failed %d", atoi((const char*)id), ret );
		}
		if ( (XML_READER_TYPE_END_ELEMENT == xmlTextReaderNodeType( reader )) &&
			(0 == xmlStrncmp(name, (const xmlChar *)"NodeConfig", 10)))
			break;
                
		ret = xmlTextReaderRead( reader );
	}
	return ret;
}
Esempio n. 4
0
MANSCDP_result_type get_MANSCDP_statues(char* MANSCDP_string)
{
    if(0 == xmlStrncmp(MANSCDP_string, "OK", xmlStrlen("OK")))
    {
        return MANSCDP_OK;
    }
    if(0 == xmlStrncmp(MANSCDP_string, "ERROR", xmlStrlen("ERROR")))
    {
        return MANSCDP_ERROR;
    }

    return MANSCDP_UNKNOWN_RESULT_TYPE;
}
Esempio n. 5
0
MANSCDP_on_off_line get_MANSCDP_online(char* MANSCDP_string)
{
    if(0 == xmlStrncmp(MANSCDP_string, "ONLINE", xmlStrlen("ONLINE")))
    {
        return MANSCDP_ONLINE;
    }
    if(0 == xmlStrncmp(MANSCDP_string, "OFFLINE", xmlStrlen("OFFLINE")))
    {
        return MANSCDP_OFFLINE;
    }

    return MANSCDP_UNKNOWN_ON_OFF_LINE;
}
void
ags_count_beats_audio_run_read(AgsFile *file, xmlNode *node, AgsPlugin *plugin)
{
  AgsCountBeatsAudioRun *count_beats_audio_run;
  AgsFileLookup *file_lookup;
  xmlNode *iter;

  /* read parent */
  ags_count_beats_audio_run_parent_plugin_interface->read(file, node, plugin);

  count_beats_audio_run = AGS_COUNT_BEATS_AUDIO_RUN(plugin);

  /* read depenendency */
  iter = node->children;

  while(iter != NULL){
    if(iter->type == XML_ELEMENT_NODE){
      if(!xmlStrncmp(iter->name,
		     "ags-dependency-list\0",
		     19)){
	xmlNode *dependency_node;

	dependency_node = iter->children;

	while(dependency_node != NULL){
	  if(dependency_node->type == XML_ELEMENT_NODE){
	    if(!xmlStrncmp(dependency_node->name,
			   "ags-dependency\0",
			   15)){
	      file_lookup = (AgsFileLookup *) g_object_new(AGS_TYPE_FILE_LOOKUP,
							   "file\0", file,
							   "node\0", dependency_node,
							   "reference\0", count_beats_audio_run,
							   NULL);
	      ags_file_add_lookup(file, (GObject *) file_lookup);
	      g_signal_connect(G_OBJECT(file_lookup), "resolve\0",
			       G_CALLBACK(ags_count_beats_audio_run_read_resolve_dependency), count_beats_audio_run);
	    }
	  }
	  
	  dependency_node = dependency_node->next;
	}
      }
    }

    iter = iter->next;
  }
}
Esempio n. 7
0
/**
 * xmlUTF8Strloc:
 * @utf:  the input UTF8 *
 * @utfchar:  the UTF8 character to be found
 *
 * a function to provide the relative location of a UTF8 char
 *
 * Returns the relative character position of the desired char
 * or -1 if not found
 */
int
xmlUTF8Strloc(const xmlChar *utf, const xmlChar *utfchar)
{
  int i, size;
  xmlChar ch;

  if (utf==NULL || utfchar==NULL) return -1;
  size = xmlUTF8Strsize(utfchar, 1);
  for (i=0; (ch=*utf) != 0; i++)
  {
    if (xmlStrncmp(utf, utfchar, size)==0)
      return(i);
    utf++;
    if ( ch & 0x80 )
    {
      /* if not simple ascii, verify proper format */
      if ( (ch & 0xc0) != 0xc0 )
        return(-1);
      /* then skip over remaining bytes for this char */
      while ( (ch <<= 1) & 0x80 )
        if ( (*utf++ & 0xc0) != 0x80 )
          return(-1);
    }
  }

  return(-1);
}
Esempio n. 8
0
static void
handle_start_sync (GstSamiContext * sctx, const xmlChar ** atts)
{
  int i;

  sami_context_pop_state (sctx, CLEAR_TAG);
  if (atts != NULL) {
    for (i = 0; (atts[i] != NULL); i += 2) {
      const xmlChar *key, *value;

      key = atts[i];
      value = atts[i + 1];

      if (!value)
        continue;
      if (!xmlStrncmp ((const xmlChar *) "start", key, 5)) {
        /* Only set a new start time if we don't have text pending */
        if (sctx->resultbuf->len == 0)
          sctx->time1 = sctx->time2;

        sctx->time2 = atoi ((const char *) value) * GST_MSECOND;
        g_string_append (sctx->resultbuf, sctx->buf->str);
        sctx->has_result = (sctx->resultbuf->len != 0) ? TRUE : FALSE;
        g_string_truncate (sctx->buf, 0);
      }
    }
  }
}
guint*
ags_script_object_read_index(gchar *xpath, guint *index_length)
{
  guint *index;
  gchar *offset;
  guint i;

  index = NULL;
  offset = xpath;
  i = 0;

  while((offset = strchr(offset, '[')) != NULL && offset[0] != '\0'){
    if(i == 0){
      index = (guint *) malloc(sizeof(guint));
    }else{
      index = (guint *) realloc(index, (i + 1) * sizeof(guint));
    }

    if(!xmlStrncmp(offset, "last()\0", 7)){
      index[i] = AGS_SCRIPT_OBJECT_XPATH_NaN;
    }else{
      sscanf(xpath, "%d\0", &(index[i]));
    }

    offset = &(offset[1]);
    i++;
  }

  *index_length = i;

  return(index);
}
Esempio n. 10
0
/**
 * \brief Remove input plugin from supportedCollectors tag
 * 
 * \param info tool configuration
 * \return 0 on success
 */
int remove_supported(conf_info_t *info)
{
	int i;
	xmlNodePtr children1;
	xmlXPathObjectPtr xpath_obj_file = eval_xpath(info, TAG_SUPPORTED);
	if (!xpath_obj_file) {
		return 1;
	}
	
	for (i = 0; i < xpath_obj_file->nodesetval->nodeNr; i++) {
		children1 = xpath_obj_file->nodesetval->nodeTab[i]->children;
		while (children1) {
			if ((!strncmp ((char*) children1->name, "name", strlen ("name") + 1))
			        && (!xmlStrncmp (children1->children->content, (xmlChar *) info->name, xmlStrlen ((xmlChar *)info->name) + 1))) {
				/* element found*/
				xmlUnlinkNode(children1);
				xmlFreeNode(children1);
				return 0;
			}
			children1 = children1->next;
		}
	}
	
	return 0;
}
static gboolean
mate_da_xml_get_bool (const xmlNode *parent, const gchar *val_name)
{
    xmlNode *element;
    gboolean ret_val = FALSE;
    xmlChar *xml_val_name;
    gint len;

    g_return_val_if_fail (parent != NULL, FALSE);
    g_return_val_if_fail (parent->children != NULL, ret_val);
    g_return_val_if_fail (val_name != NULL, FALSE);

    xml_val_name = xmlCharStrdup (val_name);
    len = xmlStrlen (xml_val_name);

    for (element = parent->children; element != NULL; element = element->next) {
	if (!xmlStrncmp (element->name, xml_val_name, len)) {
	    xmlChar *cont = xmlNodeGetContent (element);

	    if (!xmlStrcasecmp (cont, "true") || !xmlStrcasecmp (cont, "1"))
		ret_val = TRUE;
	    else
		ret_val = FALSE;

	    xmlFree (cont);
	}
    }

    xmlFree (xml_val_name);
    return ret_val;
}
Esempio n. 12
0
static void
start_sami_element (void *ctx, const xmlChar * name, const xmlChar ** atts)
{
  GstSamiContext *sctx = (GstSamiContext *) ctx;

  GST_LOG ("name:%s", name);

  if (!xmlStrncmp ((const xmlChar *) "sync", name, 4)) {
    handle_start_sync (sctx, atts);
    sctx->in_sync = TRUE;
  } else if (!xmlStrncmp ((const xmlChar *) "font", name, 4)) {
    handle_start_font (sctx, atts);
  } else if (!xmlStrncmp ((const xmlChar *) "ruby", name, 4)) {
    sami_context_push_state (sctx, RUBY_TAG);
  } else if (!xmlStrncmp ((const xmlChar *) "br", name, 2)) {
    g_string_append_c (sctx->buf, '\n');
    /* FIXME: support for furigana/ruby once implemented in pango */
  } else if (!xmlStrncmp ((const xmlChar *) "rt", name, 2)) {
    if (has_tag (sctx->state, ITALIC_TAG)) {
      g_string_append (sctx->rubybuf, "<i>");
    }
    g_string_append (sctx->rubybuf, "<span size='xx-small' rise='-100'>");
    sami_context_push_state (sctx, RT_TAG);
  } else if (!xmlStrncmp ((const xmlChar *) "p", name, 1)) {
  } else if (!xmlStrncmp ((const xmlChar *) "i", name, 1)) {
    g_string_append (sctx->buf, "<i>");
    sami_context_push_state (sctx, ITALIC_TAG);
  }
}
Esempio n. 13
0
static const NsEntry*
lookup_ns_entry(const char *prefix, int len) {
    int i;
    for (i = 0; i < COUNT_OF(ns_entries); i++) {
        if (xmlStrncmp(BAD_CAST prefix, ns_entries[i].prefix, len) == 0)
            return &ns_entries[i];
    }
    return NULL;
}
Esempio n. 14
0
/**
 * xmlUTF8Charcmp:
 * @utf1: pointer to first UTF8 char
 * @utf2: pointer to second UTF8 char
 *
 * compares the two UCS4 values
 *
 * returns result of the compare as with xmlStrncmp
 */
int
xmlUTF8Charcmp(const xmlChar *utf1, const xmlChar *utf2) {

    if (utf1 == NULL ) {
        if (utf2 == NULL)
            return 0;
        return -1;
    }
    return xmlStrncmp(utf1, utf2, xmlUTF8Size(utf1));
}
Esempio n. 15
0
static void
end_sami_element (void *ctx, const xmlChar * name)
{
  GstSamiContext *sctx = (GstSamiContext *) ctx;

  GST_LOG ("name:%s", name);

  if (!xmlStrncmp ((const xmlChar *) "sync", name, 4)) {
    sctx->in_sync = FALSE;
  } else if ((!xmlStrncmp ((const xmlChar *) "body", name, 4)) ||
      (!xmlStrncmp ((const xmlChar *) "sami", name, 4))) {
    /* We will usually have one buffer left when the body is closed
     * as we need the next sync to actually send it */
    if (sctx->buf->len != 0) {
      /* Only set a new start time if we don't have text pending */
      if (sctx->resultbuf->len == 0)
        sctx->time1 = sctx->time2;

      sctx->time2 = GST_CLOCK_TIME_NONE;
      g_string_append (sctx->resultbuf, sctx->buf->str);
      sctx->has_result = (sctx->resultbuf->len != 0) ? TRUE : FALSE;
      g_string_truncate (sctx->buf, 0);
    }
  } else if (!xmlStrncmp ((const xmlChar *) "font", name, 4)) {
    sami_context_pop_state (sctx, SPAN_TAG);
  } else if (!xmlStrncmp ((const xmlChar *) "ruby", name, 4)) {
    sami_context_pop_state (sctx, RUBY_TAG);
  } else if (!xmlStrncmp ((const xmlChar *) "i", name, 1)) {
    sami_context_pop_state (sctx, ITALIC_TAG);
  }
}
Esempio n. 16
0
/**
 * xsltUTF8Charcmp
 * @utf1: pointer to first UTF8 char
 * @utf2: pointer to second UTF8 char
 *
 * returns result of comparing the two UCS4 values
 * as with xmlStrncmp
 */
static int
xsltUTF8Charcmp(xmlChar *utf1, xmlChar *utf2) {
    int len = xmlUTF8Strsize(utf1, 1);

    if (len < 1)
        return -1;
    if (utf1 == NULL ) {
        if (utf2 == NULL)
            return 0;
        return -1;
    }
    return xmlStrncmp(utf1, utf2, len);
}
Esempio n. 17
0
MANSCDP_command_type get_MANSCDP_command_type(char* MANSCDP_command_string)
{
    if(NULL == MANSCDP_command_string)
    {
        return MANSCDP_command_type_unknown;
    }

    if(0 == xmlStrncmp(MANSCDP_command_string, "DeviceInfo", xmlStrlen("DeviceInfo")))
    {
        return MANSCDP_DeviceInfo;
    }
    if(0 == xmlStrncmp(MANSCDP_command_string, "DeviceStatus", xmlStrlen("DeviceStatus")))
    {
        return MANSCDP_DeviceStatus;
    }
    if(0 == xmlStrncmp(MANSCDP_command_string, "Catalog", xmlStrlen("Catalog")))
    {
        return MANSCDP_Catalog;
    }

    return MANSCDP_command_type_unknown;
}
Esempio n. 18
0
int xmlconfig_load( const char *filename )
{
	int rc = -1;
	int ret;
	xmlTextReaderPtr reader;
	const xmlChar *name;
        
	reader = xmlReaderForFile( filename, NULL, 0 );
	if ( reader != NULL ) {
		ret = xmlTextReaderRead( reader );
		while (ret == 1) {
			name = xmlTextReaderConstName( reader );
			if ( name &&
                            (XML_READER_TYPE_ELEMENT == xmlTextReaderNodeType( reader )) &&
                            ( 0 == xmlStrncmp( name, (const xmlChar *)"NodeConfig", 10 ) ) )
			{
				xmlconfig_load_node( reader );
			}
			else if ( name &&
                            (XML_READER_TYPE_ELEMENT == xmlTextReaderNodeType( reader )) &&
                            ( 0 == xmlStrncmp( name, (const xmlChar *)"TimerConfig", 10 ) ) )
			{
				xmlconfig_load_timer( reader );
			}
			ret = xmlTextReaderRead( reader );
		}
		xmlFreeTextReader( reader );
		if (ret != 0) {
			fprintf( stderr, "%s : failed to parse\n", filename );
			goto out;
		}
		rc = 0;
	} else {
		fprintf( stderr, "Unable to open %s\n", filename );
	}
out:
	return rc;
}
Esempio n. 19
0
void
ags_drum_input_pad_launch_task(AgsFileLaunch *file_launch, AgsDrumInputPad *drum_input_pad)
{
  xmlNode *node;

  node = file_launch->node;

  if(!xmlStrncmp(xmlGetProp(node,
			    "edit"),
		 AGS_FILE_TRUE,
		 5)){
    gtk_button_clicked((GtkButton *) drum_input_pad->edit);
  }
}
Esempio n. 20
0
struct cspay_config *
read_cspay_xml(char *fname)
{
	/*TODO
	 * validarea fisierului
	 */
	struct cspay_config *cfg;
	xmlDoc *doc = NULL;
	xmlNode *root_element = NULL;
	
	LIBXML_TEST_VERSION
	
	doc = xmlReadFile(fname, NULL, 0);
	if (!doc){
		fprintf(stderr, "*.xml file not found, try cspay.xml\n");
		doc = xmlReadFile("cspay.xml", NULL, 0);
		if (!doc) {
			fprintf(stderr, "cspay.xml not found, bye!\n");
			return NULL;
		}
	}
	
	Dprintf("Read *.xml\n");
	
	root_element = xmlDocGetRootElement(doc);
	if (!root_element){
		fprintf(stderr, "root_element\n");
		return NULL;
	}
	if (xmlStrncmp(root_element->name, (xmlChar *)"cspay-config", 12)) {
		fprintf(stderr, "This is not cspay-config xml file\n");
		return NULL;
	}
	cfg = malloc(sizeof (struct cspay_config));
	if (!cfg) {
		fprintf(stderr, "malloc cspay_config");
		return NULL;
	}
	cfg->vac_no = 0;
	cfg->fac_no = 0;
	
	Dprintf("Read root_element\n");
	
	cspay_xml_extract_from_tree(root_element, cfg);
	
	xmlFreeDoc(doc);
	xmlCleanupParser();

	return cfg;
}
Esempio n. 21
0
/*
 * process_enumerate_request_from_doc --
 *	    looks for the object through the context ptr and sets the
 *	    request with object type.
 *
 * ctext: context ptr for the original doc to parse request info.
 * req: request to be filled up.
 *
 * Returns 0 if successful or an error code otherwise.
 */
static int
process_enumerate_request_from_doc(xmlXPathContextPtr ctext, request_t *req)
{
	xmlChar expr[ISNS_MAX_LABEL_LEN + 13];
	xmlXPathObjectPtr xpath_obj = NULL;
	int i;

	int obj = 0;

	isnslog(LOG_DEBUG, "process_enumerate_request_from_doc", "entered");
	(void) xmlStrPrintf(expr, ISNS_MAX_LABEL_LEN + 13,
	    XMLSTRING_CAST "%s\"%s\"]", "//*[name()=", ISNSOBJECTTYPE);
	xpath_obj = xmlXPathEvalExpression(expr, ctext);
	isnslog(LOG_DEBUG, "process_enumerate_request_from_doc",
	"xpath obj->nodesetval->nodeNR: %d", xpath_obj->nodesetval->nodeNr);
	if ((xpath_obj) && (xpath_obj->nodesetval) &&
	    (xpath_obj->nodesetval->nodeNr > 0) &&
	    (xpath_obj->nodesetval->nodeTab)) {
	    for (i = 0; obj_table[i].obj_str != NULL; i++) {
		if (xmlStrncmp(
		    xpath_obj->nodesetval->nodeTab[0]->children->content,
		    (xmlChar *)obj_table[i].obj_str, xmlStrlen((xmlChar *)
		    xpath_obj->nodesetval->nodeTab[0]->children->content))
		    == 0) {
		    obj = obj_table[i].obj_id;
		    break;
		}
	    }
	} else {
	    if (xpath_obj) xmlXPathFreeObject(xpath_obj);
	    return (ERR_XML_VALID_OBJECT_NOT_FOUND);
	}

	if (xpath_obj) xmlXPathFreeObject(xpath_obj);

	if (obj == 0) {
	    return (ERR_XML_VALID_OBJECT_NOT_FOUND);
	}

	req->op_info.obj = obj;

	if (ISNS_MGMT_OBJECT_TYPE_ENABLED()) {
	    ISNS_MGMT_OBJECT_TYPE(obj);
	}

	return (0);
}
static gchar*
mate_da_xml_get_string (const xmlNode *parent, const gchar *val_name)
{
    const gchar * const *sys_langs;
    xmlChar *node_lang;
    xmlNode *element;
    gchar *ret_val = NULL;
    xmlChar *xml_val_name;
    gint len;
    gint i;

    g_return_val_if_fail (parent != NULL, ret_val);
    g_return_val_if_fail (parent->children != NULL, ret_val);
    g_return_val_if_fail (val_name != NULL, ret_val);

#if GLIB_CHECK_VERSION (2, 6, 0)
    sys_langs = g_get_language_names ();
#endif

    xml_val_name = xmlCharStrdup (val_name);
    len = xmlStrlen (xml_val_name);

    for (element = parent->children; element != NULL; element = element->next) {
	if (!xmlStrncmp (element->name, xml_val_name, len)) {
	    node_lang = xmlNodeGetLang (element);

	    if (node_lang == NULL) {
		ret_val = (gchar *) xmlNodeGetContent (element);
	    }
	    else {
		for (i = 0; sys_langs[i] != NULL; i++) {
		    if (!strcmp (sys_langs[i], node_lang)) {
			ret_val = (gchar *) xmlNodeGetContent (element);
			/* since sys_langs is sorted from most desirable to
			 * least desirable, exit at first match
			 */
			break;
		    }
		}
	    }
	    xmlFree (node_lang);
	}
    }

    xmlFree (xml_val_name);
    return ret_val;
}
Esempio n. 23
0
const xmlChar *
xmlStrstr(const xmlChar *str, const xmlChar *val) {
    int n;

    if (str == NULL) return(NULL);
    if (val == NULL) return(NULL);
    n = xmlStrlen(val);

    if (n == 0) return(str);
    while (*str != 0) { /* non input consuming */
        if (*str == *val) {
            if (!xmlStrncmp(str, val, n)) return((const xmlChar *) str);
        }
        str++;
    }
    return(NULL);
}
Esempio n. 24
0
/**
 * \brief Check element existence
 */
xmlNodePtr get_node(xmlXPathObjectPtr xpath_obj_file, char *nameval, char *nametag)
{
	int i;
	xmlNodePtr children1;
	
	for (i = 0; i < xpath_obj_file->nodesetval->nodeNr; i++) {
		children1 = xpath_obj_file->nodesetval->nodeTab[i]->children;
		while (children1) {
			if ((!strncmp ((char*) children1->name, nametag, strlen (nametag) + 1))
					&& (!xmlStrncmp (children1->children->content, (xmlChar *) nameval, xmlStrlen ((xmlChar *)nameval) + 1))) {
				/* element found*/
				return xpath_obj_file->nodesetval->nodeTab[i];
			}
			children1 = children1->next;
		}
	}
	return NULL;
}
Esempio n. 25
0
/**
 * \brief Get the node's children node with given name.
 * @param[in] node Search in the children nodes of this node.
 * @param[in] children_name Name of the requested children node.
 * @return Pointer to the children node with requested name. It should not be
 * freed since it is children of given node.
 */
static inline xmlNodePtr get_children(xmlNodePtr node, const xmlChar* children_name)
{
	/* check validity of parameters */
	if (!node || !children_name) {
		return (NULL);
	}

	xmlNodePtr children = node->children;

	while (children) {
		if (!xmlStrncmp(children->name, children_name, xmlStrlen(children_name) + 1)) {
			return (children);
		}
		children = children->next;
	}

	return (children);
}
Esempio n. 26
0
void
ags_synth_input_line_read(AgsFile *file, xmlNode *node, AgsPlugin *plugin)
{
  AgsSynthInputLine *gobject;
  AgsFileLookup *file_lookup;
  xmlNode *child;

  gobject = AGS_SYNTH_INPUT_LINE(plugin);

  ags_file_add_id_ref(file,
		      g_object_new(AGS_TYPE_FILE_ID_REF,
				   "application-context", file->application_context,
				   "file", file,
				   "node", node,
				   "xpath", g_strdup_printf("xpath=//*[@id='%s']", xmlGetProp(node, AGS_FILE_ID_PROP)),
				   "reference", gobject,
				   NULL));

  gobject->oscillator = ags_oscillator_new();

  file_lookup = (AgsFileLookup *) g_object_new(AGS_TYPE_FILE_LOOKUP,
					       "file", file,
					       "node", node,
					       "reference", gobject,
					       NULL);
  ags_file_add_lookup(file, (GObject *) file_lookup);
  g_signal_connect(G_OBJECT(file_lookup), "resolve",
		   G_CALLBACK(ags_synth_input_line_resolve_line), gobject);

  /* child elements */
  child = node->children;

  while(child != NULL){
    if(XML_ELEMENT_NODE == child->type){
      if(!xmlStrncmp(child->name,
		     "ags-oscillator",
		     15)){
	ags_file_read_oscillator(file, child, &(gobject->oscillator));
      }
    }

    child = child->next;
  }
}
Esempio n. 27
0
/**
 * soap_walk_tree
 * @node:       pointer to an XML subtree
 * @colonstring: node name strings that are being searched; for example, to
 *              search for nodes "a", then "b", then "c", pass "a:b:c"
 *
 * Searches an XML subtree, looking for a named node.  Very similar to
 * soap_find_node() above, but uses an entirely different algorithm, both for
 * efficiency and to make response parsing more pedantic.
 *
 * The passed colonstring is a list of tree node names separated by ':'.  At
 * each level of the tree, the corresponding name must match.  This means that
 * the whole XML tree doesn't need to be searched, and that you know you've
 * found the right node, not one that is similarly-named but is in a different
 * part of the XML tree.
 *
 * Return value: the XML node, if found, or NULL.
 **/
xmlNode         *soap_walk_tree(xmlNode *node, char *colonstring)
{
        char            *next;
        char            *c;
        int             len;            /* Length of node name string */

        if ((! node) ||
            (! colonstring) ||
            (! *colonstring) ||
            (*colonstring == ':')) {
                return(NULL);
        }

        /* Break string at ':' */
        c = strchr(colonstring, ':');
        if (c) {
                len = c - colonstring;
                next = c + 1;
        }
        else {
                len = strlen(colonstring);
                next = colonstring + len;
        }

        /* Look for this in the node tree's children */
        node = node->children;
        while (node) {
                if ((! xmlStrncmp(node->name,
                                  (const xmlChar *)colonstring,
                                  len)) &&
                    (xmlStrlen(node->name) == len)) {
                        if (*next) {
                                return(soap_walk_tree(node, next));
                        }
                        else {
                                /* Done searching */
                                return(node);
                        }
                }
                node = node->next;
        }
        return(NULL);
}
Esempio n. 28
0
xmlDocPtr find_element(xmlDocPtr xml_document_pointer, char* element_name)
{
    if(NULL != xml_document_pointer &&
       NULL != element_name)
    {
        while(true)
        {
            if(NULL == xml_document_pointer)
            {
                break;
            }
            if(0 == xmlStrncmp(xml_document_pointer->name, element_name, xmlStrlen(element_name)))
            {
                return (xmlDocPtr)xml_document_pointer;
            }
            xml_document_pointer = (xmlDocPtr)xml_document_pointer->next;
        }
    }
    return NULL;
}
Esempio n. 29
0
/**
 * \brief Get the text content of the node's children node with given children_name.
 *
 * Return value is just a pointer into the part of xmlNode so it  should not be
 * freed.
 *
 * @param[in] node Search in the children nodes of this node.
 * @param[in] children_name Name of the node which content will be returned.
 * @return Content (string) of the requested element or NULL if such element.
 * doesn't exist. It should not be freed since it is a part of given node.
 */
static inline xmlChar *get_children_content(xmlNodePtr node, xmlChar *children_name)
{
	/* check validity of parameters */
	if (!node || !children_name) {
		return (NULL);
	}

	/* init variables */
	xmlNodePtr cur = node->children;

	/* search in children nodes */
	while (cur) {
		if (!xmlStrncmp(cur->name, children_name, xmlStrlen(children_name) + 1)) {
			if (cur->children && (cur->children->type == XML_TEXT_NODE)) {
				return (cur->children->content);
			}
		}
		/* go to sibling node (next children) */
		cur = cur->next;
	}
	/* nothing found */
	return (NULL);
}
Esempio n. 30
0
/**
 * xmlDictLookup:
 * @param dict the dictionnary
 * @param name the name of the userdata
 * @param len the length of the name, if -1 it is recomputed
 *
 * Add the name to the hash dict if not present.
 *
 * Returns the internal copy of the name or NULL in case of internal error
 *
 * OOM: possible --> returns NULL and OOM flag is set
 */
XMLPUBFUNEXPORT const xmlChar*
xmlDictLookup(xmlDictPtr dict, const xmlChar *name, int len) {
    unsigned long key, okey, nbi = 0;
    xmlDictEntryPtr entry;
    xmlDictEntryPtr insert;
    const xmlChar *ret;

    if (!dict || !name)
        return(NULL);

    if (len < 0)
        len = xmlStrlen(name);

    /*
     * Check for duplicate and insertion location.
     */
    okey = xmlDictComputeKey(name, len);
    key = okey % dict->size;
    if (dict->dict[key].valid == 0) {
        insert = NULL;
    } else {
        for (insert = &(dict->dict[key]);
             insert->next;
             insert = insert->next)
        {

#ifdef __GNUC__
            if (insert->len == len) {
                if (!memcmp(insert->name, name, len))
                    return(insert->name);
            }
#else
            if ((insert->len == len) && (!xmlStrncmp(insert->name, name, len)))
                return(insert->name);
#endif
            nbi++;
        }
#ifdef __GNUC__
        if (insert->len == len) {
            if (!memcmp(insert->name, name, len))
                return(insert->name);
        }
#else
        if ((insert->len == len) && (!xmlStrncmp(insert->name, name, len)))
            return(insert->name);
#endif
    }

    if (dict->subdict) {
        key = okey % dict->subdict->size;
        if (dict->subdict->dict[key].valid != 0) {
            xmlDictEntryPtr tmp;

            for (tmp = &(dict->subdict->dict[key]); tmp->next != NULL; tmp = tmp->next)
            {
#ifdef __GNUC__
                if (tmp->len == len) {
                    if (!memcmp(tmp->name, name, len))
                        return(tmp->name);
                }
#else
                if ((tmp->len == len) && (!xmlStrncmp(tmp->name, name, len)))
                        return(tmp->name);
#endif
                nbi++;
            }
#ifdef __GNUC__
            if (tmp->len == len) {
                if (!memcmp(tmp->name, name, len))
                    return(tmp->name);
            }
#else
            if ((tmp->len == len) && (!xmlStrncmp(tmp->name, name, len)))
                return(tmp->name);
#endif
        } // if (dict->subdict->dict[key].valid != 0)

        key = okey % dict->size;
    } // if (dict->subdict)

    ret = xmlDictAddString(dict, name, len); // may set OOM flag
    if (!ret)
        return(NULL);

    if (!insert) {
        entry = &(dict->dict[key]);
    } else {
        entry = (xmlDictEntryPtr)xmlMalloc(sizeof(xmlDictEntry));
        if (!entry)
             return(NULL); //OOM
    }
    entry->name = ret;
    entry->len = len;
    entry->next = NULL;
    entry->valid = 1;

    if (insert)
        insert->next = entry;

    dict->nbElems++;

    if ((nbi > MAX_HASH_LEN) &&
        (dict->size <= ((MAX_DICT_HASH / 2) / MAX_HASH_LEN)))
    {
        xmlDictGrow(dict, MAX_HASH_LEN * 2 * dict->size);
        if(OOM_FLAG)
            return NULL;
    }

    /* Note that entry may have been freed at this point by xmlDictGrow */

    return(ret);
}