mnote-canon-entry.c

Go to the documentation of this file.
00001 /* mnote-canon-entry.c
00002  *
00003  * Copyright © 2002 Lutz Müller <lutz@users.sourceforge.net>
00004  * Copyright © 2003 Matthieu Castet <mat-c@users.sourceforge.net>
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the
00018  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019  * Boston, MA 02111-1307, USA.
00020  */
00021 
00022 #include "config.h"
00023 #include "mnote-canon-entry.h"
00024 
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <string.h>
00028 
00029 #include <libexif/exif-format.h>
00030 #include <libexif/exif-utils.h>
00031 #include <libexif/i18n.h>
00032 
00033 /* #define DEBUG */
00034 
00035 #define CF(format,target,v,maxlen)                              \
00036 {                                                               \
00037         if (format != target) {                                 \
00038                 snprintf (v, maxlen,                            \
00039                         _("Invalid format '%s', "               \
00040                         "expected '%s'."),                      \
00041                         exif_format_get_name (format),          \
00042                         exif_format_get_name (target));         \
00043                 break;                                          \
00044         }                                                       \
00045 }
00046 
00047 #define CC(number,target,v,maxlen)                                      \
00048 {                                                                       \
00049         if (number != target) {                                         \
00050                 snprintf (v, maxlen,                                    \
00051                         _("Invalid number of components (%i, "          \
00052                         "expected %i)."), (int) number, (int) target);  \
00053                 break;                                                  \
00054         }                                                               \
00055 }
00056 #define CC2(number,t1,t2,v,maxlen)                                      \
00057 {                                                                       \
00058         if ((number != t1) && (number != t2)) {                         \
00059                 snprintf (v, maxlen,                                    \
00060                         _("Invalid number of components (%i, "          \
00061                         "expected %i or %i)."), (int) number,           \
00062                         (int) t1, (int) t2);                            \
00063                 break;                                                  \
00064         }                                                               \
00065 }
00066 
00067 #define UNDEFINED 0xFF
00068     
00069 static struct  {
00070   unsigned int subtag;
00071   ExifShort value;
00072   char *name;
00073 } entries [] = {
00074   { 0,  1, N_("macro")},
00075   { 0,  2, N_("normal")},
00076   { 3,  0, N_("flash did not fire")},
00077   { 3,  1, N_("auto")},
00078   { 3,  2, N_("on")},
00079   { 3,  3, N_("red eyes reduction")},
00080   { 3,  4, N_("slow synchro")},
00081   { 3,  5, N_("auto + red yes reduction")},
00082   { 3,  6, N_("on + red eyes reduction")},
00083   { 3, 16, N_("external")},
00084   { 4,  0, N_("single or timer")},
00085   { 4,  1, N_("continuous")},
00086   { 6,  0, N_("one-Shot")},
00087   { 6,  1, N_("AI Servo")},
00088   { 6,  2, N_("AI Focus")},
00089   { 6,  3, N_("MF")},
00090   { 6,  4, N_("Single")},
00091   { 6,  5, N_("Continuous")},
00092   { 6,  6, N_("MF")},
00093   { 9,  0, N_("large")},
00094   { 9,  1, N_("medium")},
00095   { 9,  2, N_("small")},
00096   {10,  0, N_("full auto")},
00097         {10,  1, N_("manual")},
00098         {10,  2, N_("landscape")},
00099         {10,  3, N_("fast shutter")},
00100         {10,  4, N_("slow shutter")},
00101         {10,  5, N_("night")},
00102         {10,  6, N_("Black & White")},
00103         {10,  7, N_("Sepia")},
00104         {10,  8, N_("Portrait")},
00105         {10,  9, N_("Sports")},
00106         {10, 10, N_("Macro / Close-Up")},
00107         {10, 11, N_("Pan Focus")},
00108         {12, 0x0000, N_("normal")},
00109         {12, 0x0001, N_("high")},
00110         {12, 0xffff, N_("low")},
00111         {13, 0x0000, N_("normal")},
00112         {13, 0x0001, N_("high")},
00113         {13, 0xffff, N_("low")},
00114         {14, 0x0000, N_("normal")},
00115         {14, 0x0001, N_("high")},
00116         {14, 0xffff, N_("low")},
00117         {15, 15, N_("auto")},
00118         {15, 16, N_("50")},
00119         {15, 17, N_("100")},
00120         {15, 18, N_("200")},
00121         {15, 19, N_("400")},
00122         {16,  3, N_("evaluative")},
00123         {16,  4, N_("partial")},
00124         {16,  5, N_("center-weighted")},
00125         {18, 0x3000, N_("none (manual focus)")},
00126         {18, 0x3001, N_("auto-selected")},
00127         {18, 0x3002, N_("right")},
00128         {18, 0x3003, N_("center")},
00129         {18, 0x3004, N_("left")},
00130         {19,  0, N_("easy shooting")},
00131         {19,  1, N_("program")},
00132         {19,  2, N_("Tv-priority")},
00133         {19,  3, N_("Av-priority")},
00134         {19,  4, N_("manual")},
00135         {19,  5, N_("A-DEP")},
00136         {21, 0x001, N_("Canon EF 50mm f/1.8")},
00137         {21, 0x002, N_("Canon EF 28mm f/2.8")},
00138         {21, 0x004, N_("Sigma UC Zoom 35-135mm f/4-5.6")},
00139         {21, 0x006, N_("Tokina AF193-2 19-35mm f/3.5-4.5")},
00140         {21, 0x010, N_("Sigma 50mm f/2.8 EX or 28mm f/1.8")},
00141         {21, 0x011, N_("Canon EF 35mm f/2")},
00142         {21, 0x013, N_("Canon EF 15mm f/2.8")},
00143         {21, 0x021, N_("Canon EF 80-200mm f/2.8L")},
00144         {21, 0x026, N_("Cosina 100mm f/3.5 Macro AF")},
00145         {21, 0x028, N_("Tamron AF Aspherical 28-200mm f/3.8-5.6")},
00146         {21, 0x029, N_("Canon EF 50mm f/1.8 MkII")},
00147         {21, 0x039, N_("Canon EF 75-300mm f/4-5.6")},
00148         {21, 0x040, N_("Canon EF 28-80mm f/3.5-5.6")},
00149         {21, 0x124, N_("Canon MP-E 65mm f/2.8 1-5x Macro Photo")},
00150         {21, 0x125, N_("Canon TS-E 24mm f/3.5L")},
00151         {21, 0x131, N_("Sigma 17-35mm f2.8-4 EX Aspherical HSM")},
00152         {21, 0x135, N_("Canon EF 200mm f/1.8L")},
00153         {21, 0x136, N_("Canon EF 300mm f/2.8L")},
00154         {21, 0x139, N_("Canon EF 400mm f/2.8L")},
00155         {21, 0x141, N_("Canon EF 500mm f/4.5L")},
00156         {21, 0x149, N_("Canon EF 100mm f/2")},
00157         {21, 0x150, N_("Sigma 20mm EX f/1.8")},
00158         {21, 0x151, N_("Canon EF 200mm f/2.8L")},
00159         {21, 0x153, N_("Canon EF 35-350mm f/3.5-5.6L")},
00160         {21, 0x155, N_("Canon EF 85mm f/1.8 USM")},
00161         {21, 0x156, N_("Canon EF 28-105mm f/3.5-4.5 USM")},
00162         {21, 0x160, N_("Canon EF 20-35mm f/3.5-4.5 USM")},
00163         {21, 0x161, N_("Canon EF 28-70mm f/2.8L or Sigma 24-70mm EX f/2.8")},
00164         {21, 0x165, N_("Canon EF 70-200mm f/2.8 L")},
00165         {21, 0x166, N_("Canon EF 70-200mm f/2.8 L + x1.4")},
00166         {21, 0x167, N_("Canon EF 70-200mm f/2.8 L + x2")},
00167         {21, 0x169, N_("Sigma 15-30mm f/3.5-4.5 EX DG Aspherical")},
00168         {21, 0x170, N_("Canon EF 200mm f/2.8L II")},
00169         {21, 0x173, N_("Canon EF 180mm Macro f/3.5L or Sigma 180mm EX HSM Macro f/3.5")},
00170         {21, 0x174, N_("Canon EF 135mm f/2L")},
00171         {21, 0x176, N_("Canon EF 24-85mm f/3.5-4.5 USM")},
00172         {21, 0x177, N_("Canon EF 300mm f/4L IS")},
00173         {21, 0x178, N_("Canon EF 28-135mm f/3.5-5.6 IS")},
00174         {21, 0x180, N_("Canon EF 35mm f/1.4L")},
00175         {21, 0x182, N_("Canon EF 100-400mm f/4.5-5.6L IS + x2")},
00176         {21, 0x183, N_("Canon EF 100-400mm f/4.5-5.6L IS")},
00177         {21, 0x186, N_("Canon EF 70-200mm f/4L")},
00178         {21, 0x190, N_("Canon EF 100mm f/2.8 Macro")},
00179         {21, 0x191, N_("Canon EF 400mm f/4 DO IS")},
00180         {21, 0x197, N_("Canon EF 75-300mm f/4-5.6 IS")},
00181         {21, 0x198, N_("Canon EF 50mm f/1.4")},
00182         {21, 0x202, N_("Canon EF 28-80 f/3.5-5.6 USM IV")},
00183         {21, 0x213, N_("Canon EF 90-300mm f/4.5-5.6")},
00184         {21, 0x229, N_("Canon EF 16-35mm f/2.8L")},
00185         {21, 0x230, N_("Canon EF 24-70mm f/2.8L")},
00186         {21, 0x231, N_("Canon EF 17-40mm f/4L")},
00187   {31,  0, N_("single")},
00188   {31,  1, N_("continuous")},
00189   { 0,  0, NULL}
00190 };
00191 
00192 unsigned int
00193 mnote_canon_entry_count_values (const MnoteCanonEntry *entry)
00194 {
00195         unsigned int  val;
00196 
00197         if (!entry) return 0;
00198 
00199         switch (entry->tag) {
00200         case MNOTE_CANON_TAG_SETTINGS_1:
00201         case MNOTE_CANON_TAG_SETTINGS_2:
00202         case MNOTE_CANON_TAG_CUSTOM_FUNCS:
00203                 if (entry->format != EXIF_FORMAT_SHORT) return 0;
00204 
00205                 val = exif_get_short (entry->data, entry->order);
00206                 /* val is buffer size, i.e. # of values plus 1 */
00207                 return MIN (entry->size - 2, val) / 2;
00208         default:
00209                 return 1;
00210         }
00211 }
00212 
00213 char *
00214 mnote_canon_entry_get_value (const