/* Return 1/0 according to whether or not it is permissible to set the tag's value. Note that we allow ImageLength to be changed so that we can append and extend to images. Any other tag may not be altered once writing has commenced, unless its value has no effect on the format of the data that is written.  */
static int OkToChangeTag(TIFF *tif, uint32 tag)
/* Return 1/0 according to whether or not it is permissible to set the tag's value. Note that we allow ImageLength to be changed so that we can append and extend to images. Any other tag may not be altered once writing has commenced, unless its value has no effect on the format of the data that is written.  */
static int OkToChangeTag(TIFF *tif, uint32 tag)
{
	const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
	if (!fip) {
		TIFFErrorExt(tif->tif_clientdata, "TIFFSetField", "%s: Unknown %stag %u",
		    tif->tif_name, isPseudoTag(tag) ? "pseudo-" : "", tag);
		return (0);
	}
	if (tag != TIFFTAG_IMAGELENGTH && (tif->tif_flags & TIFF_BEENWRITING) &&
	    !fip->field_oktochange) {
		TIFFErrorExt(tif->tif_clientdata, "TIFFSetField",
		    "%s: Cannot modify tag \"%s\" while writing",
		    tif->tif_name, fip->field_name);
		return (0);
	}
	return (1);
}