readmsg.pp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. {
  2. $Id$
  3. This file is part of the Free Pascal run time library.
  4. Copyright (c) 1999-2000 by the Free Pascal development team
  5. reads and dumps a message file to screen.
  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. {$mode objfpc}
  13. {$h+}
  14. program readmsg;
  15. Type
  16. PCardinal = ^Cardinal;
  17. Var
  18. F : File of Cardinal;
  19. PO,PI : PCardinal;
  20. I,J,Count,C,S : Cardinal;
  21. Buf : String;
  22. begin
  23. Assign(F,Paramstr(1));
  24. Reset(F);
  25. Read(F,Count);
  26. Writeln('Message count: ',Count);
  27. S:=SizeOf(Cardinal)*Count+1;
  28. GetMem(PO,S);
  29. GetMem(PI,S);
  30. FillChar(PI^,S,0);
  31. FillChar(PO^,S,0);
  32. For I:=1 to Count do
  33. begin
  34. Read(F,C);
  35. PI[I]:=C;
  36. Read(F,C);
  37. If (C<>PI[I]) then
  38. Writeln('Error in ID: ',C,'<>ID',PI[I])
  39. else
  40. Writeln('Found ID ',C);
  41. Read(F,C);
  42. PO[I]:=C;
  43. Writeln('Found offset : ',C);
  44. end;
  45. For I:=1 to Count do
  46. begin
  47. Seek(F,PO[I] div 4);
  48. Read(F,S);
  49. Writeln('Found offset ',S,' at item ',i,' offset ',PO[I]);
  50. For J:=1 to (S div 4)-1 do
  51. begin
  52. Read(F,C);
  53. Move(C,Buf[J*4-3],4);
  54. end;
  55. J:=S-4;
  56. While Buf[J]=#0 do
  57. dec(J);
  58. SetLength(Buf,J);
  59. Writeln('String (',J,') : ',Buf);
  60. end;
  61. Writeln('Seqential read : ');
  62. Seek(F,PO[1] div 4);
  63. For I:=1 to Count do
  64. begin
  65. Read(F,S);
  66. Writeln('Found offset ',S,' at item ',i,' offset ',FilePos(F));
  67. For J:=1 to (S div 4)-1 do
  68. begin
  69. Read(F,C);
  70. Move(C,Buf[J*4-3],4);
  71. end;
  72. J:=S-4;
  73. While Buf[J]=#0 do
  74. dec(J);
  75. SetLength(Buf,J);
  76. Writeln('String (',J,') : ',Buf);
  77. end;
  78. Close(F);
  79. end.
  80. {
  81. $Log$
  82. Revision 1.1 2003-02-14 21:59:21 michael
  83. + Initial implementation
  84. }