#ifndef NOKOGIRI_NATIVE #define NOKOGIRI_NATIVE #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef USE_INCLUDED_VASPRINTF int vasprintf (char **strp, const char *fmt, va_list ap); #else #ifndef _GNU_SOURCE #define _GNU_SOURCE #endif # include #endif int is_2_6_16(void) ; #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 #ifdef HAVE_RUBY_ENCODING_H #include #define NOKOGIRI_STR_NEW2(str) \ ({ \ VALUE _string = rb_str_new2((const char *)str); \ int _enc = rb_enc_find_index("UTF-8"); \ rb_enc_associate_index(_string, _enc); \ _string; \ }) #define NOKOGIRI_STR_NEW(str, len) \ ({ \ VALUE _string = rb_str_new((const char *)str, (long)len); \ int _enc = rb_enc_find_index("UTF-8"); \ rb_enc_associate_index(_string, _enc); \ _string; \ }) #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 #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 ; #define NOKOGIRI_ROOT_NODE(_node) \ ({ \ nokogiriTuplePtr tuple = (nokogiriTuplePtr)(_node->doc->_private); \ st_insert(tuple->unlinkedNodes, (st_data_t)_node, (st_data_t)_node); \ _node; \ }) #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) #ifndef RSTRING_PTR #define RSTRING_PTR(s) (RSTRING(s)->ptr) #endif #ifndef RSTRING_LEN #define RSTRING_LEN(s) (RSTRING(s)->len) #endif #ifndef RARRAY_PTR #define RARRAY_PTR(a) RARRAY(a)->ptr #endif #ifndef RARRAY_LEN #define RARRAY_LEN(a) RARRAY(a)->len #endif #endif #endif