00001 00005 /* ***************************************************************** 00006 * 00007 * Copyright (C) 1991-1994, Thomas G. Lane. 00008 * This file is part of the Independent JPEG Group's software. 00009 * For conditions of distribution and use, see the accompanying README file. 00010 * 00011 * This file exists to provide a single place to fix any problems with 00012 * including the wrong system include files. (Common problems are taken 00013 * care of by the standard jconfig symbols, but on really weird systems 00014 * you may have to edit this file.) 00015 * 00016 * NOTE: this file is NOT intended to be included by applications using the 00017 * JPEG library. Most applications need only include jpeglib.h. 00018 */ 00019 00020 00021 /* Include auto-config file to find out which system include files we need. */ 00022 00023 #include "jconfig.h" /* auto configuration options */ 00024 #define JCONFIG_INCLUDED /* so that jpeglib.h doesn't do it again */ 00025 00026 /* 00027 * We need the NULL macro and size_t typedef. 00028 * On an ANSI-conforming system it is sufficient to include <stddef.h>. 00029 * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to 00030 * pull in <sys/types.h> as well. 00031 * Note that the core JPEG library does not require <stdio.h>; 00032 * only the default error handler and data source/destination modules do. 00033 * But we must pull it in because of the references to FILE in jpeglib.h. 00034 * You can remove those references if you want to compile without <stdio.h>. 00035 */ 00036 00037 #ifdef HAVE_STDDEF_H 00038 #include <stddef.h> 00039 #endif 00040 00041 #ifdef HAVE_STDLIB_H 00042 #include <stdlib.h> 00043 #endif 00044 00045 #ifdef NEED_SYS_TYPES_H 00046 #include <sys/types.h> 00047 #endif 00048 00049 #include <stdio.h> 00050 00051 /* 00052 * We need memory copying and zeroing functions, plus strncpy(). 00053 * ANSI and System V implementations declare these in <string.h>. 00054 * BSD doesn't have the mem() functions, but it does have bcopy()/bzero(). 00055 * Some systems may declare memset and memcpy in <memory.h>. 00056 * 00057 * NOTE: we assume the size parameters to these functions are of type size_t. 00058 * Change the casts in these macros if not! 00059 */ 00060 00061 #ifdef NEED_BSD_STRINGS 00062 00063 #include <strings.h> 00064 #define MEMZERO(target,size) bzero((void *)(target), (size_t)(size)) 00065 #define MEMCOPY(dest,src,size) bcopy((const void *)(src), (void *)(dest), (size_t)(size)) 00066 00067 #else /* not BSD, assume ANSI/SysV string lib */ 00068 00069 #include <string.h> 00070 #define MEMZERO(target,size) memset((void *)(target), 0, (size_t)(size)) 00071 #define MEMCOPY(dest,src,size) memcpy((void *)(dest), (const void *)(src), (size_t)(size)) 00072 00073 #endif 00074 00075 /* 00076 * In ANSI C, and indeed any rational implementation, size_t is also the 00077 * type returned by sizeof(). However, it seems there are some irrational 00078 * implementations out there, in which sizeof() returns an int even though 00079 * size_t is defined as long or unsigned long. To ensure consistent results 00080 * we always use this SIZEOF() macro in place of using sizeof() directly. 00081 */ 00082 00083 #define SIZEOF(object) ((size_t) sizeof(object)) 00084 00085 /* 00086 * The modules that use fread() and fwrite() always invoke them through 00087 * these macros. On some systems you may need to twiddle the argument casts. 00088 * CAUTION: argument order is different from underlying functions! 00089 */ 00090 00091 #define JFREAD(file,buf,sizeofbuf) \ 00092 ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file))) 00093 #define JFWRITE(file,buf,sizeofbuf) \ 00094 ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
1.2.8.1 written by Dimitri van Heesch,
© 1997-2001