1 /*! \file exif-loader.h 2 * \brief Defines the ExifLoader type 3 */ 4 /* 5 * Copyright (c) 2003 Lutz Mueller <lutz@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 * SPDX-License-Identifier: LGPL-2.0-or-later 23 */ 24 25 #ifndef LIBEXIF_EXIF_LOADER_H 26 #define LIBEXIF_EXIF_LOADER_H 27 28 #include <libexif/exif-data.h> 29 #include <libexif/exif-log.h> 30 #include <libexif/exif-mem.h> 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif /* __cplusplus */ 35 36 /*! Data used by the loader interface */ 37 typedef struct _ExifLoader ExifLoader; 38 39 /*! Allocate a new #ExifLoader. 40 * 41 * \return allocated ExifLoader 42 */ 43 ExifLoader *exif_loader_new (void); 44 45 /*! Allocate a new #ExifLoader using the specified memory allocator. 46 * 47 * \param[in] mem the ExifMem 48 * \return allocated ExifLoader 49 */ 50 ExifLoader *exif_loader_new_mem (ExifMem *mem); 51 52 /*! Increase the refcount of the #ExifLoader. 53 * 54 * \param[in] loader the ExifLoader to increase the refcount of. 55 */ 56 void exif_loader_ref (ExifLoader *loader); 57 58 /*! Decrease the refcount of the #ExifLoader. 59 * If the refcount reaches 0, the loader is freed. 60 * 61 * \param[in] loader ExifLoader for which to decrease the refcount 62 */ 63 void exif_loader_unref (ExifLoader *loader); 64 65 /*! Load a file into the given #ExifLoader from the filesystem. 66 * The relevant data is copied in raw form into the #ExifLoader. 67 * 68 * \param[in] loader loader to write to 69 * \param[in] fname path to the file to read 70 */ 71 void exif_loader_write_file (ExifLoader *loader, const char *fname); 72 73 /*! Load a buffer into the #ExifLoader from a memory buffer. 74 * The relevant data is copied in raw form into the #ExifLoader. 75 * 76 * \param[in] loader loader to write to 77 * \param[in] buf buffer to read from 78 * \param[in] sz size of the buffer 79 * \return 1 while EXIF data is read (or while there is still hope that 80 * there will be EXIF data later on), 0 otherwise. 81 */ 82 unsigned char exif_loader_write (ExifLoader *loader, unsigned char *buf, unsigned int sz); 83 84 /*! Free any data previously loaded and reset the #ExifLoader to its 85 * newly-initialized state. 86 * 87 * \param[in] loader the loader 88 */ 89 void exif_loader_reset (ExifLoader *loader); 90 91 /*! Create an #ExifData from the data in the loader. The loader must 92 * already contain data from a previous call to #exif_loader_write_file 93 * or #exif_loader_write. 94 * 95 * \note The #ExifData returned is created using its default options, which 96 * may take effect before the data is returned. If other options are desired, 97 * an #ExifData must be created explicitly and data extracted from the loader 98 * using #exif_loader_get_buf instead. 99 * 100 * \param[in] loader the loader 101 * \return allocated ExifData 102 * 103 * \see exif_loader_get_buf 104 */ 105 ExifData *exif_loader_get_data (ExifLoader *loader); 106 107 /*! Return the raw data read by the loader. The returned pointer is only 108 * guaranteed to be valid until the next call to a function modifying 109 * this #ExifLoader. Either or both of buf and buf_size may be NULL on 110 * entry, in which case that value is not returned. 111 * 112 * \param[in] loader the loader 113 * \param[out] buf read-only pointer to the data read by the loader, or NULL 114 * in case of error 115 * \param[out] buf_size size of the data at buf, or 0 in case of error 116 */ 117 void exif_loader_get_buf (ExifLoader *loader, const unsigned char **buf, 118 unsigned int *buf_size); 119 120 /*! Set the log message object used by this #ExifLoader. 121 * \param[in] loader the loader 122 * \param[in] log #ExifLog 123 */ 124 void exif_loader_log (ExifLoader *loader, ExifLog *log); 125 126 #ifdef __cplusplus 127 } 128 #endif /* __cplusplus */ 129 130 #endif /* !defined(LIBEXIF_EXIF_LOADER_H) */ 131