2 * PPD test program for CUPS.
4 * Copyright © 2007-2018 by Apple Inc.
5 * Copyright © 1997-2006 by Easy Software Products.
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more
12 * Include necessary headers...
15 #undef _CUPS_NO_DEPRECATED
16 #include "cups-private.h"
17 #include "ppd-private.h"
18 #include "raster-private.h"
33 static int do_ppd_tests(const char *filename
, int num_options
, cups_option_t
*options
);
34 static int do_ps_tests(void);
35 static void print_changes(cups_page_header2_t
*header
, cups_page_header2_t
*expected
);
42 static const char *dsc_code
=
44 "%%BeginFeature: *PageSize Tabloid\n"
45 "<</PageSize[792 1224]>>setpagedevice\n"
47 "} stopped cleartomark\n";
48 static const char *setpagedevice_code
=
50 "/MediaClass(Media Class)"
51 "/MediaColor((Media Color))"
52 "/MediaType(Media\\\\Type)"
54 "/AdvanceDistance 1000"
59 "/HWResolution[100 200]"
64 "/MediaPosition 8#777"
65 "/MediaWeight 16#fe01"
71 "/PageSize[612 792.1]"
82 "/cupsBorderlessScalingFactor 1.001"
131 "/cupsMarkerType(Marker Type)"
132 "/cupsRenderingIntent(Rendering Intent)"
133 "/cupsPageSizeName(Letter)"
134 "/cupsPreferredBitsPerColor 17"
137 static cups_page_header2_t setpagedevice_header
=
139 "Media Class", /* MediaClass */
140 "(Media Color)", /* MediaColor */
141 "Media\\Type", /* MediaType */
142 "Abc", /* OutputType */
143 1000, /* AdvanceDistance */
144 CUPS_ADVANCE_FILE
, /* AdvanceMedia */
145 CUPS_FALSE
, /* Collate */
146 CUPS_CUT_JOB
, /* CutMedia */
147 CUPS_TRUE
, /* Duplex */
148 { 100, 200 }, /* HWResolution */
149 { 0, 0, 0, 0 }, /* ImagingBoundingBox */
150 CUPS_TRUE
, /* InsertSheet */
151 CUPS_JOG_SET
, /* Jog */
152 CUPS_EDGE_RIGHT
, /* LeadingEdge */
153 { 0, 0 }, /* Margins */
154 CUPS_TRUE
, /* ManualFeed */
155 0777, /* MediaPosition */
156 0xfe01, /* MediaWeight */
157 CUPS_TRUE
, /* MirrorPrint */
158 CUPS_TRUE
, /* NegativePrint */
160 CUPS_ORIENT_90
, /* Orientation */
161 CUPS_TRUE
, /* OutputFaceUp */
162 { 612, 792 }, /* PageSize */
163 CUPS_TRUE
, /* Separations */
164 CUPS_TRUE
, /* TraySwitch */
165 CUPS_TRUE
, /* Tumble */
168 2, /* cupsMediaType */
169 0, /* cupsBitsPerColor */
170 0, /* cupsBitsPerPixel */
171 0, /* cupsBytesPerLine */
172 CUPS_ORDER_BANDED
, /* cupsColorOrder */
173 CUPS_CSPACE_RGB
, /* cupsColorSpace */
174 1, /* cupsCompression */
175 1, /* cupsRowCount */
178 0, /* cupsNumColors */
179 1.001f
, /* cupsBorderlessScalingFactor */
180 { 612.0f
, 792.1f
}, /* cupsPageSize */
181 { 0.0f
, 0.0f
, 0.0f
, 0.0f
}, /* cupsImagingBBox */
182 { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 },
183 /* cupsInteger[16] */
184 { 1.1f
, 2.1f
, 3.1f
, 4.1f
, 5.1f
, 6.1f
, 7.1f
, 8.1f
, 9.1f
, 10.1f
, 11.1f
, 12.1f
, 13.1f
, 14.1f
, 15.1f
, 16.1f
}, /* cupsReal[16] */
185 { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13",
186 "14", "15", "16" }, /* cupsString[16] */
187 "Marker Type", /* cupsMarkerType */
188 "Rendering Intent", /* cupsRenderingIntent */
189 "Letter" /* cupsPageSizeName */
192 static const char *default_code
=
194 "%%BeginFeature: *InstalledDuplexer False\n"
196 "} stopped cleartomark\n"
198 "%%BeginFeature: *PageRegion Letter\n"
199 "PageRegion=Letter\n"
201 "} stopped cleartomark\n"
203 "%%BeginFeature: *InputSlot Tray\n"
206 "} stopped cleartomark\n"
208 "%%BeginFeature: *OutputBin Tray1\n"
211 "} stopped cleartomark\n"
213 "%%BeginFeature: *MediaType Plain\n"
216 "} stopped cleartomark\n"
218 "%%BeginFeature: *IntOption None\n"
220 "} stopped cleartomark\n"
222 "%%BeginFeature: *StringOption None\n"
224 "} stopped cleartomark\n";
226 static const char *custom_code
=
228 "%%BeginFeature: *InstalledDuplexer False\n"
230 "} stopped cleartomark\n"
232 "%%BeginFeature: *InputSlot Tray\n"
235 "} stopped cleartomark\n"
237 "%%BeginFeature: *MediaType Plain\n"
240 "} stopped cleartomark\n"
242 "%%BeginFeature: *OutputBin Tray1\n"
245 "} stopped cleartomark\n"
247 "%%BeginFeature: *IntOption None\n"
249 "} stopped cleartomark\n"
251 "%%BeginFeature: *CustomStringOption True\n"
252 "(value\\0502\\051)\n"
254 "StringOption=Custom\n"
256 "} stopped cleartomark\n"
258 "%%BeginFeature: *CustomPageSize True\n"
266 "} stopped cleartomark\n";
268 static const char *default2_code
=
270 "%%BeginFeature: *InstalledDuplexer False\n"
272 "} stopped cleartomark\n"
274 "%%BeginFeature: *InputSlot Tray\n"
277 "} stopped cleartomark\n"
279 "%%BeginFeature: *Quality Normal\n"
282 "} stopped cleartomark\n"
284 "%%BeginFeature: *IntOption None\n"
286 "} stopped cleartomark\n"
288 "%%BeginFeature: *StringOption None\n"
290 "} stopped cleartomark\n";
294 * 'main()' - Main entry.
297 int /* O - Exit status */
298 main(int argc
, /* I - Number of command-line arguments */
299 char *argv
[]) /* I - Command-line arguments */
301 int i
; /* Looping var */
302 ppd_file_t
*ppd
= NULL
; /* PPD file loaded from disk */
303 int status
; /* Status of tests (0 = success, 1 = fail) */
304 int conflicts
; /* Number of conflicts */
305 char *s
; /* String */
306 char buffer
[8192]; /* String buffer */
307 const char *text
, /* Localized text */
308 *val
; /* Option value */
309 int num_options
; /* Number of options */
310 cups_option_t
*options
; /* Options */
311 ppd_size_t minsize
, /* Minimum size */
312 maxsize
, /* Maximum size */
313 *size
; /* Current size */
314 ppd_attr_t
*attr
; /* Current attribute */
315 _ppd_cache_t
*pc
; /* PPD cache */
323 * Setup directories for locale stuff...
326 if (access("locale", 0))
328 mkdir("locale", 0777);
329 mkdir("locale/fr", 0777);
330 symlink("../../../locale/cups_fr.po", "locale/fr/cups_fr.po");
331 mkdir("locale/zh_TW", 0777);
332 symlink("../../../locale/cups_zh_TW.po", "locale/zh_TW/cups_zh_TW.po");
335 putenv("LOCALEDIR=locale");
336 putenv("SOFTWARE=CUPS");
339 * Do tests with test.ppd...
342 fputs("ppdOpenFile(test.ppd): ", stdout
);
344 if ((ppd
= _ppdOpenFile("test.ppd", _PPD_LOCALIZATION_ALL
)) != NULL
)
348 ppd_status_t err
; /* Last error in file */
349 int line
; /* Line number in file */
353 err
= ppdLastError(&line
);
355 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
358 fputs("ppdFindAttr(wildcard): ", stdout
);
359 if ((attr
= ppdFindAttr(ppd
, "cupsTest", NULL
)) == NULL
)
362 puts("FAIL (not found)");
364 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
367 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
372 fputs("ppdFindNextAttr(wildcard): ", stdout
);
373 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", NULL
)) == NULL
)
376 puts("FAIL (not found)");
378 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Bar"))
381 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
386 fputs("ppdFindAttr(Foo): ", stdout
);
387 if ((attr
= ppdFindAttr(ppd
, "cupsTest", "Foo")) == NULL
)
390 puts("FAIL (not found)");
392 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
395 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
400 fputs("ppdFindNextAttr(Foo): ", stdout
);
401 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", "Foo")) != NULL
)
404 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
409 fputs("ppdMarkDefaults: ", stdout
);
410 ppdMarkDefaults(ppd
);
412 if ((conflicts
= ppdConflicts(ppd
)) == 0)
417 printf("FAIL (%d conflicts)\n", conflicts
);
420 fputs("ppdEmitString (defaults): ", stdout
);
421 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
422 !strcmp(s
, default_code
))
427 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
428 (int)strlen(default_code
));
437 fputs("ppdEmitString (custom size and string): ", stdout
);
438 ppdMarkOption(ppd
, "PageSize", "Custom.400x500");
439 ppdMarkOption(ppd
, "StringOption", "{String1=\"value 1\" String2=value(2)}");
441 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
442 !strcmp(s
, custom_code
))
447 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
448 (int)strlen(custom_code
));
458 * Test constraints...
461 fputs("cupsGetConflicts(InputSlot=Envelope): ", stdout
);
462 ppdMarkOption(ppd
, "PageSize", "Letter");
464 num_options
= cupsGetConflicts(ppd
, "InputSlot", "Envelope", &options
);
465 if (num_options
!= 2 ||
466 (val
= cupsGetOption("PageRegion", num_options
, options
)) == NULL
||
467 _cups_strcasecmp(val
, "Letter") ||
468 (val
= cupsGetOption("PageSize", num_options
, options
)) == NULL
||
469 _cups_strcasecmp(val
, "Letter"))
471 printf("FAIL (%d options:", num_options
);
472 for (i
= 0; i
< num_options
; i
++)
473 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
480 fputs("ppdConflicts(): ", stdout
);
481 ppdMarkOption(ppd
, "InputSlot", "Envelope");
483 if ((conflicts
= ppdConflicts(ppd
)) == 2)
487 printf("FAIL (%d)\n", conflicts
);
491 fputs("cupsResolveConflicts(InputSlot=Envelope): ", stdout
);
494 if (!cupsResolveConflicts(ppd
, "InputSlot", "Envelope", &num_options
,
497 puts("FAIL (Unable to resolve)");
500 else if (num_options
!= 2 ||
501 !cupsGetOption("PageSize", num_options
, options
))
503 printf("FAIL (%d options:", num_options
);
504 for (i
= 0; i
< num_options
; i
++)
505 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
510 puts("PASS (Resolved by changing PageSize)");
512 cupsFreeOptions(num_options
, options
);
514 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
517 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
518 num_options
== 1 && !_cups_strcasecmp(options
[0].name
, "InputSlot") &&
519 !_cups_strcasecmp(options
[0].value
, "Tray"))
520 puts("PASS (Resolved by changing InputSlot)");
521 else if (num_options
> 0)
523 printf("FAIL (%d options:", num_options
);
524 for (i
= 0; i
< num_options
; i
++)
525 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
531 puts("FAIL (Unable to resolve)");
534 cupsFreeOptions(num_options
, options
);
536 fputs("ppdInstallableConflict(): ", stdout
);
537 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
538 !ppdInstallableConflict(ppd
, "Duplex", "None"))
540 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
542 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
547 puts("FAIL (Duplex=None conflicted)");
555 fputs("ppdPageSizeLimits: ", stdout
);
556 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
558 if (fabs(minsize
.width
- 36.0) > 0.001 || fabs(minsize
.length
- 36.0) > 0.001 ||
559 fabs(maxsize
.width
- 1080.0) > 0.001 || fabs(maxsize
.length
- 86400.0) > 0.001)
561 printf("FAIL (got min=%.3fx%.3f, max=%.3fx%.3f, "
562 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
563 minsize
.length
, maxsize
.width
, maxsize
.length
);
571 puts("FAIL (returned 0)");
576 * cupsMarkOptions with PWG and IPP size names.
579 fputs("cupsMarkOptions(media=iso-a4): ", stdout
);
580 num_options
= cupsAddOption("media", "iso-a4", 0, &options
);
581 cupsMarkOptions(ppd
, num_options
, options
);
582 cupsFreeOptions(num_options
, options
);
584 size
= ppdPageSize(ppd
, NULL
);
585 if (!size
|| strcmp(size
->name
, "A4"))
587 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
593 fputs("cupsMarkOptions(media=na_letter_8.5x11in): ", stdout
);
594 num_options
= cupsAddOption("media", "na_letter_8.5x11in", 0, &options
);
595 cupsMarkOptions(ppd
, num_options
, options
);
596 cupsFreeOptions(num_options
, options
);
598 size
= ppdPageSize(ppd
, NULL
);
599 if (!size
|| strcmp(size
->name
, "Letter"))
601 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
607 fputs("cupsMarkOptions(media=oe_letter-fullbleed_8.5x11in): ", stdout
);
608 num_options
= cupsAddOption("media", "oe_letter-fullbleed_8.5x11in", 0,
610 cupsMarkOptions(ppd
, num_options
, options
);
611 cupsFreeOptions(num_options
, options
);
613 size
= ppdPageSize(ppd
, NULL
);
614 if (!size
|| strcmp(size
->name
, "Letter.Fullbleed"))
616 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
622 fputs("cupsMarkOptions(media=A4): ", stdout
);
623 num_options
= cupsAddOption("media", "A4", 0, &options
);
624 cupsMarkOptions(ppd
, num_options
, options
);
625 cupsFreeOptions(num_options
, options
);
627 size
= ppdPageSize(ppd
, NULL
);
628 if (!size
|| strcmp(size
->name
, "A4"))
630 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
640 fputs("cupsMarkOptions(media=Custom.8x10in): ", stdout
);
641 num_options
= cupsAddOption("media", "Custom.8x10in", 0, &options
);
642 cupsMarkOptions(ppd
, num_options
, options
);
643 cupsFreeOptions(num_options
, options
);
645 size
= ppdPageSize(ppd
, NULL
);
646 if (!size
|| strcmp(size
->name
, "Custom") ||
647 fabs(size
->width
- 576.0) > 0.001 ||
648 fabs(size
->length
- 720.0) > 0.001)
650 printf("FAIL (%s - %gx%g)\n", size
? size
->name
: "unknown",
651 size
? size
->width
: 0.0, size
? size
->length
: 0.0);
658 * Test localization...
661 fputs("ppdLocalizeIPPReason(text): ", stdout
);
662 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
663 !strcmp(buffer
, "Foo Reason"))
668 printf("FAIL (\"%s\" instead of \"Foo Reason\")\n", buffer
);
671 fputs("ppdLocalizeIPPReason(http): ", stdout
);
672 if (ppdLocalizeIPPReason(ppd
, "foo", "http", buffer
, sizeof(buffer
)) &&
673 !strcmp(buffer
, "http://foo/bar.html"))
678 printf("FAIL (\"%s\" instead of \"http://foo/bar.html\")\n", buffer
);
681 fputs("ppdLocalizeIPPReason(help): ", stdout
);
682 if (ppdLocalizeIPPReason(ppd
, "foo", "help", buffer
, sizeof(buffer
)) &&
683 !strcmp(buffer
, "help:anchor='foo'%20bookID=Vendor%20Help"))
688 printf("FAIL (\"%s\" instead of \"help:anchor='foo'%%20bookID=Vendor%%20Help\")\n", buffer
);
691 fputs("ppdLocalizeIPPReason(file): ", stdout
);
692 if (ppdLocalizeIPPReason(ppd
, "foo", "file", buffer
, sizeof(buffer
)) &&
693 !strcmp(buffer
, "/help/foo/bar.html"))
698 printf("FAIL (\"%s\" instead of \"/help/foo/bar.html\")\n", buffer
);
703 putenv("LC_CTYPE=fr");
704 putenv("LC_MESSAGES=fr");
706 fputs("ppdLocalizeIPPReason(fr text): ", stdout
);
707 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
708 !strcmp(buffer
, "La Long Foo Reason"))
713 printf("FAIL (\"%s\" instead of \"La Long Foo Reason\")\n", buffer
);
716 putenv("LANG=zh_TW");
717 putenv("LC_ALL=zh_TW");
718 putenv("LC_CTYPE=zh_TW");
719 putenv("LC_MESSAGES=zh_TW");
721 fputs("ppdLocalizeIPPReason(zh_TW text): ", stdout
);
722 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
723 !strcmp(buffer
, "Number 1 Foo Reason"))
728 printf("FAIL (\"%s\" instead of \"Number 1 Foo Reason\")\n", buffer
);
732 * cupsMarkerName localization...
737 putenv("LC_CTYPE=en");
738 putenv("LC_MESSAGES=en");
740 fputs("ppdLocalizeMarkerName(bogus): ", stdout
);
742 if ((text
= ppdLocalizeMarkerName(ppd
, "bogus")) != NULL
)
745 printf("FAIL (\"%s\" instead of NULL)\n", text
);
750 fputs("ppdLocalizeMarkerName(cyan): ", stdout
);
752 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
753 !strcmp(text
, "Cyan Toner"))
758 printf("FAIL (\"%s\" instead of \"Cyan Toner\")\n",
759 text
? text
: "(null)");
764 putenv("LC_CTYPE=fr");
765 putenv("LC_MESSAGES=fr");
767 fputs("ppdLocalizeMarkerName(fr cyan): ", stdout
);
768 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
769 !strcmp(text
, "La Toner Cyan"))
774 printf("FAIL (\"%s\" instead of \"La Toner Cyan\")\n",
775 text
? text
: "(null)");
778 putenv("LANG=zh_TW");
779 putenv("LC_ALL=zh_TW");
780 putenv("LC_CTYPE=zh_TW");
781 putenv("LC_MESSAGES=zh_TW");
783 fputs("ppdLocalizeMarkerName(zh_TW cyan): ", stdout
);
784 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
785 !strcmp(text
, "Number 1 Cyan Toner"))
790 printf("FAIL (\"%s\" instead of \"Number 1 Cyan Toner\")\n",
791 text
? text
: "(null)");
797 * Test new constraints...
800 fputs("ppdOpenFile(test2.ppd): ", stdout
);
802 if ((ppd
= ppdOpenFile("test2.ppd")) != NULL
)
806 ppd_status_t err
; /* Last error in file */
807 int line
; /* Line number in file */
811 err
= ppdLastError(&line
);
813 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
816 fputs("ppdMarkDefaults: ", stdout
);
817 ppdMarkDefaults(ppd
);
819 if ((conflicts
= ppdConflicts(ppd
)) == 0)
824 printf("FAIL (%d conflicts)\n", conflicts
);
827 fputs("ppdEmitString (defaults): ", stdout
);
828 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
829 !strcmp(s
, default2_code
))
834 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
835 (int)strlen(default2_code
));
844 fputs("ppdConflicts(): ", stdout
);
845 ppdMarkOption(ppd
, "PageSize", "Env10");
846 ppdMarkOption(ppd
, "InputSlot", "Envelope");
847 ppdMarkOption(ppd
, "Quality", "Photo");
849 if ((conflicts
= ppdConflicts(ppd
)) == 1)
853 printf("FAIL (%d)\n", conflicts
);
857 fputs("cupsResolveConflicts(Quality=Photo): ", stdout
);
860 if (cupsResolveConflicts(ppd
, "Quality", "Photo", &num_options
,
863 printf("FAIL (%d options:", num_options
);
864 for (i
= 0; i
< num_options
; i
++)
865 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
870 puts("PASS (Unable to resolve)");
871 cupsFreeOptions(num_options
, options
);
873 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
876 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
877 num_options
== 1 && !_cups_strcasecmp(options
->name
, "Quality") &&
878 !_cups_strcasecmp(options
->value
, "Normal"))
880 else if (num_options
> 0)
882 printf("FAIL (%d options:", num_options
);
883 for (i
= 0; i
< num_options
; i
++)
884 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
890 puts("FAIL (Unable to resolve!)");
893 cupsFreeOptions(num_options
, options
);
895 fputs("cupsResolveConflicts(loop test): ", stdout
);
896 ppdMarkOption(ppd
, "PageSize", "A4");
897 ppdMarkOption(ppd
, "InputSlot", "Tray");
898 ppdMarkOption(ppd
, "Quality", "Photo");
901 if (!cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
))
903 else if (num_options
> 0)
905 printf("FAIL (%d options:", num_options
);
906 for (i
= 0; i
< num_options
; i
++)
907 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
911 puts("FAIL (No conflicts!)");
913 fputs("ppdInstallableConflict(): ", stdout
);
914 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
915 !ppdInstallableConflict(ppd
, "Duplex", "None"))
917 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
919 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
924 puts("FAIL (Duplex=None conflicted)");
932 ppdMarkDefaults(ppd
);
934 fputs("ppdPageSizeLimits(default): ", stdout
);
935 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
937 if (fabs(minsize
.width
- 36.0) > 0.001 || fabs(minsize
.length
- 36.0) > 0.001 ||
938 fabs(maxsize
.width
- 1080.0) > 0.001 || fabs(maxsize
.length
- 86400.0) > 0.001)
940 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
941 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
942 minsize
.length
, maxsize
.width
, maxsize
.length
);
950 puts("FAIL (returned 0)");
954 ppdMarkOption(ppd
, "InputSlot", "Manual");
956 fputs("ppdPageSizeLimits(InputSlot=Manual): ", stdout
);
957 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
959 if (fabs(minsize
.width
- 100.0) > 0.001 || fabs(minsize
.length
- 100.0) > 0.001 ||
960 fabs(maxsize
.width
- 1000.0) > 0.001 || fabs(maxsize
.length
- 1000.0) > 0.001)
962 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
963 "expected min=100x100, max=1000x1000)\n", minsize
.width
,
964 minsize
.length
, maxsize
.width
, maxsize
.length
);
972 puts("FAIL (returned 0)");
976 ppdMarkOption(ppd
, "Quality", "Photo");
978 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
979 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
981 if (fabs(minsize
.width
- 200.0) > 0.001 || fabs(minsize
.length
- 200.0) > 0.001 ||
982 fabs(maxsize
.width
- 1000.0) > 0.001 || fabs(maxsize
.length
- 1000.0) > 0.001)
984 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
985 "expected min=200x200, max=1000x1000)\n", minsize
.width
,
986 minsize
.length
, maxsize
.width
, maxsize
.length
);
994 puts("FAIL (returned 0)");
998 ppdMarkOption(ppd
, "InputSlot", "Tray");
1000 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
1001 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
1003 if (fabs(minsize
.width
- 300.0) > 0.001 || fabs(minsize
.length
- 300.0) > 0.001 ||
1004 fabs(maxsize
.width
- 1080.0) > 0.001 || fabs(maxsize
.length
- 86400.0) > 0.001)
1006 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
1007 "expected min=300x300, max=1080x86400)\n", minsize
.width
,
1008 minsize
.length
, maxsize
.width
, maxsize
.length
);
1016 puts("FAIL (returned 0)");
1020 status
+= do_ps_tests();
1022 else if (!strcmp(argv
[1], "--raster"))
1024 int num_options
; /* Number of options */
1025 cups_option_t
*options
; /* Options */
1028 for (status
= 0, num_options
= 0, options
= NULL
, i
= 1; i
< argc
; i
++)
1030 if (argv
[i
][0] == '-')
1032 if (argv
[i
][1] == 'o')
1035 num_options
= cupsParseOptions(argv
[i
] + 2, num_options
, &options
);
1040 num_options
= cupsParseOptions(argv
[i
], num_options
, &options
);
1043 puts("Usage: testppd --raster [-o name=value ...] [filename.ppd ...]");
1050 puts("Usage: testppd --raster [-o name=value ...] [filename.ppd ...]");
1055 status
+= do_ppd_tests(argv
[i
], num_options
, options
);
1058 cupsFreeOptions(num_options
, options
);
1060 else if (!strncmp(argv
[1], "ipp://", 6) || !strncmp(argv
[1], "ipps://", 7))
1063 * ipp://... or ipps://...
1066 http_t
*http
; /* Connection to printer */
1067 ipp_t
*request
, /* Get-Printer-Attributes request */
1068 *response
; /* Get-Printer-Attributes response */
1069 char scheme
[32], /* URI scheme */
1070 userpass
[256], /* Username:password */
1071 host
[256], /* Hostname */
1072 resource
[256]; /* Resource path */
1073 int port
; /* Port number */
1074 static const char * const pattrs
[] =/* Requested printer attributes */
1078 "printer-description",
1079 "media-col-database"
1082 if (httpSeparateURI(HTTP_URI_CODING_ALL
, argv
[1], scheme
, sizeof(scheme
), userpass
, sizeof(userpass
), host
, sizeof(host
), &port
, resource
, sizeof(resource
)) < HTTP_URI_STATUS_OK
)
1084 printf("Bad URI \"%s\".\n", argv
[1]);
1088 http
= httpConnect2(host
, port
, NULL
, AF_UNSPEC
, !strcmp(scheme
, "ipps") ? HTTP_ENCRYPTION_ALWAYS
: HTTP_ENCRYPTION_IF_REQUESTED
, 1, 30000, NULL
);
1091 printf("Unable to connect to \"%s:%d\": %s\n", host
, port
, cupsLastErrorString());
1095 request
= ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES
);
1096 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri", NULL
, argv
[1]);
1097 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]), NULL
, pattrs
);
1098 response
= cupsDoRequest(http
, request
, resource
);
1100 if (_ppdCreateFromIPP(buffer
, sizeof(buffer
), response
))
1101 printf("Created PPD: %s\n", buffer
);
1103 puts("Unable to create PPD.");
1105 ippDelete(response
);
1111 const char *filename
; /* PPD filename */
1112 struct stat fileinfo
; /* File information */
1115 if (strchr(argv
[1], ':'))
1121 if ((filename
= cupsGetServerPPD(CUPS_HTTP_DEFAULT
, argv
[1])) == NULL
)
1123 printf("%s: %s\n", argv
[1], cupsLastErrorString());
1127 else if (!strncmp(argv
[1], "-d", 2))
1129 const char *printer
; /* Printer name */
1132 printer
= argv
[1] + 2;
1137 puts("Usage: ./testppd -d printer");
1141 filename
= cupsGetPPD(printer
);
1145 printf("%s: %s\n", printer
, cupsLastErrorString());
1152 if (lstat(filename
, &fileinfo
))
1154 printf("%s: %s\n", filename
, strerror(errno
));
1158 if (S_ISLNK(fileinfo
.st_mode
))
1160 char realfile
[1024]; /* Real file path */
1161 ssize_t realsize
; /* Size of real file path */
1164 if ((realsize
= readlink(filename
, realfile
, sizeof(realfile
) - 1)) < 0)
1165 strlcpy(realfile
, "Unknown", sizeof(realfile
));
1167 realfile
[realsize
] = '\0';
1169 if (stat(realfile
, &fileinfo
))
1170 printf("%s: symlink to \"%s\", %s\n", filename
, realfile
,
1173 printf("%s: symlink to \"%s\", %ld bytes\n", filename
, realfile
,
1174 (long)fileinfo
.st_size
);
1177 printf("%s: regular file, %ld bytes\n", filename
, (long)fileinfo
.st_size
);
1179 if ((ppd
= ppdOpenFile(filename
)) == NULL
)
1181 ppd_status_t err
; /* Last error in file */
1182 int line
; /* Line number in file */
1186 err
= ppdLastError(&line
);
1188 printf("%s: %s on line %d\n", argv
[1], ppdErrorString(err
), line
);
1192 int j
, k
; /* Looping vars */
1193 ppd_group_t
*group
; /* Option group */
1194 ppd_option_t
*option
; /* Option */
1195 ppd_coption_t
*coption
; /* Custom option */
1196 ppd_cparam_t
*cparam
; /* Custom parameter */
1197 ppd_const_t
*c
; /* UIConstraints */
1198 char lang
[255], /* LANG environment variable */
1199 lc_all
[255], /* LC_ALL environment variable */
1200 lc_ctype
[255], /* LC_CTYPE environment variable */
1201 lc_messages
[255];/* LC_MESSAGES environment variable */
1206 snprintf(lang
, sizeof(lang
), "LANG=%s", argv
[2]);
1208 snprintf(lc_all
, sizeof(lc_all
), "LC_ALL=%s", argv
[2]);
1210 snprintf(lc_ctype
, sizeof(lc_ctype
), "LC_CTYPE=%s", argv
[2]);
1212 snprintf(lc_messages
, sizeof(lc_messages
), "LC_MESSAGES=%s", argv
[2]);
1213 putenv(lc_messages
);
1217 ppdMarkDefaults(ppd
);
1221 text
= ppdLocalizeIPPReason(ppd
, argv
[3], NULL
, buffer
, sizeof(buffer
));
1222 printf("ppdLocalizeIPPReason(%s)=%s\n", argv
[3],
1223 text
? text
: "(null)");
1224 return (text
== NULL
);
1227 for (i
= ppd
->num_groups
, group
= ppd
->groups
;
1231 printf("%s (%s):\n", group
->name
, group
->text
);
1233 for (j
= group
->num_options
, option
= group
->options
;
1237 printf(" %s (%s):\n", option
->keyword
, option
->text
);
1239 for (k
= 0; k
< option
->num_choices
; k
++)
1240 printf(" - %s%s (%s)\n",
1241 option
->choices
[k
].marked
? "*" : "",
1242 option
->choices
[k
].choice
, option
->choices
[k
].text
);
1244 if ((coption
= ppdFindCustomOption(ppd
, option
->keyword
)) != NULL
)
1246 for (cparam
= (ppd_cparam_t
*)cupsArrayFirst(coption
->params
);
1248 cparam
= (ppd_cparam_t
*)cupsArrayNext(coption
->params
))
1250 switch (cparam
->type
)
1252 case PPD_CUSTOM_CURVE
:
1253 printf(" %s(%s): PPD_CUSTOM_CURVE (%g to %g)\n",
1254 cparam
->name
, cparam
->text
,
1255 cparam
->minimum
.custom_curve
,
1256 cparam
->maximum
.custom_curve
);
1259 case PPD_CUSTOM_INT
:
1260 printf(" %s(%s): PPD_CUSTOM_INT (%d to %d)\n",
1261 cparam
->name
, cparam
->text
,
1262 cparam
->minimum
.custom_int
,
1263 cparam
->maximum
.custom_int
);
1266 case PPD_CUSTOM_INVCURVE
:
1267 printf(" %s(%s): PPD_CUSTOM_INVCURVE (%g to %g)\n",
1268 cparam
->name
, cparam
->text
,
1269 cparam
->minimum
.custom_invcurve
,
1270 cparam
->maximum
.custom_invcurve
);
1273 case PPD_CUSTOM_PASSCODE
:
1274 printf(" %s(%s): PPD_CUSTOM_PASSCODE (%d to %d)\n",
1275 cparam
->name
, cparam
->text
,
1276 cparam
->minimum
.custom_passcode
,
1277 cparam
->maximum
.custom_passcode
);
1280 case PPD_CUSTOM_PASSWORD
:
1281 printf(" %s(%s): PPD_CUSTOM_PASSWORD (%d to %d)\n",
1282 cparam
->name
, cparam
->text
,
1283 cparam
->minimum
.custom_password
,
1284 cparam
->maximum
.custom_password
);
1287 case PPD_CUSTOM_POINTS
:
1288 printf(" %s(%s): PPD_CUSTOM_POINTS (%g to %g)\n",
1289 cparam
->name
, cparam
->text
,
1290 cparam
->minimum
.custom_points
,
1291 cparam
->maximum
.custom_points
);
1294 case PPD_CUSTOM_REAL
:
1295 printf(" %s(%s): PPD_CUSTOM_REAL (%g to %g)\n",
1296 cparam
->name
, cparam
->text
,
1297 cparam
->minimum
.custom_real
,
1298 cparam
->maximum
.custom_real
);
1301 case PPD_CUSTOM_STRING
:
1302 printf(" %s(%s): PPD_CUSTOM_STRING (%d to %d)\n",
1303 cparam
->name
, cparam
->text
,
1304 cparam
->minimum
.custom_string
,
1305 cparam
->maximum
.custom_string
);
1314 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
1315 printf(" %s = %gx%g, [%g %g %g %g]\n", size
->name
, size
->width
,
1316 size
->length
, size
->left
, size
->bottom
, size
->right
, size
->top
);
1318 puts("\nConstraints:");
1320 for (i
= ppd
->num_consts
, c
= ppd
->consts
; i
> 0; i
--, c
++)
1321 printf(" *UIConstraints: *%s %s *%s %s\n", c
->option1
, c
->choice1
,
1322 c
->option2
, c
->choice2
);
1323 if (ppd
->num_consts
== 0)
1324 puts(" NO CONSTRAINTS");
1328 for (i
= 0; i
< ppd
->num_filters
; i
++)
1329 printf(" %s\n", ppd
->filters
[i
]);
1331 if (ppd
->num_filters
== 0)
1332 puts(" NO FILTERS");
1334 puts("\nAttributes:");
1336 for (attr
= (ppd_attr_t
*)cupsArrayFirst(ppd
->sorted_attrs
);
1338 attr
= (ppd_attr_t
*)cupsArrayNext(ppd
->sorted_attrs
))
1339 printf(" *%s %s/%s: \"%s\"\n", attr
->name
, attr
->spec
,
1340 attr
->text
, attr
->value
? attr
->value
: "");
1342 puts("\nPPD Cache:");
1343 if ((pc
= _ppdCacheCreateWithPPD(ppd
)) == NULL
)
1344 printf(" Unable to create: %s\n", cupsLastErrorString());
1347 _ppdCacheWriteFile(pc
, "t.cache", NULL
);
1348 puts(" Wrote t.cache.");
1352 if (!strncmp(argv
[1], "-d", 2))
1357 if (getenv("MallocStackLogging") && getenv("MallocStackLoggingNoCompact"))
1359 char command
[1024]; /* malloc_history command */
1361 snprintf(command
, sizeof(command
), "malloc_history %d -all_by_size",
1366 #endif /* __APPLE__ */
1375 * 'do_ppd_tests()' - Test the default option commands in a PPD file.
1378 static int /* O - Number of errors */
1379 do_ppd_tests(const char *filename
, /* I - PPD file */
1380 int num_options
, /* I - Number of options */
1381 cups_option_t
*options
) /* I - Options */
1383 ppd_file_t
*ppd
; /* PPD file data */
1384 cups_page_header2_t header
; /* Page header */
1387 printf("\"%s\": ", filename
);
1390 if ((ppd
= ppdOpenFile(filename
)) == NULL
)
1392 ppd_status_t status
; /* Status from PPD loader */
1393 int line
; /* Line number containing error */
1396 status
= ppdLastError(&line
);
1398 puts("FAIL (bad PPD file)");
1399 printf(" %s on line %d\n", ppdErrorString(status
), line
);
1404 ppdMarkDefaults(ppd
);
1405 cupsMarkOptions(ppd
, num_options
, options
);
1407 if (cupsRasterInterpretPPD(&header
, ppd
, 0, NULL
, NULL
))
1409 puts("FAIL (error from function)");
1410 puts(cupsRasterErrorString());
1424 * 'do_ps_tests()' - Test standard PostScript commands.
1430 cups_page_header2_t header
; /* Page header */
1431 int preferred_bits
; /* Preferred bits */
1432 int errors
= 0; /* Number of errors */
1436 * Test PS exec code...
1439 fputs("_cupsRasterExecPS(\"setpagedevice\"): ", stdout
);
1442 memset(&header
, 0, sizeof(header
));
1443 header
.Collate
= CUPS_TRUE
;
1446 if (_cupsRasterExecPS(&header
, &preferred_bits
, setpagedevice_code
))
1448 puts("FAIL (error from function)");
1449 puts(cupsRasterErrorString());
1452 else if (preferred_bits
!= 17 ||
1453 memcmp(&header
, &setpagedevice_header
, sizeof(header
)))
1455 puts("FAIL (bad header)");
1457 if (preferred_bits
!= 17)
1458 printf(" cupsPreferredBitsPerColor %d, expected 17\n",
1461 print_changes(&setpagedevice_header
, &header
);
1467 fputs("_cupsRasterExecPS(\"roll\"): ", stdout
);
1470 if (_cupsRasterExecPS(&header
, &preferred_bits
,
1473 "<</PageSize[5 -2 roll]/ImagingBBox null>>"
1476 puts("FAIL (error from function)");
1477 puts(cupsRasterErrorString());
1480 else if (header
.PageSize
[0] != 792 || header
.PageSize
[1] != 612)
1482 printf("FAIL (PageSize [%d %d], expected [792 612])\n", header
.PageSize
[0],
1483 header
.PageSize
[1]);
1489 fputs("_cupsRasterExecPS(\"dup index\"): ", stdout
);
1492 if (_cupsRasterExecPS(&header
, &preferred_bits
,
1494 "<</Collate 4 index"
1496 "/Tumble 6 index>>setpagedevice\n"
1499 puts("FAIL (error from function)");
1500 puts(cupsRasterErrorString());
1505 if (!header
.Collate
)
1507 printf("FAIL (Collate false, expected true)\n");
1513 printf("FAIL (Duplex true, expected false)\n");
1519 printf("FAIL (Tumble true, expected false)\n");
1523 if(header
.Collate
&& !header
.Duplex
&& !header
.Tumble
)
1527 fputs("_cupsRasterExecPS(\"%%Begin/EndFeature code\"): ", stdout
);
1530 if (_cupsRasterExecPS(&header
, &preferred_bits
, dsc_code
))
1532 puts("FAIL (error from function)");
1533 puts(cupsRasterErrorString());
1536 else if (header
.PageSize
[0] != 792 || header
.PageSize
[1] != 1224)
1538 printf("FAIL (bad PageSize [%d %d], expected [792 1224])\n",
1539 header
.PageSize
[0], header
.PageSize
[1]);
1552 * 'print_changes()' - Print differences in the page header.
1557 cups_page_header2_t
*header
, /* I - Actual page header */
1558 cups_page_header2_t
*expected
) /* I - Expected page header */
1560 int i
; /* Looping var */
1563 if (strcmp(header
->MediaClass
, expected
->MediaClass
))
1564 printf(" MediaClass (%s), expected (%s)\n", header
->MediaClass
,
1565 expected
->MediaClass
);
1567 if (strcmp(header
->MediaColor
, expected
->MediaColor
))
1568 printf(" MediaColor (%s), expected (%s)\n", header
->MediaColor
,
1569 expected
->MediaColor
);
1571 if (strcmp(header
->MediaType
, expected
->MediaType
))
1572 printf(" MediaType (%s), expected (%s)\n", header
->MediaType
,
1573 expected
->MediaType
);
1575 if (strcmp(header
->OutputType
, expected
->OutputType
))
1576 printf(" OutputType (%s), expected (%s)\n", header
->OutputType
,
1577 expected
->OutputType
);
1579 if (header
->AdvanceDistance
!= expected
->AdvanceDistance
)
1580 printf(" AdvanceDistance %d, expected %d\n", header
->AdvanceDistance
,
1581 expected
->AdvanceDistance
);
1583 if (header
->AdvanceMedia
!= expected
->AdvanceMedia
)
1584 printf(" AdvanceMedia %d, expected %d\n", header
->AdvanceMedia
,
1585 expected
->AdvanceMedia
);
1587 if (header
->Collate
!= expected
->Collate
)
1588 printf(" Collate %d, expected %d\n", header
->Collate
,
1591 if (header
->CutMedia
!= expected
->CutMedia
)
1592 printf(" CutMedia %d, expected %d\n", header
->CutMedia
,
1593 expected
->CutMedia
);
1595 if (header
->Duplex
!= expected
->Duplex
)
1596 printf(" Duplex %d, expected %d\n", header
->Duplex
,
1599 if (header
->HWResolution
[0] != expected
->HWResolution
[0] ||
1600 header
->HWResolution
[1] != expected
->HWResolution
[1])
1601 printf(" HWResolution [%d %d], expected [%d %d]\n",
1602 header
->HWResolution
[0], header
->HWResolution
[1],
1603 expected
->HWResolution
[0], expected
->HWResolution
[1]);
1605 if (memcmp(header
->ImagingBoundingBox
, expected
->ImagingBoundingBox
,
1606 sizeof(header
->ImagingBoundingBox
)))
1607 printf(" ImagingBoundingBox [%d %d %d %d], expected [%d %d %d %d]\n",
1608 header
->ImagingBoundingBox
[0],
1609 header
->ImagingBoundingBox
[1],
1610 header
->ImagingBoundingBox
[2],
1611 header
->ImagingBoundingBox
[3],
1612 expected
->ImagingBoundingBox
[0],
1613 expected
->ImagingBoundingBox
[1],
1614 expected
->ImagingBoundingBox
[2],
1615 expected
->ImagingBoundingBox
[3]);
1617 if (header
->InsertSheet
!= expected
->InsertSheet
)
1618 printf(" InsertSheet %d, expected %d\n", header
->InsertSheet
,
1619 expected
->InsertSheet
);
1621 if (header
->Jog
!= expected
->Jog
)
1622 printf(" Jog %d, expected %d\n", header
->Jog
,
1625 if (header
->LeadingEdge
!= expected
->LeadingEdge
)
1626 printf(" LeadingEdge %d, expected %d\n", header
->LeadingEdge
,
1627 expected
->LeadingEdge
);
1629 if (header
->Margins
[0] != expected
->Margins
[0] ||
1630 header
->Margins
[1] != expected
->Margins
[1])
1631 printf(" Margins [%d %d], expected [%d %d]\n",
1632 header
->Margins
[0], header
->Margins
[1],
1633 expected
->Margins
[0], expected
->Margins
[1]);
1635 if (header
->ManualFeed
!= expected
->ManualFeed
)
1636 printf(" ManualFeed %d, expected %d\n", header
->ManualFeed
,
1637 expected
->ManualFeed
);
1639 if (header
->MediaPosition
!= expected
->MediaPosition
)
1640 printf(" MediaPosition %d, expected %d\n", header
->MediaPosition
,
1641 expected
->MediaPosition
);
1643 if (header
->MediaWeight
!= expected
->MediaWeight
)
1644 printf(" MediaWeight %d, expected %d\n", header
->MediaWeight
,
1645 expected
->MediaWeight
);
1647 if (header
->MirrorPrint
!= expected
->MirrorPrint
)
1648 printf(" MirrorPrint %d, expected %d\n", header
->MirrorPrint
,
1649 expected
->MirrorPrint
);
1651 if (header
->NegativePrint
!= expected
->NegativePrint
)
1652 printf(" NegativePrint %d, expected %d\n", header
->NegativePrint
,
1653 expected
->NegativePrint
);
1655 if (header
->NumCopies
!= expected
->NumCopies
)
1656 printf(" NumCopies %d, expected %d\n", header
->NumCopies
,
1657 expected
->NumCopies
);
1659 if (header
->Orientation
!= expected
->Orientation
)
1660 printf(" Orientation %d, expected %d\n", header
->Orientation
,
1661 expected
->Orientation
);
1663 if (header
->OutputFaceUp
!= expected
->OutputFaceUp
)
1664 printf(" OutputFaceUp %d, expected %d\n", header
->OutputFaceUp
,
1665 expected
->OutputFaceUp
);
1667 if (header
->PageSize
[0] != expected
->PageSize
[0] ||
1668 header
->PageSize
[1] != expected
->PageSize
[1])
1669 printf(" PageSize [%d %d], expected [%d %d]\n",
1670 header
->PageSize
[0], header
->PageSize
[1],
1671 expected
->PageSize
[0], expected
->PageSize
[1]);
1673 if (header
->Separations
!= expected
->Separations
)
1674 printf(" Separations %d, expected %d\n", header
->Separations
,
1675 expected
->Separations
);
1677 if (header
->TraySwitch
!= expected
->TraySwitch
)
1678 printf(" TraySwitch %d, expected %d\n", header
->TraySwitch
,
1679 expected
->TraySwitch
);
1681 if (header
->Tumble
!= expected
->Tumble
)
1682 printf(" Tumble %d, expected %d\n", header
->Tumble
,
1685 if (header
->cupsWidth
!= expected
->cupsWidth
)
1686 printf(" cupsWidth %d, expected %d\n", header
->cupsWidth
,
1687 expected
->cupsWidth
);
1689 if (header
->cupsHeight
!= expected
->cupsHeight
)
1690 printf(" cupsHeight %d, expected %d\n", header
->cupsHeight
,
1691 expected
->cupsHeight
);
1693 if (header
->cupsMediaType
!= expected
->cupsMediaType
)
1694 printf(" cupsMediaType %d, expected %d\n", header
->cupsMediaType
,
1695 expected
->cupsMediaType
);
1697 if (header
->cupsBitsPerColor
!= expected
->cupsBitsPerColor
)
1698 printf(" cupsBitsPerColor %d, expected %d\n", header
->cupsBitsPerColor
,
1699 expected
->cupsBitsPerColor
);
1701 if (header
->cupsBitsPerPixel
!= expected
->cupsBitsPerPixel
)
1702 printf(" cupsBitsPerPixel %d, expected %d\n", header
->cupsBitsPerPixel
,
1703 expected
->cupsBitsPerPixel
);
1705 if (header
->cupsBytesPerLine
!= expected
->cupsBytesPerLine
)
1706 printf(" cupsBytesPerLine %d, expected %d\n", header
->cupsBytesPerLine
,
1707 expected
->cupsBytesPerLine
);
1709 if (header
->cupsColorOrder
!= expected
->cupsColorOrder
)
1710 printf(" cupsColorOrder %d, expected %d\n", header
->cupsColorOrder
,
1711 expected
->cupsColorOrder
);
1713 if (header
->cupsColorSpace
!= expected
->cupsColorSpace
)
1714 printf(" cupsColorSpace %s, expected %s\n", _cupsRasterColorSpaceString(header
->cupsColorSpace
),
1715 _cupsRasterColorSpaceString(expected
->cupsColorSpace
));
1717 if (header
->cupsCompression
!= expected
->cupsCompression
)
1718 printf(" cupsCompression %d, expected %d\n", header
->cupsCompression
,
1719 expected
->cupsCompression
);
1721 if (header
->cupsRowCount
!= expected
->cupsRowCount
)
1722 printf(" cupsRowCount %d, expected %d\n", header
->cupsRowCount
,
1723 expected
->cupsRowCount
);
1725 if (header
->cupsRowFeed
!= expected
->cupsRowFeed
)
1726 printf(" cupsRowFeed %d, expected %d\n", header
->cupsRowFeed
,
1727 expected
->cupsRowFeed
);
1729 if (header
->cupsRowStep
!= expected
->cupsRowStep
)
1730 printf(" cupsRowStep %d, expected %d\n", header
->cupsRowStep
,
1731 expected
->cupsRowStep
);
1733 if (header
->cupsNumColors
!= expected
->cupsNumColors
)
1734 printf(" cupsNumColors %d, expected %d\n", header
->cupsNumColors
,
1735 expected
->cupsNumColors
);
1737 if (fabs(header
->cupsBorderlessScalingFactor
- expected
->cupsBorderlessScalingFactor
) > 0.001)
1738 printf(" cupsBorderlessScalingFactor %g, expected %g\n",
1739 header
->cupsBorderlessScalingFactor
,
1740 expected
->cupsBorderlessScalingFactor
);
1742 if (fabs(header
->cupsPageSize
[0] - expected
->cupsPageSize
[0]) > 0.001 ||
1743 fabs(header
->cupsPageSize
[1] - expected
->cupsPageSize
[1]) > 0.001)
1744 printf(" cupsPageSize [%g %g], expected [%g %g]\n",
1745 header
->cupsPageSize
[0], header
->cupsPageSize
[1],
1746 expected
->cupsPageSize
[0], expected
->cupsPageSize
[1]);
1748 if (fabs(header
->cupsImagingBBox
[0] - expected
->cupsImagingBBox
[0]) > 0.001 ||
1749 fabs(header
->cupsImagingBBox
[1] - expected
->cupsImagingBBox
[1]) > 0.001 ||
1750 fabs(header
->cupsImagingBBox
[2] - expected
->cupsImagingBBox
[2]) > 0.001 ||
1751 fabs(header
->cupsImagingBBox
[3] - expected
->cupsImagingBBox
[3]) > 0.001)
1752 printf(" cupsImagingBBox [%g %g %g %g], expected [%g %g %g %g]\n",
1753 header
->cupsImagingBBox
[0], header
->cupsImagingBBox
[1],
1754 header
->cupsImagingBBox
[2], header
->cupsImagingBBox
[3],
1755 expected
->cupsImagingBBox
[0], expected
->cupsImagingBBox
[1],
1756 expected
->cupsImagingBBox
[2], expected
->cupsImagingBBox
[3]);
1758 for (i
= 0; i
< 16; i
++)
1759 if (header
->cupsInteger
[i
] != expected
->cupsInteger
[i
])
1760 printf(" cupsInteger%d %d, expected %d\n", i
, header
->cupsInteger
[i
],
1761 expected
->cupsInteger
[i
]);
1763 for (i
= 0; i
< 16; i
++)
1764 if (fabs(header
->cupsReal
[i
] - expected
->cupsReal
[i
]) > 0.001)
1765 printf(" cupsReal%d %g, expected %g\n", i
, header
->cupsReal
[i
],
1766 expected
->cupsReal
[i
]);
1768 for (i
= 0; i
< 16; i
++)
1769 if (strcmp(header
->cupsString
[i
], expected
->cupsString
[i
]))
1770 printf(" cupsString%d (%s), expected (%s)\n", i
,
1771 header
->cupsString
[i
], expected
->cupsString
[i
]);
1773 if (strcmp(header
->cupsMarkerType
, expected
->cupsMarkerType
))
1774 printf(" cupsMarkerType (%s), expected (%s)\n", header
->cupsMarkerType
,
1775 expected
->cupsMarkerType
);
1777 if (strcmp(header
->cupsRenderingIntent
, expected
->cupsRenderingIntent
))
1778 printf(" cupsRenderingIntent (%s), expected (%s)\n",
1779 header
->cupsRenderingIntent
,
1780 expected
->cupsRenderingIntent
);
1782 if (strcmp(header
->cupsPageSizeName
, expected
->cupsPageSizeName
))
1783 printf(" cupsPageSizeName (%s), expected (%s)\n",
1784 header
->cupsPageSizeName
,
1785 expected
->cupsPageSizeName
);