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