Lines 47-52
Link Here
|
47 |
#endif |
47 |
#endif |
48 |
#endif /* CHAR_BIT */ |
48 |
#endif /* CHAR_BIT */ |
49 |
|
49 |
|
|
|
50 |
/* |
51 |
* Copied from libtiff-3.9 as libtiff-4.0 does not provide it anymore. |
52 |
*/ |
53 |
typedef struct { |
54 |
uint16 tdir_tag; /* see below */ |
55 |
uint16 tdir_type; /* data type; see below */ |
56 |
uint32 tdir_count; /* number of items; length in spec */ |
57 |
uint32 tdir_offset; /* byte offset to field data */ |
58 |
} OldClassicTIFFDirEntry; |
50 |
|
59 |
|
51 |
static struct { |
60 |
static struct { |
52 |
const char* name; // protocol token name |
61 |
const char* name; // protocol token name |
Lines 69-75
static const char* modenames[] = { "St
Link Here
|
69 |
|
78 |
|
70 |
|
79 |
|
71 |
static bool |
80 |
static bool |
72 |
isTIFF(const TIFFHeader& h) |
81 |
isTIFF(const TIFFHeaderClassic& h) |
73 |
{ |
82 |
{ |
74 |
if (h.tiff_magic != TIFF_BIGENDIAN && h.tiff_magic != TIFF_LITTLEENDIAN) |
83 |
if (h.tiff_magic != TIFF_BIGENDIAN && h.tiff_magic != TIFF_LITTLEENDIAN) |
75 |
return (false); |
84 |
return (false); |
Lines 82-88
isTIFF(const TIFFHeader& h)
Link Here
|
82 |
// byte swap version stamp if opposite byte order |
91 |
// byte swap version stamp if opposite byte order |
83 |
if ((u.c[0] == 0) ^ (h.tiff_magic == TIFF_BIGENDIAN)) |
92 |
if ((u.c[0] == 0) ^ (h.tiff_magic == TIFF_BIGENDIAN)) |
84 |
TIFFSwabShort(&version); |
93 |
TIFFSwabShort(&version); |
85 |
return (version == TIFF_VERSION); |
94 |
return (version == TIFFLIB_VERSION); |
86 |
} |
95 |
} |
87 |
|
96 |
|
88 |
|
97 |
|
Lines 164-189
HylaFAXServer::retrieveCmd(const char* n
Link Here
|
164 |
* a single IFD/image from a TIFF file. |
173 |
* a single IFD/image from a TIFF file. |
165 |
*/ |
174 |
*/ |
166 |
typedef struct { |
175 |
typedef struct { |
167 |
TIFFDirEntry SubFileType; |
176 |
OldClassicTIFFDirEntry SubFileType; |
168 |
TIFFDirEntry ImageWidth; |
177 |
OldClassicTIFFDirEntry ImageWidth; |
169 |
TIFFDirEntry ImageLength; |
178 |
OldClassicTIFFDirEntry ImageLength; |
170 |
TIFFDirEntry BitsPerSample; |
179 |
OldClassicTIFFDirEntry BitsPerSample; |
171 |
TIFFDirEntry Compression; |
180 |
OldClassicTIFFDirEntry Compression; |
172 |
TIFFDirEntry Photometric; |
181 |
OldClassicTIFFDirEntry Photometric; |
173 |
TIFFDirEntry FillOrder; |
182 |
OldClassicTIFFDirEntry FillOrder; |
174 |
TIFFDirEntry StripOffsets; |
183 |
OldClassicTIFFDirEntry StripOffsets; |
175 |
TIFFDirEntry Orientation; |
184 |
OldClassicTIFFDirEntry Orientation; |
176 |
TIFFDirEntry SamplesPerPixel; |
185 |
OldClassicTIFFDirEntry SamplesPerPixel; |
177 |
TIFFDirEntry RowsPerStrip; |
186 |
OldClassicTIFFDirEntry RowsPerStrip; |
178 |
TIFFDirEntry StripByteCounts; |
187 |
OldClassicTIFFDirEntry StripByteCounts; |
179 |
TIFFDirEntry XResolution; |
188 |
OldClassicTIFFDirEntry XResolution; |
180 |
TIFFDirEntry YResolution; |
189 |
OldClassicTIFFDirEntry YResolution; |
181 |
TIFFDirEntry Options; // T4 or T6 |
190 |
OldClassicTIFFDirEntry Options; // T4 or T6 |
182 |
TIFFDirEntry ResolutionUnit; |
191 |
OldClassicTIFFDirEntry ResolutionUnit; |
183 |
TIFFDirEntry PageNumber; |
192 |
OldClassicTIFFDirEntry PageNumber; |
184 |
TIFFDirEntry BadFaxLines; |
193 |
OldClassicTIFFDirEntry BadFaxLines; |
185 |
TIFFDirEntry CleanFaxData; |
194 |
OldClassicTIFFDirEntry CleanFaxData; |
186 |
TIFFDirEntry ConsecutiveBadFaxLines; |
195 |
OldClassicTIFFDirEntry ConsecutiveBadFaxLines; |
187 |
uint32 link; // offset to next directory |
196 |
uint32 link; // offset to next directory |
188 |
uint32 xres[2]; // X resolution indirect value |
197 |
uint32 xres[2]; // X resolution indirect value |
189 |
uint32 yres[2]; // Y resolution indirect value |
198 |
uint32 yres[2]; // Y resolution indirect value |
Lines 229-235
HylaFAXServer::retrievePageCmd(const cha
Link Here
|
229 |
uint32* sb; |
238 |
uint32* sb; |
230 |
TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &sb); |
239 |
TIFFGetField(tif, TIFFTAG_STRIPBYTECOUNTS, &sb); |
231 |
file_size = sizeof (DirTemplate) + |
240 |
file_size = sizeof (DirTemplate) + |
232 |
sizeof (TIFFHeader) + sizeof (uint16); |
241 |
sizeof (TIFFHeaderClassic) + sizeof (uint16); |
233 |
for (tstrip_t s = 0, ns = TIFFNumberOfStrips(tif); s < ns; s++) |
242 |
for (tstrip_t s = 0, ns = TIFFNumberOfStrips(tif); s < ns; s++) |
234 |
file_size += sb[s]; |
243 |
file_size += sb[s]; |
235 |
reply(code, "%s for %s (%lu bytes).", |
244 |
reply(code, "%s for %s (%lu bytes).", |
Lines 261-270
HylaFAXServer::openTIFF(const char* name
Link Here
|
261 |
if (fd >= 0) { |
270 |
if (fd >= 0) { |
262 |
union { |
271 |
union { |
263 |
char buf[512]; |
272 |
char buf[512]; |
264 |
TIFFHeader h; |
273 |
TIFFHeaderClassic h; |
265 |
} b; |
274 |
} b; |
266 |
ssize_t cc = Sys::read(fd, (char*) &b, sizeof (b)); |
275 |
ssize_t cc = Sys::read(fd, (char*) &b, sizeof (b)); |
267 |
if (cc > (ssize_t)sizeof (b.h) && b.h.tiff_version == TIFF_VERSION && |
276 |
if (cc > (ssize_t)sizeof (b.h) && b.h.tiff_version == TIFFLIB_VERSION && |
268 |
(b.h.tiff_magic == TIFF_BIGENDIAN || |
277 |
(b.h.tiff_magic == TIFF_BIGENDIAN || |
269 |
b.h.tiff_magic == TIFF_LITTLEENDIAN)) { |
278 |
b.h.tiff_magic == TIFF_LITTLEENDIAN)) { |
270 |
(void) lseek(fd, 0L, SEEK_SET); // rewind |
279 |
(void) lseek(fd, 0L, SEEK_SET); // rewind |
Lines 318-329
HylaFAXServer::sendTIFFData(TIFF* tif, F
Link Here
|
318 |
} |
327 |
} |
319 |
|
328 |
|
320 |
static void |
329 |
static void |
321 |
getLong(TIFF* tif, TIFFDirEntry& de) |
330 |
getLong(TIFF* tif, OldClassicTIFFDirEntry& de) |
322 |
{ |
331 |
{ |
323 |
TIFFGetField(tif, de.tdir_tag, &de.tdir_offset); |
332 |
TIFFGetField(tif, de.tdir_tag, &de.tdir_offset); |
324 |
} |
333 |
} |
325 |
static void |
334 |
static void |
326 |
getShort(TIFF* tif, TIFFDirEntry& de) |
335 |
getShort(TIFF* tif, OldClassicTIFFDirEntry& de) |
327 |
{ |
336 |
{ |
328 |
uint16 v; |
337 |
uint16 v; |
329 |
TIFFGetField(tif, de.tdir_tag, &v); |
338 |
TIFFGetField(tif, de.tdir_tag, &v); |
Lines 343-349
HylaFAXServer::sendTIFFHeader(TIFF* tif,
Link Here
|
343 |
{ |
352 |
{ |
344 |
static DirTemplate templ = { |
353 |
static DirTemplate templ = { |
345 |
#define TIFFdiroff(v) \ |
354 |
#define TIFFdiroff(v) \ |
346 |
(uint32) (sizeof (TIFFHeader) + sizeof (uint16) + \ |
355 |
(uint32) (sizeof (TIFFHeaderClassic) + sizeof (uint16) + \ |
347 |
(intptr_t) &(((DirTemplate*) 0)->v)) |
356 |
(intptr_t) &(((DirTemplate*) 0)->v)) |
348 |
{ TIFFTAG_SUBFILETYPE, TIFF_LONG, 1 }, |
357 |
{ TIFFTAG_SUBFILETYPE, TIFF_LONG, 1 }, |
349 |
{ TIFFTAG_IMAGEWIDTH, TIFF_LONG, 1 }, |
358 |
{ TIFFTAG_IMAGEWIDTH, TIFF_LONG, 1 }, |
Lines 368-374
HylaFAXServer::sendTIFFHeader(TIFF* tif,
Link Here
|
368 |
0, // next directory |
377 |
0, // next directory |
369 |
{ 0, 1 }, { 0, 1 }, // x+y resolutions |
378 |
{ 0, 1 }, { 0, 1 }, // x+y resolutions |
370 |
}; |
379 |
}; |
371 |
#define NTAGS ((TIFFdiroff(link)-TIFFdiroff(SubFileType)) / sizeof (TIFFDirEntry)) |
380 |
#define NTAGS ((TIFFdiroff(link)-TIFFdiroff(SubFileType)) / sizeof (OldClassicTIFFDirEntry)) |
372 |
/* |
381 |
/* |
373 |
* Construct the TIFF header for this IFD using |
382 |
* Construct the TIFF header for this IFD using |
374 |
* the preconstructed template above. We extract |
383 |
* the preconstructed template above. We extract |
Lines 377-390
HylaFAXServer::sendTIFFHeader(TIFF* tif,
Link Here
|
377 |
* of things about the contents of the TIFF file. |
386 |
* of things about the contents of the TIFF file. |
378 |
*/ |
387 |
*/ |
379 |
struct { |
388 |
struct { |
380 |
TIFFHeader h; |
389 |
TIFFHeaderClassic h; |
381 |
uint16 dircount; |
390 |
uint16 dircount; |
382 |
u_char dirstuff[sizeof (templ)]; |
391 |
u_char dirstuff[sizeof (templ)]; |
383 |
} buf; |
392 |
} buf; |
384 |
union { int32 i; char c[4]; } u; u.i = 1; |
393 |
union { int32 i; char c[4]; } u; u.i = 1; |
385 |
buf.h.tiff_magic = (u.c[0] == 0 ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN); |
394 |
buf.h.tiff_magic = (u.c[0] == 0 ? TIFF_BIGENDIAN : TIFF_LITTLEENDIAN); |
386 |
buf.h.tiff_version = TIFF_VERSION; |
395 |
buf.h.tiff_version = TIFFLIB_VERSION; |
387 |
buf.h.tiff_diroff = sizeof (TIFFHeader); |
396 |
buf.h.tiff_diroff = sizeof (TIFFHeaderClassic); |
388 |
buf.dircount = (uint16) NTAGS; |
397 |
buf.dircount = (uint16) NTAGS; |
389 |
getLong(tif, templ.SubFileType); |
398 |
getLong(tif, templ.SubFileType); |
390 |
getLong(tif, templ.ImageWidth); |
399 |
getLong(tif, templ.ImageWidth); |
Lines 412-418
HylaFAXServer::sendTIFFHeader(TIFF* tif,
Link Here
|
412 |
getShort(tif, templ.CleanFaxData); |
421 |
getShort(tif, templ.CleanFaxData); |
413 |
getLong(tif, templ.ConsecutiveBadFaxLines); |
422 |
getLong(tif, templ.ConsecutiveBadFaxLines); |
414 |
if (buf.h.tiff_magic == TIFF_BIGENDIAN) { |
423 |
if (buf.h.tiff_magic == TIFF_BIGENDIAN) { |
415 |
TIFFDirEntry* dp = &templ.SubFileType; |
424 |
OldClassicTIFFDirEntry* dp = &templ.SubFileType; |
416 |
for (u_int i = 0; i < NTAGS; i++) { |
425 |
for (u_int i = 0; i < NTAGS; i++) { |
417 |
if (dp->tdir_type == TIFF_SHORT) |
426 |
if (dp->tdir_type == TIFF_SHORT) |
418 |
dp->tdir_offset <<= 16; |
427 |
dp->tdir_offset <<= 16; |
Lines 957-963
HylaFAXServer::docType(const char* docna
Link Here
|
957 |
if (FileCache::lookup(docname, sb) && S_ISREG(sb.st_mode)) { |
966 |
if (FileCache::lookup(docname, sb) && S_ISREG(sb.st_mode)) { |
958 |
union { |
967 |
union { |
959 |
char buf[512]; |
968 |
char buf[512]; |
960 |
TIFFHeader h; |
969 |
TIFFHeaderClassic h; |
961 |
} b; |
970 |
} b; |
962 |
ssize_t cc = Sys::read(fd, (char*) &b, sizeof (b)); |
971 |
ssize_t cc = Sys::read(fd, (char*) &b, sizeof (b)); |
963 |
if (cc > 2 && b.buf[0] == '%' && b.buf[1] == '!') |
972 |
if (cc > 2 && b.buf[0] == '%' && b.buf[1] == '!') |