554f0ecb262ddeb168ee54956b7e088d42075326
[oweals/cde.git] / cde / lib / DtHelp / jpeg / jinclude.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /* $XConsortium: jinclude.h /main/2 1996/05/09 03:51:54 drk $ */
24 /*
25  * jinclude.h
26  *
27  * Copyright (C) 1991-1994, Thomas G. Lane.
28  * This file is part of the Independent JPEG Group's software.
29  * For conditions of distribution and use, see the accompanying README file.
30  *
31  * This file exists to provide a single place to fix any problems with
32  * including the wrong system include files.  (Common problems are taken
33  * care of by the standard jconfig symbols, but on really weird systems
34  * you may have to edit this file.)
35  *
36  * NOTE: this file is NOT intended to be included by applications using the
37  * JPEG library.  Most applications need only include jpeglib.h.
38  */
39
40
41 /* Include auto-config file to find out which system include files we need. */
42
43 #include "jconfig.h"            /* auto configuration options */
44 #define JCONFIG_INCLUDED        /* so that jpeglib.h doesn't do it again */
45
46 /*
47  * We need the NULL macro and size_t typedef.
48  * On an ANSI-conforming system it is sufficient to include <stddef.h>.
49  * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
50  * pull in <sys/types.h> as well.
51  * Note that the core JPEG library does not require <stdio.h>;
52  * only the default error handler and data source/destination modules do.
53  * But we must pull it in because of the references to FILE in jpeglib.h.
54  * You can remove those references if you want to compile without <stdio.h>.
55  */
56
57 #ifdef HAVE_STDDEF_H
58 #include <stddef.h>
59 #endif
60
61 #ifdef HAVE_STDLIB_H
62 #include <stdlib.h>
63 #endif
64
65 #ifdef NEED_SYS_TYPES_H
66 #include <sys/types.h>
67 #endif
68
69 #include <stdio.h>
70
71 /*
72  * We need memory copying and zeroing functions, plus strncpy().
73  * ANSI and System V implementations declare these in <string.h>.
74  * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
75  * Some systems may declare memset and memcpy in <memory.h>.
76  *
77  * NOTE: we assume the size parameters to these functions are of type size_t.
78  * Change the casts in these macros if not!
79  */
80
81 #ifdef NEED_BSD_STRINGS
82
83 #include <strings.h>
84 #define MEMZERO(target,size)    bzero((void *)(target), (size_t)(size))
85 #define MEMCOPY(dest,src,size)  bcopy((const void *)(src), (void *)(dest), (size_t)(size))
86
87 #else /* not BSD, assume ANSI/SysV string lib */
88
89 #include <string.h>
90 #define MEMZERO(target,size)    memset((void *)(target), 0, (size_t)(size))
91 #define MEMCOPY(dest,src,size)  memcpy((void *)(dest), (const void *)(src), (size_t)(size))
92
93 #endif
94
95 /*
96  * In ANSI C, and indeed any rational implementation, size_t is also the
97  * type returned by sizeof().  However, it seems there are some irrational
98  * implementations out there, in which sizeof() returns an int even though
99  * size_t is defined as long or unsigned long.  To ensure consistent results
100  * we always use this SIZEOF() macro in place of using sizeof() directly.
101  */
102
103 #define SIZEOF(object)  ((size_t) sizeof(object))
104
105 /*
106  * The modules that use fread() and fwrite() always invoke them through
107  * these macros.  On some systems you may need to twiddle the argument casts.
108  * CAUTION: argument order is different from underlying functions!
109  */
110
111 #define JFREAD(file,buf,sizeofbuf)  \
112   ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
113 #define JFWRITE(file,buf,sizeofbuf)  \
114   ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))