+#ifdef __linux__
+lib "anl";
+#endif
+
+#include <netdb.h>
+
function psi\endhostent() : void {
- return void(endhostent);
+ return endhostent() as void(endhostent);
}
-function psi\endnetend() : void {
- return void(endnetent);
+function psi\endnetent() : void {
+ return endnetent() as void(endnetent);
}
function psi\endprotoent() : void {
- return void(endprotoent);
+ return endprotoent() as void(endprotoent);
}
function psi\endservent() : void {
- return void(endservent);
+ return endservent() as void(endservent);
}
function psi\sethostent(bool $stayopen) : void {
let stayopen = intval($stayopen);
- return void(sethostent);
+ return sethostent(stayopen) as void(sethostent);
}
-function psi\setnetset(bool $stayopen) : void {
+function psi\setnetent(bool $stayopen) : void {
let stayopen = intval($stayopen);
- return void(setnetent);
+ return setnetent(stayopen) as void(setnetent);
}
function psi\setprotoent(bool $stayopen) : void {
let stayopen = intval($stayopen);
- return void(setprotoent);
+ return setprotoent(stayopen) as void(setprotoent);
}
function psi\setservent(bool $stayopen) : void {
let stayopen = intval($stayopen);
- return void(setservent);
+ return setservent(stayopen) as void(setservent);
}
function psi\gethostent() : array {
- return to_array(*gethostent,
+ return gethostent() as to_array(*gethostent,
to_string(h_name),
to_array(h_aliases, to_string(h_aliases)),
to_int(h_addrtype),
function psi\gai_strerror(int $errcode) : string {
let errcode = intval($errcode);
- return to_string(gai_strerror);
+ return gai_strerror(errcode) as to_string(gai_strerror);
}
// extern int getaddrinfo(const char *node, const char *service, const struct addrinfo *hints, struct addrinfo **res)
intval($ai_protocol)
);
let res = &NULL;
- return to_int(getaddrinfo);
+ return getaddrinfo(node, service, hints, res) as to_int(getaddrinfo);
set $res = to_array(**res,
to_int(ai_flags),
to_int(ai_family),
function psi\getnameinfo(string $addr, string &$host = NULL, string &$service = NULL, int $flags = 0) : int {
let sa = strval($addr);
let salen = strlen($addr);
- let hostlen = psi\NI_MAXHOST;
- let host = calloc(hostlen, psi\SIZEOF_CHAR);
- let servlen = psi\NI_MAXSERV;
- let serv = calloc(servlen, psi\SIZEOF_CHAR);
+ let hostlen = NI_MAXHOST;
+ let host = calloc(hostlen, sizeof(char));
+ let servlen = NI_MAXSERV;
+ let serv = calloc(servlen, sizeof(char));
let flags = intval($flags);
- return to_int(getnameinfo);
+ return getnameinfo(sa, salen, host, hostlen, serv, servlen, flags) as to_int(getnameinfo);
set $host = to_string(host);
set $service = to_string(serv);
}