1 /*
2  * Raster test program routines for CUPS.
3  *
4  * Copyright © 2007-2019 by Apple Inc.
5  * Copyright © 1997-2007 by Easy Software Products.
6  *
7  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
8  * information.
9  */
10 
11 /*
12  * Include necessary headers...
13  */
14 
15 #include <cups/raster-private.h>
16 #include <math.h>
17 
18 
19 /*
20  * Local functions...
21  */
22 
23 static int	do_ras_file(const char *filename);
24 static int	do_raster_tests(cups_mode_t mode);
25 static void	print_changes(cups_page_header2_t *header, cups_page_header2_t *expected);
26 
27 
28 /*
29  * 'main()' - Test the raster functions.
30  */
31 
32 int					/* O - Exit status */
main(int argc,char * argv[])33 main(int  argc,				/* I - Number of command-line args */
34      char *argv[])			/* I - Command-line arguments */
35 {
36   int	errors = 0;			/* Number of errors */
37 
38 
39   if (argc == 1)
40   {
41     errors += do_raster_tests(CUPS_RASTER_WRITE);
42     errors += do_raster_tests(CUPS_RASTER_WRITE_COMPRESSED);
43     errors += do_raster_tests(CUPS_RASTER_WRITE_PWG);
44     errors += do_raster_tests(CUPS_RASTER_WRITE_APPLE);
45   }
46   else
47   {
48     int			i;		/* Looping var */
49 
50     for (i = 1; i < argc; i ++)
51       errors += do_ras_file(argv[i]);
52   }
53 
54   return (errors);
55 }
56 
57 
58 /*
59  * 'do_ras_file()' - Test reading of a raster file.
60  */
61 
62 static int				/* O - Number of errors */
do_ras_file(const char * filename)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 */
72 
73 
74   if ((fd = open(filename, O_RDONLY)) < 0)
75   {
76     printf("%s: %s\n", filename, strerror(errno));
77     return (1);
78   }
79 
80   if ((ras = cupsRasterOpen(fd, CUPS_RASTER_READ)) == NULL)
81   {
82     printf("%s: cupsRasterOpen failed.\n", filename);
83     close(fd);
84     return (1);
85   }
86 
87   printf("%s:\n", filename);
88 
89   while (cupsRasterReadHeader2(ras, &header))
90   {
91     pages ++;
92     data = malloc(header.cupsBytesPerLine);
93 
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);
98 
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);
110   }
111 
112   printf("EOF at %ld\n", (long)lseek(fd, SEEK_CUR, 0));
113 
114   cupsRasterClose(ras);
115   close(fd);
116 
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 */
do_raster_tests(cups_mode_t mode)126 do_raster_tests(cups_mode_t mode)	/* O - Write mode */
127 {
128   unsigned		page, x, y, count;/* Looping vars */
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 
137  /*
138   * Test writing...
139   */
140 
141   printf("cupsRasterOpen(%s): ",
142          mode == CUPS_RASTER_WRITE ? "CUPS_RASTER_WRITE" :
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");
146   fflush(stdout);
147 
148   if ((fp = fopen("test.raster", "wb")) == NULL)
149   {
150     printf("FAIL (%s)\n", strerror(errno));
151     return (1);
152   }
153 
154   if ((r = cupsRasterOpen(fileno(fp), mode)) == NULL)
155   {
156     printf("FAIL (%s)\n", strerror(errno));
157     fclose(fp);
158     return (1);
159   }
160 
161   puts("PASS");
162 
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;
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;
175 
176     strlcpy(header.MediaType, "auto", sizeof(header.MediaType));
177 
178     if (page & 1)
179     {
180       header.cupsBytesPerLine *= 4;
181       header.cupsColorSpace = CUPS_CSPACE_CMYK;
182       header.cupsColorOrder = CUPS_ORDER_CHUNKED;
183       header.cupsNumColors  = 4;
184     }
185     else
186     {
187       header.cupsColorSpace = CUPS_CSPACE_W;
188       header.cupsColorOrder = CUPS_ORDER_CHUNKED;
189       header.cupsNumColors  = 1;
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 
204     printf("cupsRasterWriteHeader2(page %d): ", page + 1);
205 
206     if (cupsRasterWriteHeader2(r, &header))
207     {
208       puts("PASS");
209     }
210     else
211     {
212       puts("FAIL");
213       errors ++;
214     }
215 
216     fputs("cupsRasterWritePixels: ", stdout);
217     fflush(stdout);
218 
219     memset(data, 0, header.cupsBytesPerLine);
220     for (y = 0; y < 64; y ++)
221       if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine))
222         break;
223 
224     if (y < 64)
225     {
226       puts("FAIL");
227       errors ++;
228     }
229     else
230     {
231       for (x = 0; x < header.cupsBytesPerLine; x ++)
232 	data[x] = (unsigned char)x;
233 
234       for (y = 0; y < 64; y ++)
235 	if (!cupsRasterWritePixels(r, data, header.cupsBytesPerLine))
236 	  break;
237 
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 ++)
258 	    data[x] = (unsigned char)(x / 4);
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     }
274   }
275 
276   cupsRasterClose(r);
277   fclose(fp);
278 
279  /*
280   * Test reading...
281   */
282 
283   fputs("cupsRasterOpen(CUPS_RASTER_READ): ", stdout);
284   fflush(stdout);
285 
286   if ((fp = fopen("test.raster", "rb")) == NULL)
287   {
288     printf("FAIL (%s)\n", strerror(errno));
289     return (1);
290   }
291 
292   if ((r = cupsRasterOpen(fileno(fp), CUPS_RASTER_READ)) == NULL)
293   {
294     printf("FAIL (%s)\n", strerror(errno));
295     fclose(fp);
296     return (1);
297   }
298 
299   puts("PASS");
300 
301   for (page = 0; page < 4; page ++)
302   {
303     memset(&expected, 0, sizeof(expected));
304     expected.cupsWidth        = 256;
305     expected.cupsHeight       = 256;
306     expected.cupsBytesPerLine = 256;
307     expected.HWResolution[0]  = 64;
308     expected.HWResolution[1]  = 64;
309     expected.PageSize[0]      = 288;
310     expected.PageSize[1]      = 288;
311 
312     strlcpy(expected.MediaType, "auto", sizeof(expected.MediaType));
313 
314     if (mode != CUPS_RASTER_WRITE_PWG)
315     {
316       expected.cupsPageSize[0] = 288.0f;
317       expected.cupsPageSize[1] = 288.0f;
318     }
319 
320     if (mode >= CUPS_RASTER_WRITE_PWG)
321     {
322       strlcpy(expected.MediaClass, "PwgRaster", sizeof(expected.MediaClass));
323       expected.cupsInteger[7] = 0xffffff;
324     }
325 
326     if (page & 1)
327     {
328       expected.cupsBytesPerLine *= 4;
329       expected.cupsColorSpace = CUPS_CSPACE_CMYK;
330       expected.cupsColorOrder = CUPS_ORDER_CHUNKED;
331       expected.cupsNumColors  = 4;
332     }
333     else
334     {
335       expected.cupsColorSpace = CUPS_CSPACE_W;
336       expected.cupsColorOrder = CUPS_ORDER_CHUNKED;
337       expected.cupsNumColors  = 1;
338     }
339 
340     if (page & 2)
341     {
342       expected.cupsBytesPerLine *= 2;
343       expected.cupsBitsPerColor = 16;
344       expected.cupsBitsPerPixel = (page & 1) ? 64 : 16;
345     }
346     else
347     {
348       expected.cupsBitsPerColor = 8;
349       expected.cupsBitsPerPixel = (page & 1) ? 32 : 8;
350     }
351 
352     printf("cupsRasterReadHeader2(page %d): ", page + 1);
353     fflush(stdout);
354 
355     if (!cupsRasterReadHeader2(r, &header))
356     {
357       puts("FAIL (read error)");
358       errors ++;
359       break;
360     }
361     else if (memcmp(&header, &expected, sizeof(header)))
362     {
363       puts("FAIL (bad page header)");
364       errors ++;
365       print_changes(&header, &expected);
366     }
367     else
368       puts("PASS");
369 
370     fputs("cupsRasterReadPixels: ", stdout);
371     fflush(stdout);
372 
373     for (y = 0; y < 64; y ++)
374     {
375       if (!cupsRasterReadPixels(r, data, header.cupsBytesPerLine))
376       {
377         puts("FAIL (read error)");
378 	errors ++;
379 	break;
380       }
381 
382       if (data[0] != 0 || memcmp(data, data + 1, header.cupsBytesPerLine - 1))
383       {
384         printf("FAIL (raster line %d corrupt)\n", y);
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 
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 ++;
412 	  break;
413 	}
414 
415 	for (x = 0; x < header.cupsBytesPerLine; x ++)
416           if (data[x] != (x & 255))
417 	    break;
418 
419 	if (x < header.cupsBytesPerLine)
420 	{
421 	  printf("FAIL (raster line %d corrupt)\n", y + 64);
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 
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);
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 
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);
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 
506 	      errors ++;
507 	      break;
508 	    }
509 	  }
510 
511 	  if (y == 64)
512 	    puts("PASS");
513 	}
514       }
515     }
516   }
517 
518   cupsRasterClose(r);
519   fclose(fp);
520 
521   return (errors);
522 }
523 
524 
525 /*
526  * 'print_changes()' - Print differences in the page header.
527  */
528 
529 static void
print_changes(cups_page_header2_t * header,cups_page_header2_t * expected)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 
711   if (fabs(header->cupsBorderlessScalingFactor - expected->cupsBorderlessScalingFactor) > 0.001)
712     printf("    cupsBorderlessScalingFactor %g, expected %g\n",
713            header->cupsBorderlessScalingFactor,
714            expected->cupsBorderlessScalingFactor);
715 
716   if (fabs(header->cupsPageSize[0] - expected->cupsPageSize[0]) > 0.001 ||
717       fabs(header->cupsPageSize[1] - expected->cupsPageSize[1]) > 0.001)
718     printf("    cupsPageSize [%g %g], expected [%g %g]\n",
719            header->cupsPageSize[0], header->cupsPageSize[1],
720            expected->cupsPageSize[0], expected->cupsPageSize[1]);
721 
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)
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 ++)
738     if (fabs(header->cupsReal[i] - expected->cupsReal[i]) > 0.001)
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);
760 }
761