2002-07-25 Lutz Müller <lutz@users.sourceforge.net>
[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 #include <libexif/exif-ifd.h>
27
28 int
29 main (int argc, char **argv)
30 {
31         ExifData *ed;
32         ExifEntry *e;
33         unsigned char *eb;
34         unsigned int ebs;
35
36         printf ("Creating EXIF data...\n");
37         ed = exif_data_new ();
38
39         printf ("Creating EXIF entry...\n");
40         e = exif_entry_new ();
41         exif_content_add_entry (ed->ifd[EXIF_IFD_0], e);
42         exif_entry_initialize (e, EXIF_TAG_EXIF_VERSION);
43
44         printf ("Creating another EXIF entry...\n");
45         e = exif_entry_new ();
46         exif_content_add_entry (ed->ifd[EXIF_IFD_0], e);
47         exif_entry_initialize (e, EXIF_TAG_DATE_TIME);
48
49         printf ("Creating an EXIF entry in the EXIF IFD...\n");
50         e = exif_entry_new ();
51         exif_content_add_entry (ed->ifd[EXIF_IFD_EXIF], e);
52         exif_entry_initialize (e, EXIF_TAG_FLASH_PIX_VERSION);
53
54         exif_data_dump (ed);
55
56         printf ("Saving EXIF data to memory...\n");
57         exif_data_save_data (ed, &eb, &ebs);
58         exif_data_unref (ed);
59
60         printf ("Loading EXIF data from memory...\n");
61         ed = exif_data_new_from_data (eb, ebs);
62         exif_data_dump (ed);
63         exif_data_unref (ed);
64
65         return 0;
66 }