EXIF library (libexif) Internals  0.6.24
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 
21 #include <config.h>
22 
23 #include <stdio.h>
24 #include <stdlib.h>
25 
26 #include <libexif/exif-data.h>
27 
28 static int
30 {
31  unsigned int i, c;
32  char v[1024], *p;
33  ExifMnoteData *md;
34 
35  printf("Byte order: %s\n",
37 
38  printf("Parsing maker note...\n");
39  md = exif_data_get_mnote_data (d);
40  if (!md) {
41  fprintf (stderr, "Could not parse maker note!\n");
42  exif_data_unref (d);
43  return 1;
44  }
45 
46  printf("Increasing ref-count...\n");
48 
49  printf("Decreasing ref-count...\n");
51 
52  printf("Counting entries...\n");
53  c = exif_mnote_data_count (md);
54  printf("Found %i entries.\n", c);
55  for (i = 0; i < c; i++) {
56  printf("Dumping entry number %i...\n", i);
57  printf(" Name: '%s'\n",
58  exif_mnote_data_get_name (md, i));
59  printf(" Title: '%s'\n",
61  printf(" Description: '%s'\n",
63  p = exif_mnote_data_get_value (md, i, v, sizeof (v));
64  if (p) { printf(" Value: '%s'\n", v); }
65  }
66 
67  return 0;
68 }
69 
70 int
71 main (int argc, char **argv)
72 {
73  ExifData *d;
74  unsigned int buf_size;
75  unsigned char *buf;
76  int r;
77 
78  if (argc <= 1) {
79  fprintf (stderr, "You need to supply a filename!\n");
80  return 1;
81  }
82 
83  printf("Loading '%s'...\n", argv[1]);
84  d = exif_data_new_from_file (argv[1]);
85  if (!d) {
86  fprintf (stderr, "Could not load data from '%s'!\n", argv[1]);
87  return 1;
88  }
89  printf("Loaded '%s'.\n", argv[1]);
90 
91  printf("######### Test 1 #########\n");
92  r = test_exif_data (d);
93  if (r) return r;
94 
95  exif_data_save_data (d, &buf, &buf_size);
96  exif_data_unref (d);
97  d = exif_data_new_from_data (buf, buf_size);
98  if (!d) {
99  fprintf (stderr, "Could not load data from buf!\n");
100  return 1;
101  }
102  free (buf);
103 
104  printf ("######### Test 2 #########\n");
105  r = test_exif_data (d);
106  if (r) return r;
107 
108  printf ("Test successful!\n");
109 
110  return 1;
111 }
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:1098
ExifByteOrder exif_data_get_byte_order(ExifData *data)
Return the byte order in use by this EXIF structure.
Definition: exif-data.c:1173
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:154
ExifMnoteData * exif_data_get_mnote_data(ExifData *d)
Return the MakerNote data out of the EXIF data.
Definition: exif-data.c:90
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:1075
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:1030
Defines the ExifData type and the associated functions.
void exif_mnote_data_ref(ExifMnoteData *d)
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.
const char * exif_mnote_data_get_name(ExifMnoteData *d, unsigned int n)
Returns textual name of the given MakerNote tag.
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.
unsigned int exif_mnote_data_count(ExifMnoteData *d)
Return the number of tags in the MakerNote.
void exif_mnote_data_unref(ExifMnoteData *d)
Represents the entire EXIF data found in an image.
Definition: exif-data.h:47
int main(int argc, char **argv)
Definition: test-mnote.c:71
static int test_exif_data(ExifData *d)
Definition: test-mnote.c:29

libexif Generated by doxygen