Re: AW: New UFFI version (0.2.10) available
Kevin Rosenberg <kevin-HJRc7zDS/[email protected]> Wed, 20 Mar 2002 11:17:51 -0700 (MST)
| Newsgroups | gmane.lisp.uffi.general |
|---|---|
| Message-ID | <[email protected]> |
> http://uffi.med-info.com/manual/r1230.htm > (def-function "gethostname" > ((name :cstring) > (len :int)) > :returning :int) > > Could you please show how to use this function? Sure, see the examples in examples/getenv.cl and examples/gethostname.cl. > I believe one must allocate a garbage string so as to be able to call > convert-from-cstring and with-cstring, as name is a pure :out parameter. You are right -- the manual is in error. The gethostname.cl shows the correct call. Your technique of using a cstring should work fine. The example actually shows the use of allocate-foreign-string / convert-from-foreign-string / free-foreign-object and passing a (* :unsigned-char) for the name. > (let ((unused-storage (make-string 64))) ; 64 on Linux, 256 on Solaris... > (with-cstring (name unused-storage) > (if (zerop (call-"gethostname" name 64)) > (convert-from-cstring name)))) Thanks for the question and noting the error in the manual. Kevin