[psi/psi_decl.m4],
[psi/psi_macro.m4],
[psi/psi_composite.m4],
+ [posix/arpa_inet.m4],
[posix/errno.m4],
[posix/fcntl.m4],
[posix/glob.m4],
PSI_CONFIG_POSIX(stdlib, stdlib.h)
PSI_CONFIG_POSIX(unistd, unistd.h)
PSI_CONFIG_POSIX(sys/socket, sys/socket.h, [
- PSI_CONFIG_POSIX(netinet/in, netinet/in.h)
+ PSI_CONFIG_POSIX(netinet/in, netinet/in.h, [
+ PSI_CONFIG_POSIX(arpa/inet, arpa/inet.h)
+ ])
PSI_CONFIG_POSIX(netdb, netdb.h)
])
PSI_CONFIG_POSIX(netinet/tcp, netinet/tcp.h)
--- /dev/null
+PSI_CHECK_ARPA_INET() {
+ PSI_DECL(uint32_t htonl, [(uint32_t l)])
+ PSI_DECL(uint16_t htons, [(uint16_t s)])
+ PSI_DECL(uint32_t ntohl, [(uint32_t l)])
+ PSI_DECL(uint16_t ntohs, [(uint16_t s)])
+
+ PSI_DECL(in_addr_t inet_addr, [(const char *cp)])
+ PSI_DECL(char *inet_ntoa, [(struct in_addr in)])
+ PSI_DECL(const char *inet_ntop, [(int af, const void *src, char *dst, socklen_t size)])
+ PSI_DECL(int inet_pton, [(int af, const char *src, void *dst)])
+}
\ No newline at end of file
--- /dev/null
+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
--- /dev/null
+--TEST--
+inet_ntop/inet_pton
+--INI--
+psi.directory={PWD}/../../psi.d:{PWD}
+--SKIPIF--
+<?php
+extension_loaded("psi") or die("skip - need ext/psi");
+function_exists("psi\\inet_pton") or die("skip - need inet_pton()");
+?>
+--FILE--
+===TEST===
+<?php
+var_dump(psi\inet_pton(psi\AF_INET, "127.1.1.1", $res));
+var_dump(psi\inet_ntop(psi\AF_INET, $res));
+?>
+===DONE===
+--EXPECT--
+===TEST===
+int(1)
+string(9) "127.1.1.1"
+===DONE===
--- /dev/null
+--TEST--
+inet_addr/inet_ntoa
+--INI--
+psi.directory={PWD}/../../psi.d:{PWD}
+--FILE--
+===TEST===
+<?php
+var_dump(psi\inet_ntoa(["s_addr" => psi\inet_addr("217.0.0.1")]));
+?>
+===DONE===
+--EXPECT--
+===TEST===
+string(9) "217.0.0.1"
+===DONE===
--- /dev/null
+--TEST--
+arpa/inet
+--INI--
+psi.directory={PWD}/../../psi.d:{PWD}
+--SKIPIF--
+<?php
+extension_loaded("psi") or die("skip - need ext/psi");
+function_exists("psi\\ntohs") or die("skip - need ntohs()");
+?>
+--FILE--
+===TEST===
+<?php
+var_dump(psi\htons(psi\ntohs(55)));
+var_dump(psi\htonl(psi\ntohl(555555)));
+var_dump(psi\ntohs(psi\htons(14080)));
+var_dump(psi\ntohl(psi\htonl(595200000)));
+?>
+===DONE===
+--EXPECT--
+===TEST===
+int(55)
+int(555555)
+int(14080)
+int(595200000)
+===DONE===