On Mon, Dec 22, 2008 at 8:49 AM, William Ramsay <[email protected]> wrote:
> Can anyone explain to me how I convert a string to a null terminated
> c-pointer that points to a list of strings.
>
> For example  the c function I need to use looks like:
>
>    foo (char **str, int cnt, c-struct result)

The `sx` egg does something similar -- transforming a list of strings
into a null-terminated array of C strings.  I derived a quick example
from it and attached the code.

$ csc -X easyffi -s stringlist.scm
$ csi -q -R stringlist

#;1> (my-foo (list "bar" "baz" "quux"))
string 0: bar
string 1: baz
string 2: quux

An example of the opposite transformation (null-terminated C string
array to a vector of Scheme strings) can be found in the `hostinfo`
egg under array0->string-vector.

Attachment: stringlist.scm
Description: Binary data

_______________________________________________
Chicken-users mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to