Subject:
Re: [ruby-ffi] unsigned char *
From:
Jeffrey Jones
Date:
2/8/12 12:41 AM
To:
ruby-ffi@googlegroups.com

Hello Chuck,

Well that is embarrassing, it has been a decade since I have done any real C stuff and that was at university so the semantics have been rather lost on me.

I shall gives this a go and see how things pan out.

Thanks for the pointer (Ba-dump-tsh!)

Jeff

On 08/02/12 15:13, Chuck Remes wrote:
On Feb 6, 2012, at 3:15 AM, Jeffrey Jones wrote:

Hello all,

I am in the early stages of investigating ruby FFI for use with a
particular third party library.

This library makes use of a few functions with the following
signature.

struct * function (unsigned char*, unsigned int)

These functions are basically used for reading data in from various
places (fread for example) so it is the data itself and the data size.

Looking at all the various documentation and examples and code, I
cannot actually see what I need to do in ruby to match the signature.

module Foo
  attach_function :function, [:uchar, :uint], :pointer
end

Doesn't work because it isn't expecting a single char but a char*.

Does anyone know what I need to do? (If it is even possible?)
A "char *" is a pointer. You almost had the answer on your own.

module Foo
   attach_function :function, [:pointer, :uint], :pointer
end

Try that.

cr