Package: cffi

Function foreign-string-to-lisp

Lambda List

foreign-string-to-lisp (pointer &key offset count max-chars encoding)

Arguments

ptr -- A pointer.
offset -- An integer greater than or equal to 0. Defauls to 0.
count -- Either nil (the default), or an integer greater than or equal to 0.
max-chars -- An integer greater than or equal to 0. (1- array-total-size-limit), by default.
encoding -- Foreign encoding. Defaults to *default-foreign-encoding*.

Return Value

A Lisp string.

Details

The foreign-string-to-lisp function converts at most count octets from ptr into a Lisp string, using the defined encoding.

If count is nil (the default), characters are copied until max-chars is reached or a NULL character is found.

If ptr is a null pointer, returns nil.

Note that the :string type will automatically convert between Lisp strings and foreign strings.

Examples

  CFFI> (foreign-funcall "getenv" :string "HOME" :pointer)
  => #<FOREIGN-ADDRESS #xBFFFFFD5>
  CFFI> (foreign-string-to-lisp *)
  => "/Users/luis"  
 

See also