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.

126 lines
3.6 KiB

3 years ago
  1. unit imjinclude;
  2. { This file exists to provide a single place to fix any problems with
  3. including the wrong system include files. (Common problems are taken
  4. care of by the standard jconfig symbols, but on really weird systems
  5. you may have to edit this file.)
  6. NOTE: this file is NOT intended to be included by applications using the
  7. JPEG library. Most applications need only include jpeglib.h. }
  8. { Original: jinclude.h Copyright (C) 1991-1994, Thomas G. Lane. }
  9. interface
  10. {$I imjconfig.inc}
  11. { Include auto-config file to find out which system include files we need. }
  12. uses
  13. {$ifdef Delphi_Stream}
  14. classes,
  15. {$endif}
  16. imjmorecfg;
  17. { Nomssi:
  18. To write a dest/source manager that handle streams rather than files,
  19. you can edit the FILEptr definition and the JFREAD() and JFWRITE()
  20. functions in this unit, you don't need to change the default managers
  21. JDATASRC and JDATADST. }
  22. {$ifdef Delphi_Stream}
  23. type
  24. FILEptr = ^TStream;
  25. {$else}
  26. {$ifdef Delphi_Jpeg}
  27. type
  28. FILEptr = TCustomMemoryStream;
  29. {$else}
  30. type
  31. FILEptr = ^File;
  32. {$endif}
  33. {$endif}
  34. { We need the NULL macro and size_t typedef.
  35. On an ANSI-conforming system it is sufficient to include <stddef.h>.
  36. Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
  37. pull in <sys/types.h> as well.
  38. Note that the core JPEG library does not require <stdio.h>;
  39. only the default error handler and data source/destination modules do.
  40. But we must pull it in because of the references to FILE in jpeglib.h.
  41. You can remove those references if you want to compile without <stdio.h>.}
  42. { We need memory copying and zeroing functions, plus strncpy().
  43. ANSI and System V implementations declare these in <string.h>.
  44. BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
  45. Some systems may declare memset and memcpy in <memory.h>.
  46. NOTE: we assume the size parameters to these functions are of type size_t.
  47. Change the casts in these macros if not! }
  48. procedure MEMZERO(target : pointer; size : size_t);
  49. procedure MEMCOPY(dest, src : pointer; size : size_t);
  50. {function SIZEOF(object) : size_t;}
  51. function JFREAD(fp : FILEptr; buf : pointer; sizeofbuf : size_t) : size_t;
  52. function JFWRITE(fp : FILEptr; buf : pointer; sizeofbuf : size_t) : size_t;
  53. implementation
  54. procedure MEMZERO(target : pointer; size : size_t);
  55. begin
  56. FillChar(target^, size, 0);
  57. end;
  58. procedure MEMCOPY(dest, src : pointer; size : size_t);
  59. begin
  60. Move(src^, dest^, size);
  61. end;
  62. { In ANSI C, and indeed any rational implementation, size_t is also the
  63. type returned by sizeof(). However, it seems there are some irrational
  64. implementations out there, in which sizeof() returns an int even though
  65. size_t is defined as long or unsigned long. To ensure consistent results
  66. we always use this SIZEOF() macro in place of using sizeof() directly. }
  67. {#define
  68. SIZEOF(object) (size_t(sizeof(object))}
  69. { The modules that use fread() and fwrite() always invoke them through
  70. these macros. On some systems you may need to twiddle the argument casts.
  71. CAUTION: argument order is different from underlying functions! }
  72. function JFREAD(fp : FILEptr; buf : pointer; sizeofbuf : size_t) : size_t;
  73. var
  74. count : uint;
  75. begin
  76. {$ifdef Delphi_Stream}
  77. count := fp^.Read(buf^, sizeofbuf);
  78. {$else}
  79. blockread(fp^, buf^, sizeofbuf, count);
  80. {$endif}
  81. JFREAD := size_t(count);
  82. end;
  83. function JFWRITE(fp : FILEptr; buf : pointer; sizeofbuf : size_t) : size_t;
  84. var
  85. count : uint;
  86. begin
  87. {$ifdef Delphi_Stream}
  88. count := fp^.Write(buf^, sizeofbuf);
  89. {$else}
  90. blockwrite(fp^, buf^, sizeofbuf, count);
  91. {$endif}
  92. JFWRITE := size_t(count);
  93. end;
  94. end.