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 for (status
= 0, num_options
= 0, options
= NULL
, i
= 1; i
< argc
; i
++)
1026 if (argv
[i
][0] == '-')
1028 if (argv
[i
][1] == 'o')
1031 num_options
= cupsParseOptions(argv
[i
] + 2, num_options
, &options
);
1036 num_options
= cupsParseOptions(argv
[i
], num_options
, &options
);
1039 puts("Usage: testppd --raster [-o name=value ...] [filename.ppd ...]");
1046 puts("Usage: testppd --raster [-o name=value ...] [filename.ppd ...]");
1051 status
+= do_ppd_tests(argv
[i
], num_options
, options
);
1054 cupsFreeOptions(num_options
, options
);
1056 else if (!strncmp(argv
[1], "ipp://", 6) || !strncmp(argv
[1], "ipps://", 7))
1059 * ipp://... or ipps://...
1062 http_t
*http
; /* Connection to printer */
1063 ipp_t
*request
, /* Get-Printer-Attributes request */
1064 *response
; /* Get-Printer-Attributes response */
1065 char scheme
[32], /* URI scheme */
1066 userpass
[256], /* Username:password */
1067 host
[256], /* Hostname */
1068 resource
[256]; /* Resource path */
1069 int port
; /* Port number */
1070 static const char * const pattrs
[] =/* Requested printer attributes */
1074 "printer-description",
1075 "media-col-database"
1078 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
)
1080 printf("Bad URI \"%s\".\n", argv
[1]);
1084 http
= httpConnect2(host
, port
, NULL
, AF_UNSPEC
, !strcmp(scheme
, "ipps") ? HTTP_ENCRYPTION_ALWAYS
: HTTP_ENCRYPTION_IF_REQUESTED
, 1, 30000, NULL
);
1087 printf("Unable to connect to \"%s:%d\": %s\n", host
, port
, cupsLastErrorString());
1091 request
= ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES
);
1092 ippAddString(request
, IPP_TAG_OPERATION
, IPP_TAG_URI
, "printer-uri", NULL
, argv
[1]);
1093 ippAddStrings(request
, IPP_TAG_OPERATION
, IPP_TAG_KEYWORD
, "requested-attributes", sizeof(pattrs
) / sizeof(pattrs
[0]), NULL
, pattrs
);
1094 response
= cupsDoRequest(http
, request
, resource
);
1096 if (_ppdCreateFromIPP(buffer
, sizeof(buffer
), response
))
1097 printf("Created PPD: %s\n", buffer
);
1099 puts("Unable to create PPD.");
1101 ippDelete(response
);
1107 const char *filename
; /* PPD filename */
1108 struct stat fileinfo
; /* File information */
1111 if (strchr(argv
[1], ':'))
1117 if ((filename
= cupsGetServerPPD(CUPS_HTTP_DEFAULT
, argv
[1])) == NULL
)
1119 printf("%s: %s\n", argv
[1], cupsLastErrorString());
1123 else if (!strncmp(argv
[1], "-d", 2))
1125 const char *printer
; /* Printer name */
1128 printer
= argv
[1] + 2;
1133 puts("Usage: ./testppd -d printer");
1137 filename
= cupsGetPPD(printer
);
1141 printf("%s: %s\n", printer
, cupsLastErrorString());
1148 if (lstat(filename
, &fileinfo
))
1150 printf("%s: %s\n", filename
, strerror(errno
));
1154 if (S_ISLNK(fileinfo
.st_mode
))
1156 char realfile
[1024]; /* Real file path */
1157 ssize_t realsize
; /* Size of real file path */
1160 if ((realsize
= readlink(filename
, realfile
, sizeof(realfile
) - 1)) < 0)
1161 strlcpy(realfile
, "Unknown", sizeof(realfile
));
1163 realfile
[realsize
] = '\0';
1165 if (stat(realfile
, &fileinfo
))
1166 printf("%s: symlink to \"%s\", %s\n", filename
, realfile
,
1169 printf("%s: symlink to \"%s\", %ld bytes\n", filename
, realfile
,
1170 (long)fileinfo
.st_size
);
1173 printf("%s: regular file, %ld bytes\n", filename
, (long)fileinfo
.st_size
);
1175 if ((ppd
= ppdOpenFile(filename
)) == NULL
)
1177 ppd_status_t err
; /* Last error in file */
1178 int line
; /* Line number in file */
1182 err
= ppdLastError(&line
);
1184 printf("%s: %s on line %d\n", argv
[1], ppdErrorString(err
), line
);
1188 int j
, k
; /* Looping vars */
1189 ppd_group_t
*group
; /* Option group */
1190 ppd_option_t
*option
; /* Option */
1191 ppd_coption_t
*coption
; /* Custom option */
1192 ppd_cparam_t
*cparam
; /* Custom parameter */
1193 ppd_const_t
*c
; /* UIConstraints */
1194 char lang
[255], /* LANG environment variable */
1195 lc_all
[255], /* LC_ALL environment variable */
1196 lc_ctype
[255], /* LC_CTYPE environment variable */
1197 lc_messages
[255];/* LC_MESSAGES environment variable */
1202 snprintf(lang
, sizeof(lang
), "LANG=%s", argv
[2]);
1204 snprintf(lc_all
, sizeof(lc_all
), "LC_ALL=%s", argv
[2]);
1206 snprintf(lc_ctype
, sizeof(lc_ctype
), "LC_CTYPE=%s", argv
[2]);
1208 snprintf(lc_messages
, sizeof(lc_messages
), "LC_MESSAGES=%s", argv
[2]);
1209 putenv(lc_messages
);
1213 ppdMarkDefaults(ppd
);
1217 text
= ppdLocalizeIPPReason(ppd
, argv
[3], NULL
, buffer
, sizeof(buffer
));
1218 printf("ppdLocalizeIPPReason(%s)=%s\n", argv
[3],
1219 text
? text
: "(null)");
1220 return (text
== NULL
);
1223 for (i
= ppd
->num_groups
, group
= ppd
->groups
;
1227 printf("%s (%s):\n", group
->name
, group
->text
);
1229 for (j
= group
->num_options
, option
= group
->options
;
1233 printf(" %s (%s):\n", option
->keyword
, option
->text
);
1235 for (k
= 0; k
< option
->num_choices
; k
++)
1236 printf(" - %s%s (%s)\n",
1237 option
->choices
[k
].marked
? "*" : "",
1238 option
->choices
[k
].choice
, option
->choices
[k
].text
);
1240 if ((coption
= ppdFindCustomOption(ppd
, option
->keyword
)) != NULL
)
1242 for (cparam
= (ppd_cparam_t
*)cupsArrayFirst(coption
->params
);
1244 cparam
= (ppd_cparam_t
*)cupsArrayNext(coption
->params
))
1246 switch (cparam
->type
)
1248 case PPD_CUSTOM_CURVE
:
1249 printf(" %s(%s): PPD_CUSTOM_CURVE (%g to %g)\n",
1250 cparam
->name
, cparam
->text
,
1251 cparam
->minimum
.custom_curve
,
1252 cparam
->maximum
.custom_curve
);
1255 case PPD_CUSTOM_INT
:
1256 printf(" %s(%s): PPD_CUSTOM_INT (%d to %d)\n",
1257 cparam
->name
, cparam
->text
,
1258 cparam
->minimum
.custom_int
,
1259 cparam
->maximum
.custom_int
);
1262 case PPD_CUSTOM_INVCURVE
:
1263 printf(" %s(%s): PPD_CUSTOM_INVCURVE (%g to %g)\n",
1264 cparam
->name
, cparam
->text
,
1265 cparam
->minimum
.custom_invcurve
,
1266 cparam
->maximum
.custom_invcurve
);
1269 case PPD_CUSTOM_PASSCODE
:
1270 printf(" %s(%s): PPD_CUSTOM_PASSCODE (%d to %d)\n",
1271 cparam
->name
, cparam
->text
,
1272 cparam
->minimum
.custom_passcode
,
1273 cparam
->maximum
.custom_passcode
);
1276 case PPD_CUSTOM_PASSWORD
:
1277 printf(" %s(%s): PPD_CUSTOM_PASSWORD (%d to %d)\n",
1278 cparam
->name
, cparam
->text
,
1279 cparam
->minimum
.custom_password
,
1280 cparam
->maximum
.custom_password
);
1283 case PPD_CUSTOM_POINTS
:
1284 printf(" %s(%s): PPD_CUSTOM_POINTS (%g to %g)\n",
1285 cparam
->name
, cparam
->text
,
1286 cparam
->minimum
.custom_points
,
1287 cparam
->maximum
.custom_points
);
1290 case PPD_CUSTOM_REAL
:
1291 printf(" %s(%s): PPD_CUSTOM_REAL (%g to %g)\n",
1292 cparam
->name
, cparam
->text
,
1293 cparam
->minimum
.custom_real
,
1294 cparam
->maximum
.custom_real
);
1297 case PPD_CUSTOM_STRING
:
1298 printf(" %s(%s): PPD_CUSTOM_STRING (%d to %d)\n",
1299 cparam
->name
, cparam
->text
,
1300 cparam
->minimum
.custom_string
,
1301 cparam
->maximum
.custom_string
);
1310 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
1311 printf(" %s = %gx%g, [%g %g %g %g]\n", size
->name
, size
->width
,
1312 size
->length
, size
->left
, size
->bottom
, size
->right
, size
->top
);
1314 puts("\nConstraints:");
1316 for (i
= ppd
->num_consts
, c
= ppd
->consts
; i
> 0; i
--, c
++)
1317 printf(" *UIConstraints: *%s %s *%s %s\n", c
->option1
, c
->choice1
,
1318 c
->option2
, c
->choice2
);
1319 if (ppd
->num_consts
== 0)
1320 puts(" NO CONSTRAINTS");
1324 for (i
= 0; i
< ppd
->num_filters
; i
++)
1325 printf(" %s\n", ppd
->filters
[i
]);
1327 if (ppd
->num_filters
== 0)
1328 puts(" NO FILTERS");
1330 puts("\nAttributes:");
1332 for (attr
= (ppd_attr_t
*)cupsArrayFirst(ppd
->sorted_attrs
);
1334 attr
= (ppd_attr_t
*)cupsArrayNext(ppd
->sorted_attrs
))
1335 printf(" *%s %s/%s: \"%s\"\n", attr
->name
, attr
->spec
,
1336 attr
->text
, attr
->value
? attr
->value
: "");
1338 puts("\nPPD Cache:");
1339 if ((pc
= _ppdCacheCreateWithPPD(ppd
)) == NULL
)
1340 printf(" Unable to create: %s\n", cupsLastErrorString());
1343 _ppdCacheWriteFile(pc
, "t.cache", NULL
);
1344 puts(" Wrote t.cache.");
1348 if (!strncmp(argv
[1], "-d", 2))
1353 if (getenv("MallocStackLogging") && getenv("MallocStackLoggingNoCompact"))
1355 char command
[1024]; /* malloc_history command */
1357 snprintf(command
, sizeof(command
), "malloc_history %d -all_by_size",
1362 #endif /* __APPLE__ */
1371 * 'do_ppd_tests()' - Test the default option commands in a PPD file.
1374 static int /* O - Number of errors */
1375 do_ppd_tests(const char *filename
, /* I - PPD file */
1376 int num_options
, /* I - Number of options */
1377 cups_option_t
*options
) /* I - Options */
1379 ppd_file_t
*ppd
; /* PPD file data */
1380 cups_page_header2_t header
; /* Page header */
1383 printf("\"%s\": ", filename
);
1386 if ((ppd
= ppdOpenFile(filename
)) == NULL
)
1388 ppd_status_t status
; /* Status from PPD loader */
1389 int line
; /* Line number containing error */
1392 status
= ppdLastError(&line
);
1394 puts("FAIL (bad PPD file)");
1395 printf(" %s on line %d\n", ppdErrorString(status
), line
);
1400 ppdMarkDefaults(ppd
);
1401 cupsMarkOptions(ppd
, num_options
, options
);
1403 if (cupsRasterInterpretPPD(&header
, ppd
, 0, NULL
, NULL
))
1405 puts("FAIL (error from function)");
1406 puts(cupsRasterErrorString());
1420 * 'do_ps_tests()' - Test standard PostScript commands.
1426 cups_page_header2_t header
; /* Page header */
1427 int preferred_bits
; /* Preferred bits */
1428 int errors
= 0; /* Number of errors */
1432 * Test PS exec code...
1435 fputs("_cupsRasterExecPS(\"setpagedevice\"): ", stdout
);
1438 memset(&header
, 0, sizeof(header
));
1439 header
.Collate
= CUPS_TRUE
;
1442 if (_cupsRasterExecPS(&header
, &preferred_bits
, setpagedevice_code
))
1444 puts("FAIL (error from function)");
1445 puts(cupsRasterErrorString());
1448 else if (preferred_bits
!= 17 ||
1449 memcmp(&header
, &setpagedevice_header
, sizeof(header
)))
1451 puts("FAIL (bad header)");
1453 if (preferred_bits
!= 17)
1454 printf(" cupsPreferredBitsPerColor %d, expected 17\n",
1457 print_changes(&setpagedevice_header
, &header
);
1463 fputs("_cupsRasterExecPS(\"roll\"): ", stdout
);
1466 if (_cupsRasterExecPS(&header
, &preferred_bits
,
1469 "<</PageSize[5 -2 roll]/ImagingBBox null>>"
1472 puts("FAIL (error from function)");
1473 puts(cupsRasterErrorString());
1476 else if (header
.PageSize
[0] != 792 || header
.PageSize
[1] != 612)
1478 printf("FAIL (PageSize [%d %d], expected [792 612])\n", header
.PageSize
[0],
1479 header
.PageSize
[1]);
1485 fputs("_cupsRasterExecPS(\"dup index\"): ", stdout
);
1488 if (_cupsRasterExecPS(&header
, &preferred_bits
,
1490 "<</Collate 4 index"
1492 "/Tumble 6 index>>setpagedevice\n"
1495 puts("FAIL (error from function)");
1496 puts(cupsRasterErrorString());
1501 if (!header
.Collate
)
1503 printf("FAIL (Collate false, expected true)\n");
1509 printf("FAIL (Duplex true, expected false)\n");
1515 printf("FAIL (Tumble true, expected false)\n");
1519 if(header
.Collate
&& !header
.Duplex
&& !header
.Tumble
)
1523 fputs("_cupsRasterExecPS(\"%%Begin/EndFeature code\"): ", stdout
);
1526 if (_cupsRasterExecPS(&header
, &preferred_bits
, dsc_code
))
1528 puts("FAIL (error from function)");
1529 puts(cupsRasterErrorString());
1532 else if (header
.PageSize
[0] != 792 || header
.PageSize
[1] != 1224)
1534 printf("FAIL (bad PageSize [%d %d], expected [792 1224])\n",
1535 header
.PageSize
[0], header
.PageSize
[1]);
1548 * 'print_changes()' - Print differences in the page header.
1553 cups_page_header2_t
*header
, /* I - Actual page header */
1554 cups_page_header2_t
*expected
) /* I - Expected page header */
1556 int i
; /* Looping var */
1559 if (strcmp(header
->MediaClass
, expected
->MediaClass
))
1560 printf(" MediaClass (%s), expected (%s)\n", header
->MediaClass
,
1561 expected
->MediaClass
);
1563 if (strcmp(header
->MediaColor
, expected
->MediaColor
))
1564 printf(" MediaColor (%s), expected (%s)\n", header
->MediaColor
,
1565 expected
->MediaColor
);
1567 if (strcmp(header
->MediaType
, expected
->MediaType
))
1568 printf(" MediaType (%s), expected (%s)\n", header
->MediaType
,
1569 expected
->MediaType
);
1571 if (strcmp(header
->OutputType
, expected
->OutputType
))
1572 printf(" OutputType (%s), expected (%s)\n", header
->OutputType
,
1573 expected
->OutputType
);
1575 if (header
->AdvanceDistance
!= expected
->AdvanceDistance
)
1576 printf(" AdvanceDistance %d, expected %d\n", header
->AdvanceDistance
,
1577 expected
->AdvanceDistance
);
1579 if (header
->AdvanceMedia
!= expected
->AdvanceMedia
)
1580 printf(" AdvanceMedia %d, expected %d\n", header
->AdvanceMedia
,
1581 expected
->AdvanceMedia
);
1583 if (header
->Collate
!= expected
->Collate
)
1584 printf(" Collate %d, expected %d\n", header
->Collate
,
1587 if (header
->CutMedia
!= expected
->CutMedia
)
1588 printf(" CutMedia %d, expected %d\n", header
->CutMedia
,
1589 expected
->CutMedia
);
1591 if (header
->Duplex
!= expected
->Duplex
)
1592 printf(" Duplex %d, expected %d\n", header
->Duplex
,
1595 if (header
->HWResolution
[0] != expected
->HWResolution
[0] ||
1596 header
->HWResolution
[1] != expected
->HWResolution
[1])
1597 printf(" HWResolution [%d %d], expected [%d %d]\n",
1598 header
->HWResolution
[0], header
->HWResolution
[1],
1599 expected
->HWResolution
[0], expected
->HWResolution
[1]);
1601 if (memcmp(header
->ImagingBoundingBox
, expected
->ImagingBoundingBox
,
1602 sizeof(header
->ImagingBoundingBox
)))
1603 printf(" ImagingBoundingBox [%d %d %d %d], expected [%d %d %d %d]\n",
1604 header
->ImagingBoundingBox
[0],
1605 header
->ImagingBoundingBox
[1],
1606 header
->ImagingBoundingBox
[2],
1607 header
->ImagingBoundingBox
[3],
1608 expected
->ImagingBoundingBox
[0],
1609 expected
->ImagingBoundingBox
[1],
1610 expected
->ImagingBoundingBox
[2],
1611 expected
->ImagingBoundingBox
[3]);
1613 if (header
->InsertSheet
!= expected
->InsertSheet
)
1614 printf(" InsertSheet %d, expected %d\n", header
->InsertSheet
,
1615 expected
->InsertSheet
);
1617 if (header
->Jog
!= expected
->Jog
)
1618 printf(" Jog %d, expected %d\n", header
->Jog
,
1621 if (header
->LeadingEdge
!= expected
->LeadingEdge
)
1622 printf(" LeadingEdge %d, expected %d\n", header
->LeadingEdge
,
1623 expected
->LeadingEdge
);
1625 if (header
->Margins
[0] != expected
->Margins
[0] ||
1626 header
->Margins
[1] != expected
->Margins
[1])
1627 printf(" Margins [%d %d], expected [%d %d]\n",
1628 header
->Margins
[0], header
->Margins
[1],
1629 expected
->Margins
[0], expected
->Margins
[1]);
1631 if (header
->ManualFeed
!= expected
->ManualFeed
)
1632 printf(" ManualFeed %d, expected %d\n", header
->ManualFeed
,
1633 expected
->ManualFeed
);
1635 if (header
->MediaPosition
!= expected
->MediaPosition
)
1636 printf(" MediaPosition %d, expected %d\n", header
->MediaPosition
,
1637 expected
->MediaPosition
);
1639 if (header
->MediaWeight
!= expected
->MediaWeight
)
1640 printf(" MediaWeight %d, expected %d\n", header
->MediaWeight
,
1641 expected
->MediaWeight
);
1643 if (header
->MirrorPrint
!= expected
->MirrorPrint
)
1644 printf(" MirrorPrint %d, expected %d\n", header
->MirrorPrint
,
1645 expected
->MirrorPrint
);
1647 if (header
->NegativePrint
!= expected
->NegativePrint
)
1648 printf(" NegativePrint %d, expected %d\n", header
->NegativePrint
,
1649 expected
->NegativePrint
);
1651 if (header
->NumCopies
!= expected
->NumCopies
)
1652 printf(" NumCopies %d, expected %d\n", header
->NumCopies
,
1653 expected
->NumCopies
);
1655 if (header
->Orientation
!= expected
->Orientation
)
1656 printf(" Orientation %d, expected %d\n", header
->Orientation
,
1657 expected
->Orientation
);
1659 if (header
->OutputFaceUp
!= expected
->OutputFaceUp
)
1660 printf(" OutputFaceUp %d, expected %d\n", header
->OutputFaceUp
,
1661 expected
->OutputFaceUp
);
1663 if (header
->PageSize
[0] != expected
->PageSize
[0] ||
1664 header
->PageSize
[1] != expected
->PageSize
[1])
1665 printf(" PageSize [%d %d], expected [%d %d]\n",
1666 header
->PageSize
[0], header
->PageSize
[1],
1667 expected
->PageSize
[0], expected
->PageSize
[1]);
1669 if (header
->Separations
!= expected
->Separations
)
1670 printf(" Separations %d, expected %d\n", header
->Separations
,
1671 expected
->Separations
);
1673 if (header
->TraySwitch
!= expected
->TraySwitch
)
1674 printf(" TraySwitch %d, expected %d\n", header
->TraySwitch
,
1675 expected
->TraySwitch
);
1677 if (header
->Tumble
!= expected
->Tumble
)
1678 printf(" Tumble %d, expected %d\n", header
->Tumble
,
1681 if (header
->cupsWidth
!= expected
->cupsWidth
)
1682 printf(" cupsWidth %d, expected %d\n", header
->cupsWidth
,
1683 expected
->cupsWidth
);
1685 if (header
->cupsHeight
!= expected
->cupsHeight
)
1686 printf(" cupsHeight %d, expected %d\n", header
->cupsHeight
,
1687 expected
->cupsHeight
);
1689 if (header
->cupsMediaType
!= expected
->cupsMediaType
)
1690 printf(" cupsMediaType %d, expected %d\n", header
->cupsMediaType
,
1691 expected
->cupsMediaType
);
1693 if (header
->cupsBitsPerColor
!= expected
->cupsBitsPerColor
)
1694 printf(" cupsBitsPerColor %d, expected %d\n", header
->cupsBitsPerColor
,
1695 expected
->cupsBitsPerColor
);
1697 if (header
->cupsBitsPerPixel
!= expected
->cupsBitsPerPixel
)
1698 printf(" cupsBitsPerPixel %d, expected %d\n", header
->cupsBitsPerPixel
,
1699 expected
->cupsBitsPerPixel
);
1701 if (header
->cupsBytesPerLine
!= expected
->cupsBytesPerLine
)
1702 printf(" cupsBytesPerLine %d, expected %d\n", header
->cupsBytesPerLine
,
1703 expected
->cupsBytesPerLine
);
1705 if (header
->cupsColorOrder
!= expected
->cupsColorOrder
)
1706 printf(" cupsColorOrder %d, expected %d\n", header
->cupsColorOrder
,
1707 expected
->cupsColorOrder
);
1709 if (header
->cupsColorSpace
!= expected
->cupsColorSpace
)
1710 printf(" cupsColorSpace %s, expected %s\n", _cupsRasterColorSpaceString(header
->cupsColorSpace
),
1711 _cupsRasterColorSpaceString(expected
->cupsColorSpace
));
1713 if (header
->cupsCompression
!= expected
->cupsCompression
)
1714 printf(" cupsCompression %d, expected %d\n", header
->cupsCompression
,
1715 expected
->cupsCompression
);
1717 if (header
->cupsRowCount
!= expected
->cupsRowCount
)
1718 printf(" cupsRowCount %d, expected %d\n", header
->cupsRowCount
,
1719 expected
->cupsRowCount
);
1721 if (header
->cupsRowFeed
!= expected
->cupsRowFeed
)
1722 printf(" cupsRowFeed %d, expected %d\n", header
->cupsRowFeed
,
1723 expected
->cupsRowFeed
);
1725 if (header
->cupsRowStep
!= expected
->cupsRowStep
)
1726 printf(" cupsRowStep %d, expected %d\n", header
->cupsRowStep
,
1727 expected
->cupsRowStep
);
1729 if (header
->cupsNumColors
!= expected
->cupsNumColors
)
1730 printf(" cupsNumColors %d, expected %d\n", header
->cupsNumColors
,
1731 expected
->cupsNumColors
);
1733 if (fabs(header
->cupsBorderlessScalingFactor
- expected
->cupsBorderlessScalingFactor
) > 0.001)
1734 printf(" cupsBorderlessScalingFactor %g, expected %g\n",
1735 header
->cupsBorderlessScalingFactor
,
1736 expected
->cupsBorderlessScalingFactor
);
1738 if (fabs(header
->cupsPageSize
[0] - expected
->cupsPageSize
[0]) > 0.001 ||
1739 fabs(header
->cupsPageSize
[1] - expected
->cupsPageSize
[1]) > 0.001)
1740 printf(" cupsPageSize [%g %g], expected [%g %g]\n",
1741 header
->cupsPageSize
[0], header
->cupsPageSize
[1],
1742 expected
->cupsPageSize
[0], expected
->cupsPageSize
[1]);
1744 if (fabs(header
->cupsImagingBBox
[0] - expected
->cupsImagingBBox
[0]) > 0.001 ||
1745 fabs(header
->cupsImagingBBox
[1] - expected
->cupsImagingBBox
[1]) > 0.001 ||
1746 fabs(header
->cupsImagingBBox
[2] - expected
->cupsImagingBBox
[2]) > 0.001 ||
1747 fabs(header
->cupsImagingBBox
[3] - expected
->cupsImagingBBox
[3]) > 0.001)
1748 printf(" cupsImagingBBox [%g %g %g %g], expected [%g %g %g %g]\n",
1749 header
->cupsImagingBBox
[0], header
->cupsImagingBBox
[1],
1750 header
->cupsImagingBBox
[2], header
->cupsImagingBBox
[3],
1751 expected
->cupsImagingBBox
[0], expected
->cupsImagingBBox
[1],
1752 expected
->cupsImagingBBox
[2], expected
->cupsImagingBBox
[3]);
1754 for (i
= 0; i
< 16; i
++)
1755 if (header
->cupsInteger
[i
] != expected
->cupsInteger
[i
])
1756 printf(" cupsInteger%d %d, expected %d\n", i
, header
->cupsInteger
[i
],
1757 expected
->cupsInteger
[i
]);
1759 for (i
= 0; i
< 16; i
++)
1760 if (fabs(header
->cupsReal
[i
] - expected
->cupsReal
[i
]) > 0.001)
1761 printf(" cupsReal%d %g, expected %g\n", i
, header
->cupsReal
[i
],
1762 expected
->cupsReal
[i
]);
1764 for (i
= 0; i
< 16; i
++)
1765 if (strcmp(header
->cupsString
[i
], expected
->cupsString
[i
]))
1766 printf(" cupsString%d (%s), expected (%s)\n", i
,
1767 header
->cupsString
[i
], expected
->cupsString
[i
]);
1769 if (strcmp(header
->cupsMarkerType
, expected
->cupsMarkerType
))
1770 printf(" cupsMarkerType (%s), expected (%s)\n", header
->cupsMarkerType
,
1771 expected
->cupsMarkerType
);
1773 if (strcmp(header
->cupsRenderingIntent
, expected
->cupsRenderingIntent
))
1774 printf(" cupsRenderingIntent (%s), expected (%s)\n",
1775 header
->cupsRenderingIntent
,
1776 expected
->cupsRenderingIntent
);
1778 if (strcmp(header
->cupsPageSizeName
, expected
->cupsPageSizeName
))
1779 printf(" cupsPageSizeName (%s), expected (%s)\n",
1780 header
->cupsPageSizeName
,
1781 expected
->cupsPageSizeName
);