#pragma lib
[m6w6/ext-psi] / tests / ndbm / ndbm.psi
1 #include <fcntl.h>
2
3 #pragma lib "gdbm_compat";
4 #include <ndbm.h>
5
6
7 function psi\dbm_open(string $file, int $open_flags, int $file_mode) : object {
8 let file = pathval($file);
9 let open_flags = intval($open_flags);
10 let file_mode = intval($file_mode);
11 return dbm_open(file, open_flags, file_mode) as to_object(dbm_open);
12 }
13
14 function psi\dbm_store(object $db, string $key, string $data, int $mode) : int {
15 let db = objval($db);
16 let key = arrval($key,
17 dptr = strval($0),
18 dsize = strlen($0)
19 );
20 let content = arrval($data,
21 dptr = strval($0),
22 dsize = strlen($0)
23 );
24 let store_mode = intval($mode);
25 return dbm_store(db, key, content, store_mode) as to_int(dbm_store);
26 }
27
28 function psi\dbm_fetch(object $db, array $key) : array {
29 let db = objval($db);
30 let key = arrval($key,
31 dptr = strval($dptr),
32 dsize = intval($dsize)
33 );
34 return dbm_fetch(db, key) as to_array(dbm_fetch,
35 to_int(dsize),
36 to_string(dptr, dsize)
37 );
38 }
39
40 function psi\dbm_close(object $db) : void {
41 let db = objval($db);
42 return dbm_close(db) as void(dbm_close);
43 }