kusano 7d535a
/*
kusano 7d535a
 * jinclude.h
kusano 7d535a
 *
kusano 7d535a
 * Copyright (C) 1991-1994, Thomas G. Lane.
kusano 7d535a
 * This file is part of the Independent JPEG Group's software.
kusano 7d535a
 * For conditions of distribution and use, see the accompanying README file.
kusano 7d535a
 *
kusano 7d535a
 * This file exists to provide a single place to fix any problems with
kusano 7d535a
 * including the wrong system include files.  (Common problems are taken
kusano 7d535a
 * care of by the standard jconfig symbols, but on really weird systems
kusano 7d535a
 * you may have to edit this file.)
kusano 7d535a
 *
kusano 7d535a
 * NOTE: this file is NOT intended to be included by applications using the
kusano 7d535a
 * JPEG library.  Most applications need only include jpeglib.h.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
kusano 7d535a
/* Include auto-config file to find out which system include files we need. */
kusano 7d535a
kusano 7d535a
#include "jconfig.h"		/* auto configuration options */
kusano 7d535a
#define JCONFIG_INCLUDED	/* so that jpeglib.h doesn't do it again */
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * We need the NULL macro and size_t typedef.
kusano 7d535a
 * On an ANSI-conforming system it is sufficient to include <stddef.h>.</stddef.h>
kusano 7d535a
 * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to</stdio.h></stdlib.h>
kusano 7d535a
 * pull in <sys types.h=""> as well.</sys>
kusano 7d535a
 * Note that the core JPEG library does not require <stdio.h>;</stdio.h>
kusano 7d535a
 * only the default error handler and data source/destination modules do.
kusano 7d535a
 * But we must pull it in because of the references to FILE in jpeglib.h.
kusano 7d535a
 * You can remove those references if you want to compile without <stdio.h>.</stdio.h>
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifdef HAVE_STDDEF_H
kusano 7d535a
#include <stddef.h></stddef.h>
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#ifdef HAVE_STDLIB_H
kusano 7d535a
#include <stdlib.h></stdlib.h>
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#ifdef NEED_SYS_TYPES_H
kusano 7d535a
#include <sys types.h=""></sys>
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
#include <stdio.h></stdio.h>
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * We need memory copying and zeroing functions, plus strncpy().
kusano 7d535a
 * ANSI and System V implementations declare these in <string.h>.</string.h>
kusano 7d535a
 * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
kusano 7d535a
 * Some systems may declare memset and memcpy in <memory.h>.</memory.h>
kusano 7d535a
 *
kusano 7d535a
 * NOTE: we assume the size parameters to these functions are of type size_t.
kusano 7d535a
 * Change the casts in these macros if not!
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#ifdef NEED_BSD_STRINGS
kusano 7d535a
kusano 7d535a
#include <strings.h></strings.h>
kusano 7d535a
#define MEMZERO(target,size)	bzero((void *)(target), (size_t)(size))
kusano 7d535a
#define MEMCOPY(dest,src,size)	bcopy((const void *)(src), (void *)(dest), (size_t)(size))
kusano 7d535a
kusano 7d535a
#else /* not BSD, assume ANSI/SysV string lib */
kusano 7d535a
kusano 7d535a
#include <string.h></string.h>
kusano 7d535a
#define MEMZERO(target,size)	memset((void *)(target), 0, (size_t)(size))
kusano 7d535a
#define MEMCOPY(dest,src,size)	memcpy((void *)(dest), (const void *)(src), (size_t)(size))
kusano 7d535a
kusano 7d535a
#endif
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * In ANSI C, and indeed any rational implementation, size_t is also the
kusano 7d535a
 * type returned by sizeof().  However, it seems there are some irrational
kusano 7d535a
 * implementations out there, in which sizeof() returns an int even though
kusano 7d535a
 * size_t is defined as long or unsigned long.  To ensure consistent results
kusano 7d535a
 * we always use this SIZEOF() macro in place of using sizeof() directly.
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#define SIZEOF(object)	((size_t) sizeof(object))
kusano 7d535a
kusano 7d535a
/*
kusano 7d535a
 * The modules that use fread() and fwrite() always invoke them through
kusano 7d535a
 * these macros.  On some systems you may need to twiddle the argument casts.
kusano 7d535a
 * CAUTION: argument order is different from underlying functions!
kusano 7d535a
 */
kusano 7d535a
kusano 7d535a
#define JFREAD(file,buf,sizeofbuf)  \
kusano 7d535a
  ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
kusano 7d535a
#define JFWRITE(file,buf,sizeofbuf)  \
kusano 7d535a
  ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))