home *** CD-ROM | disk | FTP | other *** search
/ Tools / WinSN5.0Ver.iso / NETSCAP.50 / WIN1998.ZIP / ns / jpeg / jinclude.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-08  |  3.6 KB  |  109 lines

  1. /*
  2.  * jinclude.h
  3.  *
  4.  * Copyright (C) 1991-1994, Thomas G. Lane.
  5.  * This file is part of the Independent JPEG Group's software.
  6.  * For conditions of distribution and use, see the accompanying README file.
  7.  *
  8.  * This file exists to provide a single place to fix any problems with
  9.  * including the wrong system include files.  (Common problems are taken
  10.  * care of by the standard jconfig symbols, but on really weird systems
  11.  * you may have to edit this file.)
  12.  *
  13.  * NOTE: this file is NOT intended to be included by applications using the
  14.  * JPEG library.  Most applications need only include jpeglib.h.
  15.  */
  16.  
  17.  
  18. /* Include auto-config file to find out which system include files we need. */
  19.  
  20. #ifdef __MWERKS__
  21. # include "jconfig-mac-cw.h"
  22. #elif defined(_WINDOWS)
  23. # include "jwinfig.h"
  24. #elif defined(XP_OS2)
  25. # include "jos2fig.h"
  26. #else
  27. # include "jconfig.h"         /* auto configuration options */
  28. #endif
  29. #define JCONFIG_INCLUDED    /* so that jpeglib.h doesn't do it again */
  30.  
  31. /*
  32.  * We need the NULL macro and size_t typedef.
  33.  * On an ANSI-conforming system it is sufficient to include <stddef.h>.
  34.  * Otherwise, we get them from <stdlib.h> or <stdio.h>; we may have to
  35.  * pull in <sys/types.h> as well.
  36.  * Note that the core JPEG library does not require <stdio.h>;
  37.  * only the default error handler and data source/destination modules do.
  38.  * But we must pull it in because of the references to FILE in jpeglib.h.
  39.  * You can remove those references if you want to compile without <stdio.h>.
  40.  */
  41.  
  42. #ifdef HAVE_STDDEF_H
  43. #include <stddef.h>
  44. #endif
  45.  
  46. #ifdef HAVE_STDLIB_H
  47. #include <stdlib.h>
  48. #endif
  49.  
  50. #ifdef NEED_SYS_TYPES_H
  51. #include <sys/types.h>
  52. #endif
  53.  
  54. #include <stdio.h>
  55.  
  56. /*
  57.  * SunOS 4.x doesn't do a very good job providing prototypes.
  58.  */
  59. #ifdef SUNOS4
  60. int fread(void *, size_t, size_t, FILE *);
  61. void *memset(void *, int, size_t);
  62. int sscanf(const char *, const char *, ...);
  63. #endif
  64.  
  65. /*
  66.  * We need memory copying and zeroing functions, plus strncpy().
  67.  * ANSI and System V implementations declare these in <string.h>.
  68.  * BSD doesn't have the mem() functions, but it does have bcopy()/bzero().
  69.  * Some systems may declare memset and memcpy in <memory.h>.
  70.  *
  71.  * NOTE: we assume the size parameters to these functions are of type size_t.
  72.  * Change the casts in these macros if not!
  73.  */
  74.  
  75. #ifdef NEED_BSD_STRINGS
  76.  
  77. #include <strings.h>
  78. #define MEMZERO(target,size)    bzero((void *)(target), (size_t)(size))
  79. #define MEMCOPY(dest,src,size)    bcopy((const void *)(src), (void *)(dest), (size_t)(size))
  80.  
  81. #else /* not BSD, assume ANSI/SysV string lib */
  82.  
  83. #include <string.h>
  84. #define MEMZERO(target,size)    memset((void *)(target), 0, (size_t)(size))
  85. #define MEMCOPY(dest,src,size)    memcpy((void *)(dest), (const void *)(src), (size_t)(size))
  86.  
  87. #endif
  88.  
  89. /*
  90.  * In ANSI C, and indeed any rational implementation, size_t is also the
  91.  * type returned by sizeof().  However, it seems there are some irrational
  92.  * implementations out there, in which sizeof() returns an int even though
  93.  * size_t is defined as long or unsigned long.  To ensure consistent results
  94.  * we always use this SIZEOF() macro in place of using sizeof() directly.
  95.  */
  96.  
  97. #define SIZEOF(object)    ((size_t) sizeof(object))
  98.  
  99. /*
  100.  * The modules that use fread() and fwrite() always invoke them through
  101.  * these macros.  On some systems you may need to twiddle the argument casts.
  102.  * CAUTION: argument order is different from underlying functions!
  103.  */
  104.  
  105. #define JFREAD(file,buf,sizeofbuf)  \
  106.   ((size_t) fread((void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
  107. #define JFWRITE(file,buf,sizeofbuf)  \
  108.   ((size_t) fwrite((const void *) (buf), (size_t) 1, (size_t) (sizeofbuf), (file)))
  109.