exif-format.c

Go to the documentation of this file.
00001 /* exif-format.c
00002  *
00003  * Copyright (c) 2001 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., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA  02110-1301  USA.
00019  */
00020 
00021 #include <config.h>
00022 
00023 #include <libexif/exif-format.h>
00024 #include <libexif/i18n.h>
00025 
00026 #include <stdlib.h>
00027 
00032 static const struct {
00033         ExifFormat format;
00034         const char *name;
00035         unsigned char size;
00036 } ExifFormatTable[] = {
00037         {EXIF_FORMAT_SHORT,     N_("Short"),     2},
00038         {EXIF_FORMAT_RATIONAL,  N_("Rational"),  8},
00039         {EXIF_FORMAT_SRATIONAL, N_("SRational"), 8},
00040         {EXIF_FORMAT_UNDEFINED, N_("Undefined"), 1},
00041         {EXIF_FORMAT_ASCII,     N_("ASCII"),     1},
00042         {EXIF_FORMAT_LONG,      N_("Long"),      4},
00043         {EXIF_FORMAT_BYTE,      N_("Byte"),      1},
00044         {EXIF_FORMAT_SBYTE,     N_("SByte"),     1},
00045         {EXIF_FORMAT_SSHORT,    N_("SShort"),    2},
00046         {EXIF_FORMAT_SLONG,     N_("SLong"),     4},
00047         {EXIF_FORMAT_FLOAT,     N_("Float"),     4},
00048         {EXIF_FORMAT_DOUBLE,    N_("Double"),    8},
00049         {0, NULL, 0}
00050 };
00051 
00052 const char *
00053 exif_format_get_name (ExifFormat format)
00054 {
00055         unsigned int i;
00056 
00057         /* FIXME: This belongs to somewhere else. */
00058         /* libexif should use the default system locale.
00059          * If an application specifically requires UTF-8, then we
00060          * must give the application a way to tell libexif that.
00061          * 
00062          * bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
00063          */
00064         bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
00065 
00066         for (i = 0; ExifFormatTable[i].name; i++)
00067                 if (ExifFormatTable[i].format == format)
00068                         return _(ExifFormatTable[i].name);
00069         return NULL;
00070 }
00071 
00072 unsigned char
00073 exif_format_get_size (ExifFormat format)
00074 {
00075         unsigned int i;
00076 
00077         for (i = 0; ExifFormatTable[i].size; i++)
00078                 if (ExifFormatTable[i].format == format)
00079                         return ExifFormatTable[i].size;
00080         return 0;
00081 }

SourceForge.net Logo Generated by doxygen