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