home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / xloadimg.zip / xloadimage.4.1 / tiff / tiffcompat.h < prev    next >
C/C++ Source or Header  |  1993-11-02  |  6KB  |  215 lines

  1. /* $Header: /usr/people/sam/tiff/libtiff/RCS/tiffcompat.h,v 1.21 92/03/30 18:31:03 sam Exp $ */
  2.  
  3. /*
  4.  * Copyright (c) 1990, 1991, 1992 Sam Leffler
  5.  * Copyright (c) 1991, 1992 Silicon Graphics, Inc.
  6.  *
  7.  * Permission to use, copy, modify, distribute, and sell this software and 
  8.  * its documentation for any purpose is hereby granted without fee, provided
  9.  * that (i) the above copyright notices and this permission notice appear in
  10.  * all copies of the software and related documentation, and (ii) the names of
  11.  * Sam Leffler and Silicon Graphics may not be used in any advertising or
  12.  * publicity relating to the software without the specific, prior written
  13.  * permission of Sam Leffler and Silicon Graphics.
  14.  * 
  15.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  16.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  17.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  18.  * 
  19.  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
  20.  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
  21.  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  22.  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
  23.  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
  24.  * OF THIS SOFTWARE.
  25.  */
  26.  
  27. #ifndef _COMPAT_
  28. #define    _COMPAT_
  29. /*
  30.  * This file contains a hodgepodge of definitions and
  31.  * declarations that are needed to provide compatibility
  32.  * between the native system and the base UNIX implementation
  33.  * that the library assumes (~4BSD).  In particular, you
  34.  * can override the standard i/o interface (read/write/lseek)
  35.  * by redefining the ReadOK/WriteOK/SeekOK macros to your
  36.  * liking.
  37.  *
  38.  * NB: This file is a mess.
  39.  */
  40. #if (defined(__STDC__) || defined(__EXTENDED__)) && !defined(USE_PROTOTYPES)
  41. #define    USE_PROTOTYPES    1
  42. #define    USE_CONST    1
  43. #endif
  44.  
  45. #if !USE_CONST && !defined(const)
  46. #define    const
  47. #endif
  48.  
  49. #ifdef THINK_C
  50. #include <unix.h>
  51. #include <math.h>
  52. #endif
  53. #if USE_PROTOTYPES
  54. #include <stdio.h>
  55. #endif
  56. #ifndef THINK_C
  57. #include <sys/types.h>
  58. #endif
  59. #ifdef VMS
  60. #include <file.h>
  61. #include <unixio.h>
  62. #else
  63. #include <fcntl.h>
  64. #endif
  65. #if defined(THINK_C) || defined(applec)
  66. #include <stdlib.h>
  67. #endif
  68.  
  69. /*
  70.  * Workarounds for BSD lseek definitions.
  71.  */
  72. #if defined(SYSV) || defined(VMS)
  73. #if defined(SYSV)
  74. #include <unistd.h>
  75. #endif
  76. #define    L_SET    SEEK_SET
  77. #define    L_INCR    SEEK_CUR
  78. #define    L_XTND    SEEK_END
  79. #endif
  80. #ifndef L_SET
  81. #define L_SET    0
  82. #define L_INCR    1
  83. #define L_XTND    2
  84. #endif
  85.  
  86. /*
  87.  * SVID workarounds for BSD bit
  88.  * string manipulation routines.
  89.  */
  90. #if defined(__STDC__) || defined(SYSV) || defined(THINK_C) || defined(applec) || defined(VMS)
  91. #define    bzero(dst,len)        memset((char *)dst, 0, len)
  92. #define    bcopy(src,dst,len)    memcpy((char *)dst, (char *)src, len)
  93. #define    bcmp(src, dst, len)    memcmp((char *)dst, (char *)src, len)
  94. #endif
  95.  
  96. /*
  97.  * These expand the BSD typedefs.  This is done rather than typedef'ing
  98.  * them so that we don't care whether or not <sys/types.h> defines them
  99.  * (something that's hard to tell without trying to compile).
  100.  */
  101. #define u_char  unsigned char
  102. #define u_short unsigned short
  103. #define u_int   unsigned int
  104. #define u_long  unsigned long
  105.  
  106. /*
  107.  * Return an open file descriptor or -1.
  108.  */
  109. #if defined(applec) || defined(THINK_C)
  110. #define    TIFFOpenFile(name, mode, prot)    open(name, mode)
  111. #else
  112. #if defined(MSDOS)
  113. #define    TIFFOpenFile(name, mode, prot)    open(name, mode|O_BINARY, prot)
  114. #else
  115. #define    TIFFOpenFile(name, mode, prot)    open(name, mode, prot)
  116. #endif
  117. #endif
  118.  
  119. /*
  120.  * Return the size in bytes of the file
  121.  * associated with the supplied file descriptor.
  122.  */
  123. #if USE_PROTOTYPES
  124. extern    long TIFFGetFileSize(int fd);
  125. #else
  126. extern    long TIFFGetFileSize();
  127. #endif
  128.  
  129. #ifdef MMAP_SUPPORT
  130. /*
  131.  * Mapped file support.
  132.  *
  133.  * TIFFMapFileContents must map the entire file into
  134.  *     memory and return the address of the mapped
  135.  *     region and the size of the mapped region.
  136.  * TIFFUnmapFileContents does the inverse operation.
  137.  */
  138. #if USE_PROTOTYPES
  139. extern    int TIFFMapFileContents(int fd, char **paddr, long *psize);
  140. extern    void TIFFUnmapFileContents(char *addr, long size);
  141. #else
  142. extern    int TIFFMapFileContents();
  143. extern    void TIFFUnmapFileContents();
  144. #endif
  145. #endif
  146.  
  147. /*
  148.  * Mac workaround to handle the file
  149.  * extension semantics of lseek.
  150.  */
  151. #ifdef applec
  152. #define    lseek    mpw_lseek
  153. extern long mpw_lseek(int, long, int);
  154. #else
  155. extern    long lseek();
  156. #endif
  157.  
  158. /*
  159.  * Default Read/Seek/Write definitions.
  160.  */
  161. #ifndef ReadOK
  162. #define    ReadOK(fd, buf, size)    (read(fd, (char *)buf, size) == size)
  163. #endif
  164. #ifndef SeekOK
  165. #define    SeekOK(fd, off)    (lseek(fd, (long)off, L_SET) == (long)off)
  166. #endif
  167. #ifndef WriteOK
  168. #define    WriteOK(fd, buf, size)    (write(fd, (char *)buf, size) == size)
  169. #endif
  170.  
  171. #if defined(__MACH__) || defined(THINK_C)
  172. extern    void *malloc(size_t size);
  173. extern    void *realloc(void *ptr, size_t size);
  174. #else /* !__MACH__ && !THINK_C */
  175. #if defined(MSDOS)
  176. #include <malloc.h>
  177. #else /* !MSDOS */
  178. #if defined(_IBMR2)
  179. #include <stdlib.h>
  180. #else /* !_IBMR2 */
  181. extern    char *malloc();
  182. extern    char *realloc();
  183. #endif /* _IBMR2 */
  184. #endif /* !MSDOS */
  185. #endif /* !__MACH__ */
  186.  
  187. /*
  188.  * dblparam_t is the type that a double precision
  189.  * floating point value will have on the parameter
  190.  * stack (when coerced by the compiler).
  191.  */
  192. #ifdef applec
  193. typedef extended dblparam_t;
  194. #else
  195. typedef double dblparam_t;
  196. #endif
  197.  
  198. /*
  199.  * Varargs parameter list handling...YECH!!!!
  200.  */
  201. #if defined(__STDC__) && !defined(USE_VARARGS)
  202. #define    USE_VARARGS    0
  203. #endif
  204.  
  205. #if defined(USE_VARARGS)
  206. #if USE_VARARGS
  207. #include <varargs.h>
  208. #define    VA_START(ap, parmN)    va_start(ap)
  209. #else
  210. #include <stdarg.h>
  211. #define    VA_START(ap, parmN)    va_start(ap, parmN)
  212. #endif
  213. #endif /* defined(USE_VARARGS) */
  214. #endif /* _COMPAT_ */
  215.