# 1 "tif_machdep.c"

static char rcsid[] = "$Header: /usr/people/sam/tiff/libtiff/RCS/tif_machdep.c,v 1.2 92/03/06 11:52:42 sam Exp $";





























# 1 "./tiffioP.h"































# 1 "./tiffcompat.h"
























































# 1 "/usr/include/sys/types.h"














































































# 1 "/usr/include/ansi_compat.h"













































# 125 "/usr/include/ansi_compat.h"

# 80 "/usr/include/sys/types.h"
















typedef	unsigned char	u_char;
typedef	unsigned short	u_short;
typedef	unsigned int	u_int;
typedef	unsigned int	uint;		
typedef	unsigned long	u_long;
typedef	unsigned short	ushort;		

typedef	volatile char		v_char;
typedef	volatile short		v_short;
typedef	volatile long		v_long;
typedef	volatile unsigned char	vu_char;
typedef	volatile unsigned short	vu_short;
typedef	volatile unsigned long	vu_long;

typedef

	signed

		char	s_char;









typedef	struct	_physadr { int r[1]; } *physadr;




typedef	struct	label_t	{
	int	val[12];
} label_t;


typedef	struct	_quad { long val[2]; } quad;
typedef	long	daddr_t;
typedef	char *	caddr_t;
typedef u_long	gno_t;
typedef short	cnt_t;			
typedef	long	swblk_t;
typedef long	paddr_t;		
typedef	long	audit_ID_t;


typedef	short	dev_t;
typedef short	gid_t;			
typedef	unsigned long	ino_t;
typedef unsigned short	mode_t;		
typedef short	nlink_t;		
typedef	int	off_t;


typedef int	pid_t;			

typedef short	uid_t;			


typedef int	time_t;





typedef	unsigned int	size_t;



typedef int	clock_t;			

typedef long	key_t;			




























typedef long	fd_mask;






typedef	struct fd_set {
	fd_mask	fds_bits[(((4096	)+(( (sizeof(fd_mask) * 8		)	)-1))/( (sizeof(fd_mask) * 8		)	))];
} fd_set;








# 58 "./tiffcompat.h"





# 1 "/usr/include/fcntl.h"








































# 1 "/usr/include/sys/file.h"





































































































































# 1 "/usr/include/ansi_compat.h"













































# 125 "/usr/include/ansi_compat.h"

# 135 "/usr/include/sys/file.h"




# 1 "/usr/include/sys/types.h"








































































# 215 "/usr/include/sys/types.h"

# 140 "/usr/include/sys/file.h"






















































































































































struct flock {
	short	l_type;
	short	l_whence;
	off_t	l_start;
	off_t	l_len;		

	int	l_pid;



};
























































int	creat(), fcntl(), open();



# 42 "/usr/include/fcntl.h"
# 64 "./tiffcompat.h"
































































extern	long TIFFGetFileSize();




























extern	long lseek();

























extern	char *malloc();
extern	char *realloc();












typedef double dblparam_t;











# 1 "/usr/include/varargs.h"

# 1 "/usr/include/ansi_compat.h"













































# 125 "/usr/include/ansi_compat.h"

# 3 "/usr/include/varargs.h"
































typedef char *va_list;














# 1 "/usr/include/stamp.h"








































# 51 "/usr/include/varargs.h"









 
 
























# 210 "./tiffcompat.h"







# 33 "./tiffioP.h"
# 1 "./tiff.h"












































typedef	struct {
	unsigned short tiff_magic;	
	unsigned short tiff_version;	
	unsigned long  tiff_diroff;	
} TIFFHeader;














typedef	struct {
	unsigned short tdir_tag;	
	unsigned short tdir_type;	
	unsigned long  tdir_count;	
	unsigned long  tdir_offset;	
} TIFFDirEntry;













typedef	enum {
	TIFF_NOTYPE	= 0,	
	TIFF_BYTE	= 1,	
	TIFF_ASCII	= 2,	
	TIFF_SHORT	= 3,	
	TIFF_LONG	= 4,	
	TIFF_RATIONAL	= 5,	
	TIFF_SBYTE	= 6,	
	TIFF_UNDEFINED	= 7,	
	TIFF_SSHORT	= 8,	
	TIFF_SLONG	= 9,	
	TIFF_SRATIONAL	= 10,	
	TIFF_FLOAT	= 11,	
	TIFF_DOUBLE	= 12	
} TIFFDataType;




























































































































































# 34 "./tiffioP.h"




typedef	struct {
	u_long	td_fieldsset[2];	

	u_long	td_imagewidth, td_imagelength, td_imagedepth;
	u_long	td_tilewidth, td_tilelength, td_tiledepth;
	u_short	td_subfiletype;
	u_short	td_bitspersample;
	u_short	td_sampleformat;
	u_short	td_compression;
	u_short	td_photometric;
	u_short	td_threshholding;
	u_short	td_fillorder;
	u_short	td_orientation;
	u_short	td_samplesperpixel;
	u_short	td_predictor;
	u_long	td_rowsperstrip;
	u_long	td_minsamplevalue, td_maxsamplevalue;	
	float	td_xresolution, td_yresolution;
	u_short	td_resolutionunit;
	u_short	td_planarconfig;
	float	td_xposition, td_yposition;
	u_long	td_group3options;
	u_long	td_group4options;
	u_short	td_pagenumber[2];
	u_short	td_matteing;
	u_short	td_cleanfaxdata;
	u_short	td_badfaxrun;
	u_long	td_badfaxlines;
	u_short	*td_colormap[3];
	u_short	td_halftonehints[2];
	char	*td_documentname;
	char	*td_artist;
	char	*td_datetime;
	char	*td_hostcomputer;
	char	*td_imagedescription;
	char	*td_make;
	char	*td_model;
	char	*td_software;
	char	*td_pagename;
	u_long	td_stripsperimage;
	u_long	td_nstrips;		
	u_long	*td_stripoffset;
	u_long	*td_stripbytecount;

	float	*td_ycbcrcoeffs;
	u_short	td_ycbcrsubsampling[2];
	u_short	td_ycbcrpositioning;









	float	*td_whitepoint;
	float	*td_primarychromas;
	float	*td_refblackwhite;
	u_short	*td_transferfunction[4];







} TIFFDirectory;















































































 
 
 

 
 
 

typedef	struct {
	u_short	field_tag;		
	short	field_readcount;	
	short	field_writecount;	
	TIFFDataType field_type;	
	u_short	field_bit;		
	u_short	field_oktochange;	
	char	*field_name;		
} TIFFFieldInfo;







extern	 TIFFFieldInfo tiffFieldInfo[];
extern	 int tiffDataWidth[];	










struct tiff {
	char	*tif_name;		
	short	tif_fd;			
	short	tif_mode;		
	char	tif_fillorder;		
	char	tif_options;		
	short	tif_flags;










	long	tif_diroff;		
	long	tif_nextdiroff;		
	TIFFDirectory tif_dir;		
	TIFFHeader tif_header;		
	int  *tif_typeshift;	
	long  *tif_typemask;	
	long	tif_row;		
	int	tif_curdir;		
	int	tif_curstrip;		
	long	tif_curoff;		

	long 	tif_col;		
	int 	tif_curtile;		
	long 	tif_tilesize;		

	int	(*tif_predecode)();	
	int	(*tif_preencode)();	
	int	(*tif_postencode)();	
	int	(*tif_decoderow)();	
	int	(*tif_encoderow)();	
	int	(*tif_decodestrip)();	
	int	(*tif_encodestrip)();	
	int	(*tif_decodetile)();	
	int	(*tif_encodetile)();	
	int	(*tif_close)();		
	int	(*tif_seek)();		
	int	(*tif_cleanup)();	
	char	*tif_data;		

	int	tif_scanlinesize;	
	int	tif_scanlineskew;	
	char	*tif_rawdata;		
	long	tif_rawdatasize;	
	char	*tif_rawcp;		
	long	tif_rawcc;		




};


















# 1 "./tiffio.h"
































# 1 "./tiff.h"


























# 253 "./tiff.h"

# 34 "./tiffio.h"





typedef	struct tiff TIFF;
























extern char TIFFVersion[];
extern unsigned char TIFFBitRevTable[256];
extern unsigned char TIFFNoBitRevTable[256];











# 158 "./tiffio.h"

typedef	void (*TIFFErrorHandler)();

extern	void TIFFClose();
extern	TIFF *TIFFOpen();
extern	TIFF *TIFFFdOpen();
extern	char* TIFFFileName();
extern	int TIFFFileno();
extern	int TIFFGetMode();
extern	int TIFFIsTiled();
extern	unsigned int TIFFComputeTile();
extern	long TIFFCurrentRow();
extern	int TIFFCurrentDirectory();
extern	int TIFFCurrentStrip();
extern	int TIFFCurrentTile();
extern	void TIFFError();
extern	TIFFErrorHandler TIFFSetErrorHandler();
extern	int TIFFFlush();
extern	int TIFFFlushData();
extern	int TIFFGetField();
extern	int TIFFVGetField();
extern	int TIFFGetFieldDefaulted();
extern	int TIFFVGetFieldDefaulted();
extern	unsigned int TIFFNumberOfTiles();
extern	void TIFFPrintDirectory();
extern	int TIFFReadDirectory();
extern	int TIFFReadBufferSetup();
extern	int TIFFReadScanline();
extern	int TIFFReadTile();
extern	unsigned int TIFFComputeStrip();
extern	unsigned int TIFFNumberOfStrips();
extern	int TIFFReadEncodedStrip();
extern	int TIFFReadRawStrip();
extern	int TIFFReadEncodedTile();
extern	int TIFFReadRGBAImage();
extern	int TIFFReadRawTile();
extern	int TIFFScanlineSize();
extern	unsigned long TIFFStripSize();
extern	unsigned long TIFFVStripSize();
extern	unsigned long TIFFTileRowSize();
extern	unsigned long TIFFTileSize();
extern	unsigned long TIFFVTileSize();
extern	int TIFFSetDirectory();
extern	int TIFFSetField();
extern	int TIFFVSetField();
extern	void TIFFWarning();
extern	TIFFErrorHandler TIFFSetWarningHandler();
extern	int TIFFWriteDirectory();
extern	int TIFFWriteScanline();
extern	int TIFFWriteEncodedStrip();
extern	int TIFFWriteRawStrip();
extern	int TIFFWriteEncodedTile();
extern	int TIFFWriteRawTile();
extern	int TIFFSwabShort();
extern	int TIFFSwabLong();
extern	int TIFFSwabArrayOfShort();
extern	int TIFFSwabArrayOfLong();
extern	int TIFFReverseBits();
extern	int TIFFCheckTile();


# 297 "./tiffioP.h"




























extern	TIFFFieldInfo  *TIFFFindFieldInfo();
extern	TIFFFieldInfo  *TIFFFieldWithTag();
extern	int _TIFFgetfield();
extern	int TIFFNoRowEncode();
extern	int TIFFNoStripEncode();
extern	int TIFFNoTileEncode();
extern	int TIFFNoRowDecode();
extern	int TIFFNoStripDecode();
extern	int TIFFNoTileDecode();


# 33 "tif_machdep.c"

# 77 "tif_machdep.c"


# 138 "tif_machdep.c"




"Help, you've configured the library to not have IEEE floating point,but not defined how to convert between IEEE and native formats!"  








typedef	union {
	ieeedouble	ieee;
	nativedouble	native;
	char		b[8];
	double		d;
} double_t;

typedef	union {
	ieeefloat	ieee;
	nativefloat	native;
	char		b[4];
	float		f;
} float_t;

TIFFCvtIEEEFloatToNative(tif, n, f)
	TIFF *tif;
	u_int n;
	float *f;
{
	float_t *fp = (float_t *)f;

	while (n-- > 0) {
		IEEEFLOAT2NATIVE(fp);
		fp++;
	}
}

TIFFCvtNativeToIEEEFloat(tif, n, f)
	TIFF *tif;
	u_int n;
	float *f;
{
	float_t *fp = (float_t *)f;

	while (n-- > 0) {
		NATIVE2IEEEFLOAT(fp);
		fp++;
	}
}

