3
{ This file exists to provide a single place to fix any problems with
4
including the wrong system include files. (Common problems are taken
5
care of by the standard jconfig symbols, but on really weird systems
6
you may have to edit this file.)
8
NOTE: this file is NOT intended to be included by applications using the
9
JPEG library. Most applications need only include jpeglib.h. }
11
{ Original: jinclude.h Copyright (C) 1991-1994, Thomas G. Lane. }
17
{ Include auto-config file to find out which system include files we need. }
20
{$ifdef Delphi_Stream}
26
To write a dest/source manager that handle streams rather than files,
27
you can edit the FILEptr definition and the JFREAD() and JFWRITE()
28
functions in this unit, you don't need to change the default managers
29
JDATASRC and JDATADST. }
31
{$ifdef Delphi_Stream}
37
FILEptr = TCustomMemoryStream;
44
{ We need the NULL macro and size_t typedef.
45
On an ANSI-conforming system it is sufficient to include <stddef.h>.
46
Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
47
pull in <sys/types.h> as well.
48
Note that the core JPEG library does not require <stdio.h>;
49
only the default error handler and data source/destination modules do.
50
But we must pull it in because of the references to FILE in jpeglib.h.
51
You can remove those references if you want to compile without <stdio.h>.}
55
{ We need memory copying and zeroing functions, plus strncpy().
56
ANSI and System V implementations declare these in <string.h>.
57
BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
58
Some systems may declare memset and memcpy in <memory.h>.
60
NOTE: we assume the size parameters to these functions are of type size_t.
61
Change the casts in these macros if not! }
63
procedure MEMZERO(target : pointer; size : size_t);
65
procedure MEMCOPY(dest, src : pointer; size : size_t);
67
{function SIZEOF(object) : size_t;}
69
function JFREAD(fp : FILEptr; buf : pointer; sizeofbuf : size_t) : size_t;
71
function JFWRITE(fp : FILEptr; buf : pointer; sizeofbuf : size_t) : size_t;
75
procedure MEMZERO(target : pointer; size : size_t);
77
FillChar(target^, size, 0);
80
procedure MEMCOPY(dest, src : pointer; size : size_t);
82
Move(src^, dest^, size);
85
{ In ANSI C, and indeed any rational implementation, size_t is also the
86
type returned by sizeof(). However, it seems there are some irrational
87
implementations out there, in which sizeof() returns an int even though
88
size_t is defined as long or unsigned long. To ensure consistent results
89
we always use this SIZEOF() macro in place of using sizeof() directly. }
93
SIZEOF(object) (size_t(sizeof(object))}
96
{ The modules that use fread() and fwrite() always invoke them through
97
these macros. On some systems you may need to twiddle the argument casts.
98
CAUTION: argument order is different from underlying functions! }
101
function JFREAD(fp : FILEptr; buf : pointer; sizeofbuf : size_t) : size_t;
105
{$ifdef Delphi_Stream}
106
count := fp^.Read(buf^, sizeofbuf);
108
blockread(fp^, buf^, sizeofbuf, count);
110
JFREAD := size_t(count);
113
function JFWRITE(fp : FILEptr; buf : pointer; sizeofbuf : size_t) : size_t;
117
{$ifdef Delphi_Stream}
118
count := fp^.Write(buf^, sizeofbuf);
120
blockwrite(fp^, buf^, sizeofbuf, count);
122
JFWRITE := size_t(count);