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>

Go to the source code of this file.

Data Structures

struct  _ExifLoader
 

For internal use only.

More...

Defines

#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_APP13   0xed
#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.
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.
ExifLoaderexif_loader_new (void)
 Allocate a new ExifLoader.
ExifLoaderexif_loader_new_mem (ExifMem *mem)
 Allocate a new ExifLoader using the specified memory allocator.
void exif_loader_ref (ExifLoader *loader)
 Increase the refcount of the ExifLoader.
static void exif_loader_free (ExifLoader *loader)
void exif_loader_unref (ExifLoader *loader)
 Decrease the refcount of the ExifLoader.
void exif_loader_reset (ExifLoader *loader)
 Free any data previously loaded and reset the ExifLoader to its newly-initialized state.
ExifDataexif_loader_get_data (ExifLoader *loader)
 Create an ExifData from the data in the loader.
void exif_loader_get_buf (ExifLoader *loader, const unsigned char **buf, unsigned int *buf_size)
 Return the raw data read by the loader.
void exif_loader_log (ExifLoader *loader, ExifLog *log)
 Set the log message object used by this ExifLoader.

Variables

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


Define Documentation

#define JPEG_MARKER_APP0   0xe0

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

#define JPEG_MARKER_APP1   0xe1

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

#define JPEG_MARKER_APP13   0xed

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

Referenced by exif_loader_write().

#define JPEG_MARKER_APP2   0xe2

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

Referenced by exif_loader_write().

#define JPEG_MARKER_COM   0xfe

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

Referenced by exif_loader_write().

#define JPEG_MARKER_DHT   0xc4

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

Referenced by exif_loader_write().

#define JPEG_MARKER_DQT   0xdb

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

Referenced by exif_loader_write().

#define JPEG_MARKER_SOI   0xd8

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


Enumeration Type Documentation

enum ExifLoaderDataFormat

Enumerator:
EL_DATA_FORMAT_UNKNOWN 
EL_DATA_FORMAT_EXIF 
EL_DATA_FORMAT_JPEG 
EL_DATA_FORMAT_FUJI_RAW 

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

enum 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 49 of file exif-loader.c.


Function Documentation

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

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

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

Referenced by exif_loader_copy().

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

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

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

Referenced by exif_loader_write().

static void exif_loader_free ( ExifLoader loader  )  [static]

Definition at line 354 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().

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] loader the loader
[out] buf read-only pointer to the data read by the loader, or NULL in case of error
[out] buf_size size of the data at buf, or 0 in case of error

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

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] loader the loader
Returns:
allocated ExifData
See also:
exif_loader_get_buf

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

Referenced by exif_data_new_from_file(), and main().

void exif_loader_log ( ExifLoader loader,
ExifLog log 
)

Set the log message object used by this ExifLoader.

Parameters:
[in] loader the loader
[in] log ExifLog

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

ExifLoader* exif_loader_new ( void   ) 

Allocate a new ExifLoader.

Returns:
allocated ExifLoader

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

Referenced by exif_data_new_from_file(), and main().

ExifLoader* exif_loader_new_mem ( ExifMem mem  ) 

Allocate a new ExifLoader using the specified memory allocator.

Parameters:
[in] mem the ExifMem
Returns:
allocated ExifLoader

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

Referenced by exif_loader_new().

void exif_loader_ref ( ExifLoader loader  ) 

Increase the refcount of the ExifLoader.

Parameters:
[in] loader the ExifLoader to increase the refcount of.

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

void exif_loader_reset ( ExifLoader loader  ) 

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

Parameters:
[in] loader the loader

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

Referenced by exif_loader_free(), and exif_loader_write().

void exif_loader_unref ( ExifLoader loader  ) 

Decrease the refcount of the ExifLoader.

If the refcount reaches 0, the loader is freed.

Parameters:
[in] loader ExifLoader for which to decrease the refcount

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

Referenced by exif_data_new_from_file(), and main().

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] loader loader to write to
[in] buf buffer to read from
[in] sz size 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 153 of file exif-loader.c.

Referenced by exif_loader_write(), exif_loader_write_file(), and main().

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] loader loader to write to
[in] fname path to the file to read

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

Referenced by exif_data_new_from_file().


Variable Documentation

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

Magic number for EXIF header.

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


SourceForge.net Logo Generated by doxygen