LibTIFF 4.7.2
TIFF library public API and implementation reference
Loading...
Searching...
No Matches
tif_extension.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 1988-1997 Sam Leffler
3 * Copyright (c) 1991-1997 Silicon Graphics, Inc.
4 *
5 * Permission to use, copy, modify, distribute, and sell this software and
6 * its documentation for any purpose is hereby granted without fee, provided
7 * that (i) the above copyright notices and this permission notice appear in
8 * all copies of the software and related documentation, and (ii) the names of
9 * Sam Leffler and Silicon Graphics may not be used in any advertising or
10 * publicity relating to the software without the specific, prior written
11 * permission of Sam Leffler and Silicon Graphics.
12 *
13 * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
14 * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
15 * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16 *
17 * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
18 * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
19 * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
20 * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
21 * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
22 * OF THIS SOFTWARE.
23 */
24
25/*
26 * TIFF Library.
27 *
28 * Various routines support external extension of the tag set, and other
29 * application extension capabilities.
30 */
31
37#include "tiffiop.h"
38
40
41{
42 TIFFDirectory *td = &tif->tif_dir;
43
44 return td->td_customValueCount;
45}
46
47uint32_t TIFFGetTagListEntry(TIFF *tif, int tag_index)
48
49{
50 TIFFDirectory *td = &tif->tif_dir;
51
52 if (tag_index < 0 || tag_index >= td->td_customValueCount)
53 return (uint32_t)(-1);
54 else
55 return td->td_customValues[tag_index].info->field_tag;
56}
57
58/*
59** This provides read/write access to the TIFFTagMethods within the TIFF
60** structure to application code without giving access to the private
61** TIFF structure.
62*/
64
65{
66 return &(tif->tif_tagmethods);
67}
68
69void *TIFFGetClientInfo(TIFF *tif, const char *name)
70
71{
73
74 while (psLink != NULL && strcmp(psLink->name, name) != 0)
75 psLink = psLink->next;
76
77 if (psLink != NULL)
78 return psLink->data;
79 else
80 return NULL;
81}
82
83void TIFFSetClientInfo(TIFF *tif, void *data, const char *name)
84
85{
87 size_t name_len = strlen(name) + 1;
88
89 /*
90 ** Do we have an existing link with this name? If so, just
91 ** set it.
92 */
93 while (psLink != NULL && strcmp(psLink->name, name) != 0)
94 psLink = psLink->next;
95
96 if (psLink != NULL)
97 {
98 psLink->data = data;
99 return;
100 }
101
102 /*
103 ** Create a new link.
104 */
105
107 tif, 1, sizeof(TIFFClientInfoLink), "client info link");
108 if (psLink == NULL)
109 return;
110 psLink->next = tif->tif_clientinfo;
111 psLink->name = (char *)_TIFFCheckMalloc(tif, (tmsize_t)name_len,
112 sizeof(char), "client info name");
113 if (psLink->name == NULL)
114 {
115 _TIFFfreeExt(tif, psLink);
116 return;
117 }
118 _TIFFmemcpy(psLink->name, name, (tmsize_t)name_len);
119 psLink->data = data;
120
121 tif->tif_clientinfo = psLink;
122}
void _TIFFfreeExt(TIFF *tif, void *p)
Release a handle-aware allocation and its payload charge.
Definition tif_open.c:301
void * _TIFFCheckMalloc(TIFF *tif, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Allocate a checked array with an allocation-failure diagnostic.
Definition tif_aux.c:274
void TIFFSetClientInfo(TIFF *tif, void *data, const char *name)
Add or replace a handle-local named borrowed payload.
void * TIFFGetClientInfo(TIFF *tif, const char *name)
Look up a borrowed payload by its handle-local name.
uint32_t TIFFGetTagListEntry(TIFF *tif, int tag_index)
Look up a tag number by its custom-value list index.
int TIFFGetTagListCount(TIFF *tif)
Count values stored in the current custom-tag list.
TIFFTagMethods * TIFFAccessTagMethods(TIFF *tif)
Expose a handle's mutable tag-method table.
void _TIFFmemcpy(void *d, const void *s, tmsize_t c)
Copy a non-overlapping byte range.
Definition tif_unix.c:497
TIFF_SSIZE_T tmsize_t
Represent a signed memory or I/O size in bytes.
Definition tiffio.h:89
Store the current directory values and image traversal state.
Definition tif_dir.h:143
int td_customValueCount
Number of live records in td_customValues, including partial setter entries.
Definition tif_dir.h:346
TIFFTagValue * td_customValues
Owned array of custom-value records, each owning its value.
Definition tif_dir.h:348
Collect a handle's tag-access and directory-print callbacks.
Definition tiffio.h:1573
const TIFFField * info
Borrowed live descriptor; must outlive this custom value.
Definition tif_dir.h:48
uint32_t field_tag
Tag identifier in this schema namespace.
Definition tif_dir.h:995
Link a named client-data association to a TIFF handle.
Definition tiffiop.h:148
void * data
Borrowed client payload; the library does not free it.
Definition tiffiop.h:152
struct client_info * next
Next handle-owned association node, or NULL.
Definition tiffiop.h:150
char * name
Owned copy of the null-terminated association name.
Definition tiffiop.h:154
Hold private state for one open TIFF library instance.
Definition tiffiop.h:389
TIFFTagMethods tif_tagmethods
Inline table of directory field and print callbacks.
Definition tiffiop.h:742
TIFFClientInfoLink * tif_clientinfo
Head of the owned named-association list; payloads remain borrowed.
Definition tiffiop.h:747
TIFFDirectory tif_dir
Inline representation of the current image directory.
Definition tiffiop.h:572
Declare private library state, callbacks, and implementation helpers.