Freepascal: use Hosts file for name resolution on Unix. (Yury Sidorov)

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@132 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
geby 2011-01-19 14:48:41 +00:00
parent f7f7973024
commit 55add16988

View File

@ -1,9 +1,9 @@
{==============================================================================| {==============================================================================|
| Project : Ararat Synapse | 001.001.003 | | Project : Ararat Synapse | 001.001.004 |
|==============================================================================| |==============================================================================|
| Content: Socket Independent Platform Layer - FreePascal definition include | | Content: Socket Independent Platform Layer - FreePascal definition include |
|==============================================================================| |==============================================================================|
| Copyright (c)2006-2010, Lukas Gebauer | | Copyright (c)2006-2011, Lukas Gebauer |
| All rights reserved. | | All rights reserved. |
| | | |
| Redistribution and use in source and binary forms, with or without | | Redistribution and use in source and binary forms, with or without |
@ -33,7 +33,7 @@
| DAMAGE. | | DAMAGE. |
|==============================================================================| |==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).| | The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).|
| Portions created by Lukas Gebauer are Copyright (c)2006-2010. | | Portions created by Lukas Gebauer are Copyright (c)2006-2011. |
| All Rights Reserved. | | All Rights Reserved. |
|==============================================================================| |==============================================================================|
| Contributor(s): | | Contributor(s): |
@ -673,6 +673,7 @@ var
var var
a4: array [1..1] of in_addr; a4: array [1..1] of in_addr;
a6: array [1..1] of Tin6_addr; a6: array [1..1] of Tin6_addr;
he: THostEntry;
begin begin
Result := WSAEPROTONOSUPPORT; Result := WSAEPROTONOSUPPORT;
case f of case f of
@ -693,7 +694,10 @@ var
Result := WSAHOST_NOT_FOUND; Result := WSAHOST_NOT_FOUND;
a4[1] := StrTonetAddr(IP); a4[1] := StrTonetAddr(IP);
if a4[1].s_addr = INADDR_ANY then if a4[1].s_addr = INADDR_ANY then
Resolvename(ip, a4); if GetHostByName(ip, he) then
a4[1]:=HostToNet(he.Addr)
else
Resolvename(ip, a4);
end; end;
if a4[1].s_addr <> INADDR_ANY then if a4[1].s_addr <> INADDR_ANY then
begin begin
@ -788,6 +792,7 @@ var
x, n: integer; x, n: integer;
a4: array [1..255] of in_addr; a4: array [1..255] of in_addr;
a6: array [1..255] of Tin6_addr; a6: array [1..255] of Tin6_addr;
he: THostEntry;
begin begin
IPList.Clear; IPList.Clear;
if (family = AF_INET) or (family = AF_UNSPEC) then if (family = AF_INET) or (family = AF_UNSPEC) then
@ -798,7 +803,13 @@ begin
begin begin
a4[1] := StrTonetAddr(name); a4[1] := StrTonetAddr(name);
if a4[1].s_addr = INADDR_ANY then if a4[1].s_addr = INADDR_ANY then
x := Resolvename(name, a4) if GetHostByName(name, he) then
begin
a4[1]:=HostToNet(he.Addr);
x := 1;
end
else
x := Resolvename(name, a4)
else else
x := 1; x := 1;
for n := 1 to x do for n := 1 to x do