Next: , Previous: , Up: objects misc   [Index]


13.26.4 Generalised C buffers

When interfacing a C language foreign library with Vicare, it is often needed to convert Scheme objects to raw memory blocks, possibly containing ASCIIZ strings. Generalised C buffers are meant to be used in interfaces to foreign C language libraries, when a pointer to raw data is required as argument. (vicare-libs)Introduction to generalised C buffers for details.

Notice that at the C language level only general C buffers exist: Scheme strings should be converted to bytevectors at the Scheme level.

Function: size_t ik_generalised_c_buffer_len (ikptr_t buffer, ikptr_t buffer_len)

Return the number of bytes in a generalised C buffer object.

buffer must be a bytevector, pointer object or memory-block struct instance.

When buffer is a pointer object: buffer_len must be an exact integer (in the range of the C language type size_t) representing the number of bytes available in the referenced memory block. Otherwise buffer_len is ignored.

Preprocessor Macro: void * IK_GENERALISED_C_BUFFER (ikptr_t obj)
Preprocessor Macro: void * IK_GENERALISED_C_BUFFER_OR_FALSE (ikptr_t obj)

Given a bytevector object or a pointer object or a memory-block object return a void * pointer referencing the data. The second macro accepts also #f as value and returns NULL.

Preprocessor Macro: void * IK_GENERALISED_C_STICKY_BUFFER (ikptr_t obj)
Preprocessor Macro: void * IK_GENERALISED_C_STICKY_BUFFER_OR_FALSE (ikptr_t obj)

Given a pointer object or a memory-block object return a void * pointer referencing the data. The second macro accepts also #f as value and returns NULL.

Preprocessor Macro: char * IK_GENERALISED_C_STRING (ikptr_t obj)
Preprocessor Macro: char * IK_GENERALISED_C_STRING_OR_FALSE (ikptr_t obj)

Given a bytevector object or a pointer object or a memory-block object return a char * pointer referencing the data. The second macro accepts also #f as value and returns NULL.


Next: , Previous: , Up: objects misc   [Index]