~ubuntu-branches/ubuntu/lucid/fpc/lucid-proposed

« back to all changes in this revision

Viewing changes to fpcsrc/packages/base/netdb/testdns.pp

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-10-09 23:29:00 UTC
  • mfrom: (4.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20081009232900-553f61m37jkp6upv
Tags: 2.2.2-4
[ Torsten Werner ]
* Update ABI version in fpc-depends automatically.
* Remove empty directories from binary package fpc-source.

[ Mazen Neifer ]
* Removed leading path when calling update-alternatives to remove a Linitian
  error.
* Fixed clean target.
* Improved description of packages. (Closes: #498882)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{
2
 
    This file is part of the Free Pascal run time library.
3
 
    Copyright (c) 2003 by the Free Pascal development team
4
 
 
5
 
    test netdb unit, host part
6
 
 
7
 
    See the file COPYING.FPC, included in this distribution,
8
 
    for details about the copyright.
9
 
 
10
 
    This program is distributed in the hope that it will be useful,
11
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 
 
14
 
 **********************************************************************}
15
 
{$mode objfpc}
16
 
{$h+}
17
 
 
18
 
program testdns;
19
 
 
20
 
uses netdb,Sockets;
21
 
 
22
 
Procedure DumpHostEntry(Const H : THostEntry);
23
 
 
24
 
begin
25
 
  With H do
26
 
    begin
27
 
    Writeln('Name     : ',Name);
28
 
    Writeln('Addr     : ',HostAddrToStr(Addr));
29
 
    Writeln('Aliases  : ',Aliases);
30
 
    Writeln;
31
 
    end;
32
 
end;
33
 
 
34
 
Procedure TestAddr(Addr : string);
35
 
 
36
 
Var
37
 
  H : THostEntry;
38
 
 
39
 
begin
40
 
  If ResolveHostByAddr(StrToHostAddr(Addr),H) then
41
 
    DumpHostEntry(H)
42
 
  else
43
 
    Writeln('No entry for address ',Addr)
44
 
end;
45
 
 
46
 
Procedure TestName(Const N : string);
47
 
 
48
 
Var
49
 
  H : THostEntry;
50
 
 
51
 
begin
52
 
  If ResolveHostByName(N,H) then
53
 
    DumpHostEntry(H)
54
 
  else
55
 
    Writeln('No entry for hostname ',N)
56
 
end;
57
 
 
58
 
Var
59
 
  I,l : INteger;
60
 
  Ans : Array [1..10] of THostAddr;
61
 
  H   : THostAddr;
62
 
  NAns : Array[1..10] of String;
63
 
 
64
 
 
65
 
 
66
 
begin
67
 
  Writeln('Resolving name ');
68
 
  l:=ResolveName('db.wisa.be',Ans);
69
 
  Writeln('Got : ',l,' answers');
70
 
  For I:=1 to l do
71
 
    Writeln(i:2,': ',hostAddrtostr(Ans[i]));
72
 
  Writeln('Resolving address ');
73
 
  H:=StrtoHostAddr('212.224.143.202');
74
 
  L:=ResolveAddress(H,NAns);
75
 
  Writeln('Got : ',l,' answers');
76
 
  For I:=1 to l do
77
 
    Writeln(i:2,': ',NAns[i]);
78
 
  Writeln('ResolveHostByName:');
79
 
  testname('malpertuus.wisa.be');
80
 
  Writeln('ResolveHostByAddr:');
81
 
  testaddr('212.224.143.202');
82
 
end.