exif-entry.c File Reference

#include <config.h>
#include <libexif/exif-entry.h>
#include <libexif/exif-ifd.h>
#include <libexif/exif-utils.h>
#include <libexif/i18n.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <math.h>

Go to the source code of this file.

Data Structures

struct  _ExifEntryPrivate

Defines

#define M_PI   3.14159265358979323846
#define CF(entry, target, v, maxlen)
#define CC(entry, target, v, maxlen)

Functions

ExifLogexif_data_get_log (ExifData *)
static void exif_entry_log (ExifEntry *e, ExifLogCode code, const char *format,...)
static void * exif_entry_alloc (ExifEntry *e, unsigned int i)
static void * exif_entry_realloc (ExifEntry *e, void *d_orig, unsigned int i)
ExifEntryexif_entry_new (void)
 Reserve memory for and initialize a new ExifEntry.
ExifEntryexif_entry_new_mem (ExifMem *mem)
 Reserve memory for and initialize new ExifEntry using the specified memory allocator.
void exif_entry_ref (ExifEntry *e)
 Increase reference counter for ExifEntry.
void exif_entry_unref (ExifEntry *e)
 Decrease reference counter for ExifEntry.
void exif_entry_free (ExifEntry *e)
 Actually free the ExifEntry.
static ExifShort exif_get_short_convert (const unsigned char *buf, ExifFormat format, ExifByteOrder order)
 Get a value and convert it to an ExifShort.
void exif_entry_fix (ExifEntry *e)
 Fix the type or format of the given EXIF entry to bring it into spec.
static void exif_entry_format_value (ExifEntry *e, char *val, size_t maxlen)
 Format the value of an ExifEntry for human display in a generic way.
void exif_entry_dump (ExifEntry *e, unsigned int indent)
 Dump text representation of ExifEntry to stdout.
static int match_repeated_char (const unsigned char *data, unsigned char ch, size_t n)
 Check if a string consists entirely of a single, repeated character.
const char * exif_entry_get_value (ExifEntry *e, char *val, unsigned int maxlen)
 Return a localized textual representation of the value of the EXIF entry.
void exif_entry_initialize (ExifEntry *e, ExifTag tag)
 Initialize an empty ExifEntry with default data in the correct format for the given tag.

Variables

struct {
   ExifTag   tag
   const char *   strings [10]
list []
struct {
   ExifTag   tag
   struct {
      int   index
      const char *   values [4]
 list of progressively shorter string descriptions; the longest one that fits will be selected
   }   elem [25]
list2 []


Define Documentation

#define CC ( entry,
target,
v,
maxlen   ) 

Value:

{                                                                       \
        if (entry->components != target) {                              \
                exif_entry_log (entry, EXIF_LOG_CODE_CORRUPT_DATA,      \
                        _("The tag '%s' contains an invalid number of " \
                          "components (%i, expected %i)."),             \
                        exif_tag_get_name (entry->tag),         \
                        (int) entry->components, (int) target);         \
                break;                                                  \
        }                                                               \
}

Definition at line 651 of file exif-entry.c.

#define CF ( entry,
target,
v,
maxlen   ) 

Value:

{                                                                       \
        if (entry->format != target) {                                  \
                exif_entry_log (entry, EXIF_LOG_CODE_CORRUPT_DATA,      \
                        _("The tag '%s' contains data of an invalid "   \
                        "format ('%s', expected '%s')."),               \
                        exif_tag_get_name (entry->tag),                 \
                        exif_format_get_name (entry->format),           \
                        exif_format_get_name (target));                 \
                break;                                                  \
        }                                                               \
}

Definition at line 638 of file exif-entry.c.

#define M_PI   3.14159265358979323846

Definition at line 36 of file exif-entry.c.

Referenced by exif_entry_get_value().


Function Documentation

ExifLog* exif_data_get_log ( ExifData  ) 

static void* exif_entry_alloc ( ExifEntry e,
unsigned int  i 
) [static]

Definition at line 73 of file exif-entry.c.

References exif_data_get_log(), EXIF_LOG_NO_MEMORY, exif_mem_alloc(), _ExifEntryPrivate::mem, _ExifContent::parent, _ExifEntry::parent, and _ExifEntry::priv.

Referenced by exif_entry_fix(), and exif_entry_initialize().

void exif_entry_dump ( ExifEntry entry,
unsigned int  indent 
)

Dump text representation of ExifEntry to stdout.

This is intended for diagnostic purposes only.

Parameters:
[in] entry EXIF tag data
[in] indent how many levels deep to indent the data

Definition at line 592 of file exif-entry.c.

Referenced by exif_content_dump().

void exif_entry_fix ( ExifEntry entry  ) 

Fix the type or format of the given EXIF entry to bring it into spec.

If the data for this EXIF tag is in of the wrong type or is in an invalid format according to the EXIF specification, then it is converted to make it valid. This may involve, for example, converting an EXIF_FORMAT_LONG into a EXIF_FORMAT_SHORT. If the tag is unknown, its value is untouched.

Note:
Unfortunately, some conversions are to a type with a more restricted range, which could have the side effect that the converted data becomes invalid. This is unlikely as the range of each tag in the standard is designed to encompass all likely data.
Parameters:
[in,out] entry EXIF entry

Definition at line 196 of file exif-entry.c.

Referenced by fix_func().

static void exif_entry_format_value ( ExifEntry e,
char *  val,
size_t  maxlen 
) [static]

Format the value of an ExifEntry for human display in a generic way.

The output is localized. The formatting is independent of the tag number and is based entirely on the data type.

Precondition:
The ExifEntry is already a member of an ExifData.
Parameters:
[in] e EXIF entry
[out] val buffer in which to store value
[in] maxlen one less than the length of the buffer val

Definition at line 444 of file exif-entry.c.

References _, _ExifEntry::components, _ExifEntry::data, ExifSRational::denominator, ExifRational::denominator, exif_data_get_byte_order(), EXIF_FORMAT_ASCII, EXIF_FORMAT_BYTE, EXIF_FORMAT_DOUBLE, EXIF_FORMAT_FLOAT, exif_format_get_size(), EXIF_FORMAT_LONG, EXIF_FORMAT_RATIONAL, EXIF_FORMAT_SBYTE, EXIF_FORMAT_SHORT, EXIF_FORMAT_SLONG, EXIF_FORMAT_SRATIONAL, EXIF_FORMAT_SSHORT, EXIF_FORMAT_UNDEFINED, exif_get_long(), exif_get_rational(), exif_get_short(), exif_get_slong(), exif_get_srational(), exif_get_sshort(), _ExifEntry::format, MIN, ExifSRational::numerator, ExifRational::numerator, _ExifContent::parent, _ExifEntry::parent, and _ExifEntry::size.

Referenced by exif_entry_get_value().

void exif_entry_free ( ExifEntry entry  ) 

Actually free the ExifEntry.

Deprecated:
Should not be called directly. Use exif_entry_ref and exif_entry_unref instead.
Parameters:
[in] entry EXIF entry

Definition at line 155 of file exif-entry.c.

Referenced by exif_entry_unref().

const char* exif_entry_get_value ( ExifEntry entry,
char *  val,
unsigned int  maxlen 
)

Return a localized textual representation of the value of the EXIF entry.

This is meant for display to the user. The format of each tag is subject to change between locales and in newer versions of libexif. Users who require the tag data in an unambiguous form should access the data members of the ExifEntry structure directly.

Warning:
The character set of the returned string may be in the encoding of the current locale or the native encoding of the camera.
Bug:
The EXIF_TAG_XP_* tags are currently always returned in UTF-8, regardless of locale, and code points above U+FFFF are not supported.
Parameters:
[in] entry EXIF entry
[out] val buffer in which to store value
[in] maxlen length of the buffer val
Returns:
val pointer

Definition at line 830 of file exif-entry.c.

Referenced by content_foreach_func(), exif_entry_dump(), exif_mnote_data_canon_identify(), exif_mnote_data_olympus_identify(), and main().

void exif_entry_initialize ( ExifEntry e,
ExifTag  tag 
)

Initialize an empty ExifEntry with default data in the correct format for the given tag.

Bug:
Log and report failed exif_mem_malloc() calls.

Definition at line 1408 of file exif-entry.c.

Referenced by exif_content_fix(), and main().

static void exif_entry_log ( ExifEntry e,
ExifLogCode  code,
const char *  format,
  ... 
) [static]

Definition at line 51 of file exif-entry.c.

References exif_data_get_log(), exif_logv(), _ExifContent::parent, and _ExifEntry::parent.

Referenced by exif_entry_fix(), and exif_entry_get_value().

ExifEntry* exif_entry_new ( void   ) 

Reserve memory for and initialize a new ExifEntry.

No memory is allocated for the data element of the returned ExifEntry.

Returns:
new allocated ExifEntry, or NULL on error
See also:
exif_entry_new_mem, exif_entry_unref

Definition at line 109 of file exif-entry.c.

Referenced by exif_content_fix(), and main().

ExifEntry* exif_entry_new_mem ( ExifMem  ) 

Reserve memory for and initialize new ExifEntry using the specified memory allocator.

No memory is allocated for the data element of the returned ExifEntry.

Returns:
new allocated ExifEntry, or NULL on error
See also:
exif_entry_new, exif_entry_unref

Definition at line 120 of file exif-entry.c.

Referenced by exif_data_load_data_content(), and exif_entry_new().

static void* exif_entry_realloc ( ExifEntry e,
void *  d_orig,
unsigned int  i 
) [static]

Definition at line 90 of file exif-entry.c.

References exif_data_get_log(), EXIF_LOG_NO_MEMORY, exif_mem_free(), exif_mem_realloc(), _ExifEntryPrivate::mem, _ExifContent::parent, _ExifEntry::parent, and _ExifEntry::priv.

Referenced by exif_entry_fix().

void exif_entry_ref ( ExifEntry entry  ) 

Increase reference counter for ExifEntry.

Parameters:
[in] entry ExifEntry
See also:
exif_entry_unref

Definition at line 137 of file exif-entry.c.

Referenced by exif_content_add_entry().

void exif_entry_unref ( ExifEntry entry  ) 

Decrease reference counter for ExifEntry.

When the reference count drops to zero, free the entry.

Parameters:
[in] entry ExifEntry

Definition at line 145 of file exif-entry.c.

Referenced by exif_content_fix(), exif_content_free(), exif_content_remove_entry(), exif_data_load_data_content(), and main().

static ExifShort exif_get_short_convert ( const unsigned char *  buf,
ExifFormat  format,
ExifByteOrder  order 
) [inline, static]

Get a value and convert it to an ExifShort.

Bug:
Not all types are converted that could be converted and no indication is made when that occurs

Definition at line 174 of file exif-entry.c.

References EXIF_FORMAT_BYTE, EXIF_FORMAT_LONG, EXIF_FORMAT_SBYTE, EXIF_FORMAT_SHORT, EXIF_FORMAT_SLONG, EXIF_FORMAT_SSHORT, exif_get_long(), exif_get_short(), exif_get_slong(), and exif_get_sshort().

Referenced by exif_entry_fix().

static int match_repeated_char ( const unsigned char *  data,
unsigned char  ch,
size_t  n 
) [static]

Check if a string consists entirely of a single, repeated character.

Up to first n bytes are checked.

Parameters:
[in] data pointer of string to check
[in] ch character to match
[in] n maximum number of characters to match
Returns:
0 if the string matches or is of zero length, nonzero otherwise

Definition at line 624 of file exif-entry.c.

Referenced by exif_entry_get_value().


Variable Documentation

struct { ... } elem[25]

Referenced by exif_entry_get_value(), mnote_fuji_entry_get_value(), mnote_olympus_entry_get_value(), and mnote_pentax_entry_get_value().

int index

Definition at line 707 of file exif-entry.c.

Referenced by exif_entry_get_value(), mnote_fuji_entry_get_value(), mnote_olympus_entry_get_value(), and mnote_pentax_entry_get_value().

struct { ... } list[] [static]

Referenced by exif_entry_get_value().

struct { ... } list2[] [static]

Referenced by exif_entry_get_value().

const char* strings[10]

Definition at line 665 of file exif-entry.c.

Referenced by exif_entry_get_value().

ExifTag tag

Definition at line 705 of file exif-entry.c.

ExifTag tag

Definition at line 664 of file exif-entry.c.

const char* values[4]

list of progressively shorter string descriptions; the longest one that fits will be selected

Definition at line 708 of file exif-entry.c.

Referenced by exif_entry_get_value().


SourceForge.net Logo Generated by doxygen