Sha256: e8f82be3717e663b6f357627dfd41fdf47eb13c8cafe6948514bb9383f091f1a

Contents?: true

Size: 699 Bytes

Versions: 20

Compression:

Stored size: 699 Bytes

Contents

/* $Id: libxml.c 734 2009-01-22 04:41:07Z cfis $ */

/* Please see the LICENSE file for copyright and distribution information */

#include "ruby_libxml.h"

static ID READ_METHOD;

/* This method is called by libxml when it wants to read
 more data from a stream. We go with the duck typing
 solution to support StringIO objects. */
int rxml_read_callback(void *context, char *buffer, int len)
{
  VALUE io = (VALUE) context;
  VALUE string = rb_funcall(io, READ_METHOD, 1, INT2NUM(len));
  int size;

  if (string == Qnil)
    return 0;

  size = RSTRING_LEN(string);
  memcpy(buffer, StringValuePtr(string), size);

  return size;
}

void rxml_init_io(void)
{
  READ_METHOD = rb_intern("read");
}

Version data entries

20 entries across 20 versions & 3 rubygems

Version Path
libxml-ruby-2.0.0-x86-mingw32 ext/libxml/ruby_xml_io.c
libxml-ruby-2.0.0 ext/libxml/ruby_xml_io.c
libxml-ruby-r19mingw-1.1.4 ext/libxml/ruby_xml_io.c
libxml-ruby-1.1.4 ext/libxml/ruby_xml_io.c
libxml-ruby-1.1.4-x86-mswin32-60 ext/libxml/ruby_xml_io.c
coupa-libxml-ruby-1.1.4 ext/libxml/ruby_xml_io.c
libxml-ruby-1.1.0 ext/libxml/ruby_xml_io.c
libxml-ruby-1.1.0-x86-mswin32-60 ext/libxml/ruby_xml_io.c
libxml-ruby-0.9.9-x86-mswin32-60 ext/libxml/ruby_xml_io.c
libxml-ruby-1.0.0-x86-mswin32-60 ext/libxml/ruby_xml_io.c
libxml-ruby-0.9.8 ext/libxml/ruby_xml_io.c
libxml-ruby-0.9.8-x86-mswin32-60 ext/libxml/ruby_xml_io.c
libxml-ruby-0.9.9 ext/libxml/ruby_xml_io.c
libxml-ruby-1.0.0 ext/libxml/ruby_xml_io.c
libxml-ruby-1.1.3 ext/libxml/ruby_xml_io.c
libxml-ruby-1.1.2-x86-mswin32-60 ext/libxml/ruby_xml_io.c
libxml-ruby-1.1.2 ext/libxml/ruby_xml_io.c
libxml-ruby-1.1.1-x86-mswin32-60 ext/libxml/ruby_xml_io.c
libxml-ruby-1.1.1 ext/libxml/ruby_xml_io.c
libxml-ruby-1.1.3-x86-mswin32-60 ext/libxml/ruby_xml_io.c