From: Eric Hodel Date: 2005-03-29T06:44:10+09:00 Subject: Re: DL usage / DL documentation --Apple-Mail-5-595035190 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=ISO-8859-1; format=flowed On 28 Mar 2005, at 09:59, Stephan K=E4mper wrote: > Hi all, > > I currently try to call a function in a DLL, which has a prototype=20 > like this: > > int test(int an_int, long * a_ptr_to_long, char * a_string); > > How do I get a 'long *' into the method from Ruby using DL? DL just does it: require "dl" require "dl/import" require "dl/struct" module LIBC extend DL::Importable dlload "libc.dylib" typealias "const time_t *clock", "long ref" StructTm =3D struct [ "int tm_sec", # seconds (0 - 60) "int tm_min", # minutes (0 - 59) "int tm_hour", # hours (0 - 23) "int tm_mday", # day of month (1 - 31) "int tm_mon", # month of year (0 - 11) "int tm_year", # year - 1900 "int tm_wday", # day of week (Sunday =3D 0) "int tm_yday", # day of year (0 - 365) "int tm_isdst", # is summer time in effect? "long tm_gmtoff", # offset from UTC in seconds "char *tm_zone", # abbreviation of timezone name ] extern "struct tm * localtime(const time_t *clock)" def self.c_localtime(clock) tm =3D LIBC.localtime(clock) return LIBC::StructTm.new(tm) end end p LIBC.c_localtime(Time.now.to_i).tm_min --=20 Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04 --Apple-Mail-5-595035190 content-type: application/pgp-signature; x-mac-type=70674453; name=PGP.sig content-description: This is a digitally signed message part content-disposition: inline; filename=PGP.sig content-transfer-encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (Darwin) iD8DBQFCSHqRMypVHHlsnwQRAm6dAJ94rXa1yuE/F4C6XXhR2tzjFp8angCeK3yP hHiODN1D0bAY3oBoTBroyCM= =yUa6 -----END PGP SIGNATURE----- --Apple-Mail-5-595035190--