Hi all,

I wonder how can I use a win dll function which accepts a function
pointer parameter. For example, in the WPdpack lib here is a
function:

typedef void (*pcap_handler)(u_char *, const struct pcap_pkthdr *,
			     const u_char *);

int pcap_loop(pcap_t *, int, pcap_handler, u_char *);

And I would like to use like this:

p=Proc {|v1,v2,v3| fun(v1,v2,v3)}
pcap_loop(var1,var2,p,var4)

I have the following idea: In C, I create a ruby class, with which I
can store a Proc object, and this ruby class can give back a C
function's address as a 4 byte-length string.

This C function of pcap_handler type can read out the stored Proc
object, and calls it with it parameters (after converting to ruby
variables).

And then use like this:

obj=PcapHandler.new {{|v1,v2,v3| fun(v1,v2,v3)}
pcap_loop(var1,var2,obj.funAddress,var4)

Is there a simpler method? Is this solution work? How can make a more
generic solution (with variable number of params, etc.)

Thanks:
Circum