netdbh.inc 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. const
  2. _PATH_HEQUIV = '/etc/hosts.equiv';
  3. _PATH_HOSTS = '/etc/hosts';
  4. _PATH_NETWORKS = '/etc/networks';
  5. _PATH_NSSWITCH_CONF = '/etc/nsswitch.conf';
  6. _PATH_PROTOCOLS = '/etc/protocols';
  7. _PATH_SERVICES = '/etc/services';
  8. var
  9. h_errno : longint;cvar;external;
  10. function __h_errno_location:Plongint;cdecl;external clib name '__h_errno_location';
  11. const
  12. NETDB_INTERNAL = -(1);
  13. NETDB_SUCCESS = 0;
  14. HOST_NOT_FOUND = 1;
  15. TRY_AGAIN = 2;
  16. NO_RECOVERY = 3;
  17. NO_DATA = 4;
  18. NO_ADDRESS = NO_DATA;
  19. SCOPE_DELIMITER = '%';
  20. procedure herror(__str:Pchar);cdecl;external clib name 'herror';
  21. function hstrerror(__err_num:longint):Pchar;cdecl;external clib name 'hstrerror';
  22. type
  23. Phostent = ^hostent;
  24. hostent = record
  25. h_name: PChar;
  26. h_aliases: PPChar;
  27. h_addrtype: Integer;
  28. h_length: socklen_t;
  29. case Byte of
  30. 0: (h_addr_list: PPChar);
  31. 1: (h_addr: PPChar);
  32. end;
  33. PPhostent = ^Phostent;
  34. procedure sethostent(__stay_open:longint);cdecl;external clib name 'sethostent';
  35. procedure endhostent;cdecl;external clib name 'endhostent';
  36. function gethostent:Phostent;cdecl;external clib name 'gethostent';
  37. function gethostbyaddr(__addr:pointer; __len:__socklen_t; __type:longint):Phostent;cdecl;external clib name 'gethostbyaddr';
  38. function gethostbyname(__name:Pchar):Phostent;cdecl;external clib name 'gethostbyname';
  39. function gethostbyname2(__name:Pchar; __af:longint):Phostent;cdecl;external clib name 'gethostbyname2';
  40. function gethostent_r(__result_buf:Phostent; __buf:Pchar; __buflen:size_t; __result:PPhostent; __h_errnop:Plongint):longint;cdecl;external clib name 'gethostent_r';
  41. function gethostbyaddr_r(__addr:pointer; __len:__socklen_t; __type:longint; __result_buf:Phostent; __buf:Pchar;
  42. __buflen:size_t; __result:PPhostent; __h_errnop:Plongint):longint;cdecl;external clib name 'gethostbyaddr_r';
  43. function gethostbyname_r(__name:Pchar; __result_buf:Phostent; __buf:Pchar; __buflen:size_t; __result:PPhostent;
  44. __h_errnop:Plongint):longint;cdecl;external clib name 'gethostbyname_r';
  45. function gethostbyname2_r(__name:Pchar; __af:longint; __result_buf:Phostent; __buf:Pchar; __buflen:size_t;
  46. __result:PPhostent; __h_errnop:Plongint):longint;cdecl;external clib name 'gethostbyname2_r';
  47. procedure setnetent(__stay_open:longint);cdecl;external clib name 'setnetent';
  48. procedure endnetent;cdecl;external clib name 'endnetent';
  49. function getnetent:Pnetent;cdecl;external clib name 'getnetent';
  50. function getnetbyaddr(__net:uint32_t; __type:longint):Pnetent;cdecl;external clib name 'getnetbyaddr';
  51. function getnetbyname(__name:Pchar):Pnetent;cdecl;external clib name 'getnetbyname';
  52. function getnetent_r(__result_buf:Pnetent; __buf:Pchar; __buflen:size_t; __result:PPnetent; __h_errnop:Plongint):longint;cdecl;external clib name 'getnetent_r';
  53. function getnetbyaddr_r(__net:uint32_t; __type:longint; __result_buf:Pnetent; __buf:Pchar; __buflen:size_t;
  54. __result:PPnetent; __h_errnop:Plongint):longint;cdecl;external clib name 'getnetbyaddr_r';
  55. function getnetbyname_r(__name:Pchar; __result_buf:Pnetent; __buf:Pchar; __buflen:size_t; __result:PPnetent;
  56. __h_errnop:Plongint):longint;cdecl;external clib name 'getnetbyname_r';
  57. type
  58. Pservent = ^servent;
  59. servent = record
  60. s_name : Pchar;
  61. s_aliases : ^Pchar;
  62. s_port : longint;
  63. s_proto : Pchar;
  64. end;
  65. PPservent = ^Pservent;
  66. procedure setservent(__stay_open:longint);cdecl;external clib name 'setservent';
  67. procedure endservent;cdecl;external clib name 'endservent';
  68. function getservent:Pservent;cdecl;external clib name 'getservent';
  69. function getservbyname(__name:Pchar; __proto:Pchar):Pservent;cdecl;external clib name 'getservbyname';
  70. function getservbyport(__port:longint; __proto:Pchar):Pservent;cdecl;external clib name 'getservbyport';
  71. function getservent_r(__result_buf:Pservent; __buf:Pchar; __buflen:size_t; __result:PPservent):longint;cdecl;external clib name 'getservent_r';
  72. function getservbyname_r(__name:Pchar; __proto:Pchar; __result_buf:Pservent; __buf:Pchar; __buflen:size_t;
  73. __result:PPservent):longint;cdecl;external clib name 'getservbyname_r';
  74. function getservbyport_r(__port:longint; __proto:Pchar; __result_buf:Pservent; __buf:Pchar; __buflen:size_t;
  75. __result:PPservent):longint;cdecl;external clib name 'getservbyport_r';
  76. type
  77. Pprotoent = ^protoent;
  78. protoent = record
  79. p_name : Pchar;
  80. p_aliases : ^Pchar;
  81. p_proto : longint;
  82. end;
  83. PPprotoent = ^Pprotoent;
  84. procedure setprotoent(__stay_open:longint);cdecl;external clib name 'setprotoent';
  85. procedure endprotoent;cdecl;external clib name 'endprotoent';
  86. function getprotoent:Pprotoent;cdecl;external clib name 'getprotoent';
  87. function getprotobyname(__name:Pchar):Pprotoent;cdecl;external clib name 'getprotobyname';
  88. function getprotobynumber(__proto:longint):Pprotoent;cdecl;external clib name 'getprotobynumber';
  89. function getprotoent_r(__result_buf:Pprotoent; __buf:Pchar; __buflen:size_t; __result:PPprotoent):longint;cdecl;external clib name 'getprotoent_r';
  90. function getprotobyname_r(__name:Pchar; __result_buf:Pprotoent; __buf:Pchar; __buflen:size_t; __result:PPprotoent):longint;cdecl;external clib name 'getprotobyname_r';
  91. function getprotobynumber_r(__proto:longint; __result_buf:Pprotoent; __buf:Pchar; __buflen:size_t; __result:PPprotoent):longint;cdecl;external clib name 'getprotobynumber_r';
  92. function setnetgrent(__netgroup:Pchar):longint;cdecl;external clib name 'setnetgrent';
  93. procedure endnetgrent;cdecl;external clib name 'endnetgrent';
  94. function getnetgrent(__hostp:PPchar; __userp:PPchar; __domainp:PPchar):longint;cdecl;external clib name 'getnetgrent';
  95. function innetgr(__netgroup:Pchar; __host:Pchar; __user:Pchar; domain:Pchar):longint;cdecl;external clib name 'innetgr';
  96. function getnetgrent_r(__hostp:PPchar; __userp:PPchar; __domainp:PPchar; __buffer:Pchar; __buflen:size_t):longint;cdecl;external clib name 'getnetgrent_r';
  97. function rcmd(__ahost:PPchar; __rport:word; __locuser:Pchar; __remuser:Pchar; __cmd:Pchar;
  98. __fd2p:Plongint):longint;cdecl;external clib name 'rcmd';
  99. function rcmd_af(__ahost:PPchar; __rport:word; __locuser:Pchar; __remuser:Pchar; __cmd:Pchar;
  100. __fd2p:Plongint; __af:sa_family_t):longint;cdecl;external clib name 'rcmd_af';
  101. function rexec(__ahost:PPchar; __rport:longint; __name:Pchar; __pass:Pchar; __cmd:Pchar;
  102. __fd2p:Plongint):longint;cdecl;external clib name 'rexec';
  103. function rexec_af(__ahost:PPchar; __rport:longint; __name:Pchar; __pass:Pchar; __cmd:Pchar;
  104. __fd2p:Plongint; __af:sa_family_t):longint;cdecl;external clib name 'rexec_af';
  105. function ruserok(__rhost:Pchar; __suser:longint; __remuser:Pchar; __locuser:Pchar):longint;cdecl;external clib name 'ruserok';
  106. function ruserok_af(__rhost:Pchar; __suser:longint; __remuser:Pchar; __locuser:Pchar; __af:sa_family_t):longint;cdecl;external clib name 'ruserok_af';
  107. function rresvport(__alport:Plongint):longint;cdecl;external clib name 'rresvport';
  108. function rresvport_af(__alport:Plongint; __af:sa_family_t):longint;cdecl;external clib name 'rresvport_af';
  109. type
  110. Paddrinfo = ^addrinfo;
  111. addrinfo = record
  112. ai_flags : longint;
  113. ai_family : longint;
  114. ai_socktype : longint;
  115. ai_protocol : longint;
  116. ai_addrlen : socklen_t;
  117. ai_addr : Psockaddr;
  118. ai_canonname : Pchar;
  119. ai_next : Paddrinfo;
  120. end;
  121. PPaddrinfo = ^Paddrinfo;
  122. Pgaicb = ^gaicb;
  123. gaicb = record
  124. ar_name : Pchar;
  125. ar_service : Pchar;
  126. ar_request : Paddrinfo;
  127. ar_result : Paddrinfo;
  128. __return : longint;
  129. __unused : array[0..4] of longint;
  130. end;
  131. PPgaicb = ^Pgaicb;
  132. const
  133. GAI_WAIT = 0;
  134. GAI_NOWAIT = 1;
  135. AI_PASSIVE = $0001;
  136. AI_CANONNAME = $0002;
  137. AI_NUMERICHOST = $0004;
  138. EAI_BADFLAGS = -(1);
  139. EAI_NONAME = -(2);
  140. EAI_AGAIN = -(3);
  141. EAI_FAIL = -(4);
  142. EAI_NODATA = -(5);
  143. EAI_FAMILY = -(6);
  144. EAI_SOCKTYPE = -(7);
  145. EAI_SERVICE = -(8);
  146. EAI_ADDRFAMILY = -(9);
  147. EAI_MEMORY = -(10);
  148. EAI_SYSTEM = -(11);
  149. EAI_INPROGRESS = -(100);
  150. EAI_CANCELED = -(101);
  151. EAI_NOTCANCELED = -(102);
  152. EAI_ALLDONE = -(103);
  153. EAI_INTR = -(104);
  154. NI_MAXHOST = 1025;
  155. NI_MAXSERV = 32;
  156. NI_NUMERICHOST = 1;
  157. NI_NUMERICSERV = 2;
  158. NI_NOFQDN = 4;
  159. NI_NAMEREQD = 8;
  160. NI_DGRAM = 16;
  161. function getaddrinfo(__name:Pchar; __service:Pchar; __req:Paddrinfo; __pai:PPaddrinfo):longint;cdecl;external clib name 'getaddrinfo';
  162. procedure freeaddrinfo(__ai:Paddrinfo);cdecl;external clib name 'freeaddrinfo';
  163. function gai_strerror(__ecode:longint):Pchar;cdecl;external clib name 'gai_strerror';
  164. function getnameinfo(__sa:Psockaddr; __salen:socklen_t; __host:Pchar; __hostlen:socklen_t; __serv:Pchar;
  165. __servlen:socklen_t; __flags:dword):longint;cdecl;external clib name 'getnameinfo';
  166. function getaddrinfo_a(__mode:longint; __list: PPgaicb; __ent:longint; __sig:Psigevent):longint;cdecl;external clib name 'getaddrinfo_a';
  167. function gai_suspend(__list:array of Pgaicb; __ent:longint; __timeout:Ptimespec):longint;cdecl;external clib name 'gai_suspend';
  168. function gai_error(__req:Pgaicb):longint;cdecl;external clib name 'gai_error';
  169. function gai_cancel(__gaicbp:Pgaicb):longint;cdecl;external clib name 'gai_cancel';
  170. { ---------------------------------------------------------------------
  171. Borland compatibility types
  172. ---------------------------------------------------------------------}
  173. Type
  174. THostEnt = hostent;
  175. TServEnt = servent;
  176. TProtoEnt = protoent;
  177. TAddressInfo = addrinfo;