EXIF library (libexif) Internals 0.6.26
exif-mnote-data.c
Go to the documentation of this file.
1/* exif-mnote-data.c
2 *
3 * Copyright (C) 2003 Lutz Mueller <lutz@users.sourceforge.net>
4 *
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.1 of the License, or (at your option) any later version.
9 *
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.
14 *
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.
19 *
20 * SPDX-License-Identifier: LGPL-2.1-or-later
21 */
22
23#include <config.h>
24
27
28#include <stdlib.h>
29#include <string.h>
30
32{
33 unsigned int ref_count;
34};
35
36void
38{
39 if (!d || !mem) return;
40 if (d->priv) return;
41 d->priv = exif_mem_alloc (mem, sizeof (ExifMnoteDataPriv));
42 if (!d->priv) return;
43
44 d->priv->ref_count = 1;
45
46 d->mem = mem;
47 exif_mem_ref (mem);
48}
49
50void
52{
53 if (d && d->priv) d->priv->ref_count++;
54}
55
56static void
58{
59 ExifMem *mem = d ? d->mem : NULL;
60
61 if (!d) return;
62 if (d->priv) {
63 if (d->methods.free) d->methods.free (d);
64 exif_mem_free (mem, d->priv);
65 d->priv = NULL;
66 }
68 exif_mem_free (mem, d);
69 exif_mem_unref (mem);
70}
71
72void
74{
75 if (!d || !d->priv) return;
76 if (d->priv->ref_count > 0) d->priv->ref_count--;
77 if (!d->priv->ref_count)
79}
80
81void
82exif_mnote_data_load (ExifMnoteData *d, const unsigned char *buf,
83 unsigned int buf_size)
84{
85 if (!d || !d->methods.load) return;
86 d->methods.load (d, buf, buf_size);
87}
88
89void
90exif_mnote_data_save (ExifMnoteData *d, unsigned char **buf,
91 unsigned int *buf_size)
92{
93 if (!d || !d->methods.save) return;
94 d->methods.save (d, buf, buf_size);
95}
96
97void
99{
100 if (!d || !d->methods.set_byte_order) return;
101 d->methods.set_byte_order (d, o);
102}
103
104void
106{
107 if (!d || !d->methods.set_offset) return;
108 d->methods.set_offset (d, o);
109}
110
111unsigned int
113{
114 if (!d || !d->methods.count) return 0;
115 return d->methods.count (d);
116}
117
118unsigned int
120{
121 if (!d || !d->methods.get_id) return 0;
122 return d->methods.get_id (d, n);
123}
124
125const char *
127{
128 if (!d || !d->methods.get_name) return NULL;
129 return d->methods.get_name (d, n);
130}
131
132const char *
134{
135 if (!d || !d->methods.get_title) return NULL;
136 return d->methods.get_title (d, n);
137}
138
139const char *
141{
142 if (!d || !d->methods.get_description) return NULL;
143 return d->methods.get_description (d, n);
144}
145
146char *
147exif_mnote_data_get_value (ExifMnoteData *d, unsigned int n, char *val, unsigned int maxlen)
148{
149 if (!d || !d->methods.get_value) return NULL;
150 return d->methods.get_value (d, n, val, maxlen);
151}
152
153void
155{
156 if (!d) return;
157 exif_log_unref (d->log);
158 d->log = log;
159 exif_log_ref (log);
160}
ExifByteOrder
Which byte order to use.
void exif_log_unref(ExifLog *log)
Definition exif-log.c:106
void exif_log_ref(ExifLog *log)
Definition exif-log.c:99
void exif_mem_free(ExifMem *mem, void *d)
Definition exif-mem.c:91
void exif_mem_unref(ExifMem *mem)
Unrefcount an ExifMem.
Definition exif-mem.c:83
void * exif_mem_alloc(ExifMem *mem, ExifLong ds)
Definition exif-mem.c:101
void exif_mem_ref(ExifMem *mem)
Refcount an ExifMem.
Definition exif-mem.c:76
void exif_mnote_data_load(ExifMnoteData *d, const unsigned char *buf, unsigned int buf_size)
Load the MakerNote data from a memory buffer.
char * exif_mnote_data_get_value(ExifMnoteData *d, unsigned int n, char *val, unsigned int maxlen)
Return a textual representation of the value of the MakerNote entry.
static void exif_mnote_data_free(ExifMnoteData *d)
void exif_mnote_data_set_byte_order(ExifMnoteData *d, ExifByteOrder o)
void exif_mnote_data_ref(ExifMnoteData *d)
void exif_mnote_data_construct(ExifMnoteData *d, ExifMem *mem)
void exif_mnote_data_save(ExifMnoteData *d, unsigned char **buf, unsigned int *buf_size)
Save the raw MakerNote data into a memory buffer.
const char * exif_mnote_data_get_description(ExifMnoteData *d, unsigned int n)
Returns verbose textual description of the given MakerNote tag.
unsigned int exif_mnote_data_get_id(ExifMnoteData *d, unsigned int n)
Return the MakerNote tag number for the tag at the specified index within the MakerNote.
const char * exif_mnote_data_get_title(ExifMnoteData *d, unsigned int n)
Returns textual title of the given MakerNote tag.
const char * exif_mnote_data_get_name(ExifMnoteData *d, unsigned int n)
Returns textual name of the given MakerNote tag.
void exif_mnote_data_set_offset(ExifMnoteData *d, unsigned int o)
void exif_mnote_data_log(ExifMnoteData *d, ExifLog *log)
unsigned int exif_mnote_data_count(ExifMnoteData *d)
Return the number of tags in the MakerNote.
void exif_mnote_data_unref(ExifMnoteData *d)
Handling EXIF MakerNote tags.
const char *(* get_name)(ExifMnoteData *, unsigned int)
const char *(* get_description)(ExifMnoteData *, unsigned int)
void(* load)(ExifMnoteData *, const unsigned char *, unsigned int)
char *(* get_value)(ExifMnoteData *, unsigned int, char *val, unsigned int maxlen)
unsigned int(* get_id)(ExifMnoteData *, unsigned int)
void(* save)(ExifMnoteData *, unsigned char **, unsigned int *)
unsigned int(* count)(ExifMnoteData *)
void(* set_offset)(ExifMnoteData *, unsigned int)
const char *(* get_title)(ExifMnoteData *, unsigned int)
void(* set_byte_order)(ExifMnoteData *, ExifByteOrder)
void(* free)(ExifMnoteData *)
unsigned int ref_count
ExifMnoteDataPriv * priv
ExifMnoteDataMethods methods

libexif Generated by doxygen