ReactOS 0.4.16-dev-2617-g01a0906
tif_dirinfo.c File Reference
#include "tiffiop.h"
#include <stdlib.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)
 
const TIFFFieldArray_TIFFGetGpsFields (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_t n)
 
void _TIFFPrintFieldInfo (TIFF *tif, FILE *fd)
 
int TIFFDataWidth (TIFFDataType type)
 
int TIFFFieldSetGetSize (const TIFFField *fip)
 
int TIFFFieldSetGetCountSize (const TIFFField *fip)
 
const TIFFFieldTIFFFindField (TIFF *tif, uint32_t tag, TIFFDataType dt)
 
static const TIFFField_TIFFFindFieldByName (TIFF *tif, const char *field_name, TIFFDataType dt)
 
const TIFFFieldTIFFFieldWithTag (TIFF *tif, uint32_t tag)
 
const TIFFFieldTIFFFieldWithName (TIFF *tif, const char *field_name)
 
uint32_t 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)
 
int TIFFFieldIsAnonymous (const TIFFField *fip)
 
const TIFFField_TIFFFindOrRegisterField (TIFF *tif, uint32_t tag, TIFFDataType dt)
 
TIFFField_TIFFCreateAnonField (TIFF *tif, uint32_t tag, TIFFDataType field_type)
 
static TIFFSetGetFieldType _TIFFSetGetType (TIFFDataType type, short count, unsigned char passcount)
 
int TIFFMergeFieldInfo (TIFF *tif, const TIFFFieldInfo info[], uint32_t n)
 
int _TIFFCheckFieldIsValidForCodec (TIFF *tif, ttag_t tag)
 

Variables

static const TIFFFieldArray tiffFieldArray
 
static const TIFFFieldArray exifFieldArray
 
static const TIFFFieldArray gpsFieldArray
 
static const TIFFField tiffFields []
 
static const TIFFField exifFields []
 
static const TIFFField gpsFields []
 

Function Documentation

◆ _TIFFCheckFieldIsValidForCodec()

int _TIFFCheckFieldIsValidForCodec ( TIFF tif,
ttag_t  tag 
)

Definition at line 1247 of file tif_dirinfo.c.

1248{
1249 /* Filter out non-codec specific tags */
1250 switch (tag)
1251 {
1252 /* Shared tags */
1253 case TIFFTAG_PREDICTOR:
1254 /* JPEG tags */
1255 case TIFFTAG_JPEGTABLES:
1256 /* OJPEG tags */
1262 case TIFFTAG_JPEGPROC:
1264 /* CCITT* */
1270 /* LERC */
1272 break;
1273 default:
1274 return 1;
1275 }
1277 {
1278 return 0;
1279 }
1280 /* Check if codec specific tags are allowed for the current
1281 * compression scheme (codec) */
1282 switch (tif->tif_dir.td_compression)
1283 {
1284 case COMPRESSION_LZW:
1285 if (tag == TIFFTAG_PREDICTOR)
1286 return 1;
1287 break;
1289 /* No codec-specific tags */
1290 break;
1292 /* No codec-specific tags */
1293 break;
1294 case COMPRESSION_NEXT:
1295 /* No codec-specific tags */
1296 break;
1297 case COMPRESSION_JPEG:
1298 if (tag == TIFFTAG_JPEGTABLES)
1299 return 1;
1300 break;
1301 case COMPRESSION_OJPEG:
1302 switch (tag)
1303 {
1309 case TIFFTAG_JPEGPROC:
1311 return 1;
1312 }
1313 break;
1318 switch (tag)
1319 {
1323 return 1;
1326 return 1;
1327 break;
1330 return 1;
1331 break;
1332 }
1333 break;
1334 case COMPRESSION_JBIG:
1335 /* No codec-specific tags */
1336 break;
1339 if (tag == TIFFTAG_PREDICTOR)
1340 return 1;
1341 break;
1343 if (tag == TIFFTAG_PREDICTOR)
1344 return 1;
1345 break;
1346 case COMPRESSION_SGILOG:
1348 /* No codec-specific tags */
1349 break;
1350 case COMPRESSION_LZMA:
1351 if (tag == TIFFTAG_PREDICTOR)
1352 return 1;
1353 break;
1354 case COMPRESSION_ZSTD:
1355 if (tag == TIFFTAG_PREDICTOR)
1356 return 1;
1357 break;
1358 case COMPRESSION_LERC:
1360 return 1;
1361 break;
1362 }
1363 return 0;
1364}
uint16_t td_compression
Definition: tif_dir.h:88
Definition: ecma_167.h:138
TIFFDirectory tif_dir
Definition: tiffiop.h:157
int TIFFIsCODECConfigured(uint16_t scheme)
Definition: tif_codec.c:146
#define COMPRESSION_PIXARLOG
Definition: tiff.h:204
#define COMPRESSION_ZSTD
Definition: tiff.h:216
#define COMPRESSION_CCITTFAX3
Definition: tiff.h:184
#define COMPRESSION_CCITTRLE
Definition: tiff.h:183
#define TIFFTAG_JPEGDCTABLES
Definition: tiff.h:385
#define TIFFTAG_GROUP3OPTIONS
Definition: tiff.h:279
#define TIFFTAG_GROUP4OPTIONS
Definition: tiff.h:284
#define COMPRESSION_OJPEG
Definition: tiff.h:189
#define TIFFTAG_CONSECUTIVEBADFAXLINES
Definition: tiff.h:320
#define COMPRESSION_DEFLATE
Definition: tiff.h:205
#define TIFFTAG_JPEGQTABLES
Definition: tiff.h:384
#define COMPRESSION_SGILOG
Definition: tiff.h:210
#define TIFFTAG_LERC_PARAMETERS
Definition: tiff.h:502
#define COMPRESSION_CCITTRLEW
Definition: tiff.h:194
#define TIFFTAG_JPEGIFBYTECOUNT
Definition: tiff.h:380
#define TIFFTAG_JPEGACTABLES
Definition: tiff.h:386
#define TIFFTAG_JPEGRESTARTINTERVAL
Definition: tiff.h:381
#define COMPRESSION_LZMA
Definition: tiff.h:215
#define COMPRESSION_JBIG
Definition: tiff.h:209
#define COMPRESSION_LERC
Definition: tiff.h:213
#define COMPRESSION_ADOBE_DEFLATE
Definition: tiff.h:206
#define COMPRESSION_PACKBITS
Definition: tiff.h:195
#define COMPRESSION_LZW
Definition: tiff.h:188
#define TIFFTAG_JPEGIFOFFSET
Definition: tiff.h:379
#define TIFFTAG_CLEANFAXDATA
Definition: tiff.h:316
#define COMPRESSION_SGILOG24
Definition: tiff.h:211
#define TIFFTAG_BADFAXLINES
Definition: tiff.h:315
#define TIFFTAG_JPEGPROC
Definition: tiff.h:376
#define COMPRESSION_CCITTFAX4
Definition: tiff.h:186
#define COMPRESSION_NEXT
Definition: tiff.h:193
#define TIFFTAG_PREDICTOR
Definition: tiff.h:303
#define TIFFTAG_JPEGTABLES
Definition: tiff.h:346
#define COMPRESSION_JPEG
Definition: tiff.h:190
#define COMPRESSION_THUNDERSCAN
Definition: tiff.h:196

Referenced by TIFFReadDirectory().

◆ _TIFFCreateAnonField()

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

Definition at line 898 of file tif_dirinfo.c.

900{
901 TIFFField *fld;
902 (void)tif;
903
904 fld = (TIFFField *)_TIFFmallocExt(tif, sizeof(TIFFField));
905 if (fld == NULL)
906 return NULL;
907 _TIFFmemset(fld, 0, sizeof(TIFFField));
908
909 fld->field_tag = tag;
912 fld->field_type = field_type;
913 fld->field_anonymous =
914 1; /* indicate that this is an anonymous / unknown tag */
915 switch (field_type)
916 {
917 case TIFF_BYTE:
918 case TIFF_UNDEFINED:
920 break;
921 case TIFF_ASCII:
923 break;
924 case TIFF_SHORT:
926 break;
927 case TIFF_LONG:
929 break;
930 case TIFF_RATIONAL:
931 case TIFF_SRATIONAL:
932 case TIFF_FLOAT:
934 break;
935 case TIFF_SBYTE:
937 break;
938 case TIFF_SSHORT:
940 break;
941 case TIFF_SLONG:
943 break;
944 case TIFF_DOUBLE:
946 break;
947 case TIFF_IFD:
948 case TIFF_IFD8:
950 break;
951 case TIFF_LONG8:
953 break;
954 case TIFF_SLONG8:
956 break;
957 default:
959 break;
960 }
961 fld->field_bit = FIELD_CUSTOM;
962 fld->field_oktochange = TRUE;
963 fld->field_passcount = TRUE;
964 fld->field_name = (char *)_TIFFmallocExt(tif, 32);
965 if (fld->field_name == NULL)
966 {
967 _TIFFfreeExt(tif, fld);
968 return NULL;
969 }
970 fld->field_subfields = NULL;
971
972 /*
973 * note that this name is a special sign to TIFFClose() and
974 * _TIFFSetupFields() to free the field
975 * Update:
976 * This special sign is replaced by fld->field_anonymous flag.
977 */
978 (void)snprintf(fld->field_name, 32, "Tag %d", (int)tag);
979
980 return fld;
981}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
unsigned char field_oktochange
Definition: tif_dir.h:341
TIFFDataType field_type
Definition: tif_dir.h:335
unsigned char field_passcount
Definition: tif_dir.h:342
char * field_name
Definition: tif_dir.h:343
unsigned short field_bit
Definition: tif_dir.h:340
uint32_t field_anonymous
Definition: tif_dir.h:336
uint32_t field_tag
Definition: tif_dir.h:332
short field_readcount
Definition: tif_dir.h:333
TIFFSetGetFieldType set_get_field_type
Definition: tif_dir.h:338
TIFFFieldArray * field_subfields
Definition: tif_dir.h:344
short field_writecount
Definition: tif_dir.h:334
@ TIFF_SETGET_C32_SINT32
Definition: tif_dir.h:290
@ TIFF_SETGET_UNDEFINED
Definition: tif_dir.h:245
@ TIFF_SETGET_C32_ASCII
Definition: tif_dir.h:284
@ TIFF_SETGET_C32_UINT8
Definition: tif_dir.h:285
@ TIFF_SETGET_C32_UINT16
Definition: tif_dir.h:287
@ TIFF_SETGET_C32_SINT16
Definition: tif_dir.h:288
@ TIFF_SETGET_C32_UINT32
Definition: tif_dir.h:289
@ TIFF_SETGET_C32_SINT8
Definition: tif_dir.h:286
@ TIFF_SETGET_C32_IFD8
Definition: tif_dir.h:295
@ TIFF_SETGET_C32_SINT64
Definition: tif_dir.h:292
@ TIFF_SETGET_C32_DOUBLE
Definition: tif_dir.h:294
@ TIFF_SETGET_C32_UINT64
Definition: tif_dir.h:291
@ TIFF_SETGET_C32_FLOAT
Definition: tif_dir.h:293
void _TIFFfreeExt(TIFF *tif, void *p)
Definition: tif_open.c:275
void * _TIFFmallocExt(TIFF *tif, tmsize_t s)
Definition: tif_open.c:173
void _TIFFmemset(void *p, int v, tmsize_t c)
Definition: tif_unix.c:353
@ TIFF_SSHORT
Definition: tiff.h:155
@ TIFF_SLONG
Definition: tiff.h:156
@ TIFF_BYTE
Definition: tiff.h:148
@ TIFF_SBYTE
Definition: tiff.h:153
@ TIFF_IFD
Definition: tiff.h:160
@ TIFF_SHORT
Definition: tiff.h:150
@ TIFF_UNDEFINED
Definition: tiff.h:154
@ TIFF_LONG
Definition: tiff.h:151
@ TIFF_SLONG8
Definition: tiff.h:162
@ TIFF_LONG8
Definition: tiff.h:161
@ TIFF_ASCII
Definition: tiff.h:149
@ TIFF_FLOAT
Definition: tiff.h:158
@ TIFF_DOUBLE
Definition: tiff.h:159
@ TIFF_IFD8
Definition: tiff.h:163
@ TIFF_SRATIONAL
Definition: tiff.h:157
@ TIFF_RATIONAL
Definition: tiff.h:152
#define FIELD_CUSTOM
Definition: tiffio.h:346
#define TIFF_VARIABLE2
Definition: tiffio.h:344
#define snprintf
Definition: wintirpc.h:48

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

◆ _TIFFFindFieldByName()

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

Definition at line 818 of file tif_dirinfo.c.

820{
821 TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, NULL, NULL};
822 TIFFField *pkey = &key;
823 const TIFFField **ret;
824 if (tif->tif_foundfield &&
825 streq(tif->tif_foundfield->field_name, field_name) &&
826 (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
827 return (tif->tif_foundfield);
828
829 /* If we are invoked with no field information, then just return. */
830 if (!tif->tif_fields)
831 return NULL;
832
833 /* NB: use linear search since list is sorted by key#, not name */
834
835 key.field_name = (char *)field_name;
836 key.field_type = dt;
837
838 ret =
839 (const TIFFField **)td_lfind(&pkey, tif->tif_fields, &tif->tif_nfields,
840 sizeof(TIFFField *), tagNameCompare);
841
842 return tif->tif_foundfield = (ret ? *ret : NULL);
843}
return ret
Definition: mutex.c:146
#define streq(a, b)
Definition: mkg3states.c:43
Definition: copy.c:22
const TIFFField * tif_foundfield
Definition: tiffiop.h:243
size_t tif_nfields
Definition: tiffiop.h:242
TIFFField ** tif_fields
Definition: tiffiop.h:241
static int tagNameCompare(const void *a, const void *b)
Definition: tif_dirinfo.c:559
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:494
@ TIFF_NOTYPE
Definition: tiff.h:147
#define TIFF_ANY
Definition: tiffio.h:341

Referenced by TIFFFieldWithName().

◆ _TIFFFindOrRegisterField()

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

Definition at line 881 of file tif_dirinfo.c.

884{
885 const TIFFField *fld;
886
887 fld = TIFFFindField(tif, tag, dt);
888 if (fld == NULL)
889 {
890 fld = _TIFFCreateAnonField(tif, tag, dt);
891 if (fld == NULL || !_TIFFMergeFields(tif, fld, 1))
892 return NULL;
893 }
894
895 return fld;
896}
int _TIFFMergeFields(TIFF *tif, const TIFFField info[], uint32_t n)
Definition: tif_dirinfo.c:573
TIFFField * _TIFFCreateAnonField(TIFF *tif, uint32_t tag, TIFFDataType field_type)
Definition: tif_dirinfo.c:898
const TIFFField * TIFFFindField(TIFF *tif, uint32_t tag, TIFFDataType dt)
Definition: tif_dirinfo.c:795

◆ _TIFFGetExifFields()

const TIFFFieldArray * _TIFFGetExifFields ( void  )

Definition at line 509 of file tif_dirinfo.c.

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

Referenced by TIFFCreateEXIFDirectory(), and TIFFReadEXIFDirectory().

◆ _TIFFGetFields()

const TIFFFieldArray * _TIFFGetFields ( void  )

Definition at line 507 of file tif_dirinfo.c.

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

Referenced by TIFFDefaultDirectory().

◆ _TIFFGetGpsFields()

const TIFFFieldArray * _TIFFGetGpsFields ( void  )

Definition at line 511 of file tif_dirinfo.c.

511{ return (&gpsFieldArray); }
static const TIFFFieldArray gpsFieldArray
Definition: tif_dirinfo.c:50

Referenced by TIFFCreateGPSDirectory(), and TIFFReadGPSDirectory().

◆ _TIFFMergeFields()

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

Definition at line 573 of file tif_dirinfo.c.

574{
575 static const char module[] = "_TIFFMergeFields";
576 static const char reason[] = "for fields array";
577 /* TIFFField** tp; */
578 uint32_t i;
579
580 tif->tif_foundfield = NULL;
581
582 if (tif->tif_fields && tif->tif_nfields > 0)
583 {
585 tif, tif->tif_fields, (tif->tif_nfields + n), sizeof(TIFFField *),
586 reason);
587 }
588 else
589 {
590 tif->tif_fields =
591 (TIFFField **)_TIFFCheckMalloc(tif, n, sizeof(TIFFField *), reason);
592 }
593 if (!tif->tif_fields)
594 {
595 TIFFErrorExtR(tif, module, "Failed to allocate fields array");
596 return 0;
597 }
598
599 /* tp = tif->tif_fields + tif->tif_nfields; */
600 for (i = 0; i < n; i++)
601 {
602 const TIFFField *fip = TIFFFindField(tif, info[i].field_tag, TIFF_ANY);
603
604 /* only add definitions that aren't already present */
605 if (!fip)
606 {
607 tif->tif_fields[tif->tif_nfields] = (TIFFField *)(info + i);
608 tif->tif_nfields++;
609 }
610 }
611
612 /* Sort the field info by tag number */
613 qsort(tif->tif_fields, tif->tif_nfields, sizeof(TIFFField *), tagCompare);
614
615 return n;
616}
UINT32 uint32_t
Definition: types.h:75
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
_ACRTIMP void __cdecl qsort(void *, size_t, size_t, int(__cdecl *)(const void *, const void *))
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 * _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:122
static int tagCompare(const void *a, const void *b)
Definition: tif_dirinfo.c:546
void TIFFErrorExtR(TIFF *tif, const char *module, const char *fmt,...)
Definition: tif_error.c:107

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

◆ _TIFFPrintFieldInfo()

void _TIFFPrintFieldInfo ( TIFF tif,
FILE fd 
)

Definition at line 618 of file tif_dirinfo.c.

619{
620 uint32_t i;
621
622 fprintf(fd, "%s: \n", tif->tif_name);
623 for (i = 0; i < tif->tif_nfields; i++)
624 {
625 const TIFFField *fip = tif->tif_fields[i];
626 fprintf(fd, "field[%2d] %5lu, %2d, %2d, %d, %2d, %5s, %5s, %s\n",
627 (int)i, (unsigned long)fip->field_tag, fip->field_readcount,
628 fip->field_writecount, fip->field_type, fip->field_bit,
629 fip->field_oktochange ? "TRUE" : "FALSE",
630 fip->field_passcount ? "TRUE" : "FALSE", fip->field_name);
631 }
632}
int WINAPIV fprintf(FILE *file, const char *format,...)
Definition: file.c:5549
static int fd
Definition: io.c:51
char * tif_name
Definition: tiffiop.h:114

◆ _TIFFSetGetType()

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

Definition at line 990 of file tif_dirinfo.c.

992{
993 if (type == TIFF_ASCII && count == TIFF_VARIABLE && passcount == 0)
994 return TIFF_SETGET_ASCII;
995
996 else if (count == 1 && passcount == 0)
997 {
998 switch (type)
999 {
1000 case TIFF_BYTE:
1001 case TIFF_UNDEFINED:
1002 return TIFF_SETGET_UINT8;
1003 case TIFF_ASCII:
1004 return TIFF_SETGET_ASCII;
1005 case TIFF_SHORT:
1006 return TIFF_SETGET_UINT16;
1007 case TIFF_LONG:
1008 return TIFF_SETGET_UINT32;
1009 case TIFF_RATIONAL:
1010 case TIFF_SRATIONAL:
1011 case TIFF_FLOAT:
1012 return TIFF_SETGET_FLOAT;
1013 case TIFF_SBYTE:
1014 return TIFF_SETGET_SINT8;
1015 case TIFF_SSHORT:
1016 return TIFF_SETGET_SINT16;
1017 case TIFF_SLONG:
1018 return TIFF_SETGET_SINT32;
1019 case TIFF_DOUBLE:
1020 return TIFF_SETGET_DOUBLE;
1021 case TIFF_IFD:
1022 case TIFF_IFD8:
1023 return TIFF_SETGET_IFD8;
1024 case TIFF_LONG8:
1025 return TIFF_SETGET_UINT64;
1026 case TIFF_SLONG8:
1027 return TIFF_SETGET_SINT64;
1028 default:
1029 return TIFF_SETGET_UNDEFINED;
1030 }
1031 }
1032
1033 else if (count >= 1 && passcount == 0)
1034 {
1035 switch (type)
1036 {
1037 case TIFF_BYTE:
1038 case TIFF_UNDEFINED:
1039 return TIFF_SETGET_C0_UINT8;
1040 case TIFF_ASCII:
1041 return TIFF_SETGET_C0_ASCII;
1042 case TIFF_SHORT:
1043 return TIFF_SETGET_C0_UINT16;
1044 case TIFF_LONG:
1045 return TIFF_SETGET_C0_UINT32;
1046 case TIFF_RATIONAL:
1047 case TIFF_SRATIONAL:
1048 case TIFF_FLOAT:
1049 return TIFF_SETGET_C0_FLOAT;
1050 case TIFF_SBYTE:
1051 return TIFF_SETGET_C0_SINT8;
1052 case TIFF_SSHORT:
1053 return TIFF_SETGET_C0_SINT16;
1054 case TIFF_SLONG:
1055 return TIFF_SETGET_C0_SINT32;
1056 case TIFF_DOUBLE:
1057 return TIFF_SETGET_C0_DOUBLE;
1058 case TIFF_IFD:
1059 case TIFF_IFD8:
1060 return TIFF_SETGET_C0_IFD8;
1061 case TIFF_LONG8:
1062 return TIFF_SETGET_C0_UINT64;
1063 case TIFF_SLONG8:
1064 return TIFF_SETGET_C0_SINT64;
1065 default:
1066 return TIFF_SETGET_UNDEFINED;
1067 }
1068 }
1069
1070 else if (count == TIFF_VARIABLE && passcount == 1)
1071 {
1072 switch (type)
1073 {
1074 case TIFF_BYTE:
1075 case TIFF_UNDEFINED:
1076 return TIFF_SETGET_C16_UINT8;
1077 case TIFF_ASCII:
1078 return TIFF_SETGET_C16_ASCII;
1079 case TIFF_SHORT:
1081 case TIFF_LONG:
1083 case TIFF_RATIONAL:
1084 case TIFF_SRATIONAL:
1085 case TIFF_FLOAT:
1086 return TIFF_SETGET_C16_FLOAT;
1087 case TIFF_SBYTE:
1088 return TIFF_SETGET_C16_SINT8;
1089 case TIFF_SSHORT:
1091 case TIFF_SLONG:
1093 case TIFF_DOUBLE:
1095 case TIFF_IFD:
1096 case TIFF_IFD8:
1097 return TIFF_SETGET_C16_IFD8;
1098 case TIFF_LONG8:
1100 case TIFF_SLONG8:
1102 default:
1103 return TIFF_SETGET_UNDEFINED;
1104 }
1105 }
1106
1107 else if (count == TIFF_VARIABLE2 && passcount == 1)
1108 {
1109 switch (type)
1110 {
1111 case TIFF_BYTE:
1112 case TIFF_UNDEFINED:
1113 return TIFF_SETGET_C32_UINT8;
1114 case TIFF_ASCII:
1115 return TIFF_SETGET_C32_ASCII;
1116 case TIFF_SHORT:
1118 case TIFF_LONG:
1120 case TIFF_RATIONAL:
1121 case TIFF_SRATIONAL:
1122 case TIFF_FLOAT:
1123 return TIFF_SETGET_C32_FLOAT;
1124 case TIFF_SBYTE:
1125 return TIFF_SETGET_C32_SINT8;
1126 case TIFF_SSHORT:
1128 case TIFF_SLONG:
1130 case TIFF_DOUBLE:
1132 case TIFF_IFD:
1133 case TIFF_IFD8:
1134 return TIFF_SETGET_C32_IFD8;
1135 case TIFF_LONG8:
1137 case TIFF_SLONG8:
1139 default:
1140 return TIFF_SETGET_UNDEFINED;
1141 }
1142 }
1143
1144 return TIFF_SETGET_UNDEFINED;
1145}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
@ TIFF_SETGET_C16_UINT8
Definition: tif_dir.h:273
@ TIFF_SETGET_C0_SINT64
Definition: tif_dir.h:268
@ TIFF_SETGET_DOUBLE
Definition: tif_dir.h:256
@ TIFF_SETGET_SINT64
Definition: tif_dir.h:254
@ TIFF_SETGET_C16_FLOAT
Definition: tif_dir.h:281
@ TIFF_SETGET_SINT8
Definition: tif_dir.h:248
@ TIFF_SETGET_IFD8
Definition: tif_dir.h:257
@ TIFF_SETGET_C16_DOUBLE
Definition: tif_dir.h:282
@ TIFF_SETGET_UINT64
Definition: tif_dir.h:253
@ TIFF_SETGET_C0_UINT32
Definition: tif_dir.h:265
@ TIFF_SETGET_C16_UINT32
Definition: tif_dir.h:277
@ TIFF_SETGET_C16_UINT16
Definition: tif_dir.h:275
@ TIFF_SETGET_C16_SINT64
Definition: tif_dir.h:280
@ TIFF_SETGET_C0_FLOAT
Definition: tif_dir.h:269
@ TIFF_SETGET_C0_SINT32
Definition: tif_dir.h:266
@ TIFF_SETGET_C16_UINT64
Definition: tif_dir.h:279
@ TIFF_SETGET_C0_ASCII
Definition: tif_dir.h:260
@ TIFF_SETGET_UINT16
Definition: tif_dir.h:249
@ TIFF_SETGET_C16_SINT16
Definition: tif_dir.h:276
@ TIFF_SETGET_C0_UINT8
Definition: tif_dir.h:261
@ TIFF_SETGET_ASCII
Definition: tif_dir.h:246
@ TIFF_SETGET_C0_SINT8
Definition: tif_dir.h:262
@ TIFF_SETGET_C16_SINT8
Definition: tif_dir.h:274
@ TIFF_SETGET_C0_UINT64
Definition: tif_dir.h:267
@ TIFF_SETGET_FLOAT
Definition: tif_dir.h:255
@ TIFF_SETGET_C16_SINT32
Definition: tif_dir.h:278
@ TIFF_SETGET_SINT16
Definition: tif_dir.h:250
@ TIFF_SETGET_C0_SINT16
Definition: tif_dir.h:264
@ TIFF_SETGET_UINT32
Definition: tif_dir.h:251
@ TIFF_SETGET_C16_ASCII
Definition: tif_dir.h:272
@ TIFF_SETGET_UINT8
Definition: tif_dir.h:247
@ TIFF_SETGET_C0_UINT16
Definition: tif_dir.h:263
@ TIFF_SETGET_C0_IFD8
Definition: tif_dir.h:271
@ TIFF_SETGET_C16_IFD8
Definition: tif_dir.h:283
@ TIFF_SETGET_SINT32
Definition: tif_dir.h:252
@ TIFF_SETGET_C0_DOUBLE
Definition: tif_dir.h:270
#define TIFF_VARIABLE
Definition: tiffio.h:342

Referenced by TIFFMergeFieldInfo().

◆ _TIFFSetupFields()

void _TIFFSetupFields ( TIFF tif,
const TIFFFieldArray fieldarray 
)

Definition at line 513 of file tif_dirinfo.c.

514{
515 if (tif->tif_fields && tif->tif_nfields > 0)
516 {
517 uint32_t i;
518
519 for (i = 0; i < tif->tif_nfields; i++)
520 {
521 TIFFField *fld = tif->tif_fields[i];
522 if (fld->field_name != NULL)
523 {
524 if (fld->field_bit == FIELD_CUSTOM && TIFFFieldIsAnonymous(fld))
525 {
526 _TIFFfreeExt(tif, fld->field_name);
527 /* caution: tif_fields[i] must not be the beginning of a
528 * fields-array. Otherwise the following tags are also freed
529 * with the first free().
530 */
531 _TIFFfreeExt(tif, fld);
532 }
533 }
534 }
535
536 _TIFFfreeExt(tif, tif->tif_fields);
537 tif->tif_fields = NULL;
538 tif->tif_nfields = 0;
539 }
540 if (!_TIFFMergeFields(tif, fieldarray->fields, fieldarray->count))
541 {
542 TIFFErrorExtR(tif, "_TIFFSetupFields", "Setting up field info failed");
543 }
544}
uint32_t count
Definition: tif_dir.h:326
TIFFField * fields
Definition: tif_dir.h:327
int TIFFFieldIsAnonymous(const TIFFField *fip)
Definition: tif_dirinfo.c:879

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

◆ tagCompare()

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

Definition at line 546 of file tif_dirinfo.c.

547{
548 const TIFFField *ta = *(const TIFFField **)a;
549 const TIFFField *tb = *(const TIFFField **)b;
550 /* NB: be careful of return values for 16-bit platforms */
551 if (ta->field_tag != tb->field_tag)
552 return (int)ta->field_tag - (int)tb->field_tag;
553 else
554 return (ta->field_type == TIFF_ANY)
555 ? 0
556 : ((int)tb->field_type - (int)ta->field_type);
557}
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 559 of file tif_dirinfo.c.

560{
561 const TIFFField *ta = *(const TIFFField **)a;
562 const TIFFField *tb = *(const TIFFField **)b;
563 int ret = strcmp(ta->field_name, tb->field_name);
564
565 if (ret)
566 return ret;
567 else
568 return (ta->field_type == TIFF_ANY)
569 ? 0
570 : ((int)tb->field_type - (int)ta->field_type);
571}
_ACRTIMP int __cdecl strcmp(const char *, const char *)
Definition: string.c:3319

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 494 of file tif_dirinfo.c.

496{
497 char *element, *end;
498
499 end = (char *)base + *nmemb * size;
500 for (element = (char *)base; element < end; element += size)
501 if (!compar(key, element)) /* key found */
502 return element;
503
504 return NULL;
505}
GLuint GLuint end
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919

Referenced by _TIFFFindFieldByName().

◆ TIFFDataWidth()

int TIFFDataWidth ( TIFFDataType  type)

Definition at line 637 of file tif_dirinfo.c.

638{
639 switch (type)
640 {
641 case 0: /* nothing */
642 case TIFF_BYTE:
643 case TIFF_ASCII:
644 case TIFF_SBYTE:
645 case TIFF_UNDEFINED:
646 return 1;
647 case TIFF_SHORT:
648 case TIFF_SSHORT:
649 return 2;
650 case TIFF_LONG:
651 case TIFF_SLONG:
652 case TIFF_FLOAT:
653 case TIFF_IFD:
654 return 4;
655 case TIFF_RATIONAL:
656 case TIFF_SRATIONAL:
657 case TIFF_DOUBLE:
658 case TIFF_LONG8:
659 case TIFF_SLONG8:
660 case TIFF_IFD8:
661 return 8;
662 default:
663 return 0; /* will return 0 for unknown types */
664 }
665}

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

◆ TIFFFieldDataType()

TIFFDataType TIFFFieldDataType ( const TIFFField fip)

Definition at line 871 of file tif_dirinfo.c.

871{ return fip->field_type; }

◆ TIFFFieldIsAnonymous()

int TIFFFieldIsAnonymous ( const TIFFField fip)

◆ TIFFFieldName()

const char * TIFFFieldName ( const TIFFField fip)

Definition at line 869 of file tif_dirinfo.c.

869{ return fip->field_name; }

◆ TIFFFieldPassCount()

int TIFFFieldPassCount ( const TIFFField fip)

Definition at line 873 of file tif_dirinfo.c.

873{ return fip->field_passcount; }

◆ TIFFFieldReadCount()

int TIFFFieldReadCount ( const TIFFField fip)

Definition at line 875 of file tif_dirinfo.c.

875{ return fip->field_readcount; }

◆ TIFFFieldSetGetCountSize()

int TIFFFieldSetGetCountSize ( const TIFFField fip)

Definition at line 757 of file tif_dirinfo.c.

758{
759 if (fip == NULL)
760 return 0;
761
762 switch (fip->set_get_field_type)
763 {
776 return 2;
789 return 4;
790 default:
791 return 0;
792 }
793} /*-- TIFFFieldSetGetCountSize() --- */

◆ TIFFFieldSetGetSize()

int TIFFFieldSetGetSize ( const TIFFField fip)

Definition at line 673 of file tif_dirinfo.c.

674{
675 /*
676 * TIFFSetField() and TIFFGetField() must provide the parameter accordingly
677 * to the definition of "set_get_field_type" of the tag definition in
678 * dir_info.c. This function returns the data size for that purpose.
679 *
680 * Furthermore, this data size is also used for the internal storage,
681 * even for TIFF_RATIONAL values for FIELD_CUSTOM, which are stored
682 * internally as 4-byte float, but some of them should be stored internally
683 * as 8-byte double, depending on the "set_get_field_type" _FLOAT_ or
684 * _DOUBLE_.
685 */
686 if (fip == NULL)
687 return 0;
688
689 switch (fip->set_get_field_type)
690 {
697 return 1;
706 return 1;
715 return 2;
716 case TIFF_SETGET_INT:
730 return 4;
734 case TIFF_SETGET_IFD8:
747 return 8;
748 default:
749 return 0;
750 }
751} /*-- TIFFFieldSetGetSize() --- */
@ TIFF_SETGET_INT
Definition: tif_dir.h:258
@ TIFF_SETGET_UINT16_PAIR
Definition: tif_dir.h:259
@ TIFF_SETGET_OTHER
Definition: tif_dir.h:296

Referenced by _TIFFPrintField(), _TIFFVGetField(), _TIFFVSetField(), TIFFPrintDirectory(), and TIFFWriteDirectorySec().

◆ TIFFFieldTag()

uint32_t TIFFFieldTag ( const TIFFField fip)

Definition at line 867 of file tif_dirinfo.c.

867{ return fip->field_tag; }

Referenced by TIFFWriteDirectorySec().

◆ TIFFFieldWithName()

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

Definition at line 856 of file tif_dirinfo.c.

857{
858 const TIFFField *fip = _TIFFFindFieldByName(tif, field_name, TIFF_ANY);
859 if (!fip)
860 {
861 TIFFWarningExtR(tif, "TIFFFieldWithName", "Warning, unknown tag %s",
862 field_name);
863 }
864 return (fip);
865}
static const TIFFField * _TIFFFindFieldByName(TIFF *tif, const char *field_name, TIFFDataType dt)
Definition: tif_dirinfo.c:818
void TIFFWarningExtR(TIFF *tif, const char *module, const char *fmt,...)
Definition: tif_warning.c:80

◆ TIFFFieldWithTag()

const TIFFField * TIFFFieldWithTag ( TIFF tif,
uint32_t  tag 
)

Definition at line 845 of file tif_dirinfo.c.

846{
847 const TIFFField *fip = TIFFFindField(tif, tag, TIFF_ANY);
848 if (!fip)
849 {
850 TIFFWarningExtR(tif, "TIFFFieldWithTag", "Warning, unknown tag 0x%x",
851 (unsigned int)tag);
852 }
853 return (fip);
854}

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

◆ TIFFFieldWriteCount()

int TIFFFieldWriteCount ( const TIFFField fip)

Definition at line 877 of file tif_dirinfo.c.

877{ return fip->field_writecount; }

◆ TIFFFindField()

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

Definition at line 795 of file tif_dirinfo.c.

796{
797 TIFFField key = {0, 0, 0, TIFF_NOTYPE, 0, 0, 0, 0, 0, NULL, NULL};
798 TIFFField *pkey = &key;
799 const TIFFField **ret;
800 if (tif->tif_foundfield && tif->tif_foundfield->field_tag == tag &&
801 (dt == TIFF_ANY || dt == tif->tif_foundfield->field_type))
802 return tif->tif_foundfield;
803
804 /* If we are invoked with no field information, then just return. */
805 if (!tif->tif_fields)
806 return NULL;
807
808 /* NB: use sorted search (e.g. binary search) */
809
810 key.field_tag = tag;
811 key.field_type = dt;
812
813 ret = (const TIFFField **)bsearch(&pkey, tif->tif_fields, tif->tif_nfields,
814 sizeof(TIFFField *), tagCompare);
815 return tif->tif_foundfield = (ret ? *ret : NULL);
816}
#define bsearch

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

◆ TIFFMergeFieldInfo()

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

Definition at line 1147 of file tif_dirinfo.c.

1148{
1149 static const char module[] = "TIFFMergeFieldInfo";
1150 static const char reason[] = "for fields array";
1151 TIFFField *tp;
1152 size_t nfields;
1153 uint32_t i;
1154
1155 if (tif->tif_nfieldscompat > 0)
1156 {
1158 tif, tif->tif_fieldscompat, tif->tif_nfieldscompat + 1,
1159 sizeof(TIFFFieldArray), reason);
1160 }
1161 else
1162 {
1164 tif, 1, sizeof(TIFFFieldArray), reason);
1165 }
1166 if (!tif->tif_fieldscompat)
1167 {
1168 TIFFErrorExtR(tif, module, "Failed to allocate fields array");
1169 return -1;
1170 }
1171 nfields = tif->tif_nfieldscompat++;
1172
1173 tif->tif_fieldscompat[nfields].type = tfiatOther;
1174 tif->tif_fieldscompat[nfields].allocated_size = n;
1175 tif->tif_fieldscompat[nfields].count = n;
1176 tif->tif_fieldscompat[nfields].fields =
1177 (TIFFField *)_TIFFCheckMalloc(tif, n, sizeof(TIFFField), reason);
1178 if (!tif->tif_fieldscompat[nfields].fields)
1179 {
1180 TIFFErrorExtR(tif, module, "Failed to allocate fields array");
1181 return -1;
1182 }
1183
1184 tp = tif->tif_fieldscompat[nfields].fields;
1185 for (i = 0; i < n; i++)
1186 {
1187 tp->field_tag = info[i].field_tag;
1188 if (info[i].field_readcount < TIFF_VARIABLE2 ||
1189 info[i].field_writecount < TIFF_VARIABLE2)
1190 {
1191 /* The fields (field_readcount) and (field_writecount) may use the
1192 * values TIFF_VARIABLE (-1), TIFF_SPP (-2), TIFF_VARIABLE2 (-3). */
1194 tif, module,
1195 "The value of field_readcount %d and field_writecount %d "
1196 "must be greater than or equal to -3.",
1197 info[i].field_readcount, info[i].field_writecount);
1198 return -1;
1199 }
1200 if ((info[i].field_readcount == 0 || info[i].field_writecount == 0) &&
1201 info[i].field_bit != FIELD_IGNORE)
1202 {
1203 /* The fields (field_readcount) and (field_writecount) may only
1204 be zero for pseudo_tags or ignored tags. */
1206 tif, module,
1207 "The value of field_readcount %d and field_writecount %d "
1208 "may only be zero for field_bit = 0 (i.e. ignored tags).",
1209 info[i].field_readcount, info[i].field_writecount);
1210 return -1;
1211 }
1212 tp->field_readcount = info[i].field_readcount;
1213 tp->field_writecount = info[i].field_writecount;
1214 tp->field_type = info[i].field_type;
1215 tp->field_anonymous = 0;
1216 tp->set_get_field_type =
1217 _TIFFSetGetType(info[i].field_type, info[i].field_writecount,
1218 info[i].field_passcount);
1219 tp->field_bit = info[i].field_bit;
1220 tp->field_oktochange = info[i].field_oktochange;
1221 tp->field_passcount = info[i].field_passcount;
1222 /* Define an empty static string to be passed as field_name where a NULL
1223 * pointer is passed in. Otherwise, this will lead to buffer overflow
1224 * furtheron. */
1225 if (info[i].field_name == NULL)
1226 {
1227 static const char *string_static_empty = "";
1228 tp->field_name = (char *)string_static_empty;
1229 }
1230 else
1231 {
1232 tp->field_name = info[i].field_name;
1233 }
1234 tp->field_subfields = NULL;
1235 tp++;
1236 }
1237
1238 if (!_TIFFMergeFields(tif, tif->tif_fieldscompat[nfields].fields, n))
1239 {
1240 TIFFErrorExtR(tif, module, "Setting up field info failed");
1241 return -1;
1242 }
1243
1244 return 0;
1245}
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2996
TIFFFieldArrayType type
Definition: tif_dir.h:322
uint32_t allocated_size
Definition: tif_dir.h:324
size_t tif_nfieldscompat
Definition: tiffiop.h:249
TIFFFieldArray * tif_fieldscompat
Definition: tiffiop.h:248
#define FIELD_IGNORE
Definition: tif_dir.h:178
@ tfiatOther
Definition: tif_dir.h:317
static TIFFSetGetFieldType _TIFFSetGetType(TIFFDataType type, short count, unsigned char passcount)
Definition: tif_dirinfo.c:990

Variable Documentation

◆ exifFieldArray

static const TIFFFieldArray exifFieldArray
static
Initial value:
= {
@ tfiatExif
Definition: tif_dir.h:315
static const TIFFField exifFields[]
Definition: tif_dirinfo.c:350
#define TIFFArrayCount(a)
Definition: tiffiop.h:333

Definition at line 49 of file tif_dirinfo.c.

Referenced by _TIFFGetExifFields(), and TIFFCreateEXIFDirectory().

◆ exifFields

const TIFFField exifFields[]
static

Definition at line 350 of file tif_dirinfo.c.

◆ gpsFieldArray

static const TIFFFieldArray gpsFieldArray
static
Initial value:
= {
@ tfiatGps
Definition: tif_dir.h:316
static const TIFFField gpsFields[]
Definition: tif_dirinfo.c:442

Definition at line 50 of file tif_dirinfo.c.

Referenced by _TIFFGetGpsFields(), and TIFFCreateGPSDirectory().

◆ gpsFields

const TIFFField gpsFields[]
static

Definition at line 442 of file tif_dirinfo.c.

◆ tiffFieldArray

static const TIFFFieldArray tiffFieldArray
static
Initial value:
= {
@ tfiatImage
Definition: tif_dir.h:314
static const TIFFField tiffFields[]
Definition: tif_dirinfo.c:67

Definition at line 48 of file tif_dirinfo.c.

Referenced by _TIFFGetFields(), and TIFFDefaultDirectory().

◆ tiffFields

const TIFFField tiffFields[]
static

Definition at line 67 of file tif_dirinfo.c.