X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-psi;a=blobdiff_plain;f=psi.d%2Farpa_inet.psi;h=b38fc3d77a6479dfc2a794fee555587e9fcec699;hp=2a8404ee024a6fe0abc25697263c69447bba5808;hb=036752dbbcb77494de9935ac459ea5cf0ea34b4b;hpb=5b17e760a71eaa07bc91e0bc0b463f2ecfec245a diff --git a/psi.d/arpa_inet.psi b/psi.d/arpa_inet.psi index 2a8404e..b38fc3d 100644 --- a/psi.d/arpa_inet.psi +++ b/psi.d/arpa_inet.psi @@ -1,46 +1,48 @@ +#include + function psi\htonl(int $l) : int { let l = intval($l); - return to_int(htonl); + return htonl(l) as to_int(htonl); } function psi\htons(int $s) : int { let s = intval($s); - return to_int(htons); + return htons(s) as to_int(htons); } function psi\ntohl(int $l) : int { let l = intval($l); - return to_int(ntohl); + return ntohl(l) as to_int(ntohl); } function psi\ntohs(int $s) : int { let s = intval($s); - return to_int(ntohs); + return ntohs(s) as to_int(ntohs); } function psi\inet_addr(string $cp) : int { let cp = strval($cp); - return to_int(inet_addr); + return inet_addr(cp) as to_int(inet_addr); } function psi\inet_ntoa(array $in) : string { let in = arrval($in, intval($s_addr) ); - return to_string(inet_ntoa); + return inet_ntoa(in) as 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 size = sizeof(struct sockaddr_storage); let dst = calloc(1, size); - return to_string(inet_ntop); + return inet_ntop(af, src, dst, size) as 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 + let dst = calloc(1, sizeof(struct sockaddr_storage)); + return inet_pton(af, src, dst) as to_int(inet_pton); + set $dst = to_string(dst, sizeof(struct sockaddr_storage)); +}