static void saved_rack_parse_jackrack (jack_rack_t * jack_rack, saved_rack_t * saved_rack, const char * filename, xmlNodePtr jackrack) { xmlNodePtr node; xmlChar *content; saved_plugin_t * saved_plugin; #ifdef WIN32 xmlFreeFunc xmlFree = NULL; xmlMemGet( &xmlFree, NULL, NULL, NULL); #endif for (node = jackrack->children; node; node = node->next) { if (xmlStrcmp (node->name, _x("channels")) == 0) { content = xmlNodeGetContent (node); saved_rack->channels = strtoul (_s(content), NULL, 10); xmlFree (content); } else if (xmlStrcmp (node->name, _x("samplerate")) == 0) { content = xmlNodeGetContent (node); saved_rack->sample_rate = strtoul (_s(content), NULL, 10); xmlFree (content); } else if (xmlStrcmp (node->name, _x("plugin")) == 0) { saved_plugin = g_malloc0 (sizeof (saved_plugin_t)); saved_rack->plugins = g_slist_append (saved_rack->plugins, saved_plugin); saved_rack_parse_plugin (jack_rack, saved_rack, saved_plugin, filename, node); } } }
int init_lost_lib(){ if(xmlInitMemory()){ ERROR_LOG("Failed to initialize teh memory layer from libxml\n"); return -1; } if(xmlMemGet(&defaultXmlFreeFunc, &defaultXmlMallocFunc, &defaultXmlReallocFunc, &defaultXmlStrdupFunc)){ ERROR_LOG("Failed to get the default memory functions from libxml\n"); return -1; } if(xmlMemSetup(my_pkg_free, my_pkg_malloc, my_pkg_realloc, my_pkg_strdup)){ ERROR_LOG("Failed to set the pkg memory functions to libxml\n"); return -1; } headers = curl_slist_append(headers, LOST_CONTENT_TYPE); if(!headers){ ERROR_LOG("Failed to initialize header content type\n"); return -1; } headers = curl_slist_append(headers, LOST_CACHE_CONTROL); if(!headers){ ERROR_LOG("Failed to initialize header cache control\n"); return -1; } curl_global_init(CURL_GLOBAL_DEFAULT); return 0; }
void VariableScope::initXMLMemory() { xmlFreeFunc freeFunc; xmlMallocFunc mallocFunc; xmlReallocFunc reallocFunc; xmlStrdupFunc strdupFunc; xmlMemGet(&freeFunc, &mallocFunc, &reallocFunc, &strdupFunc); freeFunc = getFreeFunc(freeFunc); xmlMemSetup(freeFunc, mallocFunc, reallocFunc, strdupFunc); }
/* * This function modifies a config file according to the calibrated values. */ int cfgw_modify_file(char* file) { xmlDoc *doc = NULL; xmlNode *root_element = NULL; int ret = 0; char file_path[PATH_MAX]; snprintf(file_path, sizeof(file_path), "%s%s%s%s", gimx_params.homedir, GIMX_DIR, CONFIG_DIR, file); /* * this initialize the library and check potential ABI mismatches * between the version it was compiled for and the actual shared * library used. */ LIBXML_TEST_VERSION /*parse the file and get the DOM */ doc = xmlReadFile(file_path, NULL, 0); #ifdef WIN32 if(!xmlFree) xmlMemGet(&xmlFree,&xmlMalloc,&xmlRealloc,NULL); #endif if (doc != NULL) { /*Get the root element node */ root_element = xmlDocGetRootElement(doc); if(root_element != NULL) { ret = ProcessRootElement(root_element); } else { ret = -1; printf("error: no root element\n"); } if(ret != -1) { xmlSaveFormatFileEnc(file_path, doc, "UTF-8", 1); } } else { ret = -1; printf("error: could not parse file %s\n", file_path); } /*free the document */ xmlFreeDoc(doc); return ret; }
void Init_libxml(void) { /* Some libxml memory goo that should be done before anything else */ xmlMemGet((xmlFreeFunc *) & freeFunc, (xmlMallocFunc *) & mallocFunc, (xmlReallocFunc *) & reallocFunc, (xmlStrdupFunc *) & strdupFunc); if (xmlMemSetup((xmlFreeFunc)RubyMemFree, (xmlMallocFunc)RubyMemMalloc, (xmlReallocFunc)RubyMemRealloc, (xmlStrdupFunc)RubyMemStrdup) != 0) rb_fatal("could not install the memory handlers for libxml"); xmlInitParser(); mXML = rb_define_module("LibXML"); rb_define_const(mXML, "XML_NAMESPACE", rb_str_new2(XML_XML_NAMESPACE)); ruby_init_parser(); ruby_init_xml_parser_context(); ruby_init_xml_attr(); ruby_init_xml_attribute(); ruby_init_xml_document(); ruby_init_xml_node(); ruby_init_xml_node_set(); ruby_init_xml_ns(); ruby_init_xml_sax_parser(); ruby_init_xml_tree(); ruby_init_xml_xinclude(); ruby_init_xml_xpath(); ruby_init_xml_xpath_context(); ruby_init_xml_xpointer(); ruby_init_xml_xpointer_context(); ruby_init_input_callbacks(); /* MUFF */ ruby_init_xml_dtd(); /* MUFF */ ruby_init_xml_schema(); /* MUFF */ ruby_xml_parser_default_substitute_entities_set(cXMLParser, Qtrue); ruby_xml_parser_default_load_external_dtd_set(cXMLParser, Qtrue); }
static void saved_rack_parse_plugin (jack_rack_t * jack_rack, saved_rack_t * saved_rack, saved_plugin_t * saved_plugin, const char * filename, xmlNodePtr plugin) { plugin_desc_t * desc; settings_t * settings = NULL; xmlNodePtr node; xmlNodePtr sub_node; xmlChar *content; unsigned long num; unsigned long control = 0; #ifdef WIN32 xmlFreeFunc xmlFree = NULL; xmlMemGet( &xmlFree, NULL, NULL, NULL); #endif for (node = plugin->children; node; node = node->next) { if (xmlStrcmp (node->name, _x("id")) == 0) { content = xmlNodeGetContent (node); num = strtoul (_s(content), NULL, 10); xmlFree (content); desc = plugin_mgr_get_any_desc (jack_rack->plugin_mgr, num); if (!desc) { mlt_log_verbose( NULL, _("The file '%s' contains an unknown plugin with ID '%ld'; skipping\n"), filename, num); return; } settings = settings_new (desc, saved_rack->channels, saved_rack->sample_rate); } else if (xmlStrcmp (node->name, _x("enabled")) == 0) { content = xmlNodeGetContent (node); settings_set_enabled (settings, xmlStrcmp (content, _x("true")) == 0 ? TRUE : FALSE); xmlFree (content); } else if (xmlStrcmp (node->name, _x("wet_dry_enabled")) == 0) { content = xmlNodeGetContent (node); settings_set_wet_dry_enabled (settings, xmlStrcmp (content, _x("true")) == 0 ? TRUE : FALSE); xmlFree (content); } else if (xmlStrcmp (node->name, _x("wet_dry_locked")) == 0) { content = xmlNodeGetContent (node); settings_set_wet_dry_locked (settings, xmlStrcmp (content, _x("true")) == 0 ? TRUE : FALSE); xmlFree (content); } else if (xmlStrcmp (node->name, _x("wet_dry_values")) == 0) { unsigned long channel = 0; for (sub_node = node->children; sub_node; sub_node = sub_node->next) { if (xmlStrcmp (sub_node->name, _x("value")) == 0) { content = xmlNodeGetContent (sub_node); settings_set_wet_dry_value (settings, channel, strtod (_s(content), NULL)); xmlFree (content); channel++; } } } else if (xmlStrcmp (node->name, _x("lockall")) == 0) { content = xmlNodeGetContent (node); settings_set_lock_all (settings, xmlStrcmp (content, _x("true")) == 0 ? TRUE : FALSE); xmlFree (content); } else if (xmlStrcmp (node->name, _x("controlrow")) == 0) { gint copy = 0; for (sub_node = node->children; sub_node; sub_node = sub_node->next) { if (xmlStrcmp (sub_node->name, _x("lock")) == 0) { content = xmlNodeGetContent (sub_node); settings_set_lock (settings, control, xmlStrcmp (content, _x("true")) == 0 ? TRUE : FALSE); xmlFree (content); } else if (xmlStrcmp (sub_node->name, _x("value")) == 0) { content = xmlNodeGetContent (sub_node); settings_set_control_value (settings, copy, control, strtod (_s(content), NULL)); xmlFree (content); copy++; } } control++; } } if (settings) saved_plugin->settings = settings; }