static int erim_xml_init() { /* Initialize the global known lists. */ if (init_known_lists() != 0) return (-1); if (xmlMemSetup(driver_free, driver_alloc, driver_realloc, erim_strdup) != 0) { return (-1); } /* Initialize and check LibXML2. */ LIBXML_TEST_VERSION; /* be safe, plus calls xmlInitParser */ /* Initialize SAX callbacks. */ sax_handler.initialized = XML_SAX2_MAGIC; sax_handler.startElementNs = libxml2_cb_start_element; sax_handler.endElementNs = libxml2_cb_end_element; sax_handler.getEntity = libxml2_cb_get_entity; sax_handler.characters = libxml2_cb_character_data; return (0); }
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); }
tmx_map *parse_xml(const char *filename) { xmlTextReaderPtr reader; tmx_map *res = NULL; xmlMemSetup((xmlFreeFunc)tmx_free_func, (xmlMallocFunc)tmx_malloc, (xmlReallocFunc)tmx_alloc_func, (xmlStrdupFunc)tmx_strdup); if ((reader = create_parser(filename))) { res = parse_root_map(reader, filename); xmlFreeTextReader(reader); } return res; }
void Init_nokogiri() { xmlMemSetup( (xmlFreeFunc)ruby_xfree, (xmlMallocFunc)ruby_xmalloc, (xmlReallocFunc)ruby_xrealloc, strdup ); mNokogiri = rb_define_module("Nokogiri"); mNokogiriXml = rb_define_module_under(mNokogiri, "XML"); mNokogiriHtml = rb_define_module_under(mNokogiri, "HTML"); mNokogiriXslt = rb_define_module_under(mNokogiri, "XSLT"); mNokogiriXmlSax = rb_define_module_under(mNokogiriXml, "SAX"); mNokogiriHtmlSax = rb_define_module_under(mNokogiriHtml, "SAX"); rb_const_set( mNokogiri, rb_intern("LIBXML_VERSION"), NOKOGIRI_STR_NEW2(LIBXML_DOTTED_VERSION, "UTF-8") ); rb_const_set( mNokogiri, rb_intern("LIBXML_PARSER_VERSION"), NOKOGIRI_STR_NEW2(xmlParserVersion, "UTF-8") ); init_xml_document(); init_html_document(); init_xml_node(); init_xml_document_fragment(); init_xml_text(); init_xml_cdata(); init_xml_processing_instruction(); init_xml_attr(); init_xml_entity_reference(); init_xml_comment(); init_xml_node_set(); init_xml_xpath_context(); init_xml_xpath(); init_xml_sax_parser(); init_xml_sax_push_parser(); init_xml_reader(); init_xml_dtd(); init_xml_namespace(); init_html_sax_parser(); init_xslt_stylesheet(); init_xml_syntax_error(); init_html_entity_lookup(); init_html_element_description(); init_xml_schema(); init_xml_relax_ng(); }
void end_lost_lib(){ /* free the header list */ curl_slist_free_all(headers); /* Cleanup function for the XML library.*/ xmlCleanupParser(); if(xmlMemSetup(defaultXmlFreeFunc, defaultXmlMallocFunc, defaultXmlReallocFunc, defaultXmlStrdupFunc)){ ERROR_LOG("Failed to set the default memory functions to libxml\n"); } }
void SetPackageAllocators() { ///////////////////////////////////////////////////////////////////////// // Setup open source package memory allocation. // These callback functions in turn will call the user-specified allocator. #if USE(CURL) curl_init_mem(curl_malloc_custom, curl_free_custom, curl_realloc_custom, curl_strdup_custom, curl_calloc_custom); #endif // Nothing to do for libjpeg (jpeg_get_small, etc.) png_set_default_mem_fn(png_malloc, png_free); #if USE(LIBXML2) xmlMemSetup(xmlFreeCustom, xmlMallocCustom, xmlReallocCustom, xmlStrdupCustom); #endif // Nothing to do for sdl (SDL_malloc, etc.). // Nothing to do for zlib (zcalloc, etc.). // Nothing to do for WTF/WebKit (fastMalloc, etc.) ///////////////////////////////////////////////////////////////////////// }
void pgxml_parser_init() { /* * This code could also set parser settings from user-supplied info. * Quite how these settings are made is another matter :) */ xmlMemSetup(pgxml_pfree, pgxml_palloc, pgxml_repalloc, pgxml_pstrdup); xmlInitParser(); xmlSetGenericErrorFunc(NULL, pgxml_errorHandler); xmlSubstituteEntitiesDefault(1); xmlLoadExtDtdDefaultValue = 1; pgxml_errorMsg = NULL; errbuf = palloc(200); memset(errbuf, 0, 200); }
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); }
void Init_nokogiri() { #ifndef __MACRUBY__ xmlMemSetup( (xmlFreeFunc)ruby_xfree, (xmlMallocFunc)ruby_xmalloc, (xmlReallocFunc)ruby_xrealloc, ruby_strdup ); #endif mNokogiri = rb_define_module("Nokogiri"); mNokogiriXml = rb_define_module_under(mNokogiri, "XML"); mNokogiriHtml = rb_define_module_under(mNokogiri, "HTML"); mNokogiriXslt = rb_define_module_under(mNokogiri, "XSLT"); mNokogiriXmlSax = rb_define_module_under(mNokogiriXml, "SAX"); mNokogiriHtmlSax = rb_define_module_under(mNokogiriHtml, "SAX"); rb_const_set( mNokogiri, rb_intern("LIBXML_VERSION"), NOKOGIRI_STR_NEW2(LIBXML_DOTTED_VERSION) ); rb_const_set( mNokogiri, rb_intern("LIBXML_PARSER_VERSION"), NOKOGIRI_STR_NEW2(xmlParserVersion) ); #ifdef NOKOGIRI_USE_PACKAGED_LIBRARIES rb_const_set(mNokogiri, rb_intern("NOKOGIRI_USE_PACKAGED_LIBRARIES"), Qtrue); rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXML2_PATH"), NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXML2_PATH)); rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXSLT_PATH"), NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXSLT_PATH)); rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXML2_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXML2_PATCHES), " ")); rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXSLT_PATCHES"), rb_str_split(NOKOGIRI_STR_NEW2(NOKOGIRI_LIBXSLT_PATCHES), " ")); #else rb_const_set(mNokogiri, rb_intern("NOKOGIRI_USE_PACKAGED_LIBRARIES"), Qfalse); rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXML2_PATH"), Qnil); rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXSLT_PATH"), Qnil); rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXML2_PATCHES"), Qnil); rb_const_set(mNokogiri, rb_intern("NOKOGIRI_LIBXSLT_PATCHES"), Qnil); #endif #ifdef LIBXML_ICONV_ENABLED rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qtrue); #else rb_const_set(mNokogiri, rb_intern("LIBXML_ICONV_ENABLED"), Qfalse); #endif xmlInitParser(); init_xml_document(); init_html_document(); init_xml_node(); init_xml_document_fragment(); init_xml_text(); init_xml_cdata(); init_xml_processing_instruction(); init_xml_attr(); init_xml_entity_reference(); init_xml_comment(); init_xml_node_set(); init_xml_xpath_context(); init_xml_sax_parser_context(); init_xml_sax_parser(); init_xml_sax_push_parser(); init_xml_reader(); init_xml_dtd(); init_xml_element_content(); init_xml_attribute_decl(); init_xml_element_decl(); init_xml_entity_decl(); init_xml_namespace(); init_html_sax_parser_context(); init_html_sax_push_parser(); init_xslt_stylesheet(); init_xml_syntax_error(); init_html_entity_lookup(); init_html_element_description(); init_xml_schema(); init_xml_relax_ng(); init_nokogiri_io(); init_xml_encoding_handler(); }
/** * This is the main function */ int main(int argc, char **argv) { int ret = 0; xmlMemSetup(free, xmalloc, xrealloc, xstrdup); gGetUnicodeOptions(argc, argv); gInitOptions(&globalOptions); gParseOptions(&globalOptions, &argc, argv); xmlSetStructuredErrorFunc(&errorInfo, reportError); if (globalOptions.quiet) suppressErrors(); if (argc <= 1) { usage(argc, argv, EXIT_BAD_ARGS); } else if (!strcmp(argv[1], "ed") || !strcmp(argv[1], "edit")) { ret = edMain(argc, argv); } else if (!strcmp(argv[1], "sel") || !strcmp(argv[1], "select")) { ret = selMain(argc, argv); } else if (!strcmp(argv[1], "tr") || !strcmp(argv[1], "transform")) { ret = trMain(argc, argv); } else if (!strcmp(argv[1], "fo") || !strcmp(argv[1], "format")) { ret = foMain(argc, argv); } else if (!strcmp(argv[1], "val") || !strcmp(argv[1], "validate")) { ret = valMain(argc, argv); } else if (!strcmp(argv[1], "el") || !strcmp(argv[1], "elements")) { ret = elMain(argc, argv); } else if (!strcmp(argv[1], "c14n") || !strcmp(argv[1], "canonic")) { ret = c14nMain(argc, argv); } else if (!strcmp(argv[1], "ls") || !strcmp(argv[1], "list")) { ret = lsMain(argc, argv); } else if (!strcmp(argv[1], "pyx") || !strcmp(argv[1], "xmln")) { ret = pyxMain(argc, argv); } else if (!strcmp(argv[1], "depyx") || !strcmp(argv[1], "p2x")) { ret = depyxMain(argc, argv); } else if (!strcmp(argv[1], "esc") || !strcmp(argv[1], "escape")) { ret = escMain(argc, argv, 1); } else if (!strcmp(argv[1], "unesc") || !strcmp(argv[1], "unescape")) { ret = escMain(argc, argv, 0); } else { usage(argc, argv, EXIT_BAD_ARGS); } exit(ret); }