37 if (!ReadFile(fd, buf, size, &dwSizeRead,
NULL))
46 if (!WriteFile(fd, buf, size, &dwSizeWritten,
NULL))
48 return ((
tsize_t) dwSizeWritten);
54 DWORD dwMoveMethod, dwMoveHigh;
57 if( off == 0xFFFFFFFF )
63 dwMoveMethod = FILE_BEGIN;
66 dwMoveMethod = FILE_CURRENT;
69 dwMoveMethod = FILE_END;
72 dwMoveMethod = FILE_BEGIN;
76 return ((
toff_t)SetFilePointer(fd, (LONG) off, (PLONG)&dwMoveHigh,
83 return (CloseHandle(fd) ? 0 : -1);
118 if ((size = _tiffSizeProc(fd)) == 0xFFFFFFFF)
120 hMapFile = CreateFileMapping(fd,
NULL, PAGE_READONLY, 0, size,
NULL);
121 if (hMapFile ==
NULL)
123 *pbase = MapViewOfFile(hMapFile, FILE_MAP_READ, 0, 0, 0);
124 CloseHandle(hMapFile);
142 UnmapViewOfFile(base);
154 BOOL fSuppressMap = (mode[1] ==
'u' || (mode[1]!=0 && mode[2] ==
'u'));
157 _tiffReadProc, _tiffWriteProc,
158 _tiffSeekProc, _tiffCloseProc, _tiffSizeProc,
159 fSuppressMap ? _tiffDummyMapProc : _tiffMapProc,
160 fSuppressMap ? _tiffDummyUnmapProc : _tiffUnmapProc);
172 static const char module[] =
"TIFFOpen";
183 dwMode = OPEN_EXISTING;
186 dwMode = OPEN_ALWAYS;
189 dwMode = OPEN_ALWAYS;
192 dwMode = CREATE_ALWAYS;
194 case O_RDWR|O_CREAT|O_TRUNC:
195 dwMode = CREATE_ALWAYS;
201 (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ | GENERIC_WRITE),
202 FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL, dwMode,
203 (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
222 static const char module[] =
"TIFFOpenW";
233 case O_RDONLY: dwMode = OPEN_EXISTING;
break;
234 case O_RDWR: dwMode = OPEN_ALWAYS;
break;
235 case O_RDWR|O_CREAT: dwMode = OPEN_ALWAYS;
break;
236 case O_RDWR|O_TRUNC: dwMode = CREATE_ALWAYS;
break;
237 case O_RDWR|O_CREAT|O_TRUNC: dwMode = CREATE_ALWAYS;
break;
238 default:
return ((
TIFF*)0);
242 (m == O_RDONLY)?GENERIC_READ:(GENERIC_READ|GENERIC_WRITE),
243 FILE_SHARE_READ,
NULL, dwMode,
244 (m == O_RDONLY)?FILE_ATTRIBUTE_READONLY:FILE_ATTRIBUTE_NORMAL,
252 mbsize = WideCharToMultiByte(CP_ACP, 0, name, -1,
NULL, 0,
NULL,
NULL);
257 "Can't allocate space for filename conversion buffer");
261 WideCharToMultiByte(CP_ACP, 0, name, -1, mbname, mbsize,
266 (mbname !=
NULL) ? mbname :
"<unknown>", mode);
278 return ((
tdata_t)GlobalAlloc(GMEM_FIXED, s));
295 return ((
tdata_t)GlobalAlloc(GMEM_FIXED, s));
300 if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) !=
NULL) {
301 CopyMemory(pvTmp, p, s);
305 if ((pvTmp = GlobalAlloc(GMEM_FIXED, s)) !=
NULL) {
306 CopyMemory(pvTmp, p, old);
316 FillMemory(p, c, (BYTE)v);
328 register const BYTE *pb1 = (
const BYTE *) p1;
329 register const BYTE *pb2 = (
const BYTE *) p2;
330 register DWORD dwTmp =
c;
332 for (iTmp = 0; dwTmp-- && !iTmp; iTmp = (
int)*pb1++ - (
int)*pb2++)
338 Win32WarningHandler(
const char* module,
const char* fmt, va_list ap)
340 #ifndef TIF_PLATFORM_CONSOLE 343 LPCTSTR szTitleText =
"%s Warning";
344 LPCTSTR szDefaultModule =
"LIBTIFF";
345 LPCTSTR szTmpModule = (module ==
NULL) ? szDefaultModule : module;
346 if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmpModule) +
347 strlen(szTitleText) + strlen(fmt) + 128)*
sizeof(
char))) ==
NULL)
349 sprintf(szTitle, szTitleText, szTmpModule);
350 szTmp = szTitle + (strlen(szTitle)+2)*
sizeof(
char);
351 vsprintf(szTmp, fmt, ap);
352 MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONINFORMATION);
357 fprintf(stderr,
"%s: ", module);
358 fprintf(stderr,
"Warning, ");
359 vfprintf(stderr, fmt, ap);
360 fprintf(stderr,
".\n");
366 Win32ErrorHandler(
const char* module,
const char* fmt, va_list ap)
368 #ifndef TIF_PLATFORM_CONSOLE 371 LPCTSTR szTitleText =
"%s Error";
372 LPCTSTR szDefaultModule =
"LIBTIFF";
373 LPCTSTR szTmpModule = (module ==
NULL) ? szDefaultModule : module;
374 if ((szTitle = (LPTSTR)LocalAlloc(LMEM_FIXED, (strlen(szTmpModule) +
375 strlen(szTitleText) + strlen(fmt) + 128)*
sizeof(
char))) ==
NULL)
377 sprintf(szTitle, szTitleText, szTmpModule);
378 szTmp = szTitle + (strlen(szTitle)+2)*
sizeof(
char);
379 vsprintf(szTmp, fmt, ap);
380 MessageBoxA(GetFocus(), szTmp, szTitle, MB_OK | MB_ICONEXCLAMATION);
385 fprintf(stderr,
"%s: ", module);
386 vfprintf(stderr, fmt, ap);
387 fprintf(stderr,
".\n");
tdata_t _TIFFrealloc(tdata_t p, tsize_t s)
TIFF * TIFFFdOpen(int ifd, const char *name, const char *mode)
void(* TIFFErrorHandler)(const char *, const char *, va_list)
tdata_t _TIFFmalloc(tsize_t s)
int _TIFFmemcmp(const tdata_t p1, const tdata_t p2, tsize_t c)
GLenum GLuint GLenum GLsizei const GLchar * buf
#define INVALID_HANDLE_VALUE
TIFF * TIFFClientOpen(const char *name, const char *mode, thandle_t clientdata, TIFFReadWriteProc readproc, TIFFReadWriteProc writeproc, TIFFSeekProc seekproc, TIFFCloseProc closeproc, TIFFSizeProc sizeproc, TIFFMapFileProc mapproc, TIFFUnmapFileProc unmapproc)
TIFF * TIFFOpenW(const wchar_t *name, const char *mode)
TIFF * TIFFOpen(const char *name, const char *mode)
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
GLuint const GLchar * name
void _TIFFfree(tdata_t p)
int _TIFFgetMode(const char *mode, const char *module)
TIFFErrorHandler _TIFFerrorHandler
void _TIFFmemset(void *p, int v, tsize_t c)
TIFFErrorHandler _TIFFwarningHandler
void _TIFFmemcpy(void *d, const tdata_t s, tsize_t c)