]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
7e86f2f6 | 2 | * Raster test program routines for CUPS. |
ef416fc2 | 3 | * |
f81f6d3d MS |
4 | * Copyright © 2007-2018 by Apple Inc. |
5 | * Copyright © 1997-2007 by Easy Software Products. | |
ef416fc2 | 6 | * |
7c91db71 MS |
7 | * Licensed under Apache License v2.0. See the file "LICENSE" for more |
8 | * information. | |
ef416fc2 | 9 | */ |
10 | ||
11 | /* | |
12 | * Include necessary headers... | |
13 | */ | |
14 | ||
a4845881 | 15 | #include <cups/raster-private.h> |
7e86f2f6 | 16 | #include <math.h> |
ef416fc2 | 17 | |
18 | ||
b86bc4cf | 19 | /* |
20 | * Local functions... | |
21 | */ | |
22 | ||
f14324a7 | 23 | static int do_ras_file(const char *filename); |
db0bd74a | 24 | static int do_raster_tests(cups_mode_t mode); |
b86bc4cf | 25 | static void print_changes(cups_page_header2_t *header, |
26 | cups_page_header2_t *expected); | |
27 | ||
28 | ||
29 | /* | |
30 | * 'main()' - Test the raster functions. | |
ef416fc2 | 31 | */ |
32 | ||
33 | int /* O - Exit status */ | |
f7deaa1a | 34 | main(int argc, /* I - Number of command-line args */ |
35 | char *argv[]) /* I - Command-line arguments */ | |
ef416fc2 | 36 | { |
0b353e63 | 37 | int errors = 0; /* Number of errors */ |
f7deaa1a | 38 | |
39 | ||
40 | if (argc == 1) | |
41 | { | |
0b353e63 | 42 | errors += do_raster_tests(CUPS_RASTER_WRITE); |
db0bd74a | 43 | errors += do_raster_tests(CUPS_RASTER_WRITE_COMPRESSED); |
c8fef167 | 44 | errors += do_raster_tests(CUPS_RASTER_WRITE_PWG); |
05fa7028 | 45 | errors += do_raster_tests(CUPS_RASTER_WRITE_APPLE); |
f7deaa1a | 46 | } |
47 | else | |
48 | { | |
49 | int i; /* Looping var */ | |
f7deaa1a | 50 | |
0b353e63 | 51 | for (i = 1; i < argc; i ++) |
f81f6d3d | 52 | errors += do_ras_file(argv[i]); |
b86bc4cf | 53 | } |
f7deaa1a | 54 | |
f14324a7 MS |
55 | return (errors); |
56 | } | |
b86bc4cf | 57 | |
b86bc4cf | 58 | |
f14324a7 MS |
59 | /* |
60 | * 'do_ras_file()' - Test reading of a raster file. | |
61 | */ | |
b86bc4cf | 62 | |
f14324a7 MS |
63 | static int /* O - Number of errors */ |
64 | do_ras_file(const char *filename) /* I - Filename */ | |
65 | { | |
66 | unsigned y; /* Looping vars */ | |
67 | int fd; /* File descriptor */ | |
68 | cups_raster_t *ras; /* Raster stream */ | |
69 | cups_page_header2_t header; /* Page header */ | |
70 | unsigned char *data; /* Raster data */ | |
71 | int errors = 0; /* Number of errors */ | |
72 | unsigned pages = 0; /* Number of pages */ | |
b86bc4cf | 73 | |
b86bc4cf | 74 | |
f14324a7 | 75 | if ((fd = open(filename, O_RDONLY)) < 0) |
b86bc4cf | 76 | { |
f14324a7 MS |
77 | printf("%s: %s\n", filename, strerror(errno)); |
78 | return (1); | |
b86bc4cf | 79 | } |
f14324a7 MS |
80 | |
81 | if ((ras = cupsRasterOpen(fd, CUPS_RASTER_READ)) == NULL) | |
b86bc4cf | 82 | { |
f14324a7 MS |
83 | printf("%s: cupsRasterOpen failed.\n", filename); |
84 | close(fd); | |
85 | return (1); | |
b86bc4cf | 86 | } |
b86bc4cf | 87 | |
f14324a7 | 88 | printf("%s:\n", filename); |
b86bc4cf | 89 | |
f14324a7 | 90 | while (cupsRasterReadHeader2(ras, &header)) |
b86bc4cf | 91 | { |
f14324a7 MS |
92 | pages ++; |
93 | data = malloc(header.cupsBytesPerLine); | |
b86bc4cf | 94 | |
f14324a7 MS |
95 | printf(" Page %u: %ux%ux%u@%ux%udpi", pages, |
96 | header.cupsWidth, header.cupsHeight, header.cupsBitsPerPixel, | |
97 | header.HWResolution[0], header.HWResolution[1]); | |
98 | fflush(stdout); | |
b86bc4cf | 99 | |
f14324a7 MS |
100 | for (y = 0; y < header.cupsHeight; y ++) |
101 | if (cupsRasterReadPixels(ras, data, header.cupsBytesPerLine) < | |
102 | header.cupsBytesPerLine) | |
103 | break; | |
104 | ||
105 | if (y < header.cupsHeight) | |
106 | printf(" ERROR AT LINE %d\n", y); | |
107 | else | |
108 | putchar('\n'); | |
109 | ||
110 | free(data); | |
b86bc4cf | 111 | } |
f14324a7 | 112 | |
590e44a4 MS |
113 | printf("EOF at %ld\n", (long)lseek(fd, SEEK_CUR, 0)); |
114 | ||
f14324a7 MS |
115 | cupsRasterClose(ras); |
116 | close(fd); | |
b86bc4cf | 117 | |
f7deaa1a | 118 | return (errors); |
119 | } | |
120 | ||
121 | ||
122 | /* | |
123 | * 'do_raster_tests()' - Test reading and writing of raster data. | |
124 | */ | |
125 | ||
126 | static int /* O - Number of errors */ | |
db0bd74a | 127 | do_raster_tests(cups_mode_t mode) /* O - Write mode */ |
f7deaa1a | 128 | { |
7c91db71 | 129 | unsigned page, x, y, count;/* Looping vars */ |
f7deaa1a | 130 | FILE *fp; /* Raster file */ |
131 | cups_raster_t *r; /* Raster stream */ | |
132 | cups_page_header2_t header, /* Page header */ | |
133 | expected; /* Expected page header */ | |
134 | unsigned char data[2048]; /* Raster data */ | |
135 | int errors = 0; /* Number of errors */ | |
136 | ||
137 | ||
b86bc4cf | 138 | /* |
139 | * Test writing... | |
140 | */ | |
ef416fc2 | 141 | |
db0bd74a MS |
142 | printf("cupsRasterOpen(%s): ", |
143 | mode == CUPS_RASTER_WRITE ? "CUPS_RASTER_WRITE" : | |
05fa7028 MS |
144 | mode == CUPS_RASTER_WRITE_COMPRESSED ? "CUPS_RASTER_WRITE_COMPRESSED" : |
145 | mode == CUPS_RASTER_WRITE_PWG ? "CUPS_RASTER_WRITE_PWG" : | |
146 | "CUPS_RASTER_WRITE_APPLE"); | |
b86bc4cf | 147 | fflush(stdout); |
ef416fc2 | 148 | |
149 | if ((fp = fopen("test.raster", "wb")) == NULL) | |
150 | { | |
b86bc4cf | 151 | printf("FAIL (%s)\n", strerror(errno)); |
ef416fc2 | 152 | return (1); |
153 | } | |
154 | ||
db0bd74a | 155 | if ((r = cupsRasterOpen(fileno(fp), mode)) == NULL) |
ef416fc2 | 156 | { |
b86bc4cf | 157 | printf("FAIL (%s)\n", strerror(errno)); |
ef416fc2 | 158 | fclose(fp); |
159 | return (1); | |
160 | } | |
161 | ||
b86bc4cf | 162 | puts("PASS"); |
163 | ||
ef416fc2 | 164 | for (page = 0; page < 4; page ++) |
165 | { | |
166 | memset(&header, 0, sizeof(header)); | |
167 | header.cupsWidth = 256; | |
168 | header.cupsHeight = 256; | |
169 | header.cupsBytesPerLine = 256; | |
073e58a9 MS |
170 | header.HWResolution[0] = 64; |
171 | header.HWResolution[1] = 64; | |
172 | header.PageSize[0] = 288; | |
173 | header.PageSize[1] = 288; | |
174 | header.cupsPageSize[0] = 288.0f; | |
175 | header.cupsPageSize[1] = 288.0f; | |
ef416fc2 | 176 | |
177 | if (page & 1) | |
178 | { | |
05fa7028 | 179 | header.cupsBytesPerLine *= 4; |
ef416fc2 | 180 | header.cupsColorSpace = CUPS_CSPACE_CMYK; |
181 | header.cupsColorOrder = CUPS_ORDER_CHUNKED; | |
b86bc4cf | 182 | header.cupsNumColors = 4; |
ef416fc2 | 183 | } |
184 | else | |
185 | { | |
05fa7028 MS |
186 | header.cupsColorSpace = CUPS_CSPACE_W; |
187 | header.cupsColorOrder = CUPS_ORDER_CHUNKED; | |
b86bc4cf | 188 | header.cupsNumColors = 1; |
ef416fc2 | 189 | } |
190 | ||
191 | if (page & 2) | |
192 | { | |
193 | header.cupsBytesPerLine *= 2; | |
194 | header.cupsBitsPerColor = 16; | |
195 | header.cupsBitsPerPixel = (page & 1) ? 64 : 16; | |
196 | } | |
197 | else | |
198 | { | |
199 | header.cupsBitsPerColor = 8; | |
200 | header.cupsBitsPerPixel = (page & 1) ? 32 : 8; | |
201 | } | |
202 | ||
7c91db71 MS |
203 | printf("cupsRasterWriteHeader2(page %d): ", page + 1); |
204 | ||
b86bc4cf | 205 | if (cupsRasterWriteHeader2(r, &header)) |
7c91db71 MS |
206 | { |
207 | puts("PASS"); | |
208 | } | |
b86bc4cf | 209 | else |
210 | { | |
7c91db71 | 211 | puts("FAIL"); |
b86bc4cf | 212 | errors ++; |
213 | } | |
ef416fc2 | 214 | |
b86bc4cf | 215 | fputs("cupsRasterWritePixels: ", stdout); |
216 | fflush(stdout); | |
ef416fc2 | 217 | |
b86bc4cf | 218 | memset(data, 0, header.cupsBytesPerLine); |
ef416fc2 | 219 | for (y = 0; y < 64; y ++) |
b86bc4cf | 220 | if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) |
221 | break; | |
ef416fc2 | 222 | |
b86bc4cf | 223 | if (y < 64) |
224 | { | |
225 | puts("FAIL"); | |
226 | errors ++; | |
227 | } | |
228 | else | |
229 | { | |
230 | for (x = 0; x < header.cupsBytesPerLine; x ++) | |
7e86f2f6 | 231 | data[x] = (unsigned char)x; |
ef416fc2 | 232 | |
b86bc4cf | 233 | for (y = 0; y < 64; y ++) |
234 | if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) | |
235 | break; | |
ef416fc2 | 236 | |
b86bc4cf | 237 | if (y < 64) |
238 | { | |
239 | puts("FAIL"); | |
240 | errors ++; | |
241 | } | |
242 | else | |
243 | { | |
244 | memset(data, 255, header.cupsBytesPerLine); | |
245 | for (y = 0; y < 64; y ++) | |
246 | if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) | |
247 | break; | |
248 | ||
249 | if (y < 64) | |
250 | { | |
251 | puts("FAIL"); | |
252 | errors ++; | |
253 | } | |
254 | else | |
255 | { | |
256 | for (x = 0; x < header.cupsBytesPerLine; x ++) | |
7e86f2f6 | 257 | data[x] = (unsigned char)(x / 4); |
b86bc4cf | 258 | |
259 | for (y = 0; y < 64; y ++) | |
260 | if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine)) | |
261 | break; | |
262 | ||
263 | if (y < 64) | |
264 | { | |
265 | puts("FAIL"); | |
266 | errors ++; | |
267 | } | |
268 | else | |
269 | puts("PASS"); | |
270 | } | |
271 | } | |
272 | } | |
ef416fc2 | 273 | } |
274 | ||
275 | cupsRasterClose(r); | |
276 | fclose(fp); | |
277 | ||
b86bc4cf | 278 | /* |
279 | * Test reading... | |
280 | */ | |
281 | ||
282 | fputs("cupsRasterOpen(CUPS_RASTER_READ): ", stdout); | |
283 | fflush(stdout); | |
284 | ||
ef416fc2 | 285 | if ((fp = fopen("test.raster", "rb")) == NULL) |
286 | { | |
b86bc4cf | 287 | printf("FAIL (%s)\n", strerror(errno)); |
ef416fc2 | 288 | return (1); |
289 | } | |
290 | ||
291 | if ((r = cupsRasterOpen(fileno(fp), CUPS_RASTER_READ)) == NULL) | |
292 | { | |
b86bc4cf | 293 | printf("FAIL (%s)\n", strerror(errno)); |
ef416fc2 | 294 | fclose(fp); |
295 | return (1); | |
296 | } | |
297 | ||
b86bc4cf | 298 | puts("PASS"); |
299 | ||
ef416fc2 | 300 | for (page = 0; page < 4; page ++) |
301 | { | |
b86bc4cf | 302 | memset(&expected, 0, sizeof(expected)); |
303 | expected.cupsWidth = 256; | |
304 | expected.cupsHeight = 256; | |
305 | expected.cupsBytesPerLine = 256; | |
073e58a9 MS |
306 | expected.HWResolution[0] = 64; |
307 | expected.HWResolution[1] = 64; | |
308 | expected.PageSize[0] = 288; | |
309 | expected.PageSize[1] = 288; | |
310 | ||
311 | if (mode != CUPS_RASTER_WRITE_PWG) | |
312 | { | |
313 | expected.cupsPageSize[0] = 288.0f; | |
314 | expected.cupsPageSize[1] = 288.0f; | |
315 | } | |
ef416fc2 | 316 | |
05fa7028 | 317 | if (mode >= CUPS_RASTER_WRITE_PWG) |
771bd8cb MS |
318 | { |
319 | strlcpy(expected.MediaClass, "PwgRaster", sizeof(expected.MediaClass)); | |
320 | expected.cupsInteger[7] = 0xffffff; | |
321 | } | |
322 | ||
b86bc4cf | 323 | if (page & 1) |
ef416fc2 | 324 | { |
05fa7028 | 325 | expected.cupsBytesPerLine *= 4; |
b86bc4cf | 326 | expected.cupsColorSpace = CUPS_CSPACE_CMYK; |
327 | expected.cupsColorOrder = CUPS_ORDER_CHUNKED; | |
328 | expected.cupsNumColors = 4; | |
329 | } | |
330 | else | |
331 | { | |
05fa7028 MS |
332 | expected.cupsColorSpace = CUPS_CSPACE_W; |
333 | expected.cupsColorOrder = CUPS_ORDER_CHUNKED; | |
b86bc4cf | 334 | expected.cupsNumColors = 1; |
ef416fc2 | 335 | } |
336 | ||
b86bc4cf | 337 | if (page & 2) |
338 | { | |
339 | expected.cupsBytesPerLine *= 2; | |
340 | expected.cupsBitsPerColor = 16; | |
341 | expected.cupsBitsPerPixel = (page & 1) ? 64 : 16; | |
342 | } | |
343 | else | |
ef416fc2 | 344 | { |
b86bc4cf | 345 | expected.cupsBitsPerColor = 8; |
346 | expected.cupsBitsPerPixel = (page & 1) ? 32 : 8; | |
347 | } | |
ef416fc2 | 348 | |
7c91db71 | 349 | printf("cupsRasterReadHeader2(page %d): ", page + 1); |
b86bc4cf | 350 | fflush(stdout); |
ef416fc2 | 351 | |
b86bc4cf | 352 | if (!cupsRasterReadHeader2(r, &header)) |
353 | { | |
354 | puts("FAIL (read error)"); | |
355 | errors ++; | |
356 | break; | |
ef416fc2 | 357 | } |
7c91db71 | 358 | else if (memcmp(&header, &expected, sizeof(header))) |
ef416fc2 | 359 | { |
b86bc4cf | 360 | puts("FAIL (bad page header)"); |
361 | errors ++; | |
362 | print_changes(&header, &expected); | |
ef416fc2 | 363 | } |
7c91db71 MS |
364 | else |
365 | puts("PASS"); | |
ef416fc2 | 366 | |
b86bc4cf | 367 | fputs("cupsRasterReadPixels: ", stdout); |
368 | fflush(stdout); | |
369 | ||
ef416fc2 | 370 | for (y = 0; y < 64; y ++) |
371 | { | |
b86bc4cf | 372 | if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) |
373 | { | |
374 | puts("FAIL (read error)"); | |
375 | errors ++; | |
376 | break; | |
377 | } | |
ef416fc2 | 378 | |
b86bc4cf | 379 | if (data[0] != 0 || memcmp(data, data + 1, header.cupsBytesPerLine - 1)) |
380 | { | |
381 | printf("FAIL (raster line %d corrupt)\n", y); | |
7c91db71 MS |
382 | |
383 | for (x = 0, count = 0; x < header.cupsBytesPerLine && count < 10; x ++) | |
384 | { | |
385 | if (data[x]) | |
386 | { | |
387 | count ++; | |
388 | ||
389 | if (count == 10) | |
390 | puts(" ..."); | |
391 | else | |
392 | printf(" %4u %02X (expected %02X)\n", x, data[x], 0); | |
393 | } | |
394 | } | |
395 | ||
b86bc4cf | 396 | errors ++; |
397 | break; | |
398 | } | |
399 | } | |
400 | ||
401 | if (y == 64) | |
402 | { | |
403 | for (y = 0; y < 64; y ++) | |
404 | { | |
405 | if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) | |
406 | { | |
407 | puts("FAIL (read error)"); | |
408 | errors ++; | |
ef416fc2 | 409 | break; |
b86bc4cf | 410 | } |
411 | ||
412 | for (x = 0; x < header.cupsBytesPerLine; x ++) | |
413 | if (data[x] != (x & 255)) | |
414 | break; | |
ef416fc2 | 415 | |
b86bc4cf | 416 | if (x < header.cupsBytesPerLine) |
417 | { | |
418 | printf("FAIL (raster line %d corrupt)\n", y + 64); | |
7c91db71 MS |
419 | |
420 | for (x = 0, count = 0; x < header.cupsBytesPerLine && count < 10; x ++) | |
421 | { | |
422 | if (data[x] != (x & 255)) | |
423 | { | |
424 | count ++; | |
425 | ||
426 | if (count == 10) | |
427 | puts(" ..."); | |
428 | else | |
429 | printf(" %4u %02X (expected %02X)\n", x, data[x], x & 255); | |
430 | } | |
431 | } | |
432 | ||
b86bc4cf | 433 | errors ++; |
434 | break; | |
435 | } | |
436 | } | |
437 | ||
438 | if (y == 64) | |
439 | { | |
440 | for (y = 0; y < 64; y ++) | |
441 | { | |
442 | if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) | |
443 | { | |
444 | puts("FAIL (read error)"); | |
445 | errors ++; | |
446 | break; | |
447 | } | |
448 | ||
449 | if (data[0] != 255 || memcmp(data, data + 1, header.cupsBytesPerLine - 1)) | |
450 | { | |
451 | printf("fail (raster line %d corrupt)\n", y + 128); | |
7c91db71 MS |
452 | |
453 | for (x = 0, count = 0; x < header.cupsBytesPerLine && count < 10; x ++) | |
454 | { | |
455 | if (data[x] != 255) | |
456 | { | |
457 | count ++; | |
458 | ||
459 | if (count == 10) | |
460 | puts(" ..."); | |
461 | else | |
462 | printf(" %4u %02X (expected %02X)\n", x, data[x], 255); | |
463 | } | |
464 | } | |
465 | ||
b86bc4cf | 466 | errors ++; |
467 | break; | |
468 | } | |
469 | } | |
470 | ||
471 | if (y == 64) | |
472 | { | |
473 | for (y = 0; y < 64; y ++) | |
474 | { | |
475 | if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine)) | |
476 | { | |
477 | puts("FAIL (read error)"); | |
478 | errors ++; | |
479 | break; | |
480 | } | |
481 | ||
482 | for (x = 0; x < header.cupsBytesPerLine; x ++) | |
483 | if (data[x] != ((x / 4) & 255)) | |
484 | break; | |
485 | ||
486 | if (x < header.cupsBytesPerLine) | |
487 | { | |
488 | printf("FAIL (raster line %d corrupt)\n", y + 192); | |
7c91db71 MS |
489 | |
490 | for (x = 0, count = 0; x < header.cupsBytesPerLine && count < 10; x ++) | |
491 | { | |
492 | if (data[x] != ((x / 4) & 255)) | |
493 | { | |
494 | count ++; | |
495 | ||
496 | if (count == 10) | |
497 | puts(" ..."); | |
498 | else | |
499 | printf(" %4u %02X (expected %02X)\n", x, data[x], (x / 4) & 255); | |
500 | } | |
501 | } | |
502 | ||
b86bc4cf | 503 | errors ++; |
504 | break; | |
505 | } | |
506 | } | |
507 | ||
508 | if (y == 64) | |
509 | puts("PASS"); | |
510 | } | |
511 | } | |
ef416fc2 | 512 | } |
513 | } | |
514 | ||
515 | cupsRasterClose(r); | |
516 | fclose(fp); | |
517 | ||
f7deaa1a | 518 | return (errors); |
b86bc4cf | 519 | } |
520 | ||
521 | ||
b86bc4cf | 522 | /* |
523 | * 'print_changes()' - Print differences in the page header. | |
524 | */ | |
525 | ||
526 | static void | |
527 | print_changes( | |
528 | cups_page_header2_t *header, /* I - Actual page header */ | |
529 | cups_page_header2_t *expected) /* I - Expected page header */ | |
530 | { | |
531 | int i; /* Looping var */ | |
532 | ||
533 | ||
534 | if (strcmp(header->MediaClass, expected->MediaClass)) | |
535 | printf(" MediaClass (%s), expected (%s)\n", header->MediaClass, | |
536 | expected->MediaClass); | |
537 | ||
538 | if (strcmp(header->MediaColor, expected->MediaColor)) | |
539 | printf(" MediaColor (%s), expected (%s)\n", header->MediaColor, | |
540 | expected->MediaColor); | |
541 | ||
542 | if (strcmp(header->MediaType, expected->MediaType)) | |
543 | printf(" MediaType (%s), expected (%s)\n", header->MediaType, | |
544 | expected->MediaType); | |
545 | ||
546 | if (strcmp(header->OutputType, expected->OutputType)) | |
547 | printf(" OutputType (%s), expected (%s)\n", header->OutputType, | |
548 | expected->OutputType); | |
549 | ||
550 | if (header->AdvanceDistance != expected->AdvanceDistance) | |
551 | printf(" AdvanceDistance %d, expected %d\n", header->AdvanceDistance, | |
552 | expected->AdvanceDistance); | |
553 | ||
554 | if (header->AdvanceMedia != expected->AdvanceMedia) | |
555 | printf(" AdvanceMedia %d, expected %d\n", header->AdvanceMedia, | |
556 | expected->AdvanceMedia); | |
557 | ||
558 | if (header->Collate != expected->Collate) | |
559 | printf(" Collate %d, expected %d\n", header->Collate, | |
560 | expected->Collate); | |
561 | ||
562 | if (header->CutMedia != expected->CutMedia) | |
563 | printf(" CutMedia %d, expected %d\n", header->CutMedia, | |
564 | expected->CutMedia); | |
565 | ||
566 | if (header->Duplex != expected->Duplex) | |
567 | printf(" Duplex %d, expected %d\n", header->Duplex, | |
568 | expected->Duplex); | |
569 | ||
570 | if (header->HWResolution[0] != expected->HWResolution[0] || | |
571 | header->HWResolution[1] != expected->HWResolution[1]) | |
572 | printf(" HWResolution [%d %d], expected [%d %d]\n", | |
573 | header->HWResolution[0], header->HWResolution[1], | |
574 | expected->HWResolution[0], expected->HWResolution[1]); | |
575 | ||
576 | if (memcmp(header->ImagingBoundingBox, expected->ImagingBoundingBox, | |
577 | sizeof(header->ImagingBoundingBox))) | |
578 | printf(" ImagingBoundingBox [%d %d %d %d], expected [%d %d %d %d]\n", | |
579 | header->ImagingBoundingBox[0], | |
580 | header->ImagingBoundingBox[1], | |
581 | header->ImagingBoundingBox[2], | |
582 | header->ImagingBoundingBox[3], | |
583 | expected->ImagingBoundingBox[0], | |
584 | expected->ImagingBoundingBox[1], | |
585 | expected->ImagingBoundingBox[2], | |
586 | expected->ImagingBoundingBox[3]); | |
587 | ||
588 | if (header->InsertSheet != expected->InsertSheet) | |
589 | printf(" InsertSheet %d, expected %d\n", header->InsertSheet, | |
590 | expected->InsertSheet); | |
591 | ||
592 | if (header->Jog != expected->Jog) | |
593 | printf(" Jog %d, expected %d\n", header->Jog, | |
594 | expected->Jog); | |
595 | ||
596 | if (header->LeadingEdge != expected->LeadingEdge) | |
597 | printf(" LeadingEdge %d, expected %d\n", header->LeadingEdge, | |
598 | expected->LeadingEdge); | |
599 | ||
600 | if (header->Margins[0] != expected->Margins[0] || | |
601 | header->Margins[1] != expected->Margins[1]) | |
602 | printf(" Margins [%d %d], expected [%d %d]\n", | |
603 | header->Margins[0], header->Margins[1], | |
604 | expected->Margins[0], expected->Margins[1]); | |
605 | ||
606 | if (header->ManualFeed != expected->ManualFeed) | |
607 | printf(" ManualFeed %d, expected %d\n", header->ManualFeed, | |
608 | expected->ManualFeed); | |
609 | ||
610 | if (header->MediaPosition != expected->MediaPosition) | |
611 | printf(" MediaPosition %d, expected %d\n", header->MediaPosition, | |
612 | expected->MediaPosition); | |
613 | ||
614 | if (header->MediaWeight != expected->MediaWeight) | |
615 | printf(" MediaWeight %d, expected %d\n", header->MediaWeight, | |
616 | expected->MediaWeight); | |
617 | ||
618 | if (header->MirrorPrint != expected->MirrorPrint) | |
619 | printf(" MirrorPrint %d, expected %d\n", header->MirrorPrint, | |
620 | expected->MirrorPrint); | |
621 | ||
622 | if (header->NegativePrint != expected->NegativePrint) | |
623 | printf(" NegativePrint %d, expected %d\n", header->NegativePrint, | |
624 | expected->NegativePrint); | |
625 | ||
626 | if (header->NumCopies != expected->NumCopies) | |
627 | printf(" NumCopies %d, expected %d\n", header->NumCopies, | |
628 | expected->NumCopies); | |
629 | ||
630 | if (header->Orientation != expected->Orientation) | |
631 | printf(" Orientation %d, expected %d\n", header->Orientation, | |
632 | expected->Orientation); | |
633 | ||
634 | if (header->OutputFaceUp != expected->OutputFaceUp) | |
635 | printf(" OutputFaceUp %d, expected %d\n", header->OutputFaceUp, | |
636 | expected->OutputFaceUp); | |
637 | ||
638 | if (header->PageSize[0] != expected->PageSize[0] || | |
639 | header->PageSize[1] != expected->PageSize[1]) | |
640 | printf(" PageSize [%d %d], expected [%d %d]\n", | |
641 | header->PageSize[0], header->PageSize[1], | |
642 | expected->PageSize[0], expected->PageSize[1]); | |
643 | ||
644 | if (header->Separations != expected->Separations) | |
645 | printf(" Separations %d, expected %d\n", header->Separations, | |
646 | expected->Separations); | |
647 | ||
648 | if (header->TraySwitch != expected->TraySwitch) | |
649 | printf(" TraySwitch %d, expected %d\n", header->TraySwitch, | |
650 | expected->TraySwitch); | |
651 | ||
652 | if (header->Tumble != expected->Tumble) | |
653 | printf(" Tumble %d, expected %d\n", header->Tumble, | |
654 | expected->Tumble); | |
655 | ||
656 | if (header->cupsWidth != expected->cupsWidth) | |
657 | printf(" cupsWidth %d, expected %d\n", header->cupsWidth, | |
658 | expected->cupsWidth); | |
659 | ||
660 | if (header->cupsHeight != expected->cupsHeight) | |
661 | printf(" cupsHeight %d, expected %d\n", header->cupsHeight, | |
662 | expected->cupsHeight); | |
663 | ||
664 | if (header->cupsMediaType != expected->cupsMediaType) | |
665 | printf(" cupsMediaType %d, expected %d\n", header->cupsMediaType, | |
666 | expected->cupsMediaType); | |
667 | ||
668 | if (header->cupsBitsPerColor != expected->cupsBitsPerColor) | |
669 | printf(" cupsBitsPerColor %d, expected %d\n", header->cupsBitsPerColor, | |
670 | expected->cupsBitsPerColor); | |
671 | ||
672 | if (header->cupsBitsPerPixel != expected->cupsBitsPerPixel) | |
673 | printf(" cupsBitsPerPixel %d, expected %d\n", header->cupsBitsPerPixel, | |
674 | expected->cupsBitsPerPixel); | |
675 | ||
676 | if (header->cupsBytesPerLine != expected->cupsBytesPerLine) | |
677 | printf(" cupsBytesPerLine %d, expected %d\n", header->cupsBytesPerLine, | |
678 | expected->cupsBytesPerLine); | |
679 | ||
680 | if (header->cupsColorOrder != expected->cupsColorOrder) | |
681 | printf(" cupsColorOrder %d, expected %d\n", header->cupsColorOrder, | |
682 | expected->cupsColorOrder); | |
683 | ||
684 | if (header->cupsColorSpace != expected->cupsColorSpace) | |
685 | printf(" cupsColorSpace %d, expected %d\n", header->cupsColorSpace, | |
686 | expected->cupsColorSpace); | |
687 | ||
688 | if (header->cupsCompression != expected->cupsCompression) | |
689 | printf(" cupsCompression %d, expected %d\n", header->cupsCompression, | |
690 | expected->cupsCompression); | |
691 | ||
692 | if (header->cupsRowCount != expected->cupsRowCount) | |
693 | printf(" cupsRowCount %d, expected %d\n", header->cupsRowCount, | |
694 | expected->cupsRowCount); | |
695 | ||
696 | if (header->cupsRowFeed != expected->cupsRowFeed) | |
697 | printf(" cupsRowFeed %d, expected %d\n", header->cupsRowFeed, | |
698 | expected->cupsRowFeed); | |
699 | ||
700 | if (header->cupsRowStep != expected->cupsRowStep) | |
701 | printf(" cupsRowStep %d, expected %d\n", header->cupsRowStep, | |
702 | expected->cupsRowStep); | |
703 | ||
704 | if (header->cupsNumColors != expected->cupsNumColors) | |
705 | printf(" cupsNumColors %d, expected %d\n", header->cupsNumColors, | |
706 | expected->cupsNumColors); | |
707 | ||
7e86f2f6 | 708 | if (fabs(header->cupsBorderlessScalingFactor - expected->cupsBorderlessScalingFactor) > 0.001) |
b86bc4cf | 709 | printf(" cupsBorderlessScalingFactor %g, expected %g\n", |
710 | header->cupsBorderlessScalingFactor, | |
711 | expected->cupsBorderlessScalingFactor); | |
712 | ||
7e86f2f6 MS |
713 | if (fabs(header->cupsPageSize[0] - expected->cupsPageSize[0]) > 0.001 || |
714 | fabs(header->cupsPageSize[1] - expected->cupsPageSize[1]) > 0.001) | |
b86bc4cf | 715 | printf(" cupsPageSize [%g %g], expected [%g %g]\n", |
716 | header->cupsPageSize[0], header->cupsPageSize[1], | |
717 | expected->cupsPageSize[0], expected->cupsPageSize[1]); | |
718 | ||
7e86f2f6 MS |
719 | if (fabs(header->cupsImagingBBox[0] - expected->cupsImagingBBox[0]) > 0.001 || |
720 | fabs(header->cupsImagingBBox[1] - expected->cupsImagingBBox[1]) > 0.001 || | |
721 | fabs(header->cupsImagingBBox[2] - expected->cupsImagingBBox[2]) > 0.001 || | |
722 | fabs(header->cupsImagingBBox[3] - expected->cupsImagingBBox[3]) > 0.001) | |
b86bc4cf | 723 | printf(" cupsImagingBBox [%g %g %g %g], expected [%g %g %g %g]\n", |
724 | header->cupsImagingBBox[0], header->cupsImagingBBox[1], | |
725 | header->cupsImagingBBox[2], header->cupsImagingBBox[3], | |
726 | expected->cupsImagingBBox[0], expected->cupsImagingBBox[1], | |
727 | expected->cupsImagingBBox[2], expected->cupsImagingBBox[3]); | |
728 | ||
729 | for (i = 0; i < 16; i ++) | |
730 | if (header->cupsInteger[i] != expected->cupsInteger[i]) | |
731 | printf(" cupsInteger%d %d, expected %d\n", i, header->cupsInteger[i], | |
732 | expected->cupsInteger[i]); | |
733 | ||
734 | for (i = 0; i < 16; i ++) | |
7e86f2f6 | 735 | if (fabs(header->cupsReal[i] - expected->cupsReal[i]) > 0.001) |
b86bc4cf | 736 | printf(" cupsReal%d %g, expected %g\n", i, header->cupsReal[i], |
737 | expected->cupsReal[i]); | |
738 | ||
739 | for (i = 0; i < 16; i ++) | |
740 | if (strcmp(header->cupsString[i], expected->cupsString[i])) | |
741 | printf(" cupsString%d (%s), expected (%s)\n", i, | |
742 | header->cupsString[i], expected->cupsString[i]); | |
743 | ||
744 | if (strcmp(header->cupsMarkerType, expected->cupsMarkerType)) | |
745 | printf(" cupsMarkerType (%s), expected (%s)\n", header->cupsMarkerType, | |
746 | expected->cupsMarkerType); | |
747 | ||
748 | if (strcmp(header->cupsRenderingIntent, expected->cupsRenderingIntent)) | |
749 | printf(" cupsRenderingIntent (%s), expected (%s)\n", | |
750 | header->cupsRenderingIntent, | |
751 | expected->cupsRenderingIntent); | |
752 | ||
753 | if (strcmp(header->cupsPageSizeName, expected->cupsPageSizeName)) | |
754 | printf(" cupsPageSizeName (%s), expected (%s)\n", | |
755 | header->cupsPageSizeName, | |
756 | expected->cupsPageSizeName); | |
ef416fc2 | 757 | } |