/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.8 2015-12-06 11:13:43 erouault Exp $ */12/*3* Copyright (c) 1988-1997 Sam Leffler4* Copyright (c) 1991-1997 Silicon Graphics, Inc.5*6* Permission to use, copy, modify, distribute, and sell this software and7* its documentation for any purpose is hereby granted without fee, provided8* that (i) the above copyright notices and this permission notice appear in9* all copies of the software and related documentation, and (ii) the names of10* Sam Leffler and Silicon Graphics may not be used in any advertising or11* publicity relating to the software without the specific, prior written12* 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, ANY16* WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.17*18* IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR19* 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 OF22* LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE23* OF THIS SOFTWARE.24*/2526/*27* TIFF Library.28*29* Various routines support external extension of the tag set, and other30* application extension capabilities.31*/3233#include "tiffiop.h"3435int TIFFGetTagListCount( TIFF *tif )3637{38TIFFDirectory* td = &tif->tif_dir;3940return td->td_customValueCount;41}4243uint32 TIFFGetTagListEntry( TIFF *tif, int tag_index )4445{46TIFFDirectory* td = &tif->tif_dir;4748if( tag_index < 0 || tag_index >= td->td_customValueCount )49return (uint32)(-1);50else51return td->td_customValues[tag_index].info->field_tag;52}5354/*55** This provides read/write access to the TIFFTagMethods within the TIFF56** structure to application code without giving access to the private57** TIFF structure.58*/59TIFFTagMethods *TIFFAccessTagMethods( TIFF *tif )6061{62return &(tif->tif_tagmethods);63}6465void *TIFFGetClientInfo( TIFF *tif, const char *name )6667{68TIFFClientInfoLink *psLink = tif->tif_clientinfo;6970while( psLink != NULL && strcmp(psLink->name,name) != 0 )71psLink = psLink->next;7273if( psLink != NULL )74return psLink->data;75else76return NULL;77}7879void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )8081{82TIFFClientInfoLink *psLink = tif->tif_clientinfo;8384/*85** Do we have an existing link with this name? If so, just86** set it.87*/88while( psLink != NULL && strcmp(psLink->name,name) != 0 )89psLink = psLink->next;9091if( psLink != NULL )92{93psLink->data = data;94return;95}9697/*98** Create a new link.99*/100101psLink = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink));102assert (psLink != NULL);103psLink->next = tif->tif_clientinfo;104psLink->name = (char *) _TIFFmalloc((tmsize_t)(strlen(name)+1));105assert (psLink->name != NULL);106strcpy(psLink->name, name);107psLink->data = data;108109tif->tif_clientinfo = psLink;110}111/*112* Local Variables:113* mode: c114* c-basic-offset: 8115* fill-column: 78116* End:117*/118119120