resolve.inc 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 1999-2022 by Michael van Canney and other members of the
  4. Free Pascal development team
  5. *nix parts of the resolver
  6. See the file COPYING.FPC, included in this distribution,
  7. for details about the copyright.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. **********************************************************************}
  12. uses
  13. initc;
  14. const
  15. { Net type }
  16. socklib = 'c';
  17. AF_INET = 2;
  18. { Error constants. Returned by LastError method of THost, TNet}
  19. NETDB_INTERNAL= -1; { see errno }
  20. NETDB_SUCCESS = 0; { no problem }
  21. HOST_NOT_FOUND= 1; { Authoritative Answer Host not found }
  22. TRY_AGAIN = 2; { Non-Authoritive Host not found, or SERVERFAIL }
  23. NO_RECOVERY = 3; { Non recoverable errors, FORMERR, REFUSED, NOTIMP }
  24. NO_DATA = 4; { Valid name, no data record of requested type }
  25. NO_ADDRESS = NO_DATA; { no address, look for MX record }
  26. Type
  27. { THostEnt Object }
  28. THostEnt = record
  29. H_Name : PAnsiChar; { Official name }
  30. H_Aliases : PPAnsiChar; { Null-terminated list of aliases}
  31. H_Addrtype : longint; { Host address type }
  32. H_length : longint; { Length of address }
  33. H_Addr : PPAnsiChar; { null-terminated list of adresses }
  34. end;
  35. PHostEntry = ^THostEnt;
  36. { TNetEnt object }
  37. TNetEnt = record
  38. N_Name : PAnsiChar; { Official name }
  39. N_Aliases : PPAnsiChar; { Nill-terminated alias list }
  40. N_AddrType : longint; { Net address type }
  41. N_net : Cardinal; { Network number }
  42. end;
  43. PNetEntry = ^TNetEnt;
  44. TServEnt = record
  45. s_name : PAnsiChar; { Service name }
  46. s_aliases : PPAnsiChar; { Null-terminated alias list }
  47. s_port : longint; { Port number }
  48. s_proto : PAnsiChar; { Protocol to use }
  49. end;
  50. PServEntry = ^TServEnt;
  51. { C style calls, linked in from Libc }
  52. function gethostent : PHostEntry; cdecl; external socklib;
  53. procedure sethostent (stayopen : longint); cdecl; external socklib;
  54. procedure endhostent; cdecl; external socklib;
  55. function getnetent : PNetEntry; cdecl; external socklib;
  56. procedure setnetent ( Stayopen : Longint); cdecl; external socklib;
  57. procedure endnetent; cdecl; external socklib;
  58. function getservent : PServEntry; cdecl; external socklib;
  59. procedure setservent (StayOpen : longint); cdecl; external socklib;
  60. procedure endservent; cdecl; external socklib;
  61. function getnetbyaddr ( Net : Longint; nettype : Longint) : PNetEntry; cdecl; external socklib;
  62. function gethostbyname ( Name : PAnsiChar) : PHostEntry; cdecl; external socklib;
  63. function gethostbyaddr ( Addr : PAnsiChar; Len : Longint; HType : Longint) : PHostentry ; cdecl; external socklib;
  64. function getnetbyname ( Name : PAnsiChar) : PNetEntry; cdecl; external socklib;
  65. function getservbyname (name : PAnsiChar ; protocol : PAnsiChar) : PServEntry; cdecl; external socklib;
  66. function getservbyport (port : longint; protocol : PAnsiChar) : PServEntry; cdecl; external socklib;
  67. function GetDNSError : libcint;
  68. begin
  69. GetDNSError:=fpgetCerrno;
  70. end;
  71. Function InitResolve : Boolean;
  72. begin
  73. Result:=True;
  74. end;
  75. Function FinalResolve : Boolean;
  76. begin
  77. Result:=True;
  78. end;