Sha256: 9614196bad3fcb6c02ed74a341767acc326d6d988c88118c4dde50a3fe5776da

Contents?: true

Size: 664 Bytes

Versions: 16

Compression:

Stored size: 664 Bytes

Contents

#include <xml_io.h>

static ID id_read, id_write;

int io_read_callback(void * ctx, char * buffer, int len) {
  VALUE io = (VALUE)ctx;
  VALUE string = rb_funcall(io, id_read, 1, INT2NUM(len));

  if(NIL_P(string)) return 0;

  memcpy(buffer, StringValuePtr(string), (unsigned int)RSTRING_LEN(string));

  return RSTRING_LEN(string);
}

int io_write_callback(void * ctx, char * buffer, int len) {
  VALUE io = (VALUE)ctx;
  VALUE string = rb_str_new(buffer, len);

  rb_funcall(io, id_write, 1, string);
  return len;
}

int io_close_callback(void * ctx) {
  return 0;
}

void init_nokogiri_io() {
  id_read = rb_intern("read");
  id_write = rb_intern("write");
}

Version data entries

16 entries across 16 versions & 6 rubygems

Version Path
rubyjedi-nokogiri_java-1.4.0.20100513161003-java ext/nokogiri/xml_io.c
jwagener-nokogiri-1.4.1 ext/nokogiri/xml_io.c
revo-nokogiri-1.4.1-java ext/nokogiri/xml_io.c
revo-nokogiri-1.4.0.3-java ext/nokogiri/xml_io.c
revo-nokogiri-1.4.0-java ext/nokogiri/xml_io.c
revo-nokogiri-1.4.0.20100202165440-java ext/nokogiri/xml_io.c
nokogiri-1.4.1-x86-mswin32 ext/nokogiri/xml_io.c
nokogiri-1.4.1-x86-mingw32 ext/nokogiri/xml_io.c
nokogiri-1.4.1-java ext/nokogiri/xml_io.c
nokogiri-1.4.1 ext/nokogiri/xml_io.c
superfeedr-nokogiri-1.4.0.20091116183308 ext/nokogiri/xml_io.c
caring-nokogiri-1.4.1.pre1 ext/nokogiri/xml_io.c
nokogiri-1.4.0-java ext/nokogiri/xml_io.c
nokogiri-1.4.0-x86-mswin32 ext/nokogiri/xml_io.c
nokogiri-1.4.0-x86-mingw32 ext/nokogiri/xml_io.c
nokogiri-1.4.0 ext/nokogiri/xml_io.c