Home | History | Annotate | Download | only in libexif
      1 /*! \file exif-loader.h
      2  * \brief Defines the ExifLoader type
      3  */
      4 /*
      5  * Copyright (c) 2003 Lutz Mueller <lutz (at) users.sourceforge.net>
      6  *
      7  * This library is free software; you can redistribute it and/or
      8  * modify it under the terms of the GNU Lesser General Public
      9  * License as published by the Free Software Foundation; either
     10  * version 2 of the License, or (at your option) any later version.
     11  *
     12  * This library is distributed in the hope that it will be useful,
     13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     15  * Lesser General Public License for more details.
     16  *
     17  * You should have received a copy of the GNU Lesser General Public
     18  * License along with this library; if not, write to the
     19  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
     20  * Boston, MA  02110-1301  USA.
     21  */
     22 
     23 #ifndef __EXIF_LOADER_H__
     24 #define __EXIF_LOADER_H__
     25 
     26 #include <libexif/exif-data.h>
     27 #include <libexif/exif-log.h>
     28 #include <libexif/exif-mem.h>
     29 
     30 #ifdef __cplusplus
     31 extern "C" {
     32 #endif /* __cplusplus */
     33 
     34 /*! Data used by the loader interface */
     35 typedef struct _ExifLoader ExifLoader;
     36 
     37 /*! Allocate a new #ExifLoader.
     38  *
     39  *  \return allocated ExifLoader
     40  */
     41 ExifLoader *exif_loader_new     (void);
     42 
     43 /*! Allocate a new #ExifLoader using the specified memory allocator.
     44  *
     45  *  \param[in] mem the ExifMem
     46  *  \return allocated ExifLoader
     47  */
     48 ExifLoader *exif_loader_new_mem (ExifMem *mem);
     49 
     50 /*! Increase the refcount of the #ExifLoader.
     51  *
     52  *  \param[in] loader the ExifLoader to increase the refcount of.
     53  */
     54 void        exif_loader_ref     (ExifLoader *loader);
     55 
     56 /*! Decrease the refcount of the #ExifLoader.
     57  * If the refcount reaches 0, the loader is freed.
     58  *
     59  * \param[in] loader ExifLoader for which to decrease the refcount
     60  */
     61 void        exif_loader_unref   (ExifLoader *loader);
     62 
     63 /*! Load a file into the given #ExifLoader from the filesystem.
     64  * The relevant data is copied in raw form into the #ExifLoader.
     65  *
     66  * \param[in] loader loader to write to
     67  * \param[in] fname path to the file to read
     68  */
     69 void        exif_loader_write_file (ExifLoader *loader, const char *fname);
     70 
     71 /*! Load a buffer into the #ExifLoader from a memory buffer.
     72  * The relevant data is copied in raw form into the #ExifLoader.
     73  *
     74  * \param[in] loader loader to write to
     75  * \param[in] buf buffer to read from
     76  * \param[in] sz size of the buffer
     77  * \return 1 while EXIF data is read (or while there is still hope that
     78  *   there will be EXIF data later on), 0 otherwise.
     79  */
     80 unsigned char exif_loader_write (ExifLoader *loader, unsigned char *buf, unsigned int sz);
     81 
     82 /*! Free any data previously loaded and reset the #ExifLoader to its
     83  * newly-initialized state.
     84  *
     85  * \param[in] loader the loader
     86  */
     87 void          exif_loader_reset (ExifLoader *loader);
     88 
     89 /*! Create an #ExifData from the data in the loader. The loader must
     90  * already contain data from a previous call to #exif_loader_write_file
     91  * or #exif_loader_write.
     92  *
     93  * \note The #ExifData returned is created using its default options, which
     94  * may take effect before the data is returned. If other options are desired,
     95  * an #ExifData must be created explicitly and data extracted from the loader
     96  * using #exif_loader_get_buf instead.
     97  *
     98  * \param[in] loader the loader
     99  * \return allocated ExifData
    100  *
    101  * \see exif_loader_get_buf
    102  */
    103 ExifData     *exif_loader_get_data (ExifLoader *loader);
    104 
    105 /*! Return the raw data read by the loader.  The returned pointer is only
    106  * guaranteed to be valid until the next call to a function modifying
    107  * this #ExifLoader.  Either or both of buf and buf_size may be NULL on
    108  * entry, in which case that value is not returned.
    109  *
    110  * \param[in] loader the loader
    111  * \param[out] buf read-only pointer to the data read by the loader, or NULL
    112  *                 in case of error
    113  * \param[out] buf_size size of the data at buf, or 0 in case of error
    114  */
    115 void exif_loader_get_buf (ExifLoader *loader, const unsigned char **buf,
    116 						  unsigned int *buf_size);
    117 
    118 /*! Set the log message object used by this #ExifLoader.
    119  * \param[in] loader the loader
    120  * \param[in] log #ExifLog
    121  */
    122 void exif_loader_log (ExifLoader *loader, ExifLog *log);
    123 
    124 #ifdef __cplusplus
    125 }
    126 #endif /* __cplusplus */
    127 
    128 #endif /* __EXIF_LOADER_H__ */
    129