exif-loader.h 4.2 KB

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