Next: iklib errno, Previous: iklib memory, Up: iklib [Index]
The following functions perform operations on raw ASCII coded strings
terminated by a zero byte, for short ASCIIZ strings; some functions
act upon raw UTF-16 strings. The following bindings are exported by
the libraries (vicare)
and (vicare system $foreign)
and
reexported by the library (vicare ffi)
.
Convert from a Scheme bytevector to an ASCIIZ string. If successful
return a pointer object referencing the string, else return #f
.
Memory allocated by bytevector->cstring
must be explicitly
released by free
; memory allocated by
bytevector->guarded-cstring
is automatically released by the
garbage collector whenever the returned pointer is garbage collected.
Like bytevector->cstring
and bytevector->guarded-cstring
,
but if allocation fails raise a non–continuable exception with
components: &who
, &message
,
&out-of-memory-error
.
Convert between an ASCIIZ string and a Scheme bytevector. When used, count must be a fixnum representing the number of bytes to include in the bytevector.
Convert from a Scheme string to an ASCIIZ string. If successful
return a pointer object referencing the string, else return #f
.
The string argument must contain only characters with Unicode code points in the range [0, 255].
Memory allocated by string->cstring
must be explicitly
released by free
; memory allocated by
string->guarded-cstring
is automatically released by the
garbage collector whenever the returned pointer is garbage collected.
Convert between an UTF-16 string and a Scheme bytevector; this function works with all the possible encodings of the string. The end of the string is determined by searching for a sequence of two consecutive zero bytes, starting at even offset.
Like cstring16->bytevector
, but convert the result to a Scheme
string assuming the specified byte order (native, little endian, big
endian).
Like string->cstring
and string->guarded-cstring
, but if
allocation fails raise a non–continuable exception with components:
&who
, &message
, &out-of-memory-error
.
Convert between an ASCIIZ string and a Scheme string. When used, count must be a fixnum representing the number of bytes to include in the string.
Interface to the C function strlen()
, (libc)strlen. Return an exact integer representing the length of the
ASCIIZ string referenced by pointer.
Interface to the C function strcmp()
, (libc)strcmp. Return a fixnum representing the classic
comparison ternary result of comparing the ASCIIZ strings referenced
by pointer1 and pointer2.
Interface to the C function strncmp()
, (libc)strncmp. Return a fixnum representing the classic
comparison ternary result of comparing the first count bytes in
the ASCIIZ strings referenced by pointer1 and pointer2.
count must be an exact integer in the range of the C language type
size_t
.
Interface to the C function strdup()
, (libc)strdup. Duplicate the ASCIIZ string referenced by
pointer; if successful return a new pointer object, if allocation
fails raise a non–continuable exception with components:
&who
, &message
, &out-of-memory-error
Memory allocated by strdup
must be explicitly released by
free
; memory allocated by guarded-strdup
is automatically
released by the garbage collector whenever the returned pointer is
garbage collected.
Interface to the C function strndup()
, (libc)strndup. Duplicate the first count bytes in the
ASCIIZ string referenced by pointer; if successful return a new
pointer object, if allocation fails raise a non–continuable exception
with components: &who
, &message
,
&out-of-memory-error
. count must be an exact integer
in the range of the C language type size_t
.
Memory allocated by strdup
must be explicitly released by
free
; memory allocated by guarded-strdup
is automatically
released by the garbage collector whenever the returned pointer is
garbage collected.
Given a list of bytevectors: convert them into ASCIIZ strings and
build a NULL
terminated array of C pointers referencing the strings.
The strings and the array are stored in a single memory block. If
successful return the pointer object; if allocation fails raise a
non–continuable exception with components: &who
,
&message
, &out-of-memory-error
.
Memory allocated by bytevectors->argv
must be explicitly released
by free
; memory allocated by bytevectors->guarded-argv
is
automatically released by the garbage collector whenever the returned
pointer is garbage collected.
Given a pointer to a NULL
terminated array of C pointers referencing
ASCIIZ strings: build and return a list of bytevectors holding the
same bytes of the strings.
Given a list of Scheme strings: convert them into ASCIIZ strings and
build a NULL
terminated array of C pointers referencing the strings.
If successful return a pointer to the array; if allocation fails raise a
non–continuable exception with components: &who
,
&message
, &out-of-memory-error
. The strings and
the array are stored in a single memory block.
The string arguments must contain only characters with Unicode code points in the range [0, 255].
Memory allocated by strings->argv
must be explicitly released
by free
; memory allocated by strings->guarded-argv
is
automatically released by the garbage collector whenever the returned
pointer is garbage collected.
Given a pointer to a NULL
terminated array of C pointers referencing
ASCIIZ strings: build and return a list of strings holding the same
bytes of the strings.
Return the number of strings in the NULL
–terminated array of
strings referenced by the argv pointer.
Next: iklib errno, Previous: iklib memory, Up: iklib [Index]