EXIF library (libexif) Internals  0.6.24
exif-loader.c File Reference
#include <config.h>
#include <libexif/exif-loader.h>
#include <libexif/exif-utils.h>
#include <libexif/i18n.h>
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
Include dependency graph for exif-loader.c:

Go to the source code of this file.

Data Structures

struct  _ExifLoader
 

Macros

#define JPEG_MARKER_DCT   0xc0
 
#define JPEG_MARKER_DHT   0xc4
 
#define JPEG_MARKER_SOI   0xd8
 
#define JPEG_MARKER_DQT   0xdb
 
#define JPEG_MARKER_APP0   0xe0
 
#define JPEG_MARKER_APP1   0xe1
 
#define JPEG_MARKER_APP2   0xe2
 
#define JPEG_MARKER_APP4   0xe4
 
#define JPEG_MARKER_APP5   0xe5
 
#define JPEG_MARKER_APP11   0xeb
 
#define JPEG_MARKER_APP13   0xed
 
#define JPEG_MARKER_APP14   0xee
 
#define JPEG_MARKER_COM   0xfe
 

Enumerations

enum  ExifLoaderState {
  EL_READ = 0 , EL_READ_SIZE_BYTE_24 , EL_READ_SIZE_BYTE_16 , EL_READ_SIZE_BYTE_08 ,
  EL_READ_SIZE_BYTE_00 , EL_SKIP_BYTES , EL_EXIF_FOUND
}
 
enum  ExifLoaderDataFormat { EL_DATA_FORMAT_UNKNOWN , EL_DATA_FORMAT_EXIF , EL_DATA_FORMAT_JPEG , EL_DATA_FORMAT_FUJI_RAW }
 

Functions

static void * exif_loader_alloc (ExifLoader *l, unsigned int i)
 
void exif_loader_write_file (ExifLoader *l, const char *path)
 Load a file into the given ExifLoader from the filesystem. More...
 
static unsigned int exif_loader_copy (ExifLoader *eld, unsigned char *buf, unsigned int len)
 
unsigned char exif_loader_write (ExifLoader *eld, unsigned char *buf, unsigned int len)
 Load a buffer into the ExifLoader from a memory buffer. More...
 
ExifLoaderexif_loader_new (void)
 Allocate a new ExifLoader. More...
 
ExifLoaderexif_loader_new_mem (ExifMem *mem)
 Allocate a new ExifLoader using the specified memory allocator. More...
 
void exif_loader_ref (ExifLoader *loader)
 Increase the refcount of the ExifLoader. More...
 
static void exif_loader_free (ExifLoader *loader)
 
void exif_loader_unref (ExifLoader *loader)
 Decrease the refcount of the ExifLoader. More...
 
void exif_loader_reset (ExifLoader *loader)
 Free any data previously loaded and reset the ExifLoader to its newly-initialized state. More...
 
ExifDataexif_loader_get_data (ExifLoader *loader)
 Create an ExifData from the data in the loader. More...
 
void exif_loader_get_buf (ExifLoader *loader, const unsigned char **buf, unsigned int *buf_size)
 Return the raw data read by the loader. More...
 
void exif_loader_log (ExifLoader *loader, ExifLog *log)
 Set the log message object used by this ExifLoader. More...
 

Variables

static const unsigned char ExifHeader [] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00}
 Magic number for EXIF header. More...
 

Macro Definition Documentation

◆ JPEG_MARKER_APP0

#define JPEG_MARKER_APP0   0xe0

Definition at line 41 of file exif-loader.c.

◆ JPEG_MARKER_APP1

#define JPEG_MARKER_APP1   0xe1

Definition at line 43 of file exif-loader.c.

◆ JPEG_MARKER_APP11

#define JPEG_MARKER_APP11   0xeb

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

◆ JPEG_MARKER_APP13

#define JPEG_MARKER_APP13   0xed

Definition at line 53 of file exif-loader.c.

◆ JPEG_MARKER_APP14

#define JPEG_MARKER_APP14   0xee

Definition at line 55 of file exif-loader.c.

◆ JPEG_MARKER_APP2

#define JPEG_MARKER_APP2   0xe2

Definition at line 45 of file exif-loader.c.

◆ JPEG_MARKER_APP4

#define JPEG_MARKER_APP4   0xe4

Definition at line 47 of file exif-loader.c.

◆ JPEG_MARKER_APP5

#define JPEG_MARKER_APP5   0xe5

Definition at line 49 of file exif-loader.c.

◆ JPEG_MARKER_COM

#define JPEG_MARKER_COM   0xfe

Definition at line 57 of file exif-loader.c.

◆ JPEG_MARKER_DCT

#define JPEG_MARKER_DCT   0xc0

Definition at line 33 of file exif-loader.c.

◆ JPEG_MARKER_DHT

#define JPEG_MARKER_DHT   0xc4

Definition at line 35 of file exif-loader.c.

◆ JPEG_MARKER_DQT

#define JPEG_MARKER_DQT   0xdb

Definition at line 39 of file exif-loader.c.

◆ JPEG_MARKER_SOI

#define JPEG_MARKER_SOI   0xd8

Definition at line 37 of file exif-loader.c.

Enumeration Type Documentation

◆ ExifLoaderDataFormat

Enumerator
EL_DATA_FORMAT_UNKNOWN 
EL_DATA_FORMAT_EXIF 
EL_DATA_FORMAT_JPEG 
EL_DATA_FORMAT_FUJI_RAW 

Definition at line 69 of file exif-loader.c.

◆ ExifLoaderState

Enumerator
EL_READ 
EL_READ_SIZE_BYTE_24 
EL_READ_SIZE_BYTE_16 
EL_READ_SIZE_BYTE_08 
EL_READ_SIZE_BYTE_00 
EL_SKIP_BYTES 
EL_EXIF_FOUND 

Definition at line 59 of file exif-loader.c.

Function Documentation

◆ exif_loader_alloc()

static void* exif_loader_alloc ( ExifLoader l,
unsigned int  i 
)
static

Definition at line 101 of file exif-loader.c.

References EXIF_LOG_NO_MEMORY, exif_mem_alloc(), _ExifLoader::log, and _ExifLoader::mem.

Referenced by exif_loader_copy().

Here is the call graph for this function:

◆ exif_loader_copy()

static unsigned int exif_loader_copy ( ExifLoader eld,
unsigned char *  buf,
unsigned int  len 
)
static

Definition at line 143 of file exif-loader.c.

References _ExifLoader::buf, _ExifLoader::bytes_read, exif_loader_alloc(), MIN, and _ExifLoader::size.

Referenced by exif_loader_write().

Here is the call graph for this function:

◆ exif_loader_free()

static void exif_loader_free ( ExifLoader loader)
static

Definition at line 389 of file exif-loader.c.

References exif_loader_reset(), exif_log_unref(), exif_mem_free(), exif_mem_unref(), _ExifLoader::log, and _ExifLoader::mem.

Referenced by exif_loader_unref().

Here is the call graph for this function:

◆ exif_loader_get_buf()

void exif_loader_get_buf ( ExifLoader loader,
const unsigned char **  buf,
unsigned int *  buf_size 
)

Return the raw data read by the loader.

The returned pointer is only guaranteed to be valid until the next call to a function modifying this ExifLoader. Either or both of buf and buf_size may be NULL on entry, in which case that value is not returned.

Parameters
[in]loaderthe loader
[out]bufread-only pointer to the data read by the loader, or NULL in case of error
[out]buf_sizesize of the data at buf, or 0 in case of error

Definition at line 442 of file exif-loader.c.

References _ExifLoader::buf, _ExifLoader::bytes_read, _ExifLoader::data_format, EL_DATA_FORMAT_UNKNOWN, exif_log(), EXIF_LOG_CODE_DEBUG, and _ExifLoader::log.

Referenced by loader_null_test().

Here is the call graph for this function:

◆ exif_loader_get_data()

ExifData* exif_loader_get_data ( ExifLoader loader)

Create an ExifData from the data in the loader.

The loader must already contain data from a previous call to exif_loader_write_file or exif_loader_write.

Note
The ExifData returned is created using its default options, which may take effect before the data is returned. If other options are desired, an ExifData must be created explicitly and data extracted from the loader using exif_loader_get_buf instead.
Parameters
[in]loaderthe loader
Returns
allocated ExifData
See also
exif_loader_get_buf

Definition at line 426 of file exif-loader.c.

References _ExifLoader::buf, _ExifLoader::bytes_read, _ExifLoader::data_format, EL_DATA_FORMAT_UNKNOWN, exif_data_load_data(), exif_data_log(), exif_data_new_mem(), _ExifLoader::log, and _ExifLoader::mem.

Referenced by exif_data_new_from_file(), loader_null_test(), main(), and test_parse().

Here is the call graph for this function:

◆ exif_loader_log()

void exif_loader_log ( ExifLoader loader,
ExifLog log 
)

Set the log message object used by this ExifLoader.

Parameters
[in]loaderthe loader
[in]logExifLog

Definition at line 465 of file exif-loader.c.

References exif_log_ref(), exif_log_unref(), and _ExifLoader::log.

Referenced by loader_null_test().

Here is the call graph for this function:

◆ exif_loader_new()

ExifLoader* exif_loader_new ( void  )

Allocate a new ExifLoader.

Returns
allocated ExifLoader

Definition at line 352 of file exif-loader.c.

References exif_loader_new_mem(), exif_mem_new_default(), and exif_mem_unref().

Referenced by exif_data_new_from_file(), loader_null_test(), main(), and test_parse().

Here is the call graph for this function:

◆ exif_loader_new_mem()

ExifLoader* exif_loader_new_mem ( ExifMem mem)

Allocate a new ExifLoader using the specified memory allocator.

Parameters
[in]memthe ExifMem
Returns
allocated ExifLoader

Definition at line 363 of file exif-loader.c.

References exif_mem_alloc(), exif_mem_ref(), _ExifLoader::mem, and _ExifLoader::ref_count.

Referenced by exif_loader_new(), and loader_null_test().

Here is the call graph for this function:

◆ exif_loader_ref()

void exif_loader_ref ( ExifLoader loader)

Increase the refcount of the ExifLoader.

Parameters
[in]loaderthe ExifLoader to increase the refcount of.

Definition at line 382 of file exif-loader.c.

References _ExifLoader::ref_count.

Referenced by loader_null_test().

◆ exif_loader_reset()

void exif_loader_reset ( ExifLoader loader)

Free any data previously loaded and reset the ExifLoader to its newly-initialized state.

Parameters
[in]loaderthe loader

Definition at line 413 of file exif-loader.c.

References _ExifLoader::b_len, _ExifLoader::buf, _ExifLoader::bytes_read, _ExifLoader::data_format, EL_DATA_FORMAT_UNKNOWN, exif_mem_free(), _ExifLoader::mem, _ExifLoader::size, and _ExifLoader::state.

Referenced by exif_loader_free(), exif_loader_write(), and loader_null_test().

Here is the call graph for this function:

◆ exif_loader_unref()

void exif_loader_unref ( ExifLoader loader)

Decrease the refcount of the ExifLoader.

If the refcount reaches 0, the loader is freed.

Parameters
[in]loaderExifLoader for which to decrease the refcount

Definition at line 404 of file exif-loader.c.

References exif_loader_free(), and _ExifLoader::ref_count.

Referenced by exif_data_new_from_file(), loader_null_test(), main(), and test_parse().

Here is the call graph for this function:

◆ exif_loader_write()

unsigned char exif_loader_write ( ExifLoader loader,
unsigned char *  buf,
unsigned int  sz 
)

Load a buffer into the ExifLoader from a memory buffer.

The relevant data is copied in raw form into the ExifLoader.

Parameters
[in]loaderloader to write to
[in]bufbuffer to read from
[in]szsize of the buffer
Returns
1 while EXIF data is read (or while there is still hope that there will be EXIF data later on), 0 otherwise.

Definition at line 163 of file exif-loader.c.

References _, _ExifLoader::b, _ExifLoader::b_len, _ExifLoader::data_format, EL_DATA_FORMAT_EXIF, EL_DATA_FORMAT_FUJI_RAW, EL_DATA_FORMAT_JPEG, EL_DATA_FORMAT_UNKNOWN, EL_EXIF_FOUND, EL_READ, EL_READ_SIZE_BYTE_00, EL_READ_SIZE_BYTE_08, EL_READ_SIZE_BYTE_16, EL_READ_SIZE_BYTE_24, EL_SKIP_BYTES, exif_loader_copy(), exif_loader_reset(), exif_log(), EXIF_LOG_CODE_CORRUPT_DATA, EXIF_LOG_CODE_DEBUG, ExifHeader, JPEG_MARKER_APP0, JPEG_MARKER_APP1, JPEG_MARKER_APP11, JPEG_MARKER_APP13, JPEG_MARKER_APP14, JPEG_MARKER_APP2, JPEG_MARKER_APP4, JPEG_MARKER_APP5, JPEG_MARKER_COM, JPEG_MARKER_DCT, JPEG_MARKER_DHT, JPEG_MARKER_DQT, JPEG_MARKER_SOI, _ExifLoader::log, MAX, MIN, _ExifLoader::size, and _ExifLoader::state.

Referenced by exif_loader_write_file(), loader_null_test(), main(), and test_parse().

Here is the call graph for this function:

◆ exif_loader_write_file()

void exif_loader_write_file ( ExifLoader loader,
const char *  fname 
)

Load a file into the given ExifLoader from the filesystem.

The relevant data is copied in raw form into the ExifLoader.

Parameters
[in]loaderloader to write to
[in]fnamepath to the file to read

Definition at line 117 of file exif-loader.c.

References _, exif_loader_write(), exif_log(), EXIF_LOG_CODE_NONE, _ExifLoader::log, and size.

Referenced by exif_data_new_from_file(), and loader_null_test().

Here is the call graph for this function:

Variable Documentation

◆ ExifHeader

const unsigned char ExifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00}
static

Magic number for EXIF header.

Definition at line 98 of file exif-loader.c.

Referenced by exif_loader_write().


libexif Generated by doxygen