Repo for the search and displace ingest module that takes odf, docx and pdf and transforms it into .md to be used with search and displace operations
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

191 lines
3.8 KiB

3 years ago
  1. Unit imzutil;
  2. {
  3. Copyright (C) 1998 by Jacques Nomssi Nzali
  4. For conditions of distribution and use, see copyright notice in readme.txt
  5. }
  6. interface
  7. {$I imzconf.inc}
  8. { Type declarations }
  9. type
  10. {Byte = usigned char; 8 bits}
  11. Bytef = byte;
  12. charf = byte;
  13. int = longint;
  14. intf = int;
  15. uInt = cardinal; { 16 bits or more }
  16. uIntf = uInt;
  17. Long = longint;
  18. uLong = Cardinal;
  19. uLongf = uLong;
  20. voidp = pointer;
  21. voidpf = voidp;
  22. pBytef = ^Bytef;
  23. pIntf = ^intf;
  24. puIntf = ^uIntf;
  25. puLong = ^uLongf;
  26. ptr2int = uInt;
  27. { a pointer to integer casting is used to do pointer arithmetic.
  28. ptr2int must be an integer type and sizeof(ptr2int) must be less
  29. than sizeof(pointer) - Nomssi }
  30. type
  31. zByteArray = array[0..(MaxInt div SizeOf(Bytef))-1] of Bytef;
  32. pzByteArray = ^zByteArray;
  33. type
  34. zIntfArray = array[0..(MaxInt div SizeOf(Intf))-1] of Intf;
  35. pzIntfArray = ^zIntfArray;
  36. type
  37. zuIntArray = array[0..(MaxInt div SizeOf(uInt))-1] of uInt;
  38. PuIntArray = ^zuIntArray;
  39. { Type declarations - only for deflate }
  40. type
  41. uch = Byte;
  42. uchf = uch; { FAR }
  43. ush = Word;
  44. ushf = ush;
  45. ulg = LongInt;
  46. unsigned = uInt;
  47. pcharf = ^charf;
  48. puchf = ^uchf;
  49. pushf = ^ushf;
  50. type
  51. zuchfArray = zByteArray;
  52. puchfArray = ^zuchfArray;
  53. type
  54. zushfArray = array[0..(MaxInt div SizeOf(ushf))-1] of ushf;
  55. pushfArray = ^zushfArray;
  56. procedure zmemcpy(destp : pBytef; sourcep : pBytef; len : uInt);
  57. function zmemcmp(s1p, s2p : pBytef; len : uInt) : int;
  58. procedure zmemzero(destp : pBytef; len : uInt);
  59. procedure zcfree(opaque : voidpf; ptr : voidpf);
  60. function zcalloc (opaque : voidpf; items : uInt; size : uInt) : voidpf;
  61. implementation
  62. procedure zmemcpy(destp : pBytef; sourcep : pBytef; len : uInt);
  63. begin
  64. Move(sourcep^, destp^, len);
  65. end;
  66. function zmemcmp(s1p, s2p : pBytef; len : uInt) : int;
  67. var
  68. j : uInt;
  69. source,
  70. dest : pBytef;
  71. begin
  72. source := s1p;
  73. dest := s2p;
  74. for j := 0 to pred(len) do
  75. begin
  76. if (source^ <> dest^) then
  77. begin
  78. zmemcmp := 2*Ord(source^ > dest^)-1;
  79. exit;
  80. end;
  81. Inc(source);
  82. Inc(dest);
  83. end;
  84. zmemcmp := 0;
  85. end;
  86. procedure zmemzero(destp : pBytef; len : uInt);
  87. begin
  88. FillChar(destp^, len, 0);
  89. end;
  90. procedure zcfree(opaque : voidpf; ptr : voidpf);
  91. {$ifdef Delphi16}
  92. var
  93. Handle : THandle;
  94. {$endif}
  95. {$IFDEF FPC}
  96. var
  97. memsize : uint;
  98. {$ENDIF}
  99. begin
  100. (*
  101. {$IFDEF DPMI}
  102. {h :=} GlobalFreePtr(ptr);
  103. {$ELSE}
  104. {$IFDEF CALL_DOS}
  105. dosFree(ptr);
  106. {$ELSE}
  107. {$ifdef HugeMem}
  108. FreeMemHuge(ptr);
  109. {$else}
  110. {$ifdef Delphi16}
  111. Handle := GlobalHandle(LH(ptr).H); { HiWord(LongInt(ptr)) }
  112. GlobalUnLock(Handle);
  113. GlobalFree(Handle);
  114. {$else}
  115. {$IFDEF FPC}
  116. Dec(puIntf(ptr));
  117. memsize := puIntf(ptr)^;
  118. FreeMem(ptr, memsize+SizeOf(uInt));
  119. {$ELSE}
  120. FreeMem(ptr); { Delphi 2,3,4 }
  121. {$ENDIF}
  122. {$endif}
  123. {$endif}
  124. {$ENDIF}
  125. {$ENDIF}
  126. *)
  127. FreeMem(ptr);
  128. end;
  129. function zcalloc (opaque : voidpf; items : uInt; size : uInt) : voidpf;
  130. var
  131. p : voidpf;
  132. memsize : uLong;
  133. {$ifdef Delphi16}
  134. handle : THandle;
  135. {$endif}
  136. begin
  137. memsize := uLong(items) * size;
  138. (*
  139. { $IFDEF DPMI}
  140. p := GlobalAllocPtr(gmem_moveable, memsize);
  141. { $ELSE}
  142. { $IFDEF CALLDOS}
  143. p := dosAlloc(memsize);
  144. { $ELSE}
  145. {$ifdef HugeMem}
  146. GetMemHuge(p, memsize);
  147. { $else}
  148. { $ifdef Delphi16}
  149. Handle := GlobalAlloc(HeapAllocFlags, memsize);
  150. p := GlobalLock(Handle);
  151. { $else}
  152. { $IFDEF FPC}
  153. GetMem(p, memsize+SizeOf(uInt));
  154. puIntf(p)^:= memsize;
  155. Inc(puIntf(p));
  156. { $ELSE}
  157. GetMem(p, memsize); { Delphi: p := AllocMem(memsize); }
  158. { $ENDIF}
  159. { $endif}
  160. { $endif}
  161. { $ENDIF}
  162. { $ENDIF}
  163. *)
  164. GetMem(p, memsize);
  165. zcalloc := p;
  166. end;
  167. end.