EXIF library (libexif) Internals  0.6.24
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 
21 #include <config.h>
22 
25 
26 #include <stdlib.h>
27 #include <string.h>
28 
30 {
31  unsigned int ref_count;
32 };
33 
34 void
36 {
37  if (!d || !mem) return;
38  if (d->priv) return;
39  d->priv = exif_mem_alloc (mem, sizeof (ExifMnoteDataPriv));
40  if (!d->priv) return;
41 
42  d->priv->ref_count = 1;
43 
44  d->mem = mem;
45  exif_mem_ref (mem);
46 }
47 
48 void
50 {
51  if (d && d->priv) d->priv->ref_count++;
52 }
53 
54 static void
56 {
57  ExifMem *mem = d ? d->mem : NULL;
58 
59  if (!d) return;
60  if (d->priv) {
61  if (d->methods.free) d->methods.free (d);
62  exif_mem_free (mem, d->priv);
63  d->priv = NULL;
64  }
65  exif_log_unref (d->log);
66  exif_mem_free (mem, d);
67  exif_mem_unref (mem);
68 }
69 
70 void
72 {
73  if (!d || !d->priv) return;
74  if (d->priv->ref_count > 0) d->priv->ref_count--;
75  if (!d->priv->ref_count)
77 }
78 
79 void
80 exif_mnote_data_load (ExifMnoteData *d, const unsigned char *buf,
81  unsigned int buf_size)
82 {
83  if (!d || !d->methods.load) return;
84  d->methods.load (d, buf, buf_size);
85 }
86 
87 void
88 exif_mnote_data_save (ExifMnoteData *d, unsigned char **buf,
89  unsigned int *buf_size)
90 {
91  if (!d || !d->methods.save) return;
92  d->methods.save (d, buf, buf_size);
93 }
94 
95 void
97 {
98  if (!d || !d->methods.set_byte_order) return;
99  d->methods.set_byte_order (d, o);
100 }
101 
102 void
104 {
105  if (!d || !d->methods.set_offset) return;
106  d->methods.set_offset (d, o);
107 }
108 
109 unsigned int
111 {
112  if (!d || !d->methods.count) return 0;
113  return d->methods.count (d);
114 }
115 
116 unsigned int
118 {
119  if (!d || !d->methods.get_id) return 0;
120  return d->methods.get_id (d, n);
121 }
122 
123 const char *
125 {
126  if (!d || !d->methods.get_name) return NULL;
127  return d->methods.get_name (d, n);
128 }
129 
130 const char *
132 {
133  if (!d || !d->methods.get_title) return NULL;
134  return d->methods.get_title (d, n);
135 }
136 
137 const char *
139 {
140  if (!d || !d->methods.get_description) return NULL;
141  return d->methods.get_description (d, n);
142 }
143 
144 char *
145 exif_mnote_data_get_value (ExifMnoteData *d, unsigned int n, char *val, unsigned int maxlen)
146 {
147  if (!d || !d->methods.get_value) return NULL;
148  return d->methods.get_value (d, n, val, maxlen);
149 }
150 
151 void
153 {
154  if (!d) return;
155  exif_log_unref (d->log);
156  d->log = log;
157  exif_log_ref (log);
158 }
ExifByteOrder
Which byte order to use.
void exif_log_unref(ExifLog *log)
Definition: exif-log.c:104
void exif_log_ref(ExifLog *log)
Definition: exif-log.c:97
void exif_mem_free(ExifMem *mem, void *d)
Definition: exif-mem.c:69
void exif_mem_unref(ExifMem *mem)
Unrefcount an ExifMem.
Definition: exif-mem.c:61
void * exif_mem_alloc(ExifMem *mem, ExifLong ds)
Definition: exif-mem.c:79
void exif_mem_ref(ExifMem *mem)
Refcount an ExifMem.
Definition: exif-mem.c:54
void exif_mnote_data_load(ExifMnoteData *d, const unsigned char *buf, unsigned int buf_size)
Load the MakerNote data from a memory buffer.
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)
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.
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_name(ExifMnoteData *d, unsigned int n)
Returns textual name 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_description(ExifMnoteData *d, unsigned int n)
Returns verbose textual description of the given MakerNote tag.
const char * exif_mnote_data_get_title(ExifMnoteData *d, unsigned int n)
Returns textual title 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_description)(ExifMnoteData *, unsigned int)
void(* load)(ExifMnoteData *, const unsigned char *, unsigned int)
const char *(* get_name)(ExifMnoteData *, unsigned int)
const char *(* get_title)(ExifMnoteData *, 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)
void(* set_byte_order)(ExifMnoteData *, ExifByteOrder)
void(* free)(ExifMnoteData *)
unsigned int ref_count
ExifMnoteDataPriv * priv
ExifMnoteDataMethods methods

libexif Generated by doxygen