3 * Copyright (c) 2004 Lutz Mueller <lutz@users.sourceforge.net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301 USA.
23 #include <libexif/exif-log.h>
24 #include <libexif/i18n.h>
30 unsigned int ref_count;
43 { EXIF_LOG_CODE_DEBUG, N_("Debugging information"),
44 N_("Debugging information is available.") },
45 { EXIF_LOG_CODE_NO_MEMORY, N_("Not enough memory"),
46 N_("The system cannot provide enough memory.") },
47 { EXIF_LOG_CODE_CORRUPT_DATA, N_("Corrupt data"),
48 N_("The data provided does not follow the specification.") },
53 exif_log_code_get_title (ExifLogCode code)
57 for (i = 0; codes[i].title; i++) if (codes[i].code == code) break;
58 return _(codes[i].title);
62 exif_log_code_get_message (ExifLogCode code)
66 for (i = 0; codes[i].message; i++) if (codes[i].code == code) break;
67 return _(codes[i].message);
71 exif_log_new_mem (ExifMem *mem)
75 log = exif_mem_alloc (mem, sizeof (ExifLog));
76 if (!log) return NULL;
88 ExifMem *mem = exif_mem_new_default ();
89 ExifLog *log = exif_log_new_mem (mem);
97 exif_log_ref (ExifLog *log)
104 exif_log_unref (ExifLog *log)
107 if (log->ref_count > 0) log->ref_count--;
108 if (!log->ref_count) exif_log_free (log);
112 exif_log_free (ExifLog *log)
114 ExifMem *mem = log ? log->mem : NULL;
118 exif_mem_free (mem, log);
119 exif_mem_unref (mem);
123 exif_log_set_func (ExifLog *log, ExifLogFunc func, void *data)
130 #ifdef NO_VERBOSE_TAG_STRINGS
131 /* exif_log forms part of the API and can't be commented away */
135 exif_log (ExifLog *log, ExifLogCode code, const char *domain,
136 const char *format, ...)
140 va_start (args, format);
141 exif_logv (log, code, domain, format, args);
146 exif_logv (ExifLog *log, ExifLogCode code, const char *domain,
147 const char *format, va_list args)
150 if (!log->func) return;
151 log->func (log, code, domain, format, args, log->data);