2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
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)
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
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
23 /* $XConsortium: jinclude.h /main/2 1996/05/09 03:51:54 drk $ */
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.
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.)
36 * NOTE: this file is NOT intended to be included by applications using the
37 * JPEG library. Most applications need only include jpeglib.h.
41 /* Include auto-config file to find out which system include files we need. */
43 #include "jconfig.h" /* auto configuration options */
44 #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */
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>.
65 #ifdef NEED_SYS_TYPES_H
66 #include <sys/types.h>
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>.
77 * NOTE: we assume the size parameters to these functions are of type size_t.
78 * Change the casts in these macros if not!
81 #ifdef NEED_BSD_STRINGS
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))
87 #else /* not BSD, assume ANSI/SysV string lib */
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))
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.
103 #define SIZEOF(object) ((size_t) sizeof(object))
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!
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)))