3 static struct hostent
*NetHostDB_hostent
;
5 C_String_t
NetHostDB_getEntryName(void) {
6 return (C_String_t
)(NetHostDB_hostent
->h_name
);
9 C_Int_t
NetHostDB_getEntryAliasesNum(void) {
11 while (NetHostDB_hostent
->h_aliases
[num
] != NULL
) num
++;
15 C_String_t
NetHostDB_getEntryAliasesN(C_Int_t n
) {
16 return (C_String_t
)(NetHostDB_hostent
->h_aliases
[n
]);
19 C_Int_t
NetHostDB_getEntryAddrType(void) {
20 return NetHostDB_hostent
->h_addrtype
;
23 C_Int_t
NetHostDB_getEntryLength(void) {
24 return NetHostDB_hostent
->h_length
;
27 C_Int_t
NetHostDB_getEntryAddrsNum(void) {
29 while (NetHostDB_hostent
->h_addr_list
[num
] != NULL
) num
++;
33 void NetHostDB_getEntryAddrsN(C_Int_t n
, Array(Word8_t
) addr
) {
35 for (i
= 0; i
< NetHostDB_hostent
->h_length
; i
++) {
36 ((char*)addr
)[i
] = NetHostDB_hostent
->h_addr_list
[n
][i
];
41 C_Int_t
NetHostDB_getByAddress(Vector(Word8_t
) addr
, C_Socklen_t len
) {
43 NetHostDB_hostent
= gethostbyaddr((const char*)addr
, len
, AF_INET
);
44 return (C_Int_t
)(NetHostDB_hostent
!= NULL
and NetHostDB_hostent
->h_name
!= NULL
);
47 C_Int_t
NetHostDB_getByName(NullString8_t name
) {
49 NetHostDB_hostent
= gethostbyname((const char*)name
);
50 return (C_Int_t
)(NetHostDB_hostent
!= NULL
and NetHostDB_hostent
->h_name
!= NULL
);
53 C_Errno_t(C_Int_t
) NetHostDB_getHostName(Array(Char8_t
) buf
, C_Size_t len
) {
57 out
= gethostname ((char*)buf
, len
);
58 if (out
== -1) MLton_fixSocketErrno ();