2
0

testproto.pp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. {
  2. This file is part of the Free Pascal run time library.
  3. Copyright (c) 2005 by Marco van de Voort
  4. test netdb unit, /etc/protocols part
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$mode objfpc}
  12. {$h+}
  13. program testproto;
  14. uses netdb,Sockets;
  15. Procedure DumpProtoEntry(Const H : TProtocolEntry);
  16. begin
  17. With H do
  18. begin
  19. Writeln('Name : ',Name);
  20. Writeln('Number : ',Number);
  21. Writeln('Aliases : ',Aliases);
  22. Writeln;
  23. end;
  24. end;
  25. Procedure Testnumber(number : integer);
  26. Var
  27. H : TProtocolEntry;
  28. begin
  29. If GetProtocolByNumber(number,H) then
  30. DumpProtoEntry(H)
  31. else
  32. Writeln('No entry for number ',Number)
  33. end;
  34. Procedure TestName(Const N : string);
  35. Var
  36. H : TProtocolEntry;
  37. begin
  38. If GetProtocolByName(N,H) then
  39. DumpProtoEntry(H)
  40. else
  41. Writeln('No entry for protocol name ',N)
  42. end;
  43. var i : integer;
  44. begin
  45. testname('ip');
  46. testname('IP');
  47. testname('udp');
  48. testname('UDP');
  49. testname('xx'); // should fail
  50. for i:=0 to 10 do
  51. testnumber(i);
  52. testnumber(99); // should fail
  53. end.