Blame libtiff/tif_extension.c

Packit 7838c8
/* $Header: /cvs/maptools/cvsroot/libtiff/libtiff/tif_extension.c,v 1.8 2015-12-06 11:13:43 erouault Exp $ */
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * Copyright (c) 1988-1997 Sam Leffler
Packit 7838c8
 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
Packit 7838c8
 *
Packit 7838c8
 * Permission to use, copy, modify, distribute, and sell this software and 
Packit 7838c8
 * its documentation for any purpose is hereby granted without fee, provided
Packit 7838c8
 * that (i) the above copyright notices and this permission notice appear in
Packit 7838c8
 * all copies of the software and related documentation, and (ii) the names of
Packit 7838c8
 * Sam Leffler and Silicon Graphics may not be used in any advertising or
Packit 7838c8
 * publicity relating to the software without the specific, prior written
Packit 7838c8
 * permission of Sam Leffler and Silicon Graphics.
Packit 7838c8
 * 
Packit 7838c8
 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
Packit 7838c8
 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
Packit 7838c8
 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
Packit 7838c8
 * 
Packit 7838c8
 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
Packit 7838c8
 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
Packit 7838c8
 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
Packit 7838c8
 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
Packit 7838c8
 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
Packit 7838c8
 * OF THIS SOFTWARE.
Packit 7838c8
 */
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
 * TIFF Library.
Packit 7838c8
 *
Packit 7838c8
 * Various routines support external extension of the tag set, and other
Packit 7838c8
 * application extension capabilities. 
Packit 7838c8
 */
Packit 7838c8
Packit 7838c8
#include "tiffiop.h"
Packit 7838c8
Packit 7838c8
int TIFFGetTagListCount( TIFF *tif )
Packit 7838c8
Packit 7838c8
{
Packit 7838c8
    TIFFDirectory* td = &tif->tif_dir;
Packit 7838c8
    
Packit 7838c8
    return td->td_customValueCount;
Packit 7838c8
}
Packit 7838c8
Packit 7838c8
uint32 TIFFGetTagListEntry( TIFF *tif, int tag_index )
Packit 7838c8
Packit 7838c8
{
Packit 7838c8
    TIFFDirectory* td = &tif->tif_dir;
Packit 7838c8
Packit 7838c8
    if( tag_index < 0 || tag_index >= td->td_customValueCount )
Packit 7838c8
        return (uint32)(-1);
Packit 7838c8
    else
Packit 7838c8
        return td->td_customValues[tag_index].info->field_tag;
Packit 7838c8
}
Packit 7838c8
Packit 7838c8
/*
Packit 7838c8
** This provides read/write access to the TIFFTagMethods within the TIFF
Packit 7838c8
** structure to application code without giving access to the private
Packit 7838c8
** TIFF structure.
Packit 7838c8
*/
Packit 7838c8
TIFFTagMethods *TIFFAccessTagMethods( TIFF *tif )
Packit 7838c8
Packit 7838c8
{
Packit 7838c8
    return &(tif->tif_tagmethods);
Packit 7838c8
}
Packit 7838c8
Packit 7838c8
void *TIFFGetClientInfo( TIFF *tif, const char *name )
Packit 7838c8
Packit 7838c8
{
Packit 7838c8
    TIFFClientInfoLink *psLink = tif->tif_clientinfo;
Packit 7838c8
Packit 7838c8
    while( psLink != NULL && strcmp(psLink->name,name) != 0 )
Packit 7838c8
        psLink = psLink->next;
Packit 7838c8
Packit 7838c8
    if( psLink != NULL )
Packit 7838c8
        return psLink->data;
Packit 7838c8
    else
Packit 7838c8
        return NULL;
Packit 7838c8
}
Packit 7838c8
Packit 7838c8
void TIFFSetClientInfo( TIFF *tif, void *data, const char *name )
Packit 7838c8
Packit 7838c8
{
Packit 7838c8
    TIFFClientInfoLink *psLink = tif->tif_clientinfo;
Packit 7838c8
Packit 7838c8
    /*
Packit 7838c8
    ** Do we have an existing link with this name?  If so, just
Packit 7838c8
    ** set it.
Packit 7838c8
    */
Packit 7838c8
    while( psLink != NULL && strcmp(psLink->name,name) != 0 )
Packit 7838c8
        psLink = psLink->next;
Packit 7838c8
Packit 7838c8
    if( psLink != NULL )
Packit 7838c8
    {
Packit 7838c8
        psLink->data = data;
Packit 7838c8
        return;
Packit 7838c8
    }
Packit 7838c8
Packit 7838c8
    /*
Packit 7838c8
    ** Create a new link.
Packit 7838c8
    */
Packit 7838c8
Packit 7838c8
    psLink = (TIFFClientInfoLink *) _TIFFmalloc(sizeof(TIFFClientInfoLink));
Packit 7838c8
    assert (psLink != NULL);
Packit 7838c8
    psLink->next = tif->tif_clientinfo;
Packit 7838c8
    psLink->name = (char *) _TIFFmalloc((tmsize_t)(strlen(name)+1));
Packit 7838c8
    assert (psLink->name != NULL);
Packit 7838c8
    strcpy(psLink->name, name);
Packit 7838c8
    psLink->data = data;
Packit 7838c8
Packit 7838c8
    tif->tif_clientinfo = psLink;
Packit 7838c8
}
Packit 7838c8
/*
Packit 7838c8
 * Local Variables:
Packit 7838c8
 * mode: c
Packit 7838c8
 * c-basic-offset: 8
Packit 7838c8
 * fill-column: 78
Packit 7838c8
 * End:
Packit 7838c8
 */