Hi,<br><br>I'm new to CFFI and also to Common Lisp, i trying to use CFFI to call getifaddrs function.<br><br>I have defined a cffi-grovel for ifaddrss struct<br><br>(cstruct ifaddrs "struct ifaddrs"<br> (next "ifa_next" :type :pointer)<br>
(name "ifa_name" :type :pointer)<br> (flags "ifa_flags" :type :unsigned-int)<br> (address "ifa_addr" :type :pointer)<br> (netmask "ifa_netmask" :type :pointer)<br> (broadcast "ifa_broadaddr" :type :pointer)<br>
(point-to-point-destination "ifa_dstaddr" :type :pointer)<br> (data "ifa_data" :type :pointer))<br><br>In my package i define getifaddrs<br><br>(cffi:defcfun "getifaddrs" :int <br> ""<br>
(ifap :pointer))<br><br>I try to access the name slot of ifaddrs struct but nothing seems to work, not sure what i doing wrong<br><br>(cffi:with-foreign-object (ifa 'ifaddrs) <br>
(ice-cffi:getifaddrs ifa) <br> (cffi:foreign-string-to-lisp (cffi:foreign-slot-value ifa 'ifaddrs 'name)))<br>
<br>0: (SB-SYS:MEMORY-FAULT-ERROR)<br> 1: ("foreign function: call_into_lisp")<br> 2: ("foreign function: post_signal_tramp")<br> 3: (CFFI::FOREIGN-STRING-LENGTH #.(SB-SYS:INT-SAP #X00000060) :ENCODING :UTF-8 :OFFSET 0)<br>
4: (CFFI:FOREIGN-STRING-TO-LISP #.(SB-SYS:INT-SAP #X00000060) :OFFSET 0 :COUNT NIL :MAX-CHARS 536870908 :ENCODING NIL)<br><br> (cffi:with-foreign-pointer (ifa (cffi:foreign-type-size :pointer)) <br>
(ice-cffi:getifaddrs ifa) <br> (cffi:foreign-string-to-lisp (cffi:foreign-slot-value ifa 'ifaddrs 'name)))<br>
0: ((LAMBDA (BABEL-ENCODINGS::SRC BABEL-ENCODINGS::START BABEL-ENCODINGS::END BABEL-ENCODINGS::DEST BABEL-ENCODINGS::D-START)) #.(SB-SYS:INT-SAP #X080819B8) 0 9 "^@^@^@^@^@^@^@^@^@" 0)<br>1: (CFFI:FOREIGN-STRING-TO-LISP #.(SB-SYS:INT-SAP #X080819B8) :OFFSET 0 :COUNT NIL :MAX-CHARS 536870908 :ENCODING NIL)<br>
<br><br>any help will be appreciated.<br><br>Jose <br>