1 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
2 /* EXIFPROBE - TIFF/JPEG/EXIF image file probe */
3 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
4 /* Copyright (C) 2002,2005 by Duane H. Hesser. All rights reserved. */
5 /* */
6 /* See the file LICENSE.EXIFPROBE for terms of use. */
7 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
8
9 #ifndef lint
10 static char *ModuleId = "@(#) $Id: maker_konica.c,v 1.3 2005/07/24 22:56:26 alex Exp $";
11 #endif
12
13 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
14 /* Konica camera maker-specific routines */
15 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
16 /* */
17 /* A bare minimum is known at this time (4/22/03)...just the PrintIM */
18 /* tag. */
19 /* =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- */
20
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include "defs.h"
25 #include "datadefs.h"
26 #include "maker_datadefs.h"
27 #include "summary.h"
28 #include "maker.h"
29 #include "misc.h"
30 #include "tags.h"
31 #include "maker_extern.h"
32 #include "extern.h"
33
34 extern struct camera_id konica_model_id[];
35
36 /* Find the identifying number assigned to known Konica camera */
37 /* models. This number is used to dispatch print and interpret */
38 /* routines approopriate to the current image. */
39
40 int
konica_model_number(char * model,char * software)41 konica_model_number(char *model,char *software)
42 {
43 struct camera_id *model_id;
44 int number = NO_MODEL;
45
46 for(model_id = &konica_model_id[0]; model_id && model_id->name; ++model_id)
47 {
48 if(strncasecmp(model,model_id->name,model_id->namelen) == 0)
49 {
50 number = model_id->id;
51 setnoteversion(model_id->noteversion);
52 setnotetagset(model_id->notetagset); /* info only */
53 break;
54 }
55 }
56
57 return(number);
58 }
59
60
61 /* Dispatch a print routine for direct values in Konica cameras, */
62 /* based upon model */
63
64 void
print_konica_makervalue(struct ifd_entry * entry_ptr,int make,int model,char * prefix)65 print_konica_makervalue(struct ifd_entry *entry_ptr,int make,int model,
66 char *prefix)
67 {
68 int noteversion = 0;
69
70 if(entry_ptr && (PRINT_VALUE))
71 {
72 noteversion = getnoteversion();
73 switch(noteversion)
74 {
75 case 1:
76 print_konica_makervalue(entry_ptr,make,model,prefix);
77 break;
78 default:
79 print_value(entry_ptr,PREFIX);
80 break;
81 }
82 }
83 }
84
85 /* Model-specific print routine for Konica cameras. This routine is */
86 /* responsible for picking off any direct entry tags which are */
87 /* peculiar and will not be handled properly by print_value() */
88 /* (usually UNDEFINED values which fit in the 4-byte entry value). If */
89 /* there are no such entries, this function simply calls */
90 /* print_value(). */
91
92 void
print_konica1_makervalue(struct ifd_entry * entry_ptr,int make,int model,char * prefix)93 print_konica1_makervalue(struct ifd_entry *entry_ptr,int make,int model,
94 char *prefix)
95 {
96 if(entry_ptr && (PRINT_VALUE))
97 {
98 switch(entry_ptr->tag)
99 {
100 default:
101 print_value(entry_ptr,PREFIX);
102 break;
103 }
104 }
105 }
106
107
108 /* Dispatch a routine to decode and print offset values for Konica */
109 /* cameras. */
110
111 void
print_konica_offset_makervalue(FILE * inptr,unsigned short byteorder,struct ifd_entry * entry_ptr,unsigned long fileoffset_base,struct image_summary * summary_entry,char * parent_name,char * prefix,int indent,int make,int model,int at_offset)112 print_konica_offset_makervalue(FILE *inptr,unsigned short byteorder,
113 struct ifd_entry *entry_ptr,unsigned long fileoffset_base,
114 struct image_summary *summary_entry, char *parent_name,char *prefix,
115 int indent,int make,int model,int at_offset)
116 {
117 int noteversion = 0;
118
119 noteversion = getnoteversion();
120
121 if(entry_ptr)
122 {
123 switch(noteversion)
124 {
125 case 1:
126 konica1_offset_makervalue(inptr,byteorder,entry_ptr,
127 fileoffset_base,summary_entry,
128 parent_name,prefix,indent,
129 make,model,at_offset);
130 default:
131 print_generic_offset_makervalue(inptr,byteorder,entry_ptr,
132 fileoffset_base,parent_name,prefix,indent,
133 make,model,at_offset);
134 break;
135 }
136 }
137 }
138
139 /* Model-specific routine to print UNDEFINED values found at offsets */
140 /* in Konica makernotes. */
141
142 void
konica1_offset_makervalue(FILE * inptr,unsigned short byteorder,struct ifd_entry * entry_ptr,unsigned long fileoffset_base,struct image_summary * summary_entry,char * parent_name,char * prefix,int indent,int make,int model,int at_offset)143 konica1_offset_makervalue(FILE *inptr,unsigned short byteorder,
144 struct ifd_entry *entry_ptr,unsigned long fileoffset_base,
145 struct image_summary *summary_entry,char *parent_name,char *prefix,
146 int indent,int make,int model,int at_offset)
147 {
148 unsigned long value_offset;
149 unsigned long count;
150 char *nameoftag;
151 char *fulldirname = NULL;
152 int chpr = 0;
153
154 if(entry_ptr)
155 {
156 nameoftag = maker_tagname(entry_ptr->tag,make,model);
157 fulldirname = splice(parent_name,".",nameoftag);
158 value_offset = fileoffset_base + entry_ptr->value;
159 count = entry_ptr->count;
160
161 switch(entry_ptr->tag)
162 {
163 case 0x0e00: /* PrintIM (Epson Print Image matching) */
164 if(!at_offset && (PRINT_VALUE))
165 {
166 if(!(PRINT_OFFSET))
167 {
168 chpr += printf("@%lu:%lu",value_offset,count);
169 chpr = newline(chpr);
170 }
171 }
172 process_pim(inptr,byteorder,entry_ptr->value,fileoffset_base,
173 count,nameoftag,parent_name,prefix,indent);
174 break;
175 default:
176 print_generic_offset_makervalue(inptr,byteorder,entry_ptr,
177 fileoffset_base,fulldirname,prefix,indent,
178 make,model,at_offset);
179 break;
180 }
181 if(fulldirname)
182 free(fulldirname);
183 }
184 setcharsprinted(chpr);
185 }
186
187
188 /* Konica-specific tagnames for makernotes. */
189
190 /* The tagname routine is the first place in the code path which */
191 /* requires knowledge of the note version. If the version is not */
192 /* given in the model table (e.g. the model is unknown), then switch */
193 /* code in find_maker_scheme() should have set it. This routine */
194 /* repeats the check for non-zero noteversion and is prepared to set */
195 /* the noteversion first time through, but should never need to do */
196 /* so. Noteversion should always be non-zero; it should be set to -1 */
197 /* if generic processing is required. */
198
199 char *
maker_konica_tagname(unsigned short tag,int model)200 maker_konica_tagname(unsigned short tag,int model)
201 {
202 char *tagname = (char *)0;
203
204
205 /* If no model-specific tag is found, use a "generic" tag */
206 if(tagname == NULL)
207 {
208 switch(tag)
209 {
210 case 0x0e00: tagname = "PrintIM"; break;
211 default: break;
212 }
213 }
214 return(tagname);
215 }
216
217