ReactOS 0.4.15-dev-8100-g1887773
tif_dirinfo.c File Reference
#include <precomp.h>
Include dependency graph for tif_dirinfo.c:

Go to the source code of this file.

Functions

static voidtd_lfind (const void *key, const void *base, size_t *nmemb, size_t size, int(*compar)(const void *, const void *))
 
const TIFFFieldArray_TIFFGetFields (void)
 
const TIFFFieldArray_TIFFGetExifFields (void)
 
void _TIFFSetupFields (TIFF *tif, const TIFFFieldArray *fieldarray)
 
static int tagCompare (const void *a, const void *b)
 
static int tagNameCompare (const void *a, const void *b)
 
int _TIFFMergeFields (TIFF *tif, const TIFFField info[], uint32 n)
 
void _TIFFPrintFieldInfo (TIFF *tif, FILE *fd)
 
int TIFFDataWidth (TIFFDataType type)
 
int _TIFFDataSize (TIFFDataType type)
 
const TIFFFieldTIFFFindField (TIFF *tif, uint32 tag, TIFFDataType dt)
 
static const TIFFField_TIFFFindFieldByName (TIFF *tif, const char *field_name, TIFFDataType dt)
 
const TIFFFieldTIFFFieldWithTag (TIFF *tif, uint32 tag)
 
const TIFFFieldTIFFFieldWithName (TIFF *tif, const char *field_name)
 
uint32 TIFFFieldTag (const TIFFField *fip)
 
const charTIFFFieldName (const TIFFField *fip)
 
TIFFDataType TIFFFieldDataType (const TIFFField *fip)
 
int TIFFFieldPassCount (const TIFFField *fip)
 
int TIFFFieldReadCount (const TIFFField *fip)
 
int TIFFFieldWriteCount (const TIFFField *fip)
 
const TIFFField_TIFFFindOrRegisterField (TIFF *tif, uint32 tag, TIFFDataType dt)
 
TIFFField_TIFFCreateAnonField (TIFF *tif, uint32 tag, TIFFDataType field_type)
 
static TIFFSetGetFieldType _TIFFSetGetType (TIFFDataType type, short count, unsigned char passcount)
 
int TIFFMergeFieldInfo (TIFF *tif, const TIFFFieldInfo info[], uint32 n)
 
int _TIFFCheckFieldIsValidForCodec (TIFF *tif, ttag_t tag)
 

Variables

static const TIFFFieldArray tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields), (TIFFField*) tiffFields }
 
static const TIFFFieldArray exifFieldArray = { tfiatExif, 0, TIFFArrayCount(exifFields), (TIFFField*) exifFields }
 
static const TIFFField tiffFields []
 
static const TIFFField exifFields []
 

Function Documentation

◆ _TIFFCheckFieldIsValidForCodec()

int _TIFFCheckFieldIsValidForCodec ( TIFF tif,
ttag_t  tag 
)

Definition at line 958 of file tif_dirinfo.c.

959{
960 /* Filter out non-codec specific tags */
961 switch (tag) {
962 /* Shared tags */
964 /* JPEG tags */
966 /* OJPEG tags */
972 case TIFFTAG_JPEGPROC:
974 /* CCITT* */
980 /* LERC */
982 break;
983 default:
984 return 1;
985 }
986 /* Check if codec specific tags are allowed for the current
987 * compression scheme (codec) */
988 switch (tif->tif_dir.td_compression) {
989 case COMPRESSION_LZW:
990 if (tag == TIFFTAG_PREDICTOR)
991 return 1;
992 break;
994 /* No codec-specific tags */
995 break;
997 /* No codec-specific tags */
998 break;
999 case COMPRESSION_NEXT:
1000 /* No codec-specific tags */
1001 break;
1002 case COMPRESSION_JPEG:
1003 if (tag == TIFFTAG_JPEGTABLES)
1004 return 1;
1005 break;
1006 case COMPRESSION_OJPEG:
1007 switch (tag) {
1013 case TIFFTAG_JPEGPROC:
1015 return 1;
1016 }
1017 break;
1022 switch (tag) {
1026 return 1;
1029 return 1;
1030 break;
1033 return 1;
1034 break;
1035 }
1036 break;
1037 case COMPRESSION_JBIG:
1038 /* No codec-specific tags */
1039 break;
1042 if (tag == TIFFTAG_PREDICTOR)
1043 return 1;
1044 break;
1046 if (tag == TIFFTAG_PREDICTOR)
1047 return 1;
1048 break;
1049 case COMPRESSION_SGILOG:
1051 /* No codec-specific tags */
1052 break;
1053 case COMPRESSION_LZMA:
1054 if (tag == TIFFTAG_PREDICTOR)
1055 return 1;
1056 break;
1057 case COMPRESSION_ZSTD:
1058 if (tag == TIFFTAG_PREDICTOR)
1059 return 1;
1060 break;
1061 case COMPRESSION_LERC:
1063 return 1;
1064 break;
1065 case COMPRESSION_WEBP:
1066 if (tag == TIFFTAG_PREDICTOR)
1067 return 1;
1068 break;
1069 }
1070 return 0;
1071}
uint16 td_compression
Definition: tif_dir.h:77
Definition: ecma_167.h:138
TIFFDirectory tif_dir
Definition: tiffiop.h:151
#define COMPRESSION_PIXARLOG
Definition: tiff.h:180
#define COMPRESSION_ZSTD
Definition: tiff.h:192
#define COMPRESSION_CCITTFAX3
Definition: tiff.h:160
#define COMPRESSION_CCITTRLE
Definition: tiff.h:159
#define TIFFTAG_JPEGDCTABLES
Definition: tiff.h:359
#define TIFFTAG_GROUP3OPTIONS
Definition: tiff.h:253
#define TIFFTAG_GROUP4OPTIONS
Definition: tiff.h:258
#define COMPRESSION_OJPEG
Definition: tiff.h:165
#define TIFFTAG_CONSECUTIVEBADFAXLINES
Definition: tiff.h:294
#define COMPRESSION_DEFLATE
Definition: tiff.h:181
#define TIFFTAG_JPEGQTABLES
Definition: tiff.h:358
#define COMPRESSION_SGILOG
Definition: tiff.h:186
#define TIFFTAG_LERC_PARAMETERS
Definition: tiff.h:447
#define COMPRESSION_CCITTRLEW
Definition: tiff.h:170
#define TIFFTAG_JPEGIFBYTECOUNT
Definition: tiff.h:354
#define TIFFTAG_JPEGACTABLES
Definition: tiff.h:360
#define TIFFTAG_JPEGRESTARTINTERVAL
Definition: tiff.h:355
#define COMPRESSION_LZMA
Definition: tiff.h:191
#define COMPRESSION_WEBP
Definition: tiff.h:193
#define COMPRESSION_JBIG
Definition: tiff.h:185
#define COMPRESSION_LERC
Definition: tiff.h:189
#define COMPRESSION_ADOBE_DEFLATE
Definition: tiff.h:182
#define COMPRESSION_PACKBITS
Definition: tiff.h:171
#define COMPRESSION_LZW
Definition: tiff.h:164
#define TIFFTAG_JPEGIFOFFSET
Definition: tiff.h:353
#define TIFFTAG_CLEANFAXDATA
Definition: tiff.h:290
#define COMPRESSION_SGILOG24
Definition: tiff.h:187
#define TIFFTAG_BADFAXLINES
Definition: tiff.h:289
#define TIFFTAG_JPEGPROC
Definition: tiff.h:350
#define COMPRESSION_CCITTFAX4
Definition: tiff.h:162
#define COMPRESSION_NEXT
Definition: tiff.h:169
#define TIFFTAG_PREDICTOR
Definition: tiff.h:277
#define TIFFTAG_JPEGTABLES
Definition: tiff.h:320
#define COMPRESSION_JPEG
Definition: tiff.h:166
#define COMPRESSION_THUNDERSCAN
Definition: tiff.h:172

Referenced by TIFFReadDirectory().

◆ _TIFFCreateAnonField()

TIFFField * _TIFFCreateAnonField ( TIFF tif,
uint32  tag,
TIFFDataType  field_type 
)

Definition at line 634 of file tif_dirinfo.c.

635{
636 TIFFField *fld;
637 (void) tif;
638
639 fld = (TIFFField *) _TIFFmalloc(sizeof (TIFFField));
640 if (fld == NULL)
641 return NULL;
642 _TIFFmemset(fld, 0, sizeof(TIFFField));
643
644 fld->field_tag = tag;
647 fld->field_type = field_type;
648 fld->reserved = 0;
649 switch (field_type)
650 {
651 case TIFF_BYTE:
652 case TIFF_UNDEFINED:
655 break;
656 case TIFF_ASCII:
659 break;
660 case TIFF_SHORT:
663 break;
664 case TIFF_LONG:
667 break;
668 case TIFF_RATIONAL:
669 case TIFF_SRATIONAL:
670 case TIFF_FLOAT:
673 break;
674 case TIFF_SBYTE:
677 break;
678 case TIFF_SSHORT:
681 break;
682 case TIFF_SLONG:
685 break;
686 case TIFF_DOUBLE:
689 break;
690 case TIFF_IFD:
691 case TIFF_IFD8:
694 break;
695 case TIFF_LONG8:
698 break;
699 case TIFF_SLONG8:
702 break;
703 default:
706 break;
707 }
708 fld->field_bit = FIELD_CUSTOM;
709 fld->field_oktochange = TRUE;
710 fld->field_passcount = TRUE;
711 fld->field_name = (char *) _TIFFmalloc(32);
712 if (fld->field_name == NULL) {
713 _TIFFfree(fld);
714 return NULL;
715 }
716 fld->field_subfields = NULL;
717
718 /*
719 * note that this name is a special sign to TIFFClose() and
720 * _TIFFSetupFields() to free the field
721 */
722 (void) snprintf(fld->field_name, 32, "Tag %d", (int) tag);
723
724 return fld;
725}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
uint32 field_tag
Definition: tif_dir.h:283
unsigned char field_oktochange
Definition: tif_dir.h:291
TIFFDataType field_type
Definition: tif_dir.h:286
unsigned char field_passcount
Definition: tif_dir.h:292
char * field_name
Definition: tif_dir.h:293
TIFFSetGetFieldType get_field_type
Definition: tif_dir.h:289
TIFFSetGetFieldType set_field_type
Definition: tif_dir.h:288
unsigned short field_bit
Definition: tif_dir.h:290
short field_readcount
Definition: tif_dir.h:284
uint32 reserved
Definition: tif_dir.h:287
TIFFFieldArray * field_subfields
Definition: tif_dir.h:294
short field_writecount
Definition: tif_dir.h:285
@ TIFF_SETGET_C32_SINT32
Definition: tif_dir.h:249
@ TIFF_SETGET_UNDEFINED
Definition: tif_dir.h:204
@ TIFF_SETGET_C32_ASCII
Definition: tif_dir.h:243
@ TIFF_SETGET_C32_UINT8
Definition: tif_dir.h:244
@ TIFF_SETGET_C32_UINT16
Definition: tif_dir.h:246
@ TIFF_SETGET_C32_SINT16
Definition: tif_dir.h:247
@ TIFF_SETGET_C32_UINT32
Definition: tif_dir.h:248
@ TIFF_SETGET_C32_SINT8
Definition: tif_dir.h:245
@ TIFF_SETGET_C32_IFD8
Definition: tif_dir.h:254
@ TIFF_SETGET_C32_SINT64
Definition: tif_dir.h:251
@ TIFF_SETGET_C32_DOUBLE
Definition: tif_dir.h:253
@ TIFF_SETGET_C32_UINT64
Definition: tif_dir.h:250
@ TIFF_SETGET_C32_FLOAT
Definition: tif_dir.h:252
void _TIFFfree(void *p)
Definition: tif_unix.c:326
void _TIFFmemset(void *p, int v, tmsize_t c)
Definition: tif_unix.c:338
void * _TIFFmalloc(tmsize_t s)
Definition: tif_unix.c:309
@ TIFF_SSHORT
Definition: tiff.h:132
@ TIFF_SLONG
Definition: tiff.h:133
@ TIFF_BYTE
Definition: tiff.h:125
@ TIFF_SBYTE
Definition: tiff.h:130
@ TIFF_IFD
Definition: tiff.h:137
@ TIFF_SHORT
Definition: tiff.h:127
@ TIFF_UNDEFINED
Definition: tiff.h:131
@ TIFF_LONG
Definition: tiff.h:128
@ TIFF_SLONG8
Definition: tiff.h:139
@ TIFF_LONG8
Definition: tiff.h:138
@ TIFF_ASCII
Definition: tiff.h:126
@ TIFF_FLOAT
Definition: tiff.h:135
@ TIFF_DOUBLE
Definition: tiff.h:136
@ TIFF_IFD8
Definition: tiff.h:140
@ TIFF_SRATIONAL
Definition: tiff.h:134
@ TIFF_RATIONAL
Definition: tiff.h:129
#define FIELD_CUSTOM
Definition: tiffio.h:312
#define TIFF_VARIABLE2
Definition: tiffio.h:310
#define snprintf
Definition: wintirpc.h:48

Referenced by _TIFFFindOrRegisterField(), TIFFReadCustomDirectory(), and TIFFReadDirectory().

◆ _TIFFDataSize()

int _TIFFDataSize ( TIFFDataType  type)

Definition at line 476 of file tif_dirinfo.c.

477{
478 switch (type)
479 {
480 case TIFF_BYTE:
481 case TIFF_SBYTE:
482 case TIFF_ASCII:
483 case TIFF_UNDEFINED:
484 return 1;
485 case TIFF_SHORT:
486 case TIFF_SSHORT:
487 return 2;
488 case TIFF_LONG:
489 case TIFF_SLONG:
490 case TIFF_FLOAT:
491 case TIFF_IFD:
492 case TIFF_RATIONAL:
493 case TIFF_SRATIONAL:
494 return 4;
495 case TIFF_DOUBLE:
496 case TIFF_LONG8:
497 case TIFF_SLONG8:
498 case TIFF_IFD8:
499 return 8;
500 default:
501 return 0;
502 }
503}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545

Referenced by _TIFFVSetField(), and TIFFPrintDirectory().

◆ _TIFFFindFieldByName()

static const TIFFField * _TIFFFindFieldByName ( TIFF tif,
const char field_name,
TIFFDataType  dt 
)
static

Definition at line 531 of file tif_dirinfo.c.

532{
533 TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
534 TIFFField* pkey = &key;
535 const TIFFField **ret;
536 if (tif->tif_foundfield
537 && streq(tif->tif_foundfield->field_name, field_name)
538 && (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
539 return (tif->tif_foundfield);
540
541 /* If we are invoked with no field information, then just return. */
542 if (!tif->tif_fields)
543 return NULL;
544
545 /* NB: use linear search since list is sorted by key#, not name */
546
547 key.field_name = (char *)field_name;
548 key.field_type = dt;
549
550 ret = (const TIFFField **)
551 td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields,
552 sizeof(TIFFField *), tagNameCompare);
553
554 return tif->tif_foundfield = (ret ? *ret : NULL);
555}
#define streq(a, b)
Definition: mkg3states.c:46
Definition: copy.c:22
const TIFFField * tif_foundfield
Definition: tiffiop.h:218
size_t tif_nfields
Definition: tiffiop.h:217
TIFFField ** tif_fields
Definition: tiffiop.h:216
static int tagNameCompare(const void *a, const void *b)
Definition: tif_dirinfo.c:355
static void * td_lfind(const void *key, const void *base, size_t *nmemb, size_t size, int(*compar)(const void *, const void *))
Definition: tif_dirinfo.c:291
@ TIFF_NOTYPE
Definition: tiff.h:124
#define TIFF_ANY
Definition: tiffio.h:307
int ret

Referenced by TIFFFieldWithName().

◆ _TIFFFindOrRegisterField()

const TIFFField * _TIFFFindOrRegisterField ( TIFF tif,
uint32  tag,
TIFFDataType  dt 
)

Definition at line 618 of file tif_dirinfo.c.

620{
621 const TIFFField *fld;
622
623 fld = TIFFFindField(tif, tag, dt);
624 if (fld == NULL) {
625 fld = _TIFFCreateAnonField(tif, tag, dt);
626 if (!_TIFFMergeFields(tif, fld, 1))
627 return NULL;
628 }
629
630 return fld;
631}
const TIFFField * TIFFFindField(TIFF *tif, uint32 tag, TIFFDataType dt)
Definition: tif_dirinfo.c:506
TIFFField * _TIFFCreateAnonField(TIFF *tif, uint32 tag, TIFFDataType field_type)
Definition: tif_dirinfo.c:634
int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32 n)
Definition: tif_dirinfo.c:369

◆ _TIFFGetExifFields()

const TIFFFieldArray * _TIFFGetExifFields ( void  )

Definition at line 311 of file tif_dirinfo.c.

312{
313 return(&exifFieldArray);
314}
static const TIFFFieldArray exifFieldArray
Definition: tif_dirinfo.c:49

Referenced by TIFFCreateEXIFDirectory(), and TIFFReadEXIFDirectory().

◆ _TIFFGetFields()

const TIFFFieldArray * _TIFFGetFields ( void  )

Definition at line 305 of file tif_dirinfo.c.

306{
307 return(&tiffFieldArray);
308}
static const TIFFFieldArray tiffFieldArray
Definition: tif_dirinfo.c:48

Referenced by TIFFDefaultDirectory().

◆ _TIFFMergeFields()

int _TIFFMergeFields ( TIFF tif,
const TIFFField  info[],
uint32  n 
)

Definition at line 369 of file tif_dirinfo.c.

370{
371 static const char module[] = "_TIFFMergeFields";
372 static const char reason[] = "for fields array";
373 /* TIFFField** tp; */
374 uint32 i;
375
376 tif->tif_foundfield = NULL;
377
378 if (tif->tif_fields && tif->tif_nfields > 0) {
379 tif->tif_fields = (TIFFField**)
381 (tif->tif_nfields + n),
382 sizeof(TIFFField *), reason);
383 } else {
384 tif->tif_fields = (TIFFField **)
385 _TIFFCheckMalloc(tif, n, sizeof(TIFFField *),
386 reason);
387 }
388 if (!tif->tif_fields) {
390 "Failed to allocate fields array");
391 return 0;
392 }
393
394 /* tp = tif->tif_fields + tif->tif_nfields; */
395 for (i = 0; i < n; i++) {
396 const TIFFField *fip =
397 TIFFFindField(tif, info[i].field_tag, TIFF_ANY);
398
399 /* only add definitions that aren't already present */
400 if (!fip) {
401 tif->tif_fields[tif->tif_nfields] = (TIFFField *) (info+i);
402 tif->tif_nfields++;
403 }
404 }
405
406 /* Sort the field info by tag number */
407 qsort(tif->tif_fields, tif->tif_nfields,
408 sizeof(TIFFField *), tagCompare);
409
410 return n;
411}
unsigned int uint32
Definition: types.h:32
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
GLdouble n
Definition: glext.h:7729
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
thandle_t tif_clientdata
Definition: tiffiop.h:207
void * _TIFFCheckRealloc(TIFF *tif, void *buffer, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Definition: tif_aux.c:97
void * _TIFFCheckMalloc(TIFF *tif, tmsize_t nmemb, tmsize_t elem_size, const char *what)
Definition: tif_aux.c:121
static int tagCompare(const void *a, const void *b)
Definition: tif_dirinfo.c:342
void TIFFErrorExt(thandle_t fd, const char *module, const char *fmt,...)
Definition: tif_error.c:65

Referenced by _TIFFFindOrRegisterField(), _TIFFSetupFields(), TIFFMergeFieldInfo(), TIFFPredictorInit(), TIFFReadCustomDirectory(), and TIFFReadDirectory().

◆ _TIFFPrintFieldInfo()

void _TIFFPrintFieldInfo ( TIFF tif,
FILE fd 
)

Definition at line 414 of file tif_dirinfo.c.

415{
416 uint32 i;
417
418 fprintf(fd, "%s: \n", tif->tif_name);
419 for (i = 0; i < tif->tif_nfields; i++) {
420 const TIFFField* fip = tif->tif_fields[i];
421 fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n"
422 , (int)i
423 , (unsigned long) fip->field_tag
425 , fip->field_type
426 , fip->field_bit
427 , fip->field_oktochange ? "TRUE" : "FALSE"
428 , fip->field_passcount ? "TRUE" : "FALSE"
429 , fip->field_name
430 );
431 }
432}
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
static int fd
Definition: io.c:51
char * tif_name
Definition: tiffiop.h:116

◆ _TIFFSetGetType()

static TIFFSetGetFieldType _TIFFSetGetType ( TIFFDataType  type,
short  count,
unsigned char  passcount 
)
static

Definition at line 735 of file tif_dirinfo.c.

736{
737 if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0)
738 return TIFF_SETGET_ASCII;
739
740 else if (count == 1 && passcount == 0) {
741 switch (type)
742 {
743 case TIFF_BYTE:
744 case TIFF_UNDEFINED:
745 return TIFF_SETGET_UINT8;
746 case TIFF_ASCII:
747 return TIFF_SETGET_ASCII;
748 case TIFF_SHORT:
749 return TIFF_SETGET_UINT16;
750 case TIFF_LONG:
751 return TIFF_SETGET_UINT32;
752 case TIFF_RATIONAL:
753 case TIFF_SRATIONAL:
754 case TIFF_FLOAT:
755 return TIFF_SETGET_FLOAT;
756 case TIFF_SBYTE:
757 return TIFF_SETGET_SINT8;
758 case TIFF_SSHORT:
759 return TIFF_SETGET_SINT16;
760 case TIFF_SLONG:
761 return TIFF_SETGET_SINT32;
762 case TIFF_DOUBLE:
763 return TIFF_SETGET_DOUBLE;
764 case TIFF_IFD:
765 case TIFF_IFD8:
766 return TIFF_SETGET_IFD8;
767 case TIFF_LONG8:
768 return TIFF_SETGET_UINT64;
769 case TIFF_SLONG8:
770 return TIFF_SETGET_SINT64;
771 default:
773 }
774 }
775
776 else if (count >= 1 && passcount == 0) {
777 switch (type)
778 {
779 case TIFF_BYTE:
780 case TIFF_UNDEFINED:
782 case TIFF_ASCII:
784 case TIFF_SHORT:
786 case TIFF_LONG:
788 case TIFF_RATIONAL:
789 case TIFF_SRATIONAL:
790 case TIFF_FLOAT:
792 case TIFF_SBYTE:
794 case TIFF_SSHORT:
796 case TIFF_SLONG:
798 case TIFF_DOUBLE:
800 case TIFF_IFD:
801 case TIFF_IFD8:
802 return TIFF_SETGET_C0_IFD8;
803 case TIFF_LONG8:
805 case TIFF_SLONG8:
807 default:
809 }
810 }
811
812 else if (count == TIFF_VARIABLE && passcount == 1) {
813 switch (type)
814 {
815 case TIFF_BYTE:
816 case TIFF_UNDEFINED:
818 case TIFF_ASCII:
820 case TIFF_SHORT:
822 case TIFF_LONG:
824 case TIFF_RATIONAL:
825 case TIFF_SRATIONAL:
826 case TIFF_FLOAT:
828 case TIFF_SBYTE:
830 case TIFF_SSHORT:
832 case TIFF_SLONG:
834 case TIFF_DOUBLE:
836 case TIFF_IFD:
837 case TIFF_IFD8:
839 case TIFF_LONG8:
841 case TIFF_SLONG8:
843 default:
845 }
846 }
847
848 else if (count == TIFF_VARIABLE2 && passcount == 1) {
849 switch (type)
850 {
851 case TIFF_BYTE:
852 case TIFF_UNDEFINED:
854 case TIFF_ASCII:
856 case TIFF_SHORT:
858 case TIFF_LONG:
860 case TIFF_RATIONAL:
861 case TIFF_SRATIONAL:
862 case TIFF_FLOAT:
864 case TIFF_SBYTE:
866 case TIFF_SSHORT:
868 case TIFF_SLONG:
870 case TIFF_DOUBLE:
872 case TIFF_IFD:
873 case TIFF_IFD8:
875 case TIFF_LONG8:
877 case TIFF_SLONG8:
879 default:
881 }
882 }
883
885}
GLuint GLuint GLsizei count
Definition: gl.h:1545
@ TIFF_SETGET_C16_UINT8
Definition: tif_dir.h:232
@ TIFF_SETGET_C0_SINT64
Definition: tif_dir.h:227
@ TIFF_SETGET_DOUBLE
Definition: tif_dir.h:215
@ TIFF_SETGET_SINT64
Definition: tif_dir.h:213
@ TIFF_SETGET_C16_FLOAT
Definition: tif_dir.h:240
@ TIFF_SETGET_SINT8
Definition: tif_dir.h:207
@ TIFF_SETGET_IFD8
Definition: tif_dir.h:216
@ TIFF_SETGET_C16_DOUBLE
Definition: tif_dir.h:241
@ TIFF_SETGET_UINT64
Definition: tif_dir.h:212
@ TIFF_SETGET_C0_UINT32
Definition: tif_dir.h:224
@ TIFF_SETGET_C16_UINT32
Definition: tif_dir.h:236
@ TIFF_SETGET_C16_UINT16
Definition: tif_dir.h:234
@ TIFF_SETGET_C16_SINT64
Definition: tif_dir.h:239
@ TIFF_SETGET_C0_FLOAT
Definition: tif_dir.h:228
@ TIFF_SETGET_C0_SINT32
Definition: tif_dir.h:225
@ TIFF_SETGET_C16_UINT64
Definition: tif_dir.h:238
@ TIFF_SETGET_C0_ASCII
Definition: tif_dir.h:219
@ TIFF_SETGET_UINT16
Definition: tif_dir.h:208
@ TIFF_SETGET_C16_SINT16
Definition: tif_dir.h:235
@ TIFF_SETGET_C0_UINT8
Definition: tif_dir.h:220
@ TIFF_SETGET_ASCII
Definition: tif_dir.h:205
@ TIFF_SETGET_C0_SINT8
Definition: tif_dir.h:221
@ TIFF_SETGET_C16_SINT8
Definition: tif_dir.h:233
@ TIFF_SETGET_C0_UINT64
Definition: tif_dir.h:226
@ TIFF_SETGET_FLOAT
Definition: tif_dir.h:214
@ TIFF_SETGET_C16_SINT32
Definition: tif_dir.h:237
@ TIFF_SETGET_SINT16
Definition: tif_dir.h:209
@ TIFF_SETGET_C0_SINT16
Definition: tif_dir.h:223
@ TIFF_SETGET_UINT32
Definition: tif_dir.h:210
@ TIFF_SETGET_C16_ASCII
Definition: tif_dir.h:231
@ TIFF_SETGET_UINT8
Definition: tif_dir.h:206
@ TIFF_SETGET_C0_UINT16
Definition: tif_dir.h:222
@ TIFF_SETGET_C0_IFD8
Definition: tif_dir.h:230
@ TIFF_SETGET_C16_IFD8
Definition: tif_dir.h:242
@ TIFF_SETGET_SINT32
Definition: tif_dir.h:211
@ TIFF_SETGET_C0_DOUBLE
Definition: tif_dir.h:229
#define TIFF_VARIABLE
Definition: tiffio.h:308

Referenced by TIFFMergeFieldInfo().

◆ _TIFFSetupFields()

void _TIFFSetupFields ( TIFF tif,
const TIFFFieldArray fieldarray 
)

Definition at line 317 of file tif_dirinfo.c.

318{
319 if (tif->tif_fields && tif->tif_nfields > 0) {
320 uint32 i;
321
322 for (i = 0; i < tif->tif_nfields; i++) {
323 TIFFField *fld = tif->tif_fields[i];
324 if (fld->field_bit == FIELD_CUSTOM &&
325 strncmp("Tag ", fld->field_name, 4) == 0) {
326 _TIFFfree(fld->field_name);
327 _TIFFfree(fld);
328 }
329 }
330
331 _TIFFfree(tif->tif_fields);
332 tif->tif_fields = NULL;
333 tif->tif_nfields = 0;
334 }
335 if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count)) {
336 TIFFErrorExt(tif->tif_clientdata, "_TIFFSetupFields",
337 "Setting up field info failed");
338 }
339}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
TIFFField * fields
Definition: tif_dir.h:279
uint32 count
Definition: tif_dir.h:278

Referenced by TIFFCreateCustomDirectory(), TIFFDefaultDirectory(), and TIFFReadCustomDirectory().

◆ tagCompare()

static int tagCompare ( const void a,
const void b 
)
static

Definition at line 342 of file tif_dirinfo.c.

343{
344 const TIFFField* ta = *(const TIFFField**) a;
345 const TIFFField* tb = *(const TIFFField**) b;
346 /* NB: be careful of return values for 16-bit platforms */
347 if (ta->field_tag != tb->field_tag)
348 return (int)ta->field_tag - (int)tb->field_tag;
349 else
350 return (ta->field_type == TIFF_ANY) ?
351 0 : ((int)tb->field_type - (int)ta->field_type);
352}
return
Definition: dirsup.c:529
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
static const WCHAR tb[]
Definition: suminfo.c:285

Referenced by _TIFFMergeFields(), and TIFFFindField().

◆ tagNameCompare()

static int tagNameCompare ( const void a,
const void b 
)
static

Definition at line 355 of file tif_dirinfo.c.

356{
357 const TIFFField* ta = *(const TIFFField**) a;
358 const TIFFField* tb = *(const TIFFField**) b;
359 int ret = strcmp(ta->field_name, tb->field_name);
360
361 if (ret)
362 return ret;
363 else
364 return (ta->field_type == TIFF_ANY) ?
365 0 : ((int)tb->field_type - (int)ta->field_type);
366}
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469

Referenced by _TIFFFindFieldByName().

◆ td_lfind()

static void * td_lfind ( const void key,
const void base,
size_t nmemb,
size_t  size,
int(*)(const void *, const void *)  compar 
)
static

Definition at line 291 of file tif_dirinfo.c.

293{
294 char *element, *end;
295
296 end = (char *)base + *nmemb * size;
297 for (element = (char *)base; element < end; element += size)
298 if (!compar(key, element)) /* key found */
299 return element;
300
301 return NULL;
302}
GLuint GLuint end
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919

Referenced by _TIFFFindFieldByName().

◆ TIFFDataWidth()

int TIFFDataWidth ( TIFFDataType  type)

Definition at line 438 of file tif_dirinfo.c.

439{
440 switch(type)
441 {
442 case 0: /* nothing */
443 case TIFF_BYTE:
444 case TIFF_ASCII:
445 case TIFF_SBYTE:
446 case TIFF_UNDEFINED:
447 return 1;
448 case TIFF_SHORT:
449 case TIFF_SSHORT:
450 return 2;
451 case TIFF_LONG:
452 case TIFF_SLONG:
453 case TIFF_FLOAT:
454 case TIFF_IFD:
455 return 4;
456 case TIFF_RATIONAL:
457 case TIFF_SRATIONAL:
458 case TIFF_DOUBLE:
459 case TIFF_LONG8:
460 case TIFF_SLONG8:
461 case TIFF_IFD8:
462 return 8;
463 default:
464 return 0; /* will return 0 for unknown types */
465 }
466}

Referenced by _TIFFRewriteField(), EstimateStripByteCounts(), and TIFFReadDirEntryArrayWithLimit().

◆ TIFFFieldDataType()

TIFFDataType TIFFFieldDataType ( const TIFFField fip)

Definition at line 594 of file tif_dirinfo.c.

595{
596 return fip->field_type;
597}

◆ TIFFFieldName()

const char * TIFFFieldName ( const TIFFField fip)

Definition at line 588 of file tif_dirinfo.c.

589{
590 return fip->field_name;
591}

◆ TIFFFieldPassCount()

int TIFFFieldPassCount ( const TIFFField fip)

Definition at line 600 of file tif_dirinfo.c.

601{
602 return fip->field_passcount;
603}

◆ TIFFFieldReadCount()

int TIFFFieldReadCount ( const TIFFField fip)

Definition at line 606 of file tif_dirinfo.c.

607{
608 return fip->field_readcount;
609}

◆ TIFFFieldTag()

uint32 TIFFFieldTag ( const TIFFField fip)

Definition at line 582 of file tif_dirinfo.c.

583{
584 return fip->field_tag;
585}

Referenced by TIFFWriteDirectorySec().

◆ TIFFFieldWithName()

const TIFFField * TIFFFieldWithName ( TIFF tif,
const char field_name 
)

Definition at line 570 of file tif_dirinfo.c.

571{
572 const TIFFField* fip =
573 _TIFFFindFieldByName(tif, field_name, TIFF_ANY);
574 if (!fip) {
575 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithName",
576 "Internal error, unknown tag %s", field_name);
577 }
578 return (fip);
579}
static const TIFFField * _TIFFFindFieldByName(TIFF *tif, const char *field_name, TIFFDataType dt)
Definition: tif_dirinfo.c:531

◆ TIFFFieldWithTag()

const TIFFField * TIFFFieldWithTag ( TIFF tif,
uint32  tag 
)

Definition at line 558 of file tif_dirinfo.c.

559{
560 const TIFFField* fip = TIFFFindField(tif, tag, TIFF_ANY);
561 if (!fip) {
562 TIFFErrorExt(tif->tif_clientdata, "TIFFFieldWithTag",
563 "Internal error, unknown tag 0x%x",
564 (unsigned int) tag);
565 }
566 return (fip);
567}

Referenced by _TIFFVSetField(), CheckDirCount(), TIFFFetchStripThing(), TIFFPrintDirectory(), TIFFReadDirectory(), and TIFFUnsetField().

◆ TIFFFieldWriteCount()

int TIFFFieldWriteCount ( const TIFFField fip)

Definition at line 612 of file tif_dirinfo.c.

613{
614 return fip->field_writecount;
615}

◆ TIFFFindField()

const TIFFField * TIFFFindField ( TIFF tif,
uint32  tag,
TIFFDataType  dt 
)

Definition at line 506 of file tif_dirinfo.c.

507{
508 TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, 0, NULL, NULL};
509 TIFFField* pkey = &key;
510 const TIFFField **ret;
511 if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
512 (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
513 return tif->tif_foundfield;
514
515 /* If we are invoked with no field information, then just return. */
516 if (!tif->tif_fields)
517 return NULL;
518
519 /* NB: use sorted search (e.g. binary search) */
520
521 key.field_tag = tag;
522 key.field_type = dt;
523
524 ret = (const TIFFField **) bsearch(&pkey, tif->tif_fields,
525 tif->tif_nfields,
526 sizeof(TIFFField *), tagCompare);
527 return tif->tif_foundfield = (ret ? *ret : NULL);
528}
#define bsearch

Referenced by _TIFFFindOrRegisterField(), _TIFFMergeFields(), _TIFFRewriteField(), _TIFFVGetField(), _TIFFVSetField(), OkToChangeTag(), TIFFFieldWithTag(), and TIFFVGetField().

◆ TIFFMergeFieldInfo()

int TIFFMergeFieldInfo ( TIFF tif,
const TIFFFieldInfo  info[],
uint32  n 
)

Definition at line 888 of file tif_dirinfo.c.

889{
890 static const char module[] = "TIFFMergeFieldInfo";
891 static const char reason[] = "for fields array";
892 TIFFField *tp;
893 size_t nfields;
894 uint32 i;
895
896 if (tif->tif_nfieldscompat > 0) {
899 tif->tif_nfieldscompat + 1,
900 sizeof(TIFFFieldArray), reason);
901 } else {
903 _TIFFCheckMalloc(tif, 1, sizeof(TIFFFieldArray),
904 reason);
905 }
906 if (!tif->tif_fieldscompat) {
908 "Failed to allocate fields array");
909 return -1;
910 }
911 nfields = tif->tif_nfieldscompat++;
912
913 tif->tif_fieldscompat[nfields].type = tfiatOther;
914 tif->tif_fieldscompat[nfields].allocated_size = n;
915 tif->tif_fieldscompat[nfields].count = n;
916 tif->tif_fieldscompat[nfields].fields =
917 (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField),
918 reason);
919 if (!tif->tif_fieldscompat[nfields].fields) {
921 "Failed to allocate fields array");
922 return -1;
923 }
924
925 tp = tif->tif_fieldscompat[nfields].fields;
926 for (i = 0; i < n; i++) {
927 tp->field_tag = info[i].field_tag;
928 tp->field_readcount = info[i].field_readcount;
929 tp->field_writecount = info[i].field_writecount;
930 tp->field_type = info[i].field_type;
931 tp->reserved = 0;
932 tp->set_field_type =
933 _TIFFSetGetType(info[i].field_type,
934 info[i].field_readcount,
935 info[i].field_passcount);
936 tp->get_field_type =
937 _TIFFSetGetType(info[i].field_type,
938 info[i].field_readcount,
939 info[i].field_passcount);
940 tp->field_bit = info[i].field_bit;
941 tp->field_oktochange = info[i].field_oktochange;
942 tp->field_passcount = info[i].field_passcount;
943 tp->field_name = info[i].field_name;
944 tp->field_subfields = NULL;
945 tp++;
946 }
947
948 if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n)) {
950 "Setting up field info failed");
951 return -1;
952 }
953
954 return 0;
955}
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
TIFFFieldArrayType type
Definition: tif_dir.h:276
uint32 allocated_size
Definition: tif_dir.h:277
size_t tif_nfieldscompat
Definition: tiffiop.h:224
TIFFFieldArray * tif_fieldscompat
Definition: tiffiop.h:223
@ tfiatOther
Definition: tif_dir.h:272
static TIFFSetGetFieldType _TIFFSetGetType(TIFFDataType type, short count, unsigned char passcount)
Definition: tif_dirinfo.c:735

Variable Documentation

◆ exifFieldArray

static const TIFFFieldArray exifFieldArray = { tfiatExif, 0, TIFFArrayCount(exifFields), (TIFFField*) exifFields }
static

◆ exifFields

const TIFFField exifFields[]
static

Definition at line 221 of file tif_dirinfo.c.

◆ tiffFieldArray

static const TIFFFieldArray tiffFieldArray = { tfiatImage, 0, TIFFArrayCount(tiffFields), (TIFFField*) tiffFields }
static

Definition at line 48 of file tif_dirinfo.c.

Referenced by _TIFFGetFields(), and TIFFDefaultDirectory().

◆ tiffFields

const TIFFField tiffFields[]
static

Definition at line 55 of file tif_dirinfo.c.