New.
[platform/upstream/libexif.git] / test / test-mem.c
1 /* test-mem.c
2  *
3  * Copyright (C) 2002 Lutz Müller <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., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #include <config.h>
22
23 #include <stdio.h>
24
25 #include <libexif/exif-data.h>
26
27 int
28 main (int argc, char **argv)
29 {
30         ExifData *ed;
31         ExifEntry *e;
32         unsigned char *eb;
33         unsigned int ebs;
34
35         printf ("Creating EXIF data...\n");
36         ed = exif_data_new ();
37
38         printf ("Creating EXIF entry...\n");
39         e = exif_entry_new ();
40         exif_content_add_entry (ed->ifd0, e);
41         exif_entry_initialize (e, EXIF_TAG_EXIF_VERSION);
42
43         printf ("Creating another EXIF entry...\n");
44         e = exif_entry_new ();
45         exif_content_add_entry (ed->ifd0, e);
46         exif_entry_initialize (e, EXIF_TAG_DATE_TIME);
47
48         printf ("Creating an EXIF entry in the EXIF IFD...\n");
49         e = exif_entry_new ();
50         exif_content_add_entry (ed->ifd_exif, e);
51         exif_entry_initialize (e, EXIF_TAG_FLASH_PIX_VERSION);
52
53         exif_data_dump (ed);
54
55         printf ("Saving EXIF data to memory...\n");
56         exif_data_save_data (ed, &eb, &ebs);
57         exif_data_unref (ed);
58
59         printf ("Loading EXIF data from memory...\n");
60         ed = exif_data_new_from_data (eb, ebs);
61         exif_data_dump (ed);
62         exif_data_unref (ed);
63
64         return 0;
65 }