exif-content.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*! \file exif-content.h
  2. * \brief Handling EXIF IFDs
  3. */
  4. /*
  5. * Copyright (c) 2001 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_CONTENT_H__
  23. #define __EXIF_CONTENT_H__
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif /* __cplusplus */
  27. /*! Holds all EXIF tags in a single IFD */
  28. typedef struct _ExifContent ExifContent;
  29. typedef struct _ExifContentPrivate ExifContentPrivate;
  30. #include <libexif/exif-tag.h>
  31. #include <libexif/exif-entry.h>
  32. #include <libexif/exif-data.h>
  33. #include <libexif/exif-log.h>
  34. #include <libexif/exif-mem.h>
  35. struct _ExifContent
  36. {
  37. ExifEntry **entries;
  38. unsigned int count;
  39. /*! Data containing this content */
  40. ExifData *parent;
  41. ExifContentPrivate *priv;
  42. };
  43. /* Lifecycle */
  44. ExifContent *exif_content_new (void);
  45. ExifContent *exif_content_new_mem (ExifMem *);
  46. void exif_content_ref (ExifContent *content);
  47. void exif_content_unref (ExifContent *content);
  48. void exif_content_free (ExifContent *content);
  49. /*! Add an EXIF tag to an IFD.
  50. * If this tag already exists in the IFD, this function does nothing.
  51. * \pre The "tag" member of the entry must be set on entry.
  52. *
  53. * \param[out] c IFD
  54. * \param[in] entry EXIF entry to add
  55. */
  56. void exif_content_add_entry (ExifContent *c, ExifEntry *entry);
  57. /*! Remove an EXIF tag from an IFD.
  58. * If this tag does not exist in the IFD, this function does nothing.
  59. *
  60. * \param[out] c IFD
  61. * \param[in] e EXIF entry to remove
  62. */
  63. void exif_content_remove_entry (ExifContent *c, ExifEntry *e);
  64. /*! Return the #ExifEntry in this IFD corresponding to the given tag.
  65. * This is a pointer into a member of the #ExifContent array and must NOT be
  66. * freed or unrefed by the caller.
  67. *
  68. * \param[in] content EXIF content for an IFD
  69. * \param[in] tag EXIF tag to return
  70. * \return #ExifEntry of the tag, or NULL on error
  71. */
  72. ExifEntry *exif_content_get_entry (ExifContent *content, ExifTag tag);
  73. /*! Fix the IFD to bring it into specification. Call #exif_entry_fix on
  74. * each entry in this IFD to fix existing entries, create any new entries
  75. * that are mandatory in this IFD but do not yet exist, and remove any
  76. * entries that are not allowed in this IFD.
  77. *
  78. * \param[in,out] c EXIF content for an IFD
  79. */
  80. void exif_content_fix (ExifContent *c);
  81. typedef void (* ExifContentForeachEntryFunc) (ExifEntry *, void *user_data);
  82. /*! Executes function on each EXIF tag in this IFD in turn.
  83. * The tags will not necessarily be visited in numerical order.
  84. *
  85. * \param[in,out] content IFD over which to iterate
  86. * \param[in] func function to call for each entry
  87. * \param[in] user_data data to pass into func on each call
  88. */
  89. void exif_content_foreach_entry (ExifContent *content,
  90. ExifContentForeachEntryFunc func,
  91. void *user_data);
  92. /*! Return the IFD number in which the given #ExifContent is found.
  93. *
  94. * \param[in] c an #ExifContent*
  95. * \return IFD number, or #EXIF_IFD_COUNT on error
  96. */
  97. ExifIfd exif_content_get_ifd (ExifContent *c);
  98. /*! Return a textual representation of the EXIF data for a tag.
  99. *
  100. * \param[in] c #ExifContent* for an IFD
  101. * \param[in] t #ExifTag to return
  102. * \param[out] v char* buffer in which to store value
  103. * \param[in] m unsigned int length of the buffer v
  104. * \return the v pointer, or NULL on error
  105. */
  106. #define exif_content_get_value(c,t,v,m) \
  107. (exif_content_get_entry (c,t) ? \
  108. exif_entry_get_value (exif_content_get_entry (c,t),v,m) : NULL)
  109. /*! Dump contents of the IFD to stdout.
  110. * This is intended for diagnostic purposes only.
  111. *
  112. * \param[in] content IFD data
  113. * \param[in] indent how many levels deep to indent the data
  114. */
  115. void exif_content_dump (ExifContent *content, unsigned int indent);
  116. /*! Set the log message object for this IFD.
  117. *
  118. * \param[in] content IFD
  119. * \param[in] log #ExifLog*
  120. */
  121. void exif_content_log (ExifContent *content, ExifLog *log);
  122. #ifdef __cplusplus
  123. }
  124. #endif /* __cplusplus */
  125. #endif /* __EXIF_CONTENT_H__ */