exif-log.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*! \file exif-log.h
  2. * \brief Log message infrastructure
  3. */
  4. /*
  5. * Copyright (c) 2004 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_LOG_H__
  23. #define __EXIF_LOG_H__
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif /* __cplusplus */
  27. #include <libexif/exif-mem.h>
  28. #include <stdarg.h>
  29. /*! State maintained by the logging interface */
  30. typedef struct _ExifLog ExifLog;
  31. /*! Create a new logging instance.
  32. * \see exif_log_free
  33. *
  34. * \return new instance of #ExifLog
  35. */
  36. ExifLog *exif_log_new (void);
  37. ExifLog *exif_log_new_mem (ExifMem *);
  38. void exif_log_ref (ExifLog *log);
  39. void exif_log_unref (ExifLog *log);
  40. /*! Delete instance of #ExifLog.
  41. * \see exif_log_new
  42. *
  43. * \param[in] log #ExifLog
  44. * \return new instance of #ExifLog
  45. */
  46. void exif_log_free (ExifLog *log);
  47. typedef enum {
  48. EXIF_LOG_CODE_NONE,
  49. EXIF_LOG_CODE_DEBUG,
  50. EXIF_LOG_CODE_NO_MEMORY,
  51. EXIF_LOG_CODE_CORRUPT_DATA
  52. } ExifLogCode;
  53. /*! Return a textual description of the given class of error log.
  54. *
  55. * \param[in] code logging message class
  56. * \return textual description of the log class
  57. */
  58. const char *exif_log_code_get_title (ExifLogCode code);
  59. /*! Return a verbose description of the given class of error log.
  60. *
  61. * \param[in] code logging message class
  62. * \return verbose description of the log class
  63. */
  64. const char *exif_log_code_get_message (ExifLogCode code);
  65. /*! Log callback function prototype.
  66. */
  67. typedef void (* ExifLogFunc) (ExifLog *log, ExifLogCode, const char *domain,
  68. const char *format, va_list args, void *data);
  69. /*! Register log callback function.
  70. * Calls to the log callback function are purely for diagnostic purposes.
  71. *
  72. * \param[in] log logging state variable
  73. * \param[in] func callback function to set
  74. * \param[in] data data to pass into callback function
  75. */
  76. void exif_log_set_func (ExifLog *log, ExifLogFunc func, void *data);
  77. #ifndef NO_VERBOSE_TAG_STRINGS
  78. void exif_log (ExifLog *log, ExifLogCode, const char *domain,
  79. const char *format, ...)
  80. #ifdef __GNUC__
  81. __attribute__((__format__(printf,4,5)))
  82. #endif
  83. ;
  84. #else
  85. #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  86. #define exif_log(...) do { } while (0)
  87. #elif defined(__GNUC__)
  88. #define exif_log(x...) do { } while (0)
  89. #else
  90. #define exif_log (void)
  91. #endif
  92. #endif
  93. void exif_logv (ExifLog *log, ExifLogCode, const char *domain,
  94. const char *format, va_list args);
  95. /* For your convenience */
  96. #define EXIF_LOG_NO_MEMORY(l,d,s) exif_log ((l), EXIF_LOG_CODE_NO_MEMORY, (d), "Could not allocate %lu byte(s).", (unsigned long)(s))
  97. #ifdef __cplusplus
  98. }
  99. #endif /* __cplusplus */
  100. #endif /* __EXIF_LOG_H__ */