parser: accept trailing comma in enums; __restrict for arrays
[m6w6/ext-psi] / psi.d / glob.psi
1 #include <glob.h>
2
3 function psi\glob(string $pattern, int $flags, array &$glob = NULL, callable $errfn = NULL) : int {
4 let path = strval($pattern);
5 let flags = intval($flags);
6 let err = callback intval($errfn(
7 to_string(epath),
8 to_int(eerrno)
9 ));
10 let buf = &arrval($glob,
11 intval($gl_matchc),
12 intval($gl_pathc),
13 intval($gl_offs),
14 intval($gl_flags),
15 &arrval($gl_pathv,
16 strval($gl_pathv)
17 )
18 );
19 return glob(path, flags, err, buf) as to_int(glob);
20 set $glob = to_array(*buf,
21 to_int(gl_matchc),
22 to_int(gl_pathc),
23 to_int(gl_offs),
24 to_int(gl_flags),
25 to_array(*gl_pathv, gl_pathc + gl_offs, to_string(*gl_pathv))
26 );
27 }