Source file pkcs11_slot_list.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
open Ctypes
type _t
type t =
{
length: P11_ulong.t ptr;
mutable content: Pkcs11_CK_SLOT_ID.t ptr;
}
type u = Pkcs11_CK_SLOT_ID.t list
let get_length (t:t) : P11_ulong.t =
!@ (t.length)
let get_content (t:t) : Pkcs11_CK_SLOT_ID.t ptr =
t.content
let get_length_addr (t:t) : P11_ulong.t ptr =
t.length
let create () : t =
{
length = Ctypes.allocate ulong Unsigned.ULong.zero;
content = from_voidp Pkcs11_CK_SLOT_ID.typ null;
}
let allocate (t:t) : unit =
let n = get_length t |> Unsigned.ULong.to_int in
let data = allocate_n Pkcs11_CK_SLOT_ID.typ ~count:n in
t.content <- data;
()
let view (t:t) : u =
let length = get_length t |> Unsigned.ULong.to_int in
let array = CArray.from_ptr (get_content t) length in
CArray.to_list array
let make (u : u) : t =
let array = CArray.of_list ulong u in
{
length = Ctypes.allocate ulong (Unsigned.ULong.of_int (List.length u));
content = CArray.start array;
}