]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testppd.c
4 * PPD test program for CUPS.
6 * Copyright 2007-2012 by Apple Inc.
7 * Copyright 1997-2006 by Easy Software Products.
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 * main() - Main entry.
23 * Include necessary headers...
26 #include "cups-private.h"
40 static const char *default_code
=
42 "%%BeginFeature: *InstalledDuplexer False\n"
44 "} stopped cleartomark\n"
46 "%%BeginFeature: *PageRegion Letter\n"
49 "} stopped cleartomark\n"
51 "%%BeginFeature: *InputSlot Tray\n"
54 "} stopped cleartomark\n"
56 "%%BeginFeature: *MediaType Plain\n"
59 "} stopped cleartomark\n"
61 "%%BeginFeature: *IntOption None\n"
63 "} stopped cleartomark\n"
65 "%%BeginFeature: *StringOption None\n"
67 "} stopped cleartomark\n";
69 static const char *custom_code
=
71 "%%BeginFeature: *InstalledDuplexer False\n"
73 "} stopped cleartomark\n"
75 "%%BeginFeature: *InputSlot Tray\n"
78 "} stopped cleartomark\n"
80 "%%BeginFeature: *MediaType Plain\n"
83 "} stopped cleartomark\n"
85 "%%BeginFeature: *IntOption None\n"
87 "} stopped cleartomark\n"
89 "%%BeginFeature: *CustomStringOption True\n"
90 "(value\\0502\\051)\n"
92 "StringOption=Custom\n"
94 "} stopped cleartomark\n"
96 "%%BeginFeature: *CustomPageSize True\n"
104 "} stopped cleartomark\n";
106 static const char *default2_code
=
108 "%%BeginFeature: *InstalledDuplexer False\n"
110 "} stopped cleartomark\n"
112 "%%BeginFeature: *InputSlot Tray\n"
115 "} stopped cleartomark\n"
117 "%%BeginFeature: *Quality Normal\n"
120 "} stopped cleartomark\n"
122 "%%BeginFeature: *IntOption None\n"
124 "} stopped cleartomark\n"
126 "%%BeginFeature: *StringOption None\n"
128 "} stopped cleartomark\n";
132 * 'main()' - Main entry.
135 int /* O - Exit status */
136 main(int argc
, /* I - Number of command-line arguments */
137 char *argv
[]) /* I - Command-line arguments */
139 int i
; /* Looping var */
140 ppd_file_t
*ppd
; /* PPD file loaded from disk */
141 int status
; /* Status of tests (0 = success, 1 = fail) */
142 int conflicts
; /* Number of conflicts */
143 char *s
; /* String */
144 char buffer
[8192]; /* String buffer */
145 const char *text
, /* Localized text */
146 *val
; /* Option value */
147 int num_options
; /* Number of options */
148 cups_option_t
*options
; /* Options */
149 ppd_size_t minsize
, /* Minimum size */
150 maxsize
, /* Maximum size */
151 *size
; /* Current size */
152 ppd_attr_t
*attr
; /* Current attribute */
153 _ppd_cache_t
*pc
; /* PPD cache */
161 * Setup directories for locale stuff...
164 if (access("locale", 0))
166 mkdir("locale", 0777);
167 mkdir("locale/fr", 0777);
168 symlink("../../../locale/cups_fr.po", "locale/fr/cups_fr.po");
169 mkdir("locale/zh_TW", 0777);
170 symlink("../../../locale/cups_zh_TW.po", "locale/zh_TW/cups_zh_TW.po");
173 putenv("LOCALEDIR=locale");
174 putenv("SOFTWARE=CUPS");
177 * Do tests with test.ppd...
180 fputs("ppdOpenFile(test.ppd): ", stdout
);
182 if ((ppd
= _ppdOpenFile("test.ppd", _PPD_LOCALIZATION_ALL
)) != NULL
)
186 ppd_status_t err
; /* Last error in file */
187 int line
; /* Line number in file */
191 err
= ppdLastError(&line
);
193 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
196 fputs("ppdFindAttr(wildcard): ", stdout
);
197 if ((attr
= ppdFindAttr(ppd
, "cupsTest", NULL
)) == NULL
)
200 puts("FAIL (not found)");
202 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
205 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
210 fputs("ppdFindNextAttr(wildcard): ", stdout
);
211 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", NULL
)) == NULL
)
214 puts("FAIL (not found)");
216 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Bar"))
219 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
224 fputs("ppdFindAttr(Foo): ", stdout
);
225 if ((attr
= ppdFindAttr(ppd
, "cupsTest", "Foo")) == NULL
)
228 puts("FAIL (not found)");
230 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
233 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
238 fputs("ppdFindNextAttr(Foo): ", stdout
);
239 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", "Foo")) != NULL
)
242 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
247 fputs("ppdMarkDefaults: ", stdout
);
248 ppdMarkDefaults(ppd
);
250 if ((conflicts
= ppdConflicts(ppd
)) == 0)
255 printf("FAIL (%d conflicts)\n", conflicts
);
258 fputs("ppdEmitString (defaults): ", stdout
);
259 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
260 !strcmp(s
, default_code
))
265 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
266 (int)strlen(default_code
));
275 fputs("ppdEmitString (custom size and string): ", stdout
);
276 ppdMarkOption(ppd
, "PageSize", "Custom.400x500");
277 ppdMarkOption(ppd
, "StringOption", "{String1=\"value 1\" String2=value(2)}");
279 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
280 !strcmp(s
, custom_code
))
285 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
286 (int)strlen(custom_code
));
296 * Test constraints...
299 fputs("cupsGetConflicts(InputSlot=Envelope): ", stdout
);
300 ppdMarkOption(ppd
, "PageSize", "Letter");
302 num_options
= cupsGetConflicts(ppd
, "InputSlot", "Envelope", &options
);
303 if (num_options
!= 2 ||
304 (val
= cupsGetOption("PageRegion", num_options
, options
)) == NULL
||
305 _cups_strcasecmp(val
, "Letter") ||
306 (val
= cupsGetOption("PageSize", num_options
, options
)) == NULL
||
307 _cups_strcasecmp(val
, "Letter"))
309 printf("FAIL (%d options:", num_options
);
310 for (i
= 0; i
< num_options
; i
++)
311 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
318 fputs("ppdConflicts(): ", stdout
);
319 ppdMarkOption(ppd
, "InputSlot", "Envelope");
321 if ((conflicts
= ppdConflicts(ppd
)) == 2)
325 printf("FAIL (%d)\n", conflicts
);
329 fputs("cupsResolveConflicts(InputSlot=Envelope): ", stdout
);
332 if (!cupsResolveConflicts(ppd
, "InputSlot", "Envelope", &num_options
,
335 puts("FAIL (Unable to resolve)");
338 else if (num_options
!= 2 ||
339 !cupsGetOption("PageSize", num_options
, options
))
341 printf("FAIL (%d options:", num_options
);
342 for (i
= 0; i
< num_options
; i
++)
343 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
348 puts("PASS (Resolved by changing PageSize)");
350 cupsFreeOptions(num_options
, options
);
352 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
355 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
356 num_options
== 1 && !_cups_strcasecmp(options
[0].name
, "InputSlot") &&
357 !_cups_strcasecmp(options
[0].value
, "Tray"))
358 puts("PASS (Resolved by changing InputSlot)");
359 else if (num_options
> 0)
361 printf("FAIL (%d options:", num_options
);
362 for (i
= 0; i
< num_options
; i
++)
363 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
369 puts("FAIL (Unable to resolve)");
372 cupsFreeOptions(num_options
, options
);
374 fputs("ppdInstallableConflict(): ", stdout
);
375 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
376 !ppdInstallableConflict(ppd
, "Duplex", "None"))
378 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
380 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
385 puts("FAIL (Duplex=None conflicted)");
393 fputs("ppdPageSizeLimits: ", stdout
);
394 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
396 if (minsize
.width
!= 36 || minsize
.length
!= 36 ||
397 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
399 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
400 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
401 minsize
.length
, maxsize
.width
, maxsize
.length
);
409 puts("FAIL (returned 0)");
414 * cupsMarkOptions with PWG and IPP size names.
417 fputs("cupsMarkOptions(media=iso-a4): ", stdout
);
418 num_options
= cupsAddOption("media", "iso-a4", 0, &options
);
419 cupsMarkOptions(ppd
, num_options
, options
);
420 cupsFreeOptions(num_options
, options
);
422 size
= ppdPageSize(ppd
, NULL
);
423 if (!size
|| strcmp(size
->name
, "A4"))
425 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
431 fputs("cupsMarkOptions(media=na_letter_8.5x11in): ", stdout
);
432 num_options
= cupsAddOption("media", "na_letter_8.5x11in", 0, &options
);
433 cupsMarkOptions(ppd
, num_options
, options
);
434 cupsFreeOptions(num_options
, options
);
436 size
= ppdPageSize(ppd
, NULL
);
437 if (!size
|| strcmp(size
->name
, "Letter"))
439 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
445 fputs("cupsMarkOptions(media=oe_letter-fullbleed_8.5x11in): ", stdout
);
446 num_options
= cupsAddOption("media", "oe_letter-fullbleed_8.5x11in", 0,
448 cupsMarkOptions(ppd
, num_options
, options
);
449 cupsFreeOptions(num_options
, options
);
451 size
= ppdPageSize(ppd
, NULL
);
452 if (!size
|| strcmp(size
->name
, "Letter.Fullbleed"))
454 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
460 fputs("cupsMarkOptions(media=A4): ", stdout
);
461 num_options
= cupsAddOption("media", "A4", 0, &options
);
462 cupsMarkOptions(ppd
, num_options
, options
);
463 cupsFreeOptions(num_options
, options
);
465 size
= ppdPageSize(ppd
, NULL
);
466 if (!size
|| strcmp(size
->name
, "A4"))
468 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
478 fputs("cupsMarkOptions(media=Custom.8x10in): ", stdout
);
479 num_options
= cupsAddOption("media", "Custom.8x10in", 0, &options
);
480 cupsMarkOptions(ppd
, num_options
, options
);
481 cupsFreeOptions(num_options
, options
);
483 size
= ppdPageSize(ppd
, NULL
);
484 if (!size
|| strcmp(size
->name
, "Custom") ||
485 size
->width
!= 576 || size
->length
!= 720)
487 printf("FAIL (%s - %gx%g)\n", size
? size
->name
: "unknown",
488 size
? size
->width
: 0.0, size
? size
->length
: 0.0);
495 * Test localization...
498 fputs("ppdLocalizeIPPReason(text): ", stdout
);
499 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
500 !strcmp(buffer
, "Foo Reason"))
505 printf("FAIL (\"%s\" instead of \"Foo Reason\")\n", buffer
);
508 fputs("ppdLocalizeIPPReason(http): ", stdout
);
509 if (ppdLocalizeIPPReason(ppd
, "foo", "http", buffer
, sizeof(buffer
)) &&
510 !strcmp(buffer
, "http://foo/bar.html"))
515 printf("FAIL (\"%s\" instead of \"http://foo/bar.html\")\n", buffer
);
518 fputs("ppdLocalizeIPPReason(help): ", stdout
);
519 if (ppdLocalizeIPPReason(ppd
, "foo", "help", buffer
, sizeof(buffer
)) &&
520 !strcmp(buffer
, "help:anchor='foo'%20bookID=Vendor%20Help"))
525 printf("FAIL (\"%s\" instead of \"help:anchor='foo'%%20bookID=Vendor%%20Help\")\n", buffer
);
528 fputs("ppdLocalizeIPPReason(file): ", stdout
);
529 if (ppdLocalizeIPPReason(ppd
, "foo", "file", buffer
, sizeof(buffer
)) &&
530 !strcmp(buffer
, "/help/foo/bar.html"))
535 printf("FAIL (\"%s\" instead of \"/help/foo/bar.html\")\n", buffer
);
540 putenv("LC_CTYPE=fr");
541 putenv("LC_MESSAGES=fr");
543 fputs("ppdLocalizeIPPReason(fr text): ", stdout
);
544 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
545 !strcmp(buffer
, "La Long Foo Reason"))
550 printf("FAIL (\"%s\" instead of \"La Long Foo Reason\")\n", buffer
);
553 putenv("LANG=zh_TW");
554 putenv("LC_ALL=zh_TW");
555 putenv("LC_CTYPE=zh_TW");
556 putenv("LC_MESSAGES=zh_TW");
558 fputs("ppdLocalizeIPPReason(zh_TW text): ", stdout
);
559 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
560 !strcmp(buffer
, "Number 1 Foo Reason"))
565 printf("FAIL (\"%s\" instead of \"Number 1 Foo Reason\")\n", buffer
);
569 * cupsMarkerName localization...
574 putenv("LC_CTYPE=en");
575 putenv("LC_MESSAGES=en");
577 fputs("ppdLocalizeMarkerName(bogus): ", stdout
);
579 if ((text
= ppdLocalizeMarkerName(ppd
, "bogus")) != NULL
)
582 printf("FAIL (\"%s\" instead of NULL)\n", text
);
587 fputs("ppdLocalizeMarkerName(cyan): ", stdout
);
589 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
590 !strcmp(text
, "Cyan Toner"))
595 printf("FAIL (\"%s\" instead of \"Cyan Toner\")\n",
596 text
? text
: "(null)");
601 putenv("LC_CTYPE=fr");
602 putenv("LC_MESSAGES=fr");
604 fputs("ppdLocalizeMarkerName(fr cyan): ", stdout
);
605 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
606 !strcmp(text
, "La Toner Cyan"))
611 printf("FAIL (\"%s\" instead of \"La Toner Cyan\")\n",
612 text
? text
: "(null)");
615 putenv("LANG=zh_TW");
616 putenv("LC_ALL=zh_TW");
617 putenv("LC_CTYPE=zh_TW");
618 putenv("LC_MESSAGES=zh_TW");
620 fputs("ppdLocalizeMarkerName(zh_TW cyan): ", stdout
);
621 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
622 !strcmp(text
, "Number 1 Cyan Toner"))
627 printf("FAIL (\"%s\" instead of \"Number 1 Cyan Toner\")\n",
628 text
? text
: "(null)");
634 * Test new constraints...
637 fputs("ppdOpenFile(test2.ppd): ", stdout
);
639 if ((ppd
= ppdOpenFile("test2.ppd")) != NULL
)
643 ppd_status_t err
; /* Last error in file */
644 int line
; /* Line number in file */
648 err
= ppdLastError(&line
);
650 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
653 fputs("ppdMarkDefaults: ", stdout
);
654 ppdMarkDefaults(ppd
);
656 if ((conflicts
= ppdConflicts(ppd
)) == 0)
661 printf("FAIL (%d conflicts)\n", conflicts
);
664 fputs("ppdEmitString (defaults): ", stdout
);
665 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
666 !strcmp(s
, default2_code
))
671 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
672 (int)strlen(default2_code
));
681 fputs("ppdConflicts(): ", stdout
);
682 ppdMarkOption(ppd
, "PageSize", "Env10");
683 ppdMarkOption(ppd
, "InputSlot", "Envelope");
684 ppdMarkOption(ppd
, "Quality", "Photo");
686 if ((conflicts
= ppdConflicts(ppd
)) == 1)
690 printf("FAIL (%d)\n", conflicts
);
694 fputs("cupsResolveConflicts(Quality=Photo): ", stdout
);
697 if (cupsResolveConflicts(ppd
, "Quality", "Photo", &num_options
,
700 printf("FAIL (%d options:", num_options
);
701 for (i
= 0; i
< num_options
; i
++)
702 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
707 puts("PASS (Unable to resolve)");
708 cupsFreeOptions(num_options
, options
);
710 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
713 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
714 num_options
== 1 && !_cups_strcasecmp(options
->name
, "Quality") &&
715 !_cups_strcasecmp(options
->value
, "Normal"))
717 else if (num_options
> 0)
719 printf("FAIL (%d options:", num_options
);
720 for (i
= 0; i
< num_options
; i
++)
721 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
727 puts("FAIL (Unable to resolve!)");
730 cupsFreeOptions(num_options
, options
);
732 fputs("cupsResolveConflicts(loop test): ", stdout
);
733 ppdMarkOption(ppd
, "PageSize", "A4");
734 ppdMarkOption(ppd
, "InputSlot", "Tray");
735 ppdMarkOption(ppd
, "Quality", "Photo");
738 if (!cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
))
740 else if (num_options
> 0)
742 printf("FAIL (%d options:", num_options
);
743 for (i
= 0; i
< num_options
; i
++)
744 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
748 puts("FAIL (No conflicts!)");
750 fputs("ppdInstallableConflict(): ", stdout
);
751 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
752 !ppdInstallableConflict(ppd
, "Duplex", "None"))
754 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
756 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
761 puts("FAIL (Duplex=None conflicted)");
769 ppdMarkDefaults(ppd
);
771 fputs("ppdPageSizeLimits(default): ", stdout
);
772 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
774 if (minsize
.width
!= 36 || minsize
.length
!= 36 ||
775 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
777 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
778 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
779 minsize
.length
, maxsize
.width
, maxsize
.length
);
787 puts("FAIL (returned 0)");
791 ppdMarkOption(ppd
, "InputSlot", "Manual");
793 fputs("ppdPageSizeLimits(InputSlot=Manual): ", stdout
);
794 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
796 if (minsize
.width
!= 100 || minsize
.length
!= 100 ||
797 maxsize
.width
!= 1000 || maxsize
.length
!= 1000)
799 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
800 "expected min=100x100, max=1000x1000)\n", minsize
.width
,
801 minsize
.length
, maxsize
.width
, maxsize
.length
);
809 puts("FAIL (returned 0)");
813 ppdMarkOption(ppd
, "Quality", "Photo");
815 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
816 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
818 if (minsize
.width
!= 200 || minsize
.length
!= 200 ||
819 maxsize
.width
!= 1000 || maxsize
.length
!= 1000)
821 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
822 "expected min=200x200, max=1000x1000)\n", minsize
.width
,
823 minsize
.length
, maxsize
.width
, maxsize
.length
);
831 puts("FAIL (returned 0)");
835 ppdMarkOption(ppd
, "InputSlot", "Tray");
837 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
838 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
840 if (minsize
.width
!= 300 || minsize
.length
!= 300 ||
841 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
843 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
844 "expected min=300x300, max=1080x86400)\n", minsize
.width
,
845 minsize
.length
, maxsize
.width
, maxsize
.length
);
853 puts("FAIL (returned 0)");
859 const char *filename
; /* PPD filename */
860 struct stat fileinfo
; /* File information */
863 if (!strncmp(argv
[1], "-d", 2))
865 const char *printer
; /* Printer name */
868 printer
= argv
[1] + 2;
873 puts("Usage: ./testppd -d printer");
877 filename
= cupsGetPPD(printer
);
881 printf("%s: %s\n", printer
, cupsLastErrorString());
888 if (lstat(filename
, &fileinfo
))
890 printf("%s: %s\n", filename
, strerror(errno
));
894 if (S_ISLNK(fileinfo
.st_mode
))
896 char realfile
[1024]; /* Real file path */
897 ssize_t realsize
; /* Size of real file path */
900 if ((realsize
= readlink(filename
, realfile
, sizeof(realfile
) - 1)) < 0)
901 strlcpy(realfile
, "Unknown", sizeof(realfile
));
903 realfile
[realsize
] = '\0';
905 if (stat(realfile
, &fileinfo
))
906 printf("%s: symlink to \"%s\", %s\n", filename
, realfile
,
909 printf("%s: symlink to \"%s\", %ld bytes\n", filename
, realfile
,
910 (long)fileinfo
.st_size
);
913 printf("%s: regular file, %ld bytes\n", filename
, (long)fileinfo
.st_size
);
915 if ((ppd
= ppdOpenFile(filename
)) == NULL
)
917 ppd_status_t err
; /* Last error in file */
918 int line
; /* Line number in file */
922 err
= ppdLastError(&line
);
924 printf("%s: %s on line %d\n", argv
[1], ppdErrorString(err
), line
);
928 int j
, k
; /* Looping vars */
929 ppd_group_t
*group
; /* Option group */
930 ppd_option_t
*option
; /* Option */
931 ppd_coption_t
*coption
; /* Custom option */
932 ppd_cparam_t
*cparam
; /* Custom parameter */
933 ppd_const_t
*c
; /* UIConstraints */
934 char lang
[255], /* LANG environment variable */
935 lc_all
[255], /* LC_ALL environment variable */
936 lc_ctype
[255], /* LC_CTYPE environment variable */
937 lc_messages
[255];/* LC_MESSAGES environment variable */
942 snprintf(lang
, sizeof(lang
), "LANG=%s", argv
[2]);
944 snprintf(lc_all
, sizeof(lc_all
), "LC_ALL=%s", argv
[2]);
946 snprintf(lc_ctype
, sizeof(lc_ctype
), "LC_CTYPE=%s", argv
[2]);
948 snprintf(lc_messages
, sizeof(lc_messages
), "LC_MESSAGES=%s", argv
[2]);
953 ppdMarkDefaults(ppd
);
957 text
= ppdLocalizeIPPReason(ppd
, argv
[3], NULL
, buffer
, sizeof(buffer
));
958 printf("ppdLocalizeIPPReason(%s)=%s\n", argv
[3],
959 text
? text
: "(null)");
960 return (text
== NULL
);
963 for (i
= ppd
->num_groups
, group
= ppd
->groups
;
967 printf("%s (%s):\n", group
->name
, group
->text
);
969 for (j
= group
->num_options
, option
= group
->options
;
973 printf(" %s (%s):\n", option
->keyword
, option
->text
);
975 for (k
= 0; k
< option
->num_choices
; k
++)
976 printf(" - %s%s (%s)\n",
977 option
->choices
[k
].marked
? "*" : "",
978 option
->choices
[k
].choice
, option
->choices
[k
].text
);
980 if ((coption
= ppdFindCustomOption(ppd
, option
->keyword
)) != NULL
)
982 for (cparam
= (ppd_cparam_t
*)cupsArrayFirst(coption
->params
);
984 cparam
= (ppd_cparam_t
*)cupsArrayNext(coption
->params
))
986 switch (cparam
->type
)
988 case PPD_CUSTOM_CURVE
:
989 printf(" %s(%s): PPD_CUSTOM_CURVE (%g to %g)\n",
990 cparam
->name
, cparam
->text
,
991 cparam
->minimum
.custom_curve
,
992 cparam
->maximum
.custom_curve
);
995 case PPD_CUSTOM_INT
:
996 printf(" %s(%s): PPD_CUSTOM_INT (%d to %d)\n",
997 cparam
->name
, cparam
->text
,
998 cparam
->minimum
.custom_int
,
999 cparam
->maximum
.custom_int
);
1002 case PPD_CUSTOM_INVCURVE
:
1003 printf(" %s(%s): PPD_CUSTOM_INVCURVE (%g to %g)\n",
1004 cparam
->name
, cparam
->text
,
1005 cparam
->minimum
.custom_invcurve
,
1006 cparam
->maximum
.custom_invcurve
);
1009 case PPD_CUSTOM_PASSCODE
:
1010 printf(" %s(%s): PPD_CUSTOM_PASSCODE (%d to %d)\n",
1011 cparam
->name
, cparam
->text
,
1012 cparam
->minimum
.custom_passcode
,
1013 cparam
->maximum
.custom_passcode
);
1016 case PPD_CUSTOM_PASSWORD
:
1017 printf(" %s(%s): PPD_CUSTOM_PASSWORD (%d to %d)\n",
1018 cparam
->name
, cparam
->text
,
1019 cparam
->minimum
.custom_password
,
1020 cparam
->maximum
.custom_password
);
1023 case PPD_CUSTOM_POINTS
:
1024 printf(" %s(%s): PPD_CUSTOM_POINTS (%g to %g)\n",
1025 cparam
->name
, cparam
->text
,
1026 cparam
->minimum
.custom_points
,
1027 cparam
->maximum
.custom_points
);
1030 case PPD_CUSTOM_REAL
:
1031 printf(" %s(%s): PPD_CUSTOM_REAL (%g to %g)\n",
1032 cparam
->name
, cparam
->text
,
1033 cparam
->minimum
.custom_real
,
1034 cparam
->maximum
.custom_real
);
1037 case PPD_CUSTOM_STRING
:
1038 printf(" %s(%s): PPD_CUSTOM_STRING (%d to %d)\n",
1039 cparam
->name
, cparam
->text
,
1040 cparam
->minimum
.custom_string
,
1041 cparam
->maximum
.custom_string
);
1050 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
1051 printf(" %s = %gx%g, [%g %g %g %g]\n", size
->name
, size
->width
,
1052 size
->length
, size
->left
, size
->bottom
, size
->right
, size
->top
);
1054 puts("\nConstraints:");
1056 for (i
= ppd
->num_consts
, c
= ppd
->consts
; i
> 0; i
--, c
++)
1057 printf(" *UIConstraints: *%s %s *%s %s\n", c
->option1
, c
->choice1
,
1058 c
->option2
, c
->choice2
);
1059 if (ppd
->num_consts
== 0)
1060 puts(" NO CONSTRAINTS");
1064 for (i
= 0; i
< ppd
->num_filters
; i
++)
1065 printf(" %s\n", ppd
->filters
[i
]);
1067 if (ppd
->num_filters
== 0)
1068 puts(" NO FILTERS");
1070 puts("\nAttributes:");
1072 for (attr
= (ppd_attr_t
*)cupsArrayFirst(ppd
->sorted_attrs
);
1074 attr
= (ppd_attr_t
*)cupsArrayNext(ppd
->sorted_attrs
))
1075 printf(" *%s %s/%s: \"%s\"\n", attr
->name
, attr
->spec
,
1076 attr
->text
, attr
->value
? attr
->value
: "");
1078 puts("\nPPD Cache:");
1079 if ((pc
= _ppdCacheCreateWithPPD(ppd
)) == NULL
)
1080 printf(" Unable to create: %s\n", cupsLastErrorString());
1083 _ppdCacheWriteFile(pc
, "t.cache", NULL
);
1084 puts(" Wrote t.cache.");
1088 if (!strncmp(argv
[1], "-d", 2))
1093 if (getenv("MallocStackLogging") && getenv("MallocStackLoggingNoCompact"))
1095 char command
[1024]; /* malloc_history command */
1097 snprintf(command
, sizeof(command
), "malloc_history %d -all_by_size",
1102 #endif /* __APPLE__ */