main.html
Main Page
|
classes.html
Alphabetical List
|
annotated.html
Data Structures
|
dirs.html
Directories
|
files.html
File List
|
functions.html
Data Fields
|
globals.html
Globals
dir_000000.html
libexif
exif-content.c
exif-content_8c.html
Go to the documentation of this file.
00001
/* exif-content.c
00002
*
00003
* Copyright ? 2001 Lutz M?ller <lutz@users.sourceforge.net>
00004
*
00005
* This library is free software; you can redistribute it and/or
00006
* modify it under the terms of the GNU Lesser General Public
00007
* License as published by the Free Software Foundation; either
00008
* version 2 of the License, or (at your option) any later version.
00009
*
00010
* This library is distributed in the hope that it will be useful,
00011
* but WITHOUT ANY WARRANTY; without even the implied warranty of
00012
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013
* Lesser General Public License for more details.
00014
*
00015
* You should have received a copy of the GNU Lesser General Public
00016
* License along with this library; if not, write to the
00017
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018
* Boston, MA 02111-1307, USA.
00019
*/
00020
00021
#include <config.h>
00022
00023
#include <
exif-content_8h.html
libexif/exif-content.h
>
00024
00025
#include <stdlib.h>
00026
#include <stdio.h>
00027
#include <string.h>
00028
00029
/* unused constant
00030
* static const unsigned char ExifHeader[] = {0x45, 0x78, 0x69, 0x66, 0x00, 0x00};
00031
*/
00032
struct__ExifContentPrivate.html
00033
struct
struct__ExifContentPrivate.html
_ExifContentPrivate
00034 {
struct__ExifContentPrivate.html#o0
00035
unsigned
int
struct__ExifContentPrivate.html#o0
ref_count
;
00036
struct__ExifContentPrivate.html#o1
00037
struct__ExifMem.html
ExifMem
*
struct__ExifContentPrivate.html#o1
mem
;
struct__ExifContentPrivate.html#o2
00038
struct__ExifLog.html
ExifLog
*
struct__ExifContentPrivate.html#o2
log
;
00039 };
00040
00041
struct__ExifContent.html
ExifContent
*
exif-content_8h.html#a4
00042
exif-content_8c.html#a0
exif_content_new
(
void
)
00043 {
00044
struct__ExifMem.html
ExifMem
*mem =
exif-mem_8c.html#a9
exif_mem_new_default
();
00045
struct__ExifContent.html
ExifContent
*content =
exif-content_8c.html#a1
exif_content_new_mem
(mem);
00046
00047
exif-mem_8c.html#a5
exif_mem_unref
(mem);
00048
00049
return
content;
00050 }
00051
00052
struct__ExifContent.html
ExifContent
*
exif-content_8h.html#a5
00053
exif-content_8c.html#a1
exif_content_new_mem
(
struct__ExifMem.html
ExifMem
*mem)
00054 {
00055
struct__ExifContent.html
ExifContent
*content;
00056
00057
if
(!mem)
return
NULL;
00058
00059         content =
exif-mem_8c.html#a7
exif_mem_alloc
(mem, (
exif-utils_8h.html#a6
ExifLong
)
sizeof
(
struct__ExifContent.html
ExifContent
));
00060
if
(!content)
00061
return
NULL;
00062         content->
struct__ExifContent.html#o3
priv
=
exif-mem_8c.html#a7
exif_mem_alloc
(mem,
00063                                 (
exif-utils_8h.html#a6
ExifLong
)
sizeof
(
struct__ExifContentPrivate.html
ExifContentPrivate
));
00064
if
(!content->
struct__ExifContent.html#o3
priv
) {
00065
exif-mem_8c.html#a6
exif_mem_free
(mem, content);
00066
return
NULL;
00067         }
00068
00069         content->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o0
ref_count
= 1;
00070
00071         content->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o1
mem
= mem;
00072
exif-mem_8c.html#a4
exif_mem_ref
(mem);
00073
00074
return
content;
00075 }
00076
00077
void
exif-content_8h.html#a6
00078
exif-content_8c.html#a2
exif_content_ref
(
struct__ExifContent.html
ExifContent
*content)
00079 {
00080         content->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o0
ref_count
++;
00081 }
00082
00083
void
exif-content_8h.html#a7
00084
exif-content_8c.html#a3
exif_content_unref
(
struct__ExifContent.html
ExifContent
*content)
00085 {
00086         content->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o0
ref_count
--;
00087
if
(!content->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o0
ref_count
)
00088
exif-content_8c.html#a4
exif_content_free
(content);
00089 }
00090
00091
void
exif-content_8h.html#a8
00092
exif-content_8c.html#a4
exif_content_free
(
struct__ExifContent.html
ExifContent
*content)
00093 {
00094
struct__ExifMem.html
ExifMem
*mem = (content && content->
struct__ExifContent.html#o3
priv
) ? content->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o1
mem
: NULL;
00095
unsigned
int
i;
00096
00097
if
(!content)
return
;
00098
00099
for
(i = 0; i < content->count; i++)
00100
exif-entry_8c.html#a16
exif_entry_unref
(content->
struct__ExifContent.html#o0
entries
[i]);
00101
exif-mem_8c.html#a6
exif_mem_free
(mem, content->
struct__ExifContent.html#o0
entries
);
00102
00103
if
(content->
struct__ExifContent.html#o3
priv
) {
00104
exif-log_8c.html#a9
exif_log_unref
(content->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o2
log
);
00105         }
00106
00107
exif-mem_8c.html#a6
exif_mem_free
(mem, content->
struct__ExifContent.html#o3
priv
);
00108
exif-mem_8c.html#a6
exif_mem_free
(mem, content);
00109
exif-mem_8c.html#a5
exif_mem_unref
(mem);
00110 }
00111
00112
void
exif-content_8h.html#a15
00113
exif-content_8c.html#a5
exif_content_dump
(
struct__ExifContent.html
ExifContent
*content,
unsigned
int
indent)
00114 {
00115
char
buf[1024];
00116
unsigned
int
i;
00117
00118
for
(i = 0; i < 2 * indent; i++)
00119                 buf[i] =
' '
;
00120         buf[i] =
'\0'
;
00121
00122
if
(!content)
00123
return
;
00124
00125         printf (
"%sDumping exif content (%i entries)...\n"
, buf,
00126                 content->
struct__ExifContent.html#o1
count
);
00127
for
(i = 0; i < content->count; i++)
00128
exif-entry_8c.html#a19
exif_entry_dump
(content->
struct__ExifContent.html#o0
entries
[i], indent + 1);
00129 }
00130
00131
void
exif-content_8h.html#a9
00132
exif-content_8c.html#a6
exif_content_add_entry
(
struct__ExifContent.html
ExifContent
*c,
struct__ExifEntry.html
ExifEntry
*entry)
00133 {
00134
if
(!c || !c->
struct__ExifContent.html#o3
priv
|| !entry || entry->
struct__ExifEntry.html#o5
parent
)
return
;
00135
00136
/* One tag can only be added once to an IFD. */
00137
if
(
exif-content_8c.html#a8
exif_content_get_entry
(c, entry->
struct__ExifEntry.html#o0
tag
)) {
00138
exif-log_8c.html#a12
exif_log
(c->priv->log,
exif-log_8h.html#a17a4
EXIF_LOG_CODE_DEBUG
,
"ExifContent"
,
00139
"An attempt has been made to add "
00140
"the tag '%s' twice to an IFD. This is against "
00141
"specification."
,
exif-tag_8c.html#a26
exif_tag_get_name
(entry->
struct__ExifEntry.html#o0
tag
));
00142
return
;
00143         }
00144
00145         entry->
struct__ExifEntry.html#o5
parent
= c;
00146         c->
struct__ExifContent.html#o0
entries
=
exif-mem_8c.html#a8
exif_mem_realloc
(c->priv->mem,
00147                 c->entries, sizeof (
struct__ExifEntry.html
ExifEntry
) * (c->count + 1));
00148
if
(!c->entries)
return
;
00149         c->entries[c->count] = entry;
00150
exif-entry_8c.html#a15
exif_entry_ref
(entry);
00151         c->count++;
00152 }
00153
00154
void
exif-content_8h.html#a10
00155
exif-content_8c.html#a7
exif_content_remove_entry
(
struct__ExifContent.html
ExifContent
*c,
struct__ExifEntry.html
ExifEntry
*e)
00156 {
00157
unsigned
int
i;
00158
00159
if
(!c || !c->
struct__ExifContent.html#o3
priv
|| !e || (e->
struct__ExifEntry.html#o5
parent
!= c))
return
;
00160
00161
/* Search the entry */
00162
for
(i = 0; i < c->count; i++)
if
(c->
struct__ExifContent.html#o0
entries
[i] == e)
break
;
00163
if
(i == c->
struct__ExifContent.html#o1
count
)
return
;
00164
00165
/* Remove the entry */
00166         memmove (&c->
struct__ExifContent.html#o0
entries
[i], &c->
struct__ExifContent.html#o0
entries
[i + 1],
00167                  sizeof (
struct__ExifEntry.html
ExifEntry
) * (c->
struct__ExifContent.html#o1
count
- i - 1));
00168         c->
struct__ExifContent.html#o1
count
--;
00169         e->
struct__ExifEntry.html#o5
parent
= NULL;
00170
exif-entry_8c.html#a16
exif_entry_unref
(e);
00171         c->
struct__ExifContent.html#o0
entries
=
exif-mem_8c.html#a8
exif_mem_realloc
(c->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o1
mem
, c->
struct__ExifContent.html#o0
entries
,
00172
sizeof
(
struct__ExifEntry.html
ExifEntry
) * c->
struct__ExifContent.html#o1
count
);
00173 }
00174
00175
struct__ExifEntry.html
ExifEntry
*
exif-content_8h.html#a11
00176
exif-content_8c.html#a8
exif_content_get_entry
(
struct__ExifContent.html
ExifContent
*content,
exif-tag_8h.html#a153
ExifTag
mnote-canon-tag_8c.html#a0
tag
)
00177 {
00178
unsigned
int
i;
00179
00180
if
(!content)
00181
return
(NULL);
00182
00183
for
(i = 0; i < content->count; i++)
00184
if
(content->
struct__ExifContent.html#o0
entries
[i]->
struct__ExifEntry.html#o0
tag
== tag)
00185
return
(content->
struct__ExifContent.html#o0
entries
[i]);
00186
return
(NULL);
00187 }
00188
00189
void
exif-content_8h.html#a13
00190
exif-content_8c.html#a9
exif_content_foreach_entry
(
struct__ExifContent.html
ExifContent
*content,
00191
exif-content_8h.html#a3
ExifContentForeachEntryFunc
func,
void
*data)
00192 {
00193
unsigned
int
i;
00194
00195
if
(!content || !func)
00196
return
;
00197
00198
for
(i = 0; i < content->count; i++)
00199                 func (content->
struct__ExifContent.html#o0
entries
[i], data);
00200 }
00201
00202
void
exif-content_8h.html#a16
00203
exif-content_8c.html#a10
exif_content_log
(
struct__ExifContent.html
ExifContent
*content,
struct__ExifLog.html
ExifLog
*log)
00204 {
00205
if
(!content || !content->
struct__ExifContent.html#o3
priv
|| !log || content->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o2
log
== log)
00206
return
;
00207
00208
if
(content->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o2
log
)
exif-log_8c.html#a9
exif_log_unref
(content->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o2
log
);
00209         content->
struct__ExifContent.html#o3
priv
->
struct__ExifContentPrivate.html#o2
log
= log;
00210
exif-log_8c.html#a8
exif_log_ref
(log);
00211 }
00212
00213
exif-ifd_8h.html#a7
ExifIfd
exif-content_8h.html#a14
00214
exif-content_8c.html#a11
exif_content_get_ifd
(
struct__ExifContent.html
ExifContent
*c)
00215 {
00216
if
(!c || !c->
struct__ExifContent.html#o2
parent
)
return
exif-ifd_8h.html#a7a5
EXIF_IFD_COUNT
;
00217
00218
return
00219                 ((c)->parent->ifd[
exif-ifd_8h.html#a7a0
EXIF_IFD_0
] == (c)) ?
exif-ifd_8h.html#a7a0
EXIF_IFD_0
:
00220                 ((c)->parent->ifd[
exif-ifd_8h.html#a7a1
EXIF_IFD_1
] == (c)) ?
exif-ifd_8h.html#a7a1
EXIF_IFD_1
:
00221                 ((c)->parent->ifd[
exif-ifd_8h.html#a7a2
EXIF_IFD_EXIF
] == (c)) ?
exif-ifd_8h.html#a7a2
EXIF_IFD_EXIF
:
00222                 ((c)->parent->ifd[
exif-ifd_8h.html#a7a3
EXIF_IFD_GPS
] == (c)) ?
exif-ifd_8h.html#a7a3
EXIF_IFD_GPS
:
00223                 ((c)->parent->ifd[
exif-ifd_8h.html#a7a4
EXIF_IFD_INTEROPERABILITY
] == (c)) ?
exif-ifd_8h.html#a7a4
EXIF_IFD_INTEROPERABILITY
:
00224
exif-ifd_8h.html#a7a5
EXIF_IFD_COUNT
;
00225 }
00226
00227
static
void
exif-content_8c.html#a12
00228
exif-content_8c.html#a12
fix_func
(
struct__ExifEntry.html
ExifEntry
*e,
void
*data)
00229 {
00230
exif-entry_8c.html#a18
exif_entry_fix
(e);
00231 }
00232
00233
void
exif-content_8h.html#a12
00234
exif-content_8c.html#a13
exif_content_fix
(
struct__ExifContent.html
ExifContent
*c)
00235 {
00236
exif-ifd_8h.html#a7
ExifIfd
exif-ifd_8c.html#a0
ifd
=
exif-content_8c.html#a11
exif_content_get_ifd
(c);
00237
exif-data-type_8h.html#a5
ExifDataType
dt;
00238
exif-tag_8h.html#a153
ExifTag
t;
00239
struct__ExifEntry.html
ExifEntry
*e;
00240
00241
if
(!c)
return
;
00242
00243         dt =
exif-data_8c.html#a51
exif_data_get_data_type
(c->
struct__ExifContent.html#o2
parent
);
00244
00245
/* First of all, fix all existing entries. */
00246
exif-content_8c.html#a9
exif_content_foreach_entry
(c,
exif-content_8c.html#a12
fix_func
, NULL);
00247
00248
/*
00249
* Then check for existing tags that are not allowed and for
00250
* non-existing mandatory tags.
00251
*/
00252
for
(t = 0; t <= 0xffff; t++) {
00253
switch
(
exif-tag_8c.html#a30
exif_tag_get_support_level_in_ifd
(t, ifd, dt)) {
00254
case
exif-tag_8h.html#a154a143
EXIF_SUPPORT_LEVEL_MANDATORY
:
00255
if
(
exif-content_8c.html#a8
exif_content_get_entry
(c, t))
break
;
00256
exif-log_8c.html#a12
exif_log
(c->priv->log,
exif-log_8h.html#a17a4
EXIF_LOG_CODE_DEBUG
,
"exif-content"
,
00257
"Tag '%s' is mandatory in IFD '%s' and has therefore been added."
,
00258
exif-tag_8c.html#a22
exif_tag_get_name_in_ifd
(t, ifd),
exif-ifd_8c.html#a3
exif_ifd_get_name
(ifd));
00259                         e =
exif-entry_8c.html#a13
exif_entry_new
();
00260
exif-content_8c.html#a6
exif_content_add_entry
(c, e);
00261
exif-entry_8c.html#a21
exif_entry_initialize
(e, t);
00262
exif-entry_8c.html#a16
exif_entry_unref
(e);
00263
break
;
00264
case
exif-tag_8h.html#a154a142
EXIF_SUPPORT_LEVEL_NOT_RECORDED
:
00265                         e =
exif-content_8c.html#a8
exif_content_get_entry
(c, t);
00266
if
(!e)
break
;
00267
exif-log_8c.html#a12
exif_log
(c->priv->log,
exif-log_8h.html#a17a4
EXIF_LOG_CODE_DEBUG
,
"exif-content"
,
00268
"Tag '%s' is not recoreded in IFD '%s' and has therefore been "
00269
"removed."
,
exif-tag_8c.html#a22
exif_tag_get_name_in_ifd
(t, ifd),
00270
exif-ifd_8c.html#a3
exif_ifd_get_name
(ifd));
00271
exif-content_8c.html#a7
exif_content_remove_entry
(c, e);
00272
break
;
00273
case
exif-tag_8h.html#a154a144
EXIF_SUPPORT_LEVEL_OPTIONAL
:
00274
default
:
00275
break
;
00276                 }
00277         }
00278 }
Generated on Fri Sep 9 16:28:11 2005 for EXIF library (libexif) Internals by
http://www.doxygen.org/index.html
doxygen
1.4.4
