Import Debian changes 20180207-1
[hcoop/debian/mlton.git] / runtime / basis / Net / NetServDB.c
1 #include "platform.h"
2
3 static struct servent *NetHostDB_servent;
4
5 C_String_t NetServDB_getEntryName(void) {
6 return (C_String_t)(NetHostDB_servent->s_name);
7 }
8
9 C_Int_t NetServDB_getEntryAliasesNum(void) {
10 int num = 0;
11 while (NetHostDB_servent->s_aliases[num] != NULL) num++;
12 return num;
13 }
14
15 C_String_t NetServDB_getEntryAliasesN(C_Int_t n) {
16 return (C_String_t)(NetHostDB_servent->s_aliases[n]);
17 }
18
19 C_Int_t NetServDB_getEntryPort(void) {
20 return NetHostDB_servent->s_port;
21 }
22
23 C_String_t NetServDB_getEntryProto(void) {
24 return (C_String_t)(NetHostDB_servent->s_proto);
25 }
26
27 C_Int_t NetServDB_getByName(NullString8_t name, NullString8_t proto) {
28 NetHostDB_servent = getservbyname((const char*)name, (const char*)proto);
29 return (C_Int_t)(NetHostDB_servent != NULL and NetHostDB_servent->s_name != NULL);
30 }
31
32 C_Int_t NetServDB_getByNameNull(NullString8_t name) {
33 return NetServDB_getByName(name, (NullString8_t)NULL);
34 }
35
36 C_Int_t NetServDB_getByPort(C_Int_t port, NullString8_t proto) {
37 NetHostDB_servent = getservbyport(port, (const char*)proto);
38 return (C_Int_t)(NetHostDB_servent != NULL and NetHostDB_servent->s_name != NULL);
39 }
40
41 C_Int_t NetServDB_getByPortNull(C_Int_t port) {
42 return NetServDB_getByPort(port, (NullString8_t)NULL);
43 }