parser: RETURN [<native call> AS] SET_FUNC
[m6w6/ext-psi] / psi.d / arpa_inet.psi
1 function psi\htonl(int $l) : int {
2 let l = intval($l);
3 return htonl(l) as to_int(htonl);
4 }
5 function psi\htons(int $s) : int {
6 let s = intval($s);
7 return htons(s) as to_int(htons);
8 }
9
10 function psi\ntohl(int $l) : int {
11 let l = intval($l);
12 return ntohl(l) as to_int(ntohl);
13 }
14 function psi\ntohs(int $s) : int {
15 let s = intval($s);
16 return ntohs(s) as to_int(ntohs);
17 }
18
19
20 function psi\inet_addr(string $cp) : int {
21 let cp = strval($cp);
22 return inet_addr(cp) as to_int(inet_addr);
23 }
24
25 function psi\inet_ntoa(array $in) : string {
26 let in = arrval($in,
27 intval($s_addr)
28 );
29 return inet_ntoa(in) as to_string(inet_ntoa);
30 }
31
32 function psi\inet_ntop(int $af, string $src) : string {
33 let af = intval($af);
34 let src = strval($src);
35 let size = psi\SIZEOF_STRUCT_SOCKADDR_STORAGE;
36 let dst = calloc(1, size);
37 return inet_ntop(af, src, dst, size) as to_string(inet_ntop);
38 }
39
40 function psi\inet_pton(int $af, string $src, string &$dst) : int {
41 let af = intval($af);
42 let src = strval($src);
43 let dst = calloc(1, psi\SIZEOF_STRUCT_SOCKADDR_STORAGE);
44 return inet_pton(af, src, dst) as to_int(inet_pton);
45 set $dst = to_string(dst, psi\SIZEOF_STRUCT_SOCKADDR_STORAGE);
46 }