1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
|
/* exif-mnote-data.c
*
* Copyright (C) 2003 Lutz Mueller <lutz@users.sourceforge.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <config.h>
#include <libexif/exif-mnote-data.h>
#include <libexif/exif-mnote-data-priv.h>
#include <stdlib.h>
#include <string.h>
struct _ExifMnoteDataPriv
{
unsigned int ref_count;
};
void
exif_mnote_data_construct (ExifMnoteData *d, ExifMem *mem)
{
if (!d || !mem) return;
if (d->priv) return;
d->priv = exif_mem_alloc (mem, sizeof (ExifMnoteDataPriv));
if (!d->priv) return;
d->priv->ref_count = 1;
d->mem = mem;
exif_mem_ref (mem);
}
void
exif_mnote_data_ref (ExifMnoteData *d)
{
if (d && d->priv) d->priv->ref_count++;
}
static void
exif_mnote_data_free (ExifMnoteData *d)
{
ExifMem *mem = d ? d->mem : NULL;
if (!d) return;
if (d->priv) {
if (d->methods.free) d->methods.free (d);
exif_mem_free (mem, d->priv);
d->priv = NULL;
}
exif_log_unref (d->log);
exif_mem_free (mem, d);
exif_mem_unref (mem);
}
void
exif_mnote_data_unref (ExifMnoteData *d)
{
if (!d || !d->priv) return;
if (d->priv->ref_count > 0) d->priv->ref_count--;
if (!d->priv->ref_count)
exif_mnote_data_free (d);
}
void
exif_mnote_data_load (ExifMnoteData *d, const unsigned char *buf,
unsigned int buf_size)
{
if (!d || !d->methods.load) return;
d->methods.load (d, buf, buf_size);
}
void
exif_mnote_data_save (ExifMnoteData *d, unsigned char **buf,
unsigned int *buf_size)
{
if (!d || !d->methods.save) return;
d->methods.save (d, buf, buf_size);
}
void
exif_mnote_data_set_byte_order (ExifMnoteData *d, ExifByteOrder o)
{
if (!d || !d->methods.set_byte_order) return;
d->methods.set_byte_order (d, o);
}
void
exif_mnote_data_set_offset (ExifMnoteData *d, unsigned int o)
{
if (!d || !d->methods.set_offset) return;
d->methods.set_offset (d, o);
}
unsigned int
exif_mnote_data_count (ExifMnoteData *d)
{
if (!d || !d->methods.count) return 0;
return d->methods.count (d);
}
unsigned int
exif_mnote_data_get_id (ExifMnoteData *d, unsigned int n)
{
if (!d || !d->methods.get_id) return 0;
return d->methods.get_id (d, n);
}
const char *
exif_mnote_data_get_name (ExifMnoteData *d, unsigned int n)
{
if (!d || !d->methods.get_name) return NULL;
return d->methods.get_name (d, n);
}
const char *
exif_mnote_data_get_title (ExifMnoteData *d, unsigned int n)
{
if (!d || !d->methods.get_title) return NULL;
return d->methods.get_title (d, n);
}
const char *
exif_mnote_data_get_description (ExifMnoteData *d, unsigned int n)
{
if (!d || !d->methods.get_description) return NULL;
return d->methods.get_description (d, n);
}
char *
exif_mnote_data_get_value (ExifMnoteData *d, unsigned int n, char *val, unsigned int maxlen)
{
if (!d || !d->methods.get_value) return NULL;
return d->methods.get_value (d, n, val, maxlen);
}
void
exif_mnote_data_log (ExifMnoteData *d, ExifLog *log)
{
if (!d) return;
exif_log_unref (d->log);
d->log = log;
exif_log_ref (log);
}
|