File indexing completed on 2024-05-12 04:19:44
0001 /* 0002 * jinclude.h 0003 * 0004 * Copyright (C) 1991-1994, Thomas G. Lane. 0005 * This file is part of the Independent JPEG Group's software. 0006 * For conditions of distribution and use, see the accompanying README file. 0007 * 0008 * This file exists to provide a single place to fix any problems with 0009 * including the wrong system include files. (Common problems are taken 0010 * care of by the standard jconfig symbols, but on really weird systems 0011 * you may have to edit this file.) 0012 * 0013 * NOTE: this file is NOT intended to be included by applications using the 0014 * JPEG library. Most applications need only include jpeglib.h. 0015 */ 0016 0017 /* Include auto-config file to find out which system include files we need. */ 0018 0019 #include "jconfig.h" /* auto configuration options */ 0020 #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ 0021 0022 /* 0023 * We need the NULL macro and size_t typedef. 0024 * On an ANSI-conforming system it is sufficient to include <stddef.h>. 0025 * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to 0026 * pull in <sys/types.h> as well. 0027 * Note that the core JPEG library does not require <stdio.h>; 0028 * only the default error handler and data source/destination modules do. 0029 * But we must pull it in because of the references to FILE in jpeglib.h. 0030 * You can remove those references if you want to compile without <stdio.h>. 0031 */ 0032 0033 #ifdef HAVE_STDDEF_H 0034 #include <stddef.h> 0035 #endif 0036 0037 #ifdef HAVE_STDLIB_H 0038 #include <stdlib.h> 0039 #endif 0040 0041 #ifdef NEED_SYS_TYPES_H 0042 #include <sys/types.h> 0043 #endif 0044 0045 #include <stdio.h> 0046 0047 /* 0048 * We need memory copying and zeroing functions, plus strncpy(). 0049 * ANSI and System V implementations declare these in <string.h>. 0050 * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). 0051 * Some systems may declare memset and memcpy in <memory.h>. 0052 * 0053 * NOTE: we assume the size parameters to these functions are of type size_t. 0054 * Change the casts in these macros if not! 0055 */ 0056 0057 #ifdef NEED_BSD_STRINGS 0058 0059 #include <strings.h> 0060 #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) 0061 #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) 0062 0063 #else /* not BSD, assume ANSI/SysV string lib */ 0064 0065 #include <string.h> 0066 #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) 0067 #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) 0068 0069 #endif 0070 0071 /* 0072 * In ANSI C, and indeed any rational implementation, size_t is also the 0073 * type returned by sizeof(). However, it seems there are some irrational 0074 * implementations out there, in which sizeof() returns an int even though 0075 * size_t is defined as long or unsigned long. To ensure consistent results 0076 * we always use this SIZEOF() macro in place of using sizeof() directly. 0077 */ 0078 0079 #define SIZEOF(object) ((size_t) sizeof(object)) 0080 0081 /* 0082 * The modules that use fread() and fwrite() always invoke them through 0083 * these macros. On some systems you may need to twiddle the argument casts. 0084 * CAUTION: argument order is different from underlying functions! 0085 */ 0086 0087 #define JFREAD(file,buf,sizeofbuf) \ 0088 ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 0089 #define JFWRITE(file,buf,sizeofbuf) \ 0090 ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))