1
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_msdos.c,v 1.2 2005/12/21 12:23:13 joris Exp $ */
4
* Copyright (c) 1988-1997 Sam Leffler
5
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
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.
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.
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
28
* TIFF Library MSDOS-specific Routines.
30
#if defined(__WATCOMC__) || defined(__BORLANDC__) || defined(_MSC_VER)
31
#include <io.h> /* for open, close, etc. function prototypes */
37
_tiffReadProc(thandle_t fd, tdata_t buf, tsize_t size)
39
return (read((int) fd, buf, size));
43
_tiffWriteProc(thandle_t fd, tdata_t buf, tsize_t size)
45
return (write((int) fd, buf, size));
49
_tiffSeekProc(thandle_t fd, toff_t off, int whence)
51
return (lseek((int) fd, (off_t) off, whence));
55
_tiffCloseProc(thandle_t fd)
57
return (close((int) fd));
63
_tiffSizeProc(thandle_t fd)
66
return (fstat((int) fd, &sb) < 0 ? 0 : sb.st_size);
70
_tiffMapProc(thandle_t fd, tdata_t* pbase, toff_t* psize)
76
_tiffUnmapProc(thandle_t fd, tdata_t base, toff_t size)
81
* Open a TIFF file descriptor for read/writing.
84
TIFFFdOpen(int fd, const char* name, const char* mode)
88
tif = TIFFClientOpen(name, mode,
90
_tiffReadProc, _tiffWriteProc, _tiffSeekProc, _tiffCloseProc,
91
_tiffSizeProc, _tiffMapProc, _tiffUnmapProc);
98
* Open a TIFF file for read/writing.
101
TIFFOpen(const char* name, const char* mode)
103
static const char module[] = "TIFFOpen";
106
m = _TIFFgetMode(mode, module);
109
fd = open(name, m|O_BINARY, 0666);
111
TIFFErrorExt(0, module, "%s: Cannot open", name);
114
return (TIFFFdOpen(fd, name, mode));
118
extern char* malloc();
119
extern char* realloc();
125
_TIFFmalloc(tsize_t s)
127
return (malloc((size_t) s));
137
_TIFFrealloc(tdata_t p, tsize_t s)
139
return (realloc(p, (size_t) s));
143
_TIFFmemset(tdata_t p, int v, tsize_t c)
145
memset(p, v, (size_t) c);
149
_TIFFmemcpy(tdata_t d, const tdata_t s, tsize_t c)
151
memcpy(d, s, (size_t) c);
155
_TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c)
157
return (memcmp(p1, p2, (size_t) c));
161
msdosWarningHandler(const char* module, const char* fmt, va_list ap)
164
fprintf(stderr, "%s: ", module);
165
fprintf(stderr, "Warning, ");
166
vfprintf(stderr, fmt, ap);
167
fprintf(stderr, ".\n");
169
TIFFErrorHandler _TIFFwarningHandler = msdosWarningHandler;
172
msdosErrorHandler(const char* module, const char* fmt, va_list ap)
175
fprintf(stderr, "%s: ", module);
176
vfprintf(stderr, fmt, ap);
177
fprintf(stderr, ".\n");
179
TIFFErrorHandler _TIFFerrorHandler = msdosErrorHandler;