Module Ctypes_helpers
module Reachable_ptr : sig ... endval ptr_from_string : string -> char Ctypes.ptrptr_from_string sallocates memory for a C string with lengthString.length sand content copied froms. The string is notnullterminated.
val string_from_ptr : char Ctypes.ptr -> length:int -> stringstring_from_ptrallocates an OCaml string.
val string_from_carray : char Ctypes.CArray.t -> stringstring_from_carray arrayallocates a fresh OCaml string whose content are copied fromarray.
val carray_from_string : string -> char Ctypes.CArray.tcarray_from_stringallocates a fresh array, whose content is identical to the strings. The resulting C string is not null terminated.
val string_copy : string -> int -> char Ctypes.ptr -> unitstring_copy str length ptrcopy the content ofstrinto thelengthbytes of memory pointed to byptr.
val make_string : string -> 'a Ctypes.structure -> (Unsigned.ULong.t, 'a Ctypes.structure) Ctypes.field -> ('b Reachable_ptr.t, 'a Ctypes.structure) Ctypes.field -> unit* Copy an OCaml string to a Ctypes struct. * * Parameters: * - str is the source string * - p is the structure * - lengthField is the field within that struct that holds then length * - dataField idem for data * - typ is the type of the data
val view_string : 'b Ctypes.structure -> (ulong, 'b Ctypes.structure) Ctypes.field -> ('a Reachable_ptr.t, 'b Ctypes.structure) Ctypes.field -> string* Read an OCaml string from a Ctypes struct. * * Parameters: same as make_string.
val make_string_option : string option -> ('a, [ `Struct ]) Ctypes.structured -> (Unsigned.ULong.t, ('a, [ `Struct ]) Ctypes.structured) Ctypes.field -> ('b Reachable_ptr.t, ('a, [ `Struct ]) Ctypes.structured) Ctypes.field -> unit* Copy a string option to a pointer + length. * Copying None sets the pointer to NULL and length to 0. * Parameters are the same as make_string.
val view_string_option : ('a, [ `Struct ]) Ctypes.structured -> (ulong, 'a Ctypes.structure) Ctypes.field -> ('b Reachable_ptr.t, ('a, [ `Struct ]) Ctypes.structured) Ctypes.field -> string option* Make a string option out of a pointer + length. * Same semantics for copy as make_string_option. * Same arguments as view_string.
val blank_padded : length:int -> string -> stringPad a string with ' ' up to
length. RaisesBuffer_overflowif the string is too long.
val packed_field : 't Ctypes.typ -> string -> 'a Ctypes.typ -> ('a, ('s, [< `Struct | `Union ]) Ctypes_static.structured as 't) Ctypes.fieldLike
Ctypes.fieldexcept that it will always align to 1 byte.