Hello,

On Sun, Dec 12, 2010 at 1:10 AM, pepone.onrez <pepone.on...@gmail.com> wrote:
> (cffi:with-foreign-object (ifa 'ifaddrs)
>            (ice-cffi:getifaddrs ifa)
>            (cffi:foreign-string-to-lisp (cffi:foreign-slot-value ifa 'ifaddrs 
> 'name)))

Here's getifaddrs's signature:
  int getifaddrs(struct ifaddrs **ifap);

getifaddrs() allocates the actual struct. Here's how it would be
called using C code:

  struct ifaddrs *p;
  getifaddrs(&p);
  // do something with p->name

The equivalent CFFI code would be something like:

  (with-foreign-object (p :pointer)
    (getifaddrs p)
    (foreign-slot-value (mem-ref p :pointer) 'ifaddrs 'name))

If you define NAME's type to be :STRING, that code will yield a Lisp string.

HTH,

-- 
Luís Oliveira
http://r42.eu/~luis/

_______________________________________________
cffi-devel mailing list
cffi-devel@common-lisp.net
http://common-lisp.net/cgi-bin/mailman/listinfo/cffi-devel

Reply via email to