readmsg.pp 1.9 KB

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