File: NetServDB.c

package info (click to toggle)
mlton 20070826-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 33,184 kB
  • ctags: 70,419
  • sloc: ansic: 16,154; lisp: 2,727; makefile: 1,635; sh: 1,234; pascal: 256; asm: 97
file content (46 lines) | stat: -rw-r--r-- 1,178 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#define _ISOC99_SOURCE
#define _BSD_SOURCE

#include "platform.h"

static struct servent *servent;

C_String_t NetServDB_getEntryName(void) {
  return (C_String_t)(servent->s_name);
}

C_Int_t NetServDB_getEntryAliasesNum(void) {
  int num = 0;
  while (servent->s_aliases[num] != NULL) num++;
  return num;
}

C_String_t NetServDB_getEntryAliasesN(C_Int_t n) {
  return (C_String_t)(servent->s_aliases[n]);
}

C_Int_t NetServDB_getEntryPort(void) {
  return servent->s_port;
}

C_String_t NetServDB_getEntryProto(void) {
  return (C_String_t)(servent->s_proto);
}

C_Int_t NetServDB_getByName(NullString8_t name, NullString8_t proto) {
  servent = getservbyname((const char*)name, (const char*)proto);
  return (C_Int_t)(servent != NULL and servent->s_name != NULL);
}

C_Int_t NetServDB_getByNameNull(NullString8_t name) {
  return NetServDB_getByName(name, (NullString8_t)NULL);
}

C_Int_t NetServDB_getByPort(C_Int_t port, NullString8_t proto) {
  servent = getservbyport(port, (const char*)proto);
  return (C_Int_t)(servent != NULL and servent->s_name != NULL);
}

C_Int_t NetServDB_getByPortNull(C_Int_t port) {
  return NetServDB_getByPort(port, (NullString8_t)NULL);
}