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
&raquo
dir_000003.html
pentax
exif-mnote-data-pentax.c
exif-mnote-data-pentax_8c.html
Go to the documentation of this file.
00001
/* exif-mnote-data-pentax.c
00002
*
00003
* Copyright ? 2002, 2003 Lutz Mueller <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
#include "
exif-mnote-data-pentax_8h.html
exif-mnote-data-pentax.h
"
00023
00024
#include <stdlib.h>
00025
#include <string.h>
00026
#include <stdio.h>
00027
00028
#include <
exif-byte-order_8h.html
libexif/exif-byte-order.h
>
00029
#include <
exif-utils_8h.html
libexif/exif-utils.h
>
00030
00031
/* #define DEBUG */
00032
00033
static
void
exif-mnote-data-pentax_8c.html#a0
00034
exif-mnote-data-pentax_8c.html#a0
exif_mnote_data_pentax_clear
(
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*n)
00035 {
00036
struct__ExifMnoteData.html
ExifMnoteData
*d = (
struct__ExifMnoteData.html
ExifMnoteData
*) n;
00037
unsigned
int
i;
00038
00039
if
(!n)
return
;
00040
00041
if
(n->
struct__ExifMnoteDataPentax.html#o1
entries
) {
00042
for
(i = 0; i < n->count; i++)
00043
if
(n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o3
data
) {
00044
exif-mem_8c.html#a6
exif_mem_free
(d->
struct__ExifMnoteData.html#o3
mem
, n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o3
data
);
00045                                 n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o3
data
= NULL;
00046                         }
00047
exif-mem_8c.html#a6
exif_mem_free
(d->
struct__ExifMnoteData.html#o3
mem
, n->
struct__ExifMnoteDataPentax.html#o1
entries
);
00048                 n->
struct__ExifMnoteDataPentax.html#o1
entries
= NULL;
00049                 n->
struct__ExifMnoteDataPentax.html#o2
count
= 0;
00050         }
00051 }
00052
00053
static
void
exif-mnote-data-pentax_8c.html#a1
00054
exif-mnote-data-pentax_8c.html#a1
exif_mnote_data_pentax_free
(
struct__ExifMnoteData.html
ExifMnoteData
*n)
00055 {
00056
if
(!n)
return
;
00057
00058
exif-mnote-data-pentax_8c.html#a0
exif_mnote_data_pentax_clear
((
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*) n);
00059 }
00060
00061
static
char
*
exif-mnote-data-pentax_8c.html#a2
00062
exif-mnote-data-pentax_8c.html#a2
exif_mnote_data_pentax_get_value
(
struct__ExifMnoteData.html
ExifMnoteData
*d,
unsigned
int
i,
char
*val,
unsigned
int
maxlen)
00063 {
00064
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*n = (
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*) d;
00065
00066
if
(!n)
return
NULL;
00067
if
(n->
struct__ExifMnoteDataPentax.html#o2
count
<= i)
return
NULL;
00068
return
mnote-pentax-entry_8c.html#a7
mnote_pentax_entry_get_value
(&n->
struct__ExifMnoteDataPentax.html#o1
entries
[i], val, maxlen);
00069 }
00070
00071
static
void
exif-mnote-data-pentax_8c.html#a3
00072
exif-mnote-data-pentax_8c.html#a3
exif_mnote_data_pentax_load
(
struct__ExifMnoteData.html
ExifMnoteData
*en,
00073
const
unsigned
char
*buf,
unsigned
int
buf_size)
00074 {
00075
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*n = (
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*) en;
00076
unsigned
int
i, o, s;
00077
exif-utils_8h.html#a4
ExifShort
c;
00078
00079
/* Number of entries */
00080
if
(buf_size < 2)
return
;
00081         c =
exif-utils_8c.html#a2
exif_get_short
(buf + 6 + n->
struct__ExifMnoteDataPentax.html#o4
offset
, n->
struct__ExifMnoteDataPentax.html#o3
order
);
00082         n->
struct__ExifMnoteDataPentax.html#o1
entries
=
exif-mem_8c.html#a7
exif_mem_alloc
(en->
struct__ExifMnoteData.html#o3
mem
, sizeof (
struct__MnotePentaxEntry.html
MnotePentaxEntry
) * c);
00083
if
(!n->
struct__ExifMnoteDataPentax.html#o1
entries
)
return
;
00084
00085
for
(i = 0; i < c; i++) {
00086             o = 6 + 2 + n->
struct__ExifMnoteDataPentax.html#o4
offset
+ 12 * i;
00087
if
(o + 8 > buf_size)
return
;
00088
00089             n->
struct__ExifMnoteDataPentax.html#o2
count
= i + 1;
00090             n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o0
tag
=
exif-utils_8c.html#a2
exif_get_short
(buf + o + 0, n->
struct__ExifMnoteDataPentax.html#o3
order
);
00091             n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o1
format
=
exif-utils_8c.html#a2
exif_get_short
(buf + o + 2, n->
struct__ExifMnoteDataPentax.html#o3
order
);
00092             n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o2
components
=
exif-utils_8c.html#a7
exif_get_long
(buf + o + 4, n->
struct__ExifMnoteDataPentax.html#o3
order
);
00093             n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o5
order
= n->
struct__ExifMnoteDataPentax.html#o3
order
;
00094
00095
/*
00096
* Size? If bigger than 4 bytes, the actual data is not
00097
* in the entry but somewhere else (offset).
00098
*/
00099             s =
exif-format_8c.html#a5
exif_format_get_size
(n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o1
format
) *
00100                                       n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o2
components
;
00101
if
(!s)
return
;
00102             o += 8;
00103
if
(s > 4) o =
exif-utils_8c.html#a7
exif_get_long
(buf + o, n->
struct__ExifMnoteDataPentax.html#o3
order
) + 6;
00104
if
(o + s > buf_size)
return
;
00105
00106
/* Sanity check */
00107             n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o3
data
=
exif-mem_8c.html#a7
exif_mem_alloc
(en->
struct__ExifMnoteData.html#o3
mem
, sizeof (
char
) * s);
00108
if
(!n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o3
data
)
return
;
00109             n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o4
size
= s;
00110             memcpy (n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o3
data
, buf + o, s);
00111         }
00112 }
00113
00114
static
unsigned
int
exif-mnote-data-pentax_8c.html#a4
00115
exif-mnote-data-pentax_8c.html#a4
exif_mnote_data_pentax_count
(
struct__ExifMnoteData.html
ExifMnoteData
*n)
00116 {
00117
return
n ? ((
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*) n)->count : 0;
00118 }
00119
00120
static
unsigned
int
exif-mnote-data-pentax_8c.html#a5
00121
exif-mnote-data-pentax_8c.html#a5
exif_mnote_data_pentax_get_id
(
struct__ExifMnoteData.html
ExifMnoteData
*d,
unsigned
int
n)
00122 {
00123
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*note = (
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*) d;
00124
00125
if
(!note)
return
0;
00126
if
(note->
struct__ExifMnoteDataPentax.html#o2
count
<= n)
return
0;
00127
return
note->
struct__ExifMnoteDataPentax.html#o1
entries
[n].
struct__MnotePentaxEntry.html#o0
tag
;
00128 }
00129
00130
static
const
char
*
exif-mnote-data-pentax_8c.html#a6
00131
exif-mnote-data-pentax_8c.html#a6
exif_mnote_data_pentax_get_name
(
struct__ExifMnoteData.html
ExifMnoteData
*d,
unsigned
int
n)
00132 {
00133
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*note = (
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*) d;
00134
00135
if
(!note)
return
NULL;
00136
if
(note->
struct__ExifMnoteDataPentax.html#o2
count
<= n)
return
NULL;
00137
return
mnote-pentax-tag_8c.html#a5
mnote_pentax_tag_get_name
(note->
struct__ExifMnoteDataPentax.html#o1
entries
[n].
struct__MnotePentaxEntry.html#o0
tag
);
00138 }
00139
00140
static
const
char
*
exif-mnote-data-pentax_8c.html#a7
00141
exif-mnote-data-pentax_8c.html#a7
exif_mnote_data_pentax_get_title
(
struct__ExifMnoteData.html
ExifMnoteData
*d,
unsigned
int
n)
00142 {
00143
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*note = (
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*) d;
00144
00145
if
(!note)
return
NULL;
00146
if
(note->
struct__ExifMnoteDataPentax.html#o2
count
<= n)
return
NULL;
00147
return
mnote-pentax-tag_8c.html#a6
mnote_pentax_tag_get_title
(note->
struct__ExifMnoteDataPentax.html#o1
entries
[n].
struct__MnotePentaxEntry.html#o0
tag
);
00148 }
00149
00150
static
const
char
*
exif-mnote-data-pentax_8c.html#a8
00151
exif-mnote-data-pentax_8c.html#a8
exif_mnote_data_pentax_get_description
(
struct__ExifMnoteData.html
ExifMnoteData
*d,
unsigned
int
n)
00152 {
00153
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*note = (
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*) d;
00154
00155
if
(!note)
return
NULL;
00156
if
(note->
struct__ExifMnoteDataPentax.html#o2
count
<= n)
return
NULL;
00157
return
mnote-pentax-tag_8c.html#a7
mnote_pentax_tag_get_description
(note->
struct__ExifMnoteDataPentax.html#o1
entries
[n].
struct__MnotePentaxEntry.html#o0
tag
);
00158 }
00159
00160
static
void
exif-mnote-data-pentax_8c.html#a9
00161
exif-mnote-data-pentax_8c.html#a9
exif_mnote_data_pentax_set_offset
(
struct__ExifMnoteData.html
ExifMnoteData
*d,
unsigned
int
o)
00162 {
00163
if
(d) ((
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*) d)->offset = o;
00164 }
00165
00166
static
void
exif-mnote-data-pentax_8c.html#a10
00167
exif-mnote-data-pentax_8c.html#a10
exif_mnote_data_pentax_set_byte_order
(
struct__ExifMnoteData.html
ExifMnoteData
*d,
exif-byte-order_8h.html#a3
ExifByteOrder
o)
00168 {
00169
exif-byte-order_8h.html#a3
ExifByteOrder
o_orig;
00170
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*n = (
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
*) d;
00171
unsigned
int
i;
00172
00173
if
(!n)
return
;
00174
00175         o_orig = n->
struct__ExifMnoteDataPentax.html#o3
order
;
00176         n->
struct__ExifMnoteDataPentax.html#o3
order
= o;
00177
for
(i = 0; i < n->count; i++) {
00178                 n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o5
order
= o;
00179
exif-utils_8c.html#a0
exif_array_set_byte_order
(n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o1
format
, n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o3
data
,
00180                                 n->
struct__ExifMnoteDataPentax.html#o1
entries
[i].
struct__MnotePentaxEntry.html#o2
components
, o_orig, o);
00181         }
00182 }
00183
00184
struct__ExifMnoteData.html
ExifMnoteData
*
exif-mnote-data-pentax_8h.html#a1
00185
exif-mnote-data-pentax_8c.html#a11
exif_mnote_data_pentax_new
(
struct__ExifMem.html
ExifMem
*mem)
00186 {
00187
struct__ExifMnoteData.html
ExifMnoteData
*d;
00188
00189
if
(!mem)
return
NULL;
00190
00191         d =
exif-mem_8c.html#a7
exif_mem_alloc
(mem,
sizeof
(
struct__ExifMnoteDataPentax.html
ExifMnoteDataPentax
));
00192
if
(!d)
return
NULL;
00193
00194
exif-mnote-data-priv_8h.html#a2
exif_mnote_data_construct
(d, mem);
00195
00196
/* Set up function pointers */
00197         d->
struct__ExifMnoteData.html#o1
methods
.
struct__ExifMnoteDataMethods.html#o0
free
=
exif-mnote-data-pentax_8c.html#a1
exif_mnote_data_pentax_free
;
00198         d->
struct__ExifMnoteData.html#o1
methods
.
struct__ExifMnoteDataMethods.html#o4
set_byte_order
=
exif-mnote-data-pentax_8c.html#a10
exif_mnote_data_pentax_set_byte_order
;
00199         d->
struct__ExifMnoteData.html#o1
methods
.
struct__ExifMnoteDataMethods.html#o3
set_offset
=
exif-mnote-data-pentax_8c.html#a9
exif_mnote_data_pentax_set_offset
;
00200         d->
struct__ExifMnoteData.html#o1
methods
.
struct__ExifMnoteDataMethods.html#o2
load
=
exif-mnote-data-pentax_8c.html#a3
exif_mnote_data_pentax_load
;
00201         d->
struct__ExifMnoteData.html#o1
methods
.
struct__ExifMnoteDataMethods.html#o5
count
=
exif-mnote-data-pentax_8c.html#a4
exif_mnote_data_pentax_count
;
00202         d->
struct__ExifMnoteData.html#o1
methods
.
struct__ExifMnoteDataMethods.html#o6
get_id
=
exif-mnote-data-pentax_8c.html#a5
exif_mnote_data_pentax_get_id
;
00203         d->
struct__ExifMnoteData.html#o1
methods
.
struct__ExifMnoteDataMethods.html#o7
get_name
=
exif-mnote-data-pentax_8c.html#a6
exif_mnote_data_pentax_get_name
;
00204         d->
struct__ExifMnoteData.html#o1
methods
.
struct__ExifMnoteDataMethods.html#o8
get_title
=
exif-mnote-data-pentax_8c.html#a7
exif_mnote_data_pentax_get_title
;
00205         d->
struct__ExifMnoteData.html#o1
methods
.
struct__ExifMnoteDataMethods.html#o9
get_description
=
exif-mnote-data-pentax_8c.html#a8
exif_mnote_data_pentax_get_description
;
00206         d->
struct__ExifMnoteData.html#o1
methods
.
struct__ExifMnoteDataMethods.html#o10
get_value
=
exif-mnote-data-pentax_8c.html#a2
exif_mnote_data_pentax_get_value
;
00207
00208
return
d;
00209 }
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
