roentgen b75cab
/* $Id: check_tag.c,v 1.3 2008/04/15 14:19:37 dron Exp $ */
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * Copyright (c) 2004, Andrey Kiselev  <dron@ak4719.spb.edu></dron@ak4719.spb.edu>
roentgen b75cab
 *
roentgen b75cab
 * Permission to use, copy, modify, distribute, and sell this software and 
roentgen b75cab
 * its documentation for any purpose is hereby granted without fee, provided
roentgen b75cab
 * that (i) the above copyright notices and this permission notice appear in
roentgen b75cab
 * all copies of the software and related documentation, and (ii) the names of
roentgen b75cab
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
roentgen b75cab
 * publicity relating to the software without the specific, prior written
roentgen b75cab
 * permission of Sam Leffler and Silicon Graphics.
roentgen b75cab
 * 
roentgen b75cab
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
roentgen b75cab
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
roentgen b75cab
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
roentgen b75cab
 * 
roentgen b75cab
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
roentgen b75cab
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
roentgen b75cab
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
roentgen b75cab
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
roentgen b75cab
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
roentgen b75cab
 * OF THIS SOFTWARE.
roentgen b75cab
 */
roentgen b75cab
roentgen b75cab
/*
roentgen b75cab
 * TIFF Library
roentgen b75cab
 *
roentgen b75cab
 * Helper testing routines.
roentgen b75cab
 */
roentgen b75cab
roentgen b75cab
#include "tiffio.h"
roentgen b75cab
roentgen b75cab
int
roentgen b75cab
CheckShortField(TIFF *tif, const ttag_t field, const uint16 value)
roentgen b75cab
{
roentgen b75cab
	uint16 tmp = 123;
roentgen b75cab
roentgen b75cab
	if (!TIFFGetField(tif, field, &tmp)) {
roentgen b75cab
		fprintf (stderr, "Problem fetching tag %lu.\n",
roentgen b75cab
			 (unsigned long) field);
roentgen b75cab
		return -1;
roentgen b75cab
	}
roentgen b75cab
	if (tmp != value) {
roentgen b75cab
		fprintf (stderr, "Wrong SHORT value fetched for tag %lu.\n",
roentgen b75cab
			 (unsigned long) field);
roentgen b75cab
		return -1;
roentgen b75cab
	}
roentgen b75cab
roentgen b75cab
	return 0;
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
int
roentgen b75cab
CheckShortPairedField(TIFF *tif, const ttag_t field, const uint16 *values)
roentgen b75cab
{
roentgen b75cab
	uint16 tmp[2] = { 123, 456 };
roentgen b75cab
roentgen b75cab
	if (!TIFFGetField(tif, field, tmp, tmp + 1)) {
roentgen b75cab
		fprintf (stderr, "Problem fetching tag %lu.\n",
roentgen b75cab
			 (unsigned long) field);
roentgen b75cab
		return -1;
roentgen b75cab
	}
roentgen b75cab
	if (tmp[0] != values[0] || tmp[1] != values[1]) {
roentgen b75cab
		fprintf (stderr, "Wrong SHORT PAIR fetched for tag %lu.\n",
roentgen b75cab
			 (unsigned long) field);
roentgen b75cab
		return -1;
roentgen b75cab
	}
roentgen b75cab
roentgen b75cab
	return 0;
roentgen b75cab
}
roentgen b75cab
roentgen b75cab
int
roentgen b75cab
CheckLongField(TIFF *tif, const ttag_t field, const uint32 value)
roentgen b75cab
{
roentgen b75cab
	uint32 tmp = 123;
roentgen b75cab
roentgen b75cab
	if (!TIFFGetField(tif, field, &tmp)) {
roentgen b75cab
		fprintf (stderr, "Problem fetching tag %lu.\n",
roentgen b75cab
			 (unsigned long) field);
roentgen b75cab
		return -1;
roentgen b75cab
	}
roentgen b75cab
	if (tmp != value) {
roentgen b75cab
		fprintf (stderr, "Wrong LONG value fetched for tag %lu.\n",
roentgen b75cab
			 (unsigned long) field);
roentgen b75cab
		return -1;
roentgen b75cab
	}
roentgen b75cab
roentgen b75cab
	return 0;
roentgen b75cab
}
roentgen b75cab
roentgen b75cab