jinclude.h

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

Generated on Tue Jan 6 22:41:37 2009 for Autodesk DWF 3D Toolkit by  doxygen 1.4.5