[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

questions regarding ffi



my declaration of utsname is
#.(defconstant _SYS_NMLN           32) ; Important: do not change this value !
(def-c-struct utsname
  (sysname (c-array char #._SYS_NMLN))
  (nodename (c-array char #._SYS_NMLN))
  (release (c-array char #._SYS_NMLN))
  (version (c-array char #._SYS_NMLN))
  (machine (c-array char #._SYS_NMLN))
)
and uname is
(def-c-call-out uname (:arguments (name (c-ptr utsname) :out :alloca))
(:return-type int))

when i call uname as follows i get
(multiple-value-setq (r s) (uname)
s has the value
#S(UTSNAME :SYSNAME #(65 73 88 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) :NODENAME #(109 97 100 97 109 101 0 48 51 56 48 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) :RELEASE #(50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) :VERSION #(51 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0) :MACHINE #(48 48 48 48 51 49 57 48 51 56 48 48 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0))

is there a way to declare utsname so that the structure members are strings
rather than these arrays.  simply declareing as follows
(def-c-struct utsname
  (sysname (c-string #._SYS_NMLN)) ...
gives me a error as c-string is a pointer to a string, not a actual string.
thanks,
dan stanger