posix: arpa_inet
[m6w6/ext-psi] / psi.d / arpa_inet.psi
diff --git a/psi.d/arpa_inet.psi b/psi.d/arpa_inet.psi
new file mode 100644 (file)
index 0000000..2a8404e
--- /dev/null
@@ -0,0 +1,46 @@
+function psi\htonl(int $l) : int {
+       let l = intval($l);
+       return to_int(htonl);
+}
+function psi\htons(int $s) : int {
+       let s = intval($s);
+       return to_int(htons);
+}
+
+function psi\ntohl(int $l) : int {
+       let l = intval($l);
+       return to_int(ntohl);
+}
+function psi\ntohs(int $s) : int {
+       let s = intval($s);
+       return to_int(ntohs);
+}
+
+
+function psi\inet_addr(string $cp) : int {
+       let cp = strval($cp);
+       return to_int(inet_addr);
+}
+
+function psi\inet_ntoa(array $in) : string {
+       let in = arrval($in,
+               intval($s_addr)
+       );
+       return to_string(inet_ntoa);
+}
+
+function psi\inet_ntop(int $af, string $src) : string {
+       let af = intval($af);
+       let src = strval($src);
+       let size = psi\SIZEOF_STRUCT_SOCKADDR_STORAGE;
+       let dst = calloc(1, size);
+       return to_string(inet_ntop);
+}
+
+function psi\inet_pton(int $af, string $src, string &$dst) : int {
+       let af = intval($af);
+       let src = strval($src);
+       let dst = calloc(1, psi\SIZEOF_STRUCT_SOCKADDR_STORAGE);
+       return to_int(inet_pton);
+       set $dst = to_string(dst, psi\SIZEOF_STRUCT_SOCKADDR_STORAGE);
+}
\ No newline at end of file