EXIF library (libexif) Internals 0.6.26
test-mnote.c
Go to the documentation of this file.
1/* exif-mnote.c
2 *
3 * Copyright 2002 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 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.0-or-later
21 */
22
23#include <config.h>
24
25#include <stdio.h>
26#include <stdlib.h>
27
28#include <libexif/exif-data.h>
29
30static const char *strornull(const char *ptr) {
31 if (!ptr)
32 return "(none)";
33 return ptr;
34}
35
36static int
38{
39 unsigned int i, c;
40 char v[1024], *p;
41 ExifMnoteData *md;
42
43 printf("Byte order: %s\n",
45
46 printf("Parsing maker note...\n");
48 if (!md) {
49 fprintf (stderr, "Could not parse maker note!\n");
51 return 1;
52 }
53
54 printf("Increasing ref-count...\n");
56
57 printf("Decreasing ref-count...\n");
59
60 printf("Counting entries...\n");
61 c = exif_mnote_data_count (md);
62 printf("Found %i entries.\n", c);
63 for (i = 0; i < c; i++) {
64 printf("Dumping entry number %i...\n", i);
65 printf(" Name: '%s'\n",
67 printf(" Title: '%s'\n",
69 printf(" Description: '%s'\n",
71 p = exif_mnote_data_get_value (md, i, v, sizeof (v));
72 if (p) { printf(" Value: '%s'\n", v); }
73 }
74
75 return 0;
76}
77
78int
79main (int argc, char **argv)
80{
81 ExifData *d;
82 unsigned int buf_size;
83 unsigned char *buf;
84 int r;
85
86 if (argc <= 1) {
87 fprintf (stderr, "You need to supply a filename!\n");
88 return 1;
89 }
90
91 printf("Loading '%s'...\n", argv[1]);
92 d = exif_data_new_from_file (argv[1]);
93 if (!d) {
94 fprintf (stderr, "Could not load data from '%s'!\n", argv[1]);
95 return 1;
96 }
97 printf("Loaded '%s'.\n", argv[1]);
98
99 printf("######### Test 1 #########\n");
100 r = test_exif_data (d);
101 if (r) return r;
102
103 exif_data_save_data (d, &buf, &buf_size);
104 exif_data_unref (d);
105 d = exif_data_new_from_data (buf, buf_size);
106 free (buf);
107 if (!d) {
108 fprintf (stderr, "Could not load data from buf!\n");
109 return 1;
110 }
111
112 printf ("######### Test 2 #########\n");
113 r = test_exif_data (d);
114 exif_data_unref (d);
115 if (r) return r;
116
117 printf ("Test successful!\n");
118
119 return 0;
120}
const char * exif_byte_order_get_name(ExifByteOrder order)
Return a short, localized, textual name for the given byte order.
void exif_data_unref(ExifData *data)
Definition exif-data.c:1110
ExifByteOrder exif_data_get_byte_order(ExifData *data)
Return the byte order in use by this EXIF structure.
Definition exif-data.c:1185
ExifMnoteData * exif_data_get_mnote_data(ExifData *d)
Return the MakerNote data out of the EXIF data.
Definition exif-data.c:92
ExifData * exif_data_new_from_data(const unsigned char *data, unsigned int size)
Allocate a new ExifData and load EXIF data from a memory buffer.
Definition exif-data.c:156
ExifData * exif_data_new_from_file(const char *path)
Allocate a new ExifData and load EXIF data from a JPEG file.
Definition exif-data.c:1087
void exif_data_save_data(ExifData *data, unsigned char **d, unsigned int *ds)
Store raw EXIF data representing the ExifData structure into a memory buffer.
Definition exif-data.c:1042
Defines the ExifData type and the associated functions.
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_ref(ExifMnoteData *d)
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.
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_count(ExifMnoteData *d)
Return the number of tags in the MakerNote.
void exif_mnote_data_unref(ExifMnoteData *d)
int main(void)
Represents the entire EXIF data found in an image.
Definition exif-data.h:48
static const char * strornull(const char *ptr)
Definition test-mnote.c:30
static int test_exif_data(ExifData *d)
Definition test-mnote.c:37

libexif Generated by doxygen