DEADSOFTWARE

fix link libraries on osx
[d2df-sdl.git] / src / lib / vampimg / JpegLib / imjinclude.pas
1 unit imjinclude;
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. }
13 interface
15 {$I imjconfig.inc}
17 { Include auto-config file to find out which system include files we need. }
19 uses
20 {$ifdef Delphi_Stream}
21 classes,
22 {$endif}
23 imjmorecfg;
25 { Nomssi:
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}
32 type
33 FILEptr = ^TStream;
34 {$else}
35 {$ifdef Delphi_Jpeg}
36 type
37 FILEptr = TCustomMemoryStream;
38 {$else}
39 type
40 FILEptr = ^File;
41 {$endif}
42 {$endif}
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;
73 implementation
75 procedure MEMZERO(target : pointer; size : size_t);
76 begin
77 FillChar(target^, size, 0);
78 end;
80 procedure MEMCOPY(dest, src : pointer; size : size_t);
81 begin
82 Move(src^, dest^, size);
83 end;
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. }
92 {#define
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;
102 var
103 count : uint;
104 begin
105 {$ifdef Delphi_Stream}
106 count := fp^.Read(buf^, sizeofbuf);
107 {$else}
108 blockread(fp^, buf^, sizeofbuf, count);
109 {$endif}
110 JFREAD := size_t(count);
111 end;
113 function JFWRITE(fp : FILEptr; buf : pointer; sizeofbuf : size_t) : size_t;
114 var
115 count : uint;
116 begin
117 {$ifdef Delphi_Stream}
118 count := fp^.Write(buf^, sizeofbuf);
119 {$else}
120 blockwrite(fp^, buf^, sizeofbuf, count);
121 {$endif}
122 JFWRITE := size_t(count);
123 end;
126 end.