[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-users] FFI string with embedded nulls
From: |
Toby Butzon |
Subject: |
[Chicken-users] FFI string with embedded nulls |
Date: |
Tue, 2 Aug 2005 20:40:37 -0400 |
User-agent: |
Mutt/1.5.8i |
Howdy,
This all goes on the assumption that Scheme and Chicken are OK even with
a string with embedded nulls (e.g., "foo\0bar"). That's true, right?
Now then, I have a function that looks vaguely like:
unsigned int foo(char *to, char *from, unsigned int fromlen);
which reads ``from'' and fills some result based on that into a
pre-allocated (via malloc() or, in Chicken, (allocate ...)) ``to''.
Both strings may have embedded nulls: ``fromlen'' therefore tells the
function how long ``from'' is (since strlen() won't work), and the
return value is used similarly by the caller.
So what I'm trying to do in Chicken is create a function (foo from) that
calls the C function and returns the appropriate string, already filled
out as a Scheme string (and the memory allocated for ``to'' already
freed).
I'm stumped. How do I get the string to turn into a Scheme string
without truncating it at the first embedded null?
-- TB
- [Chicken-users] FFI string with embedded nulls,
Toby Butzon <=