1 /*! \file exif-loader.h
2 * \brief Defines the ExifLoader type
5 * Copyright (c) 2003 Lutz Mueller <lutz@users.sourceforge.net>
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.
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.
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.
23 #ifndef __EXIF_LOADER_H__
24 #define __EXIF_LOADER_H__
26 #include <libexif/exif-data.h>
27 #include <libexif/exif-log.h>
28 #include <libexif/exif-mem.h>
32 #endif /* __cplusplus */
34 /*! Data used by the loader interface */
35 typedef struct _ExifLoader ExifLoader;
37 /*! Allocate a new #ExifLoader.
39 * \return allocated ExifLoader
41 ExifLoader *exif_loader_new (void);
43 /*! Allocate a new #ExifLoader using the specified memory allocator.
45 * \param[in] mem the ExifMem
46 * \return allocated ExifLoader
48 ExifLoader *exif_loader_new_mem (ExifMem *mem);
50 /*! Increase the refcount of the #ExifLoader.
52 * \param[in] loader the ExifLoader to increase the refcount of.
54 void exif_loader_ref (ExifLoader *loader);
56 /*! Decrease the refcount of the #ExifLoader.
57 * If the refcount reaches 0, the loader is freed.
59 * \param[in] loader ExifLoader for which to decrease the refcount
61 void exif_loader_unref (ExifLoader *loader);
63 /*! Load a file into the given #ExifLoader from the filesystem.
64 * The relevant data is copied in raw form into the #ExifLoader.
66 * \param[in] loader loader to write to
67 * \param[in] fname path to the file to read
69 void exif_loader_write_file (ExifLoader *loader, const char *fname);
71 /*! Load a buffer into the #ExifLoader from a memory buffer.
72 * The relevant data is copied in raw form into the #ExifLoader.
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.
80 unsigned char exif_loader_write (ExifLoader *loader, unsigned char *buf, unsigned int sz);
82 /*! Free any data previously loaded and reset the #ExifLoader to its
83 * newly-initialized state.
85 * \param[in] loader the loader
87 void exif_loader_reset (ExifLoader *loader);
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.
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.
98 * \param[in] loader the loader
99 * \return allocated ExifData
101 * \see exif_loader_get_buf
103 ExifData *exif_loader_get_data (ExifLoader *loader);
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.
110 * \param[in] loader the loader
111 * \param[out] buf read-only pointer to the data read by the loader, or NULL
113 * \param[out] buf_size size of the data at buf, or 0 in case of error
115 void exif_loader_get_buf (ExifLoader *loader, const unsigned char **buf,
116 unsigned int *buf_size);
118 /*! Set the log message object used by this #ExifLoader.
119 * \param[in] loader the loader
120 * \param[in] log #ExifLog
122 void exif_loader_log (ExifLoader *loader, ExifLog *log);
126 #endif /* __cplusplus */
128 #endif /* __EXIF_LOADER_H__ */