#ifndef NOKOGIRI_NATIVE #define NOKOGIRI_NATIVE #include #include #include #include #ifdef USE_INCLUDED_VASPRINTF int vasprintf (char **strp, const char *fmt, va_list ap); #else #define _GNU_SOURCE # include #undef _GNU_SOURCE #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_RUBY_ENCODING_H #include #else #include #endif #ifndef UNUSED # if defined(__GNUC__) # define MAYBE_UNUSED(name) name __attribute__((unused)) # define UNUSED(name) MAYBE_UNUSED(UNUSED_ ## name) # else # define MAYBE_UNUSED(name) name # define UNUSED(name) name # endif #endif #ifndef NORETURN # if defined(__GNUC__) # define NORETURN(name) __attribute__((noreturn)) name # else # define NORETURN(name) name # endif #endif #ifdef HAVE_RUBY_ENCODING_H #include #define NOKOGIRI_STR_NEW2(str) \ NOKOGIRI_STR_NEW(str, strlen((const char *)(str))) #define NOKOGIRI_STR_NEW(str, len) \ rb_external_str_new_with_enc((const char *)(str), (long)(len), rb_utf8_encoding()) #else #define NOKOGIRI_STR_NEW2(str) \ rb_str_new2((const char *)(str)) #define NOKOGIRI_STR_NEW(str, len) \ rb_str_new((const char *)(str), (long)(len)) #endif #define RBSTR_OR_QNIL(_str) \ (_str ? NOKOGIRI_STR_NEW2(_str) : Qnil) #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern VALUE mNokogiri ; extern VALUE mNokogiriXml ; extern VALUE mNokogiriXmlSax ; extern VALUE mNokogiriHtml ; extern VALUE mNokogiriHtmlSax ; extern VALUE mNokogiriXslt ; void nokogiri_root_node(xmlNodePtr); void nokogiri_root_nsdef(xmlNsPtr, xmlDocPtr); #ifdef DEBUG #define NOKOGIRI_DEBUG_START(p) if (getenv("NOKOGIRI_NO_FREE")) return ; if (getenv("NOKOGIRI_DEBUG")) fprintf(stderr,"nokogiri: %s:%d %p start\n", __FILE__, __LINE__, p); #define NOKOGIRI_DEBUG_END(p) if (getenv("NOKOGIRI_DEBUG")) fprintf(stderr,"nokogiri: %s:%d %p end\n", __FILE__, __LINE__, p); #else #define NOKOGIRI_DEBUG_START(p) #define NOKOGIRI_DEBUG_END(p) #endif #ifndef RSTRING_PTR #define RSTRING_PTR(s) (RSTRING(s)->ptr) #endif #ifndef RSTRING_LEN #define RSTRING_LEN(s) (RSTRING(s)->len) #endif #if !defined(RARRAY_PTR) && defined(RARRAY) #define RARRAY_PTR(a) RARRAY(a)->ptr #endif #ifndef RARRAY_LEN #define RARRAY_LEN(a) RARRAY(a)->len #endif #ifndef __builtin_expect # if defined(__GNUC__) # define __builtin_expect(expr, c) __builtin_expect((long)(expr), (long)(c)) # endif #endif #endif