1 
2 /*
3  * Copyright (c) 1988-1997 Sam Leffler
4  * Copyright (c) 1991-1997 Silicon Graphics, Inc.
5  *
6  * Permission to use, copy, modify, distribute, and sell this software and
7  * its documentation for any purpose is hereby granted without fee, provided
8  * that (i) the above copyright notices and this permission notice appear in
9  * all copies of the software and related documentation, and (ii) the names of
10  * Sam Leffler and Silicon Graphics may not be used in any advertising or
11  * publicity relating to the software without the specific, prior written
12  * permission of Sam Leffler and Silicon Graphics.
13  *
14  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
15  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
16  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
17  *
18  * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
19  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
20  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
22  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
23  * OF THIS SOFTWARE.
24  */
25 
26 /*
27  * TIFF Library.
28  */
29 #include "tiffiop.h"
30 
31 /*
32  * Dummy functions to fill the omitted client procedures.
33  */
34 static int
_tiffDummyMapProc(thandle_t fd,void ** pbase,toff_t * psize)35 _tiffDummyMapProc(thandle_t fd, void** pbase, toff_t* psize)
36 {
37 	(void) fd; (void) pbase; (void) psize;
38 	return (0);
39 }
40 
41 static void
_tiffDummyUnmapProc(thandle_t fd,void * base,toff_t size)42 _tiffDummyUnmapProc(thandle_t fd, void* base, toff_t size)
43 {
44 	(void) fd; (void) base; (void) size;
45 }
46 
47 int
_TIFFgetMode(const char * mode,const char * module)48 _TIFFgetMode(const char* mode, const char* module)
49 {
50 	int m = -1;
51 
52 	switch (mode[0]) {
53 	case 'r':
54 		m = O_RDONLY;
55 		if (mode[1] == '+')
56 			m = O_RDWR;
57 		break;
58 	case 'w':
59 	case 'a':
60 		m = O_RDWR|O_CREAT;
61 		if (mode[0] == 'w')
62 			m |= O_TRUNC;
63 		break;
64 	default:
65 		TIFFErrorExt(0, module, "\"%s\": Bad mode", mode);
66 		break;
67 	}
68 	return (m);
69 }
70 
71 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)72 TIFFClientOpen(
73 	const char* name, const char* mode,
74 	thandle_t clientdata,
75 	TIFFReadWriteProc readproc,
76 	TIFFReadWriteProc writeproc,
77 	TIFFSeekProc seekproc,
78 	TIFFCloseProc closeproc,
79 	TIFFSizeProc sizeproc,
80 	TIFFMapFileProc mapproc,
81 	TIFFUnmapFileProc unmapproc
82 )
83 {
84 	static const char module[] = "TIFFClientOpen";
85 	TIFF *tif;
86 	int m;
87 	const char* cp;
88 
89 	/* The following are configuration checks. They should be redundant, but should not
90 	 * compile to any actual code in an optimised release build anyway. If any of them
91 	 * fail, (makefile-based or other) configuration is not correct */
92 #ifndef NDEBUG
93 	assert(sizeof(uint8)==1);
94 	assert(sizeof(int8)==1);
95 	assert(sizeof(uint16)==2);
96 	assert(sizeof(int16)==2);
97 	assert(sizeof(uint32)==4);
98 	assert(sizeof(int32)==4);
99 	assert(sizeof(uint64)==8);
100 	assert(sizeof(int64)==8);
101 	assert(sizeof(tmsize_t)==sizeof(void*));
102 	{
103 		union{
104 			uint8 a8[2];
105 			uint16 a16;
106 		} n;
107 		n.a8[0]=1;
108 		n.a8[1]=0;
109 		#ifdef WORDS_BIGENDIAN
110 		assert(n.a16==256);
111 		#else
112 		assert(n.a16==1);
113 		#endif
114 	}
115 #endif /* !NDEBUG */
116 
117 	m = _TIFFgetMode(mode, module);
118 	if (m == -1)
119 		goto bad2;
120 	tif = (TIFF *)_TIFFmalloc((tmsize_t)(sizeof (TIFF) + strlen(name) + 1));
121 	if (tif == NULL) {
122 		TIFFErrorExt(clientdata, module, "%s: Out of memory (TIFF structure)", name);
123 		goto bad2;
124 	}
125 	_TIFFmemset(tif, 0, sizeof (*tif));
126 	tif->tif_name = (char *)tif + sizeof (TIFF);
127 	strcpy(tif->tif_name, name);
128 	tif->tif_mode = m &~ (O_CREAT|O_TRUNC);
129 	tif->tif_curdir = (uint16) -1;		/* non-existent directory */
130 	tif->tif_curoff = 0;
131 	tif->tif_curstrip = (uint32) -1;	/* invalid strip */
132 	tif->tif_row = (uint32) -1;		/* read/write pre-increment */
133 	tif->tif_clientdata = clientdata;
134 	if (!readproc || !writeproc || !seekproc || !closeproc || !sizeproc) {
135 		TIFFErrorExt(clientdata, module,
136 		    "One of the client procedures is NULL pointer.");
137 		goto bad2;
138 	}
139 	tif->tif_readproc = readproc;
140 	tif->tif_writeproc = writeproc;
141 	tif->tif_seekproc = seekproc;
142 	tif->tif_closeproc = closeproc;
143 	tif->tif_sizeproc = sizeproc;
144 	if (mapproc)
145 		tif->tif_mapproc = mapproc;
146 	else
147 		tif->tif_mapproc = _tiffDummyMapProc;
148 	if (unmapproc)
149 		tif->tif_unmapproc = unmapproc;
150 	else
151 		tif->tif_unmapproc = _tiffDummyUnmapProc;
152 	_TIFFSetDefaultCompressionState(tif);    /* setup default state */
153 	/*
154 	 * Default is to return data MSB2LSB and enable the
155 	 * use of memory-mapped files and strip chopping when
156 	 * a file is opened read-only.
157 	 */
158 	tif->tif_flags = FILLORDER_MSB2LSB;
159 	if (m == O_RDONLY )
160 		tif->tif_flags |= TIFF_MAPPED;
161 
162 	#ifdef STRIPCHOP_DEFAULT
163 	if (m == O_RDONLY || m == O_RDWR)
164 		tif->tif_flags |= STRIPCHOP_DEFAULT;
165 	#endif
166 
167 	/*
168 	 * Process library-specific flags in the open mode string.
169 	 * The following flags may be used to control intrinsic library
170 	 * behaviour that may or may not be desirable (usually for
171 	 * compatibility with some application that claims to support
172 	 * TIFF but only supports some braindead idea of what the
173 	 * vendor thinks TIFF is):
174 	 *
175 	 * 'l' use little-endian byte order for creating a file
176 	 * 'b' use big-endian byte order for creating a file
177 	 * 'L' read/write information using LSB2MSB bit order
178 	 * 'B' read/write information using MSB2LSB bit order
179 	 * 'H' read/write information using host bit order
180 	 * 'M' enable use of memory-mapped files when supported
181 	 * 'm' disable use of memory-mapped files
182 	 * 'C' enable strip chopping support when reading
183 	 * 'c' disable strip chopping support
184 	 * 'h' read TIFF header only, do not load the first IFD
185 	 * '4' ClassicTIFF for creating a file (default)
186 	 * '8' BigTIFF for creating a file
187 	 *
188 	 * The use of the 'l' and 'b' flags is strongly discouraged.
189 	 * These flags are provided solely because numerous vendors,
190 	 * typically on the PC, do not correctly support TIFF; they
191 	 * only support the Intel little-endian byte order.  This
192 	 * support is not configured by default because it supports
193 	 * the violation of the TIFF spec that says that readers *MUST*
194 	 * support both byte orders.  It is strongly recommended that
195 	 * you not use this feature except to deal with busted apps
196 	 * that write invalid TIFF.  And even in those cases you should
197 	 * bang on the vendors to fix their software.
198 	 *
199 	 * The 'L', 'B', and 'H' flags are intended for applications
200 	 * that can optimize operations on data by using a particular
201 	 * bit order.  By default the library returns data in MSB2LSB
202 	 * bit order for compatibiltiy with older versions of this
203 	 * library.  Returning data in the bit order of the native cpu
204 	 * makes the most sense but also requires applications to check
205 	 * the value of the FillOrder tag; something they probably do
206 	 * not do right now.
207 	 *
208 	 * The 'M' and 'm' flags are provided because some virtual memory
209 	 * systems exhibit poor behaviour when large images are mapped.
210 	 * These options permit clients to control the use of memory-mapped
211 	 * files on a per-file basis.
212 	 *
213 	 * The 'C' and 'c' flags are provided because the library support
214 	 * for chopping up large strips into multiple smaller strips is not
215 	 * application-transparent and as such can cause problems.  The 'c'
216 	 * option permits applications that only want to look at the tags,
217 	 * for example, to get the unadulterated TIFF tag information.
218 	 */
219 	for (cp = mode; *cp; cp++)
220 		switch (*cp) {
221 			case 'b':
222 				#ifndef WORDS_BIGENDIAN
223 				if (m&O_CREAT)
224 					tif->tif_flags |= TIFF_SWAB;
225 				#endif
226 				break;
227 			case 'l':
228 				#ifdef WORDS_BIGENDIAN
229 				if ((m&O_CREAT))
230 					tif->tif_flags |= TIFF_SWAB;
231 				#endif
232 				break;
233 			case 'B':
234 				tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) |
235 				    FILLORDER_MSB2LSB;
236 				break;
237 			case 'L':
238 				tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) |
239 				    FILLORDER_LSB2MSB;
240 				break;
241 			case 'H':
242 				tif->tif_flags = (tif->tif_flags &~ TIFF_FILLORDER) |
243 				    HOST_FILLORDER;
244 				break;
245 			case 'M':
246 				if (m == O_RDONLY)
247 					tif->tif_flags |= TIFF_MAPPED;
248 				break;
249 			case 'm':
250 				if (m == O_RDONLY)
251 					tif->tif_flags &= ~TIFF_MAPPED;
252 				break;
253 			case 'C':
254 				if (m == O_RDONLY)
255 					tif->tif_flags |= TIFF_STRIPCHOP;
256 				break;
257 			case 'c':
258 				if (m == O_RDONLY)
259 					tif->tif_flags &= ~TIFF_STRIPCHOP;
260 				break;
261 			case 'h':
262 				tif->tif_flags |= TIFF_HEADERONLY;
263 				break;
264 			case '8':
265 				if (m&O_CREAT)
266 					tif->tif_flags |= TIFF_BIGTIFF;
267 				break;
268 		}
269 	/*
270 	 * Read in TIFF header.
271 	 */
272 	if ((m & O_TRUNC) ||
273 	    !ReadOK(tif, &tif->tif_header, sizeof (TIFFHeaderClassic))) {
274 		if (tif->tif_mode == O_RDONLY) {
275 			TIFFErrorExt(tif->tif_clientdata, name,
276 			    "Cannot read TIFF header");
277 			goto bad;
278 		}
279 		/*
280 		 * Setup header and write.
281 		 */
282 		#ifdef WORDS_BIGENDIAN
283 		tif->tif_header.common.tiff_magic = tif->tif_flags & TIFF_SWAB
284 		    ? TIFF_LITTLEENDIAN : TIFF_BIGENDIAN;
285 		#else
286 		tif->tif_header.common.tiff_magic = tif->tif_flags & TIFF_SWAB
287 		    ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN;
288 		#endif
289 		if (!(tif->tif_flags&TIFF_BIGTIFF))
290 		{
291 			tif->tif_header.common.tiff_version = TIFF_VERSION_CLASSIC;
292 			tif->tif_header.classic.tiff_diroff = 0;
293 			if (tif->tif_flags & TIFF_SWAB)
294 				TIFFSwabShort(&tif->tif_header.common.tiff_version);
295 			tif->tif_header_size = sizeof(TIFFHeaderClassic);
296 		}
297 		else
298 		{
299 			tif->tif_header.common.tiff_version = TIFF_VERSION_BIG;
300 			tif->tif_header.big.tiff_offsetsize = 8;
301 			tif->tif_header.big.tiff_unused = 0;
302 			tif->tif_header.big.tiff_diroff = 0;
303 			if (tif->tif_flags & TIFF_SWAB)
304 			{
305 				TIFFSwabShort(&tif->tif_header.common.tiff_version);
306 				TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize);
307 			}
308 			tif->tif_header_size = sizeof (TIFFHeaderBig);
309 		}
310 		/*
311 		 * The doc for "fopen" for some STD_C_LIBs says that if you
312 		 * open a file for modify ("+"), then you must fseek (or
313 		 * fflush?) between any freads and fwrites.  This is not
314 		 * necessary on most systems, but has been shown to be needed
315 		 * on Solaris.
316 		 */
317 		TIFFSeekFile( tif, 0, SEEK_SET );
318 		if (!WriteOK(tif, &tif->tif_header, (tmsize_t)(tif->tif_header_size))) {
319 			TIFFErrorExt(tif->tif_clientdata, name,
320 			    "Error writing TIFF header");
321 			goto bad;
322 		}
323 		/*
324 		 * Setup the byte order handling.
325 		 */
326 		if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN) {
327 			#ifndef WORDS_BIGENDIAN
328 			tif->tif_flags |= TIFF_SWAB;
329 			#endif
330 		} else {
331 			#ifdef WORDS_BIGENDIAN
332 			tif->tif_flags |= TIFF_SWAB;
333 			#endif
334 		}
335 		/*
336 		 * Setup default directory.
337 		 */
338 		if (!TIFFDefaultDirectory(tif))
339 			goto bad;
340 		tif->tif_diroff = 0;
341 		tif->tif_dirlist = NULL;
342 		tif->tif_dirlistsize = 0;
343 		tif->tif_dirnumber = 0;
344 		return (tif);
345 	}
346 	/*
347 	 * Setup the byte order handling.
348 	 */
349 	if (tif->tif_header.common.tiff_magic != TIFF_BIGENDIAN &&
350 	    tif->tif_header.common.tiff_magic != TIFF_LITTLEENDIAN
351 	    #if MDI_SUPPORT
352 	    &&
353 	    #if HOST_BIGENDIAN
354 	    tif->tif_header.common.tiff_magic != MDI_BIGENDIAN
355 	    #else
356 	    tif->tif_header.common.tiff_magic != MDI_LITTLEENDIAN
357 	    #endif
358 	    ) {
359 		TIFFErrorExt(tif->tif_clientdata, name,
360 		    "Not a TIFF or MDI file, bad magic number %d (0x%x)",
361 	    #else
362 	    ) {
363 		TIFFErrorExt(tif->tif_clientdata, name,
364 		    "Not a TIFF file, bad magic number %d (0x%x)",
365 	    #endif
366 		    tif->tif_header.common.tiff_magic,
367 		    tif->tif_header.common.tiff_magic);
368 		goto bad;
369 	}
370 	if (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN) {
371 		#ifndef WORDS_BIGENDIAN
372 		tif->tif_flags |= TIFF_SWAB;
373 		#endif
374 	} else {
375 		#ifdef WORDS_BIGENDIAN
376 		tif->tif_flags |= TIFF_SWAB;
377 		#endif
378 	}
379 	if (tif->tif_flags & TIFF_SWAB)
380 		TIFFSwabShort(&tif->tif_header.common.tiff_version);
381 	if ((tif->tif_header.common.tiff_version != TIFF_VERSION_CLASSIC)&&
382 	    (tif->tif_header.common.tiff_version != TIFF_VERSION_BIG)) {
383 		TIFFErrorExt(tif->tif_clientdata, name,
384 		    "Not a TIFF file, bad version number %d (0x%x)",
385 		    tif->tif_header.common.tiff_version,
386 		    tif->tif_header.common.tiff_version);
387 		goto bad;
388 	}
389 	if (tif->tif_header.common.tiff_version == TIFF_VERSION_CLASSIC)
390 	{
391 		if (tif->tif_flags & TIFF_SWAB)
392 			TIFFSwabLong(&tif->tif_header.classic.tiff_diroff);
393 		tif->tif_header_size = sizeof(TIFFHeaderClassic);
394 	}
395 	else
396 	{
397 		if (!ReadOK(tif, ((uint8*)(&tif->tif_header) + sizeof(TIFFHeaderClassic)), (sizeof(TIFFHeaderBig)-sizeof(TIFFHeaderClassic))))
398 		{
399 			TIFFErrorExt(tif->tif_clientdata, name,
400 			    "Cannot read TIFF header");
401 			goto bad;
402 		}
403 		if (tif->tif_flags & TIFF_SWAB)
404 		{
405 			TIFFSwabShort(&tif->tif_header.big.tiff_offsetsize);
406 			TIFFSwabLong8(&tif->tif_header.big.tiff_diroff);
407 		}
408 		if (tif->tif_header.big.tiff_offsetsize != 8)
409 		{
410 			TIFFErrorExt(tif->tif_clientdata, name,
411 			    "Not a TIFF file, bad BigTIFF offsetsize %d (0x%x)",
412 			    tif->tif_header.big.tiff_offsetsize,
413 			    tif->tif_header.big.tiff_offsetsize);
414 			goto bad;
415 		}
416 		if (tif->tif_header.big.tiff_unused != 0)
417 		{
418 			TIFFErrorExt(tif->tif_clientdata, name,
419 			    "Not a TIFF file, bad BigTIFF unused %d (0x%x)",
420 			    tif->tif_header.big.tiff_unused,
421 			    tif->tif_header.big.tiff_unused);
422 			goto bad;
423 		}
424 		tif->tif_header_size = sizeof(TIFFHeaderBig);
425 		tif->tif_flags |= TIFF_BIGTIFF;
426 	}
427 	tif->tif_flags |= TIFF_MYBUFFER;
428 	tif->tif_rawcp = tif->tif_rawdata = 0;
429 	tif->tif_rawdatasize = 0;
430         tif->tif_rawdataoff = 0;
431         tif->tif_rawdataloaded = 0;
432 
433 	switch (mode[0]) {
434 		case 'r':
435 			if (!(tif->tif_flags&TIFF_BIGTIFF))
436 				tif->tif_nextdiroff = tif->tif_header.classic.tiff_diroff;
437 			else
438 				tif->tif_nextdiroff = tif->tif_header.big.tiff_diroff;
439 			/*
440 			 * Try to use a memory-mapped file if the client
441 			 * has not explicitly suppressed usage with the
442 			 * 'm' flag in the open mode (see above).
443 			 */
444 			if (tif->tif_flags & TIFF_MAPPED)
445 			{
446 				toff_t n;
447 				if (TIFFMapFileContents(tif,(void**)(&tif->tif_base),&n))
448 				{
449 					tif->tif_size=(tmsize_t)n;
450 					assert((toff_t)tif->tif_size==n);
451 				}
452 				else
453 					tif->tif_flags &= ~TIFF_MAPPED;
454 			}
455 			/*
456 			 * Sometimes we do not want to read the first directory (for example,
457 			 * it may be broken) and want to proceed to other directories. I this
458 			 * case we use the TIFF_HEADERONLY flag to open file and return
459 			 * immediately after reading TIFF header.
460 			 */
461 			if (tif->tif_flags & TIFF_HEADERONLY)
462 				return (tif);
463 
464 			/*
465 			 * Setup initial directory.
466 			 */
467 			if (TIFFReadDirectory(tif)) {
468 				tif->tif_rawcc = (tmsize_t)-1;
469 				tif->tif_flags |= TIFF_BUFFERSETUP;
470 				return (tif);
471 			}
472 			break;
473 		case 'a':
474 			/*
475 			 * New directories are automatically append
476 			 * to the end of the directory chain when they
477 			 * are written out (see TIFFWriteDirectory).
478 			 */
479 			if (!TIFFDefaultDirectory(tif))
480 				goto bad;
481 			return (tif);
482 	}
483 bad:
484 	tif->tif_mode = O_RDONLY;	/* XXX avoid flush */
485         TIFFCleanup(tif);
486 bad2:
487 	return ((TIFF*)0);
488 }
489 
490 /*
491  * Query functions to access private data.
492  */
493 
494 /*
495  * Return open file's name.
496  */
497 const char *
498 TIFFFileName(TIFF* tif)
499 {
500 	return (tif->tif_name);
501 }
502 
503 /*
504  * Set the file name.
505  */
506 const char *
507 TIFFSetFileName(TIFF* tif, const char *name)
508 {
509 	const char* old_name = tif->tif_name;
510 	tif->tif_name = (char *)name;
511 	return (old_name);
512 }
513 
514 /*
515  * Return open file's I/O descriptor.
516  */
517 int
518 TIFFFileno(TIFF* tif)
519 {
520 	return (tif->tif_fd);
521 }
522 
523 /*
524  * Set open file's I/O descriptor, and return previous value.
525  */
526 int
527 TIFFSetFileno(TIFF* tif, int fd)
528 {
529         int old_fd = tif->tif_fd;
530 	tif->tif_fd = fd;
531 	return old_fd;
532 }
533 
534 /*
535  * Return open file's clientdata.
536  */
537 thandle_t
538 TIFFClientdata(TIFF* tif)
539 {
540 	return (tif->tif_clientdata);
541 }
542 
543 /*
544  * Set open file's clientdata, and return previous value.
545  */
546 thandle_t
547 TIFFSetClientdata(TIFF* tif, thandle_t newvalue)
548 {
549 	thandle_t m = tif->tif_clientdata;
550 	tif->tif_clientdata = newvalue;
551 	return m;
552 }
553 
554 /*
555  * Return read/write mode.
556  */
557 int
558 TIFFGetMode(TIFF* tif)
559 {
560 	return (tif->tif_mode);
561 }
562 
563 /*
564  * Return read/write mode.
565  */
566 int
567 TIFFSetMode(TIFF* tif, int mode)
568 {
569 	int old_mode = tif->tif_mode;
570 	tif->tif_mode = mode;
571 	return (old_mode);
572 }
573 
574 /*
575  * Return nonzero if file is organized in
576  * tiles; zero if organized as strips.
577  */
578 int
579 TIFFIsTiled(TIFF* tif)
580 {
581 	return (isTiled(tif));
582 }
583 
584 /*
585  * Return current row being read/written.
586  */
587 uint32
588 TIFFCurrentRow(TIFF* tif)
589 {
590 	return (tif->tif_row);
591 }
592 
593 /*
594  * Return index of the current directory.
595  */
596 uint16
597 TIFFCurrentDirectory(TIFF* tif)
598 {
599 	return (tif->tif_curdir);
600 }
601 
602 /*
603  * Return current strip.
604  */
605 uint32
606 TIFFCurrentStrip(TIFF* tif)
607 {
608 	return (tif->tif_curstrip);
609 }
610 
611 /*
612  * Return current tile.
613  */
614 uint32
615 TIFFCurrentTile(TIFF* tif)
616 {
617 	return (tif->tif_curtile);
618 }
619 
620 /*
621  * Return nonzero if the file has byte-swapped data.
622  */
623 int
624 TIFFIsByteSwapped(TIFF* tif)
625 {
626 	return ((tif->tif_flags & TIFF_SWAB) != 0);
627 }
628 
629 /*
630  * Return nonzero if the data is returned up-sampled.
631  */
632 int
633 TIFFIsUpSampled(TIFF* tif)
634 {
635 	return (isUpSampled(tif));
636 }
637 
638 /*
639  * Return nonzero if the data is returned in MSB-to-LSB bit order.
640  */
641 int
642 TIFFIsMSB2LSB(TIFF* tif)
643 {
644 	return (isFillOrder(tif, FILLORDER_MSB2LSB));
645 }
646 
647 /*
648  * Return nonzero if given file was written in big-endian order.
649  */
650 int
651 TIFFIsBigEndian(TIFF* tif)
652 {
653 	return (tif->tif_header.common.tiff_magic == TIFF_BIGENDIAN);
654 }
655 
656 /*
657  * Return pointer to file read method.
658  */
659 TIFFReadWriteProc
660 TIFFGetReadProc(TIFF* tif)
661 {
662 	return (tif->tif_readproc);
663 }
664 
665 /*
666  * Return pointer to file write method.
667  */
668 TIFFReadWriteProc
669 TIFFGetWriteProc(TIFF* tif)
670 {
671 	return (tif->tif_writeproc);
672 }
673 
674 /*
675  * Return pointer to file seek method.
676  */
677 TIFFSeekProc
678 TIFFGetSeekProc(TIFF* tif)
679 {
680 	return (tif->tif_seekproc);
681 }
682 
683 /*
684  * Return pointer to file close method.
685  */
686 TIFFCloseProc
687 TIFFGetCloseProc(TIFF* tif)
688 {
689 	return (tif->tif_closeproc);
690 }
691 
692 /*
693  * Return pointer to file size requesting method.
694  */
695 TIFFSizeProc
696 TIFFGetSizeProc(TIFF* tif)
697 {
698 	return (tif->tif_sizeproc);
699 }
700 
701 /*
702  * Return pointer to memory mapping method.
703  */
704 TIFFMapFileProc
705 TIFFGetMapFileProc(TIFF* tif)
706 {
707 	return (tif->tif_mapproc);
708 }
709 
710 /*
711  * Return pointer to memory unmapping method.
712  */
713 TIFFUnmapFileProc
714 TIFFGetUnmapFileProc(TIFF* tif)
715 {
716 	return (tif->tif_unmapproc);
717 }
718 
719 /* vim: set ts=8 sts=8 sw=8 noet: */
720 /*
721  * Local Variables:
722  * mode: c
723  * c-basic-offset: 8
724  * fill-column: 78
725  * End:
726  */
727