|
roentgen |
b75cab |
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.7 2010-03-10 18:56:48 bfriesen Exp $ */
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* Copyright (c) 1988-1997 Sam Leffler
|
|
roentgen |
b75cab |
* Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
|
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 |
* Various routines support external extension of the tag set, and other
|
|
roentgen |
b75cab |
* application extension capabilities.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
#include "tiffiop.h"
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
int TIFFGetTagListCount( TIFF *tif )
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
TIFFDirectory* td = &tif->tif_dir;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
return td->td_customValueCount;
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
uint32 TIFFGetTagListEntry( TIFF *tif, int tag_index )
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
TIFFDirectory* td = &tif->tif_dir;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
if( tag_index < 0 || tag_index >= td->td_customValueCount )
|
|
roentgen |
b75cab |
return (uint32)(-1);
|
|
roentgen |
b75cab |
else
|
|
roentgen |
b75cab |
return td->td_customValues[tag_index].info->field_tag;
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
** This provides read/write access to the TIFFTagMethods within the TIFF
|
|
roentgen |
b75cab |
** structure to application code without giving access to the private
|
|
roentgen |
b75cab |
** TIFF structure.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
TIFFTagMethods *TIFFAccessTagMethods( TIFF *tif )
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
return &(tif->tif_tagmethods);
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
void *TIFFGetClientInfo( TIFF *tif, const char *name )
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
TIFFClientInfoLink *link = tif->tif_clientinfo;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
while( link != NULL && strcmp(link->name,name) != 0 )
|
|
roentgen |
b75cab |
link = link->next;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
if( link != NULL )
|
|
roentgen |
b75cab |
return link->data;
|
|
roentgen |
b75cab |
else
|
|
roentgen |
b75cab |
return NULL;
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
TIFFClientInfoLink *link = tif->tif_clientinfo;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
** Do we have an existing link with this name? If so, just
|
|
roentgen |
b75cab |
** set it.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
while( link != NULL && strcmp(link->name,name) != 0 )
|
|
roentgen |
b75cab |
link = link->next;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
if( link != NULL )
|
|
roentgen |
b75cab |
{
|
|
roentgen |
b75cab |
link->data = data;
|
|
roentgen |
b75cab |
return;
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
** Create a new link.
|
|
roentgen |
b75cab |
*/
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
link = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink));
|
|
roentgen |
b75cab |
assert (link != NULL);
|
|
roentgen |
b75cab |
link->next = tif->tif_clientinfo;
|
|
roentgen |
b75cab |
link->name = (char *) _TIFFmalloc((tmsize_t)(strlen(name)+1));
|
|
roentgen |
b75cab |
assert (link->name != NULL);
|
|
roentgen |
b75cab |
strcpy(link->name, name);
|
|
roentgen |
b75cab |
link->data = data;
|
|
roentgen |
b75cab |
|
|
roentgen |
b75cab |
tif->tif_clientinfo = link;
|
|
roentgen |
b75cab |
}
|
|
roentgen |
b75cab |
/*
|
|
roentgen |
b75cab |
* Local Variables:
|
|
roentgen |
b75cab |
* mode: c
|
|
roentgen |
b75cab |
* c-basic-offset: 8
|
|
roentgen |
b75cab |
* fill-column: 78
|
|
roentgen |
b75cab |
* End:
|
|
roentgen |
b75cab |
*/
|