]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testppd.c
4 * PPD test program for CUPS.
6 * Copyright 2007-2013 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 #undef _CUPS_NO_DEPRECATED
27 #include "cups-private.h"
41 static const char *default_code
=
43 "%%BeginFeature: *InstalledDuplexer False\n"
45 "} stopped cleartomark\n"
47 "%%BeginFeature: *PageRegion Letter\n"
50 "} stopped cleartomark\n"
52 "%%BeginFeature: *InputSlot Tray\n"
55 "} stopped cleartomark\n"
57 "%%BeginFeature: *MediaType Plain\n"
60 "} stopped cleartomark\n"
62 "%%BeginFeature: *IntOption None\n"
64 "} stopped cleartomark\n"
66 "%%BeginFeature: *StringOption None\n"
68 "} stopped cleartomark\n";
70 static const char *custom_code
=
72 "%%BeginFeature: *InstalledDuplexer False\n"
74 "} stopped cleartomark\n"
76 "%%BeginFeature: *InputSlot Tray\n"
79 "} stopped cleartomark\n"
81 "%%BeginFeature: *MediaType Plain\n"
84 "} stopped cleartomark\n"
86 "%%BeginFeature: *IntOption None\n"
88 "} stopped cleartomark\n"
90 "%%BeginFeature: *CustomStringOption True\n"
91 "(value\\0502\\051)\n"
93 "StringOption=Custom\n"
95 "} stopped cleartomark\n"
97 "%%BeginFeature: *CustomPageSize True\n"
105 "} stopped cleartomark\n";
107 static const char *default2_code
=
109 "%%BeginFeature: *InstalledDuplexer False\n"
111 "} stopped cleartomark\n"
113 "%%BeginFeature: *InputSlot Tray\n"
116 "} stopped cleartomark\n"
118 "%%BeginFeature: *Quality Normal\n"
121 "} stopped cleartomark\n"
123 "%%BeginFeature: *IntOption None\n"
125 "} stopped cleartomark\n"
127 "%%BeginFeature: *StringOption None\n"
129 "} stopped cleartomark\n";
133 * 'main()' - Main entry.
136 int /* O - Exit status */
137 main(int argc
, /* I - Number of command-line arguments */
138 char *argv
[]) /* I - Command-line arguments */
140 int i
; /* Looping var */
141 ppd_file_t
*ppd
; /* PPD file loaded from disk */
142 int status
; /* Status of tests (0 = success, 1 = fail) */
143 int conflicts
; /* Number of conflicts */
144 char *s
; /* String */
145 char buffer
[8192]; /* String buffer */
146 const char *text
, /* Localized text */
147 *val
; /* Option value */
148 int num_options
; /* Number of options */
149 cups_option_t
*options
; /* Options */
150 ppd_size_t minsize
, /* Minimum size */
151 maxsize
, /* Maximum size */
152 *size
; /* Current size */
153 ppd_attr_t
*attr
; /* Current attribute */
154 _ppd_cache_t
*pc
; /* PPD cache */
162 * Setup directories for locale stuff...
165 if (access("locale", 0))
167 mkdir("locale", 0777);
168 mkdir("locale/fr", 0777);
169 symlink("../../../locale/cups_fr.po", "locale/fr/cups_fr.po");
170 mkdir("locale/zh_TW", 0777);
171 symlink("../../../locale/cups_zh_TW.po", "locale/zh_TW/cups_zh_TW.po");
174 putenv("LOCALEDIR=locale");
175 putenv("SOFTWARE=CUPS");
178 * Do tests with test.ppd...
181 fputs("ppdOpenFile(test.ppd): ", stdout
);
183 if ((ppd
= _ppdOpenFile("test.ppd", _PPD_LOCALIZATION_ALL
)) != NULL
)
187 ppd_status_t err
; /* Last error in file */
188 int line
; /* Line number in file */
192 err
= ppdLastError(&line
);
194 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
197 fputs("ppdFindAttr(wildcard): ", stdout
);
198 if ((attr
= ppdFindAttr(ppd
, "cupsTest", NULL
)) == NULL
)
201 puts("FAIL (not found)");
203 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
206 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
211 fputs("ppdFindNextAttr(wildcard): ", stdout
);
212 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", NULL
)) == NULL
)
215 puts("FAIL (not found)");
217 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Bar"))
220 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
225 fputs("ppdFindAttr(Foo): ", stdout
);
226 if ((attr
= ppdFindAttr(ppd
, "cupsTest", "Foo")) == NULL
)
229 puts("FAIL (not found)");
231 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
234 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
239 fputs("ppdFindNextAttr(Foo): ", stdout
);
240 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", "Foo")) != NULL
)
243 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
248 fputs("ppdMarkDefaults: ", stdout
);
249 ppdMarkDefaults(ppd
);
251 if ((conflicts
= ppdConflicts(ppd
)) == 0)
256 printf("FAIL (%d conflicts)\n", conflicts
);
259 fputs("ppdEmitString (defaults): ", stdout
);
260 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
261 !strcmp(s
, default_code
))
266 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
267 (int)strlen(default_code
));
276 fputs("ppdEmitString (custom size and string): ", stdout
);
277 ppdMarkOption(ppd
, "PageSize", "Custom.400x500");
278 ppdMarkOption(ppd
, "StringOption", "{String1=\"value 1\" String2=value(2)}");
280 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
281 !strcmp(s
, custom_code
))
286 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
287 (int)strlen(custom_code
));
297 * Test constraints...
300 fputs("cupsGetConflicts(InputSlot=Envelope): ", stdout
);
301 ppdMarkOption(ppd
, "PageSize", "Letter");
303 num_options
= cupsGetConflicts(ppd
, "InputSlot", "Envelope", &options
);
304 if (num_options
!= 2 ||
305 (val
= cupsGetOption("PageRegion", num_options
, options
)) == NULL
||
306 _cups_strcasecmp(val
, "Letter") ||
307 (val
= cupsGetOption("PageSize", num_options
, options
)) == NULL
||
308 _cups_strcasecmp(val
, "Letter"))
310 printf("FAIL (%d options:", num_options
);
311 for (i
= 0; i
< num_options
; i
++)
312 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
319 fputs("ppdConflicts(): ", stdout
);
320 ppdMarkOption(ppd
, "InputSlot", "Envelope");
322 if ((conflicts
= ppdConflicts(ppd
)) == 2)
326 printf("FAIL (%d)\n", conflicts
);
330 fputs("cupsResolveConflicts(InputSlot=Envelope): ", stdout
);
333 if (!cupsResolveConflicts(ppd
, "InputSlot", "Envelope", &num_options
,
336 puts("FAIL (Unable to resolve)");
339 else if (num_options
!= 2 ||
340 !cupsGetOption("PageSize", num_options
, options
))
342 printf("FAIL (%d options:", num_options
);
343 for (i
= 0; i
< num_options
; i
++)
344 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
349 puts("PASS (Resolved by changing PageSize)");
351 cupsFreeOptions(num_options
, options
);
353 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
356 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
357 num_options
== 1 && !_cups_strcasecmp(options
[0].name
, "InputSlot") &&
358 !_cups_strcasecmp(options
[0].value
, "Tray"))
359 puts("PASS (Resolved by changing InputSlot)");
360 else if (num_options
> 0)
362 printf("FAIL (%d options:", num_options
);
363 for (i
= 0; i
< num_options
; i
++)
364 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
370 puts("FAIL (Unable to resolve)");
373 cupsFreeOptions(num_options
, options
);
375 fputs("ppdInstallableConflict(): ", stdout
);
376 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
377 !ppdInstallableConflict(ppd
, "Duplex", "None"))
379 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
381 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
386 puts("FAIL (Duplex=None conflicted)");
394 fputs("ppdPageSizeLimits: ", stdout
);
395 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
397 if (minsize
.width
!= 36 || minsize
.length
!= 36 ||
398 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
400 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
401 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
402 minsize
.length
, maxsize
.width
, maxsize
.length
);
410 puts("FAIL (returned 0)");
415 * cupsMarkOptions with PWG and IPP size names.
418 fputs("cupsMarkOptions(media=iso-a4): ", stdout
);
419 num_options
= cupsAddOption("media", "iso-a4", 0, &options
);
420 cupsMarkOptions(ppd
, num_options
, options
);
421 cupsFreeOptions(num_options
, options
);
423 size
= ppdPageSize(ppd
, NULL
);
424 if (!size
|| strcmp(size
->name
, "A4"))
426 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
432 fputs("cupsMarkOptions(media=na_letter_8.5x11in): ", stdout
);
433 num_options
= cupsAddOption("media", "na_letter_8.5x11in", 0, &options
);
434 cupsMarkOptions(ppd
, num_options
, options
);
435 cupsFreeOptions(num_options
, options
);
437 size
= ppdPageSize(ppd
, NULL
);
438 if (!size
|| strcmp(size
->name
, "Letter"))
440 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
446 fputs("cupsMarkOptions(media=oe_letter-fullbleed_8.5x11in): ", stdout
);
447 num_options
= cupsAddOption("media", "oe_letter-fullbleed_8.5x11in", 0,
449 cupsMarkOptions(ppd
, num_options
, options
);
450 cupsFreeOptions(num_options
, options
);
452 size
= ppdPageSize(ppd
, NULL
);
453 if (!size
|| strcmp(size
->name
, "Letter.Fullbleed"))
455 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
461 fputs("cupsMarkOptions(media=A4): ", stdout
);
462 num_options
= cupsAddOption("media", "A4", 0, &options
);
463 cupsMarkOptions(ppd
, num_options
, options
);
464 cupsFreeOptions(num_options
, options
);
466 size
= ppdPageSize(ppd
, NULL
);
467 if (!size
|| strcmp(size
->name
, "A4"))
469 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
479 fputs("cupsMarkOptions(media=Custom.8x10in): ", stdout
);
480 num_options
= cupsAddOption("media", "Custom.8x10in", 0, &options
);
481 cupsMarkOptions(ppd
, num_options
, options
);
482 cupsFreeOptions(num_options
, options
);
484 size
= ppdPageSize(ppd
, NULL
);
485 if (!size
|| strcmp(size
->name
, "Custom") ||
486 size
->width
!= 576 || size
->length
!= 720)
488 printf("FAIL (%s - %gx%g)\n", size
? size
->name
: "unknown",
489 size
? size
->width
: 0.0, size
? size
->length
: 0.0);
496 * Test localization...
499 fputs("ppdLocalizeIPPReason(text): ", stdout
);
500 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
501 !strcmp(buffer
, "Foo Reason"))
506 printf("FAIL (\"%s\" instead of \"Foo Reason\")\n", buffer
);
509 fputs("ppdLocalizeIPPReason(http): ", stdout
);
510 if (ppdLocalizeIPPReason(ppd
, "foo", "http", buffer
, sizeof(buffer
)) &&
511 !strcmp(buffer
, "http://foo/bar.html"))
516 printf("FAIL (\"%s\" instead of \"http://foo/bar.html\")\n", buffer
);
519 fputs("ppdLocalizeIPPReason(help): ", stdout
);
520 if (ppdLocalizeIPPReason(ppd
, "foo", "help", buffer
, sizeof(buffer
)) &&
521 !strcmp(buffer
, "help:anchor='foo'%20bookID=Vendor%20Help"))
526 printf("FAIL (\"%s\" instead of \"help:anchor='foo'%%20bookID=Vendor%%20Help\")\n", buffer
);
529 fputs("ppdLocalizeIPPReason(file): ", stdout
);
530 if (ppdLocalizeIPPReason(ppd
, "foo", "file", buffer
, sizeof(buffer
)) &&
531 !strcmp(buffer
, "/help/foo/bar.html"))
536 printf("FAIL (\"%s\" instead of \"/help/foo/bar.html\")\n", buffer
);
541 putenv("LC_CTYPE=fr");
542 putenv("LC_MESSAGES=fr");
544 fputs("ppdLocalizeIPPReason(fr text): ", stdout
);
545 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
546 !strcmp(buffer
, "La Long Foo Reason"))
551 printf("FAIL (\"%s\" instead of \"La Long Foo Reason\")\n", buffer
);
554 putenv("LANG=zh_TW");
555 putenv("LC_ALL=zh_TW");
556 putenv("LC_CTYPE=zh_TW");
557 putenv("LC_MESSAGES=zh_TW");
559 fputs("ppdLocalizeIPPReason(zh_TW text): ", stdout
);
560 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
561 !strcmp(buffer
, "Number 1 Foo Reason"))
566 printf("FAIL (\"%s\" instead of \"Number 1 Foo Reason\")\n", buffer
);
570 * cupsMarkerName localization...
575 putenv("LC_CTYPE=en");
576 putenv("LC_MESSAGES=en");
578 fputs("ppdLocalizeMarkerName(bogus): ", stdout
);
580 if ((text
= ppdLocalizeMarkerName(ppd
, "bogus")) != NULL
)
583 printf("FAIL (\"%s\" instead of NULL)\n", text
);
588 fputs("ppdLocalizeMarkerName(cyan): ", stdout
);
590 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
591 !strcmp(text
, "Cyan Toner"))
596 printf("FAIL (\"%s\" instead of \"Cyan Toner\")\n",
597 text
? text
: "(null)");
602 putenv("LC_CTYPE=fr");
603 putenv("LC_MESSAGES=fr");
605 fputs("ppdLocalizeMarkerName(fr cyan): ", stdout
);
606 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
607 !strcmp(text
, "La Toner Cyan"))
612 printf("FAIL (\"%s\" instead of \"La Toner Cyan\")\n",
613 text
? text
: "(null)");
616 putenv("LANG=zh_TW");
617 putenv("LC_ALL=zh_TW");
618 putenv("LC_CTYPE=zh_TW");
619 putenv("LC_MESSAGES=zh_TW");
621 fputs("ppdLocalizeMarkerName(zh_TW cyan): ", stdout
);
622 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
623 !strcmp(text
, "Number 1 Cyan Toner"))
628 printf("FAIL (\"%s\" instead of \"Number 1 Cyan Toner\")\n",
629 text
? text
: "(null)");
635 * Test new constraints...
638 fputs("ppdOpenFile(test2.ppd): ", stdout
);
640 if ((ppd
= ppdOpenFile("test2.ppd")) != NULL
)
644 ppd_status_t err
; /* Last error in file */
645 int line
; /* Line number in file */
649 err
= ppdLastError(&line
);
651 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
654 fputs("ppdMarkDefaults: ", stdout
);
655 ppdMarkDefaults(ppd
);
657 if ((conflicts
= ppdConflicts(ppd
)) == 0)
662 printf("FAIL (%d conflicts)\n", conflicts
);
665 fputs("ppdEmitString (defaults): ", stdout
);
666 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
667 !strcmp(s
, default2_code
))
672 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
673 (int)strlen(default2_code
));
682 fputs("ppdConflicts(): ", stdout
);
683 ppdMarkOption(ppd
, "PageSize", "Env10");
684 ppdMarkOption(ppd
, "InputSlot", "Envelope");
685 ppdMarkOption(ppd
, "Quality", "Photo");
687 if ((conflicts
= ppdConflicts(ppd
)) == 1)
691 printf("FAIL (%d)\n", conflicts
);
695 fputs("cupsResolveConflicts(Quality=Photo): ", stdout
);
698 if (cupsResolveConflicts(ppd
, "Quality", "Photo", &num_options
,
701 printf("FAIL (%d options:", num_options
);
702 for (i
= 0; i
< num_options
; i
++)
703 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
708 puts("PASS (Unable to resolve)");
709 cupsFreeOptions(num_options
, options
);
711 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
714 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
715 num_options
== 1 && !_cups_strcasecmp(options
->name
, "Quality") &&
716 !_cups_strcasecmp(options
->value
, "Normal"))
718 else if (num_options
> 0)
720 printf("FAIL (%d options:", num_options
);
721 for (i
= 0; i
< num_options
; i
++)
722 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
728 puts("FAIL (Unable to resolve!)");
731 cupsFreeOptions(num_options
, options
);
733 fputs("cupsResolveConflicts(loop test): ", stdout
);
734 ppdMarkOption(ppd
, "PageSize", "A4");
735 ppdMarkOption(ppd
, "InputSlot", "Tray");
736 ppdMarkOption(ppd
, "Quality", "Photo");
739 if (!cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
))
741 else if (num_options
> 0)
743 printf("FAIL (%d options:", num_options
);
744 for (i
= 0; i
< num_options
; i
++)
745 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
749 puts("FAIL (No conflicts!)");
751 fputs("ppdInstallableConflict(): ", stdout
);
752 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
753 !ppdInstallableConflict(ppd
, "Duplex", "None"))
755 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
757 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
762 puts("FAIL (Duplex=None conflicted)");
770 ppdMarkDefaults(ppd
);
772 fputs("ppdPageSizeLimits(default): ", stdout
);
773 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
775 if (minsize
.width
!= 36 || minsize
.length
!= 36 ||
776 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
778 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
779 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
780 minsize
.length
, maxsize
.width
, maxsize
.length
);
788 puts("FAIL (returned 0)");
792 ppdMarkOption(ppd
, "InputSlot", "Manual");
794 fputs("ppdPageSizeLimits(InputSlot=Manual): ", stdout
);
795 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
797 if (minsize
.width
!= 100 || minsize
.length
!= 100 ||
798 maxsize
.width
!= 1000 || maxsize
.length
!= 1000)
800 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
801 "expected min=100x100, max=1000x1000)\n", minsize
.width
,
802 minsize
.length
, maxsize
.width
, maxsize
.length
);
810 puts("FAIL (returned 0)");
814 ppdMarkOption(ppd
, "Quality", "Photo");
816 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
817 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
819 if (minsize
.width
!= 200 || minsize
.length
!= 200 ||
820 maxsize
.width
!= 1000 || maxsize
.length
!= 1000)
822 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
823 "expected min=200x200, max=1000x1000)\n", minsize
.width
,
824 minsize
.length
, maxsize
.width
, maxsize
.length
);
832 puts("FAIL (returned 0)");
836 ppdMarkOption(ppd
, "InputSlot", "Tray");
838 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
839 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
841 if (minsize
.width
!= 300 || minsize
.length
!= 300 ||
842 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
844 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
845 "expected min=300x300, max=1080x86400)\n", minsize
.width
,
846 minsize
.length
, maxsize
.width
, maxsize
.length
);
854 puts("FAIL (returned 0)");
860 const char *filename
; /* PPD filename */
861 struct stat fileinfo
; /* File information */
864 if (!strncmp(argv
[1], "-d", 2))
866 const char *printer
; /* Printer name */
869 printer
= argv
[1] + 2;
874 puts("Usage: ./testppd -d printer");
878 filename
= cupsGetPPD(printer
);
882 printf("%s: %s\n", printer
, cupsLastErrorString());
889 if (lstat(filename
, &fileinfo
))
891 printf("%s: %s\n", filename
, strerror(errno
));
895 if (S_ISLNK(fileinfo
.st_mode
))
897 char realfile
[1024]; /* Real file path */
898 ssize_t realsize
; /* Size of real file path */
901 if ((realsize
= readlink(filename
, realfile
, sizeof(realfile
) - 1)) < 0)
902 strlcpy(realfile
, "Unknown", sizeof(realfile
));
904 realfile
[realsize
] = '\0';
906 if (stat(realfile
, &fileinfo
))
907 printf("%s: symlink to \"%s\", %s\n", filename
, realfile
,
910 printf("%s: symlink to \"%s\", %ld bytes\n", filename
, realfile
,
911 (long)fileinfo
.st_size
);
914 printf("%s: regular file, %ld bytes\n", filename
, (long)fileinfo
.st_size
);
916 if ((ppd
= ppdOpenFile(filename
)) == NULL
)
918 ppd_status_t err
; /* Last error in file */
919 int line
; /* Line number in file */
923 err
= ppdLastError(&line
);
925 printf("%s: %s on line %d\n", argv
[1], ppdErrorString(err
), line
);
929 int j
, k
; /* Looping vars */
930 ppd_group_t
*group
; /* Option group */
931 ppd_option_t
*option
; /* Option */
932 ppd_coption_t
*coption
; /* Custom option */
933 ppd_cparam_t
*cparam
; /* Custom parameter */
934 ppd_const_t
*c
; /* UIConstraints */
935 char lang
[255], /* LANG environment variable */
936 lc_all
[255], /* LC_ALL environment variable */
937 lc_ctype
[255], /* LC_CTYPE environment variable */
938 lc_messages
[255];/* LC_MESSAGES environment variable */
943 snprintf(lang
, sizeof(lang
), "LANG=%s", argv
[2]);
945 snprintf(lc_all
, sizeof(lc_all
), "LC_ALL=%s", argv
[2]);
947 snprintf(lc_ctype
, sizeof(lc_ctype
), "LC_CTYPE=%s", argv
[2]);
949 snprintf(lc_messages
, sizeof(lc_messages
), "LC_MESSAGES=%s", argv
[2]);
954 ppdMarkDefaults(ppd
);
958 text
= ppdLocalizeIPPReason(ppd
, argv
[3], NULL
, buffer
, sizeof(buffer
));
959 printf("ppdLocalizeIPPReason(%s)=%s\n", argv
[3],
960 text
? text
: "(null)");
961 return (text
== NULL
);
964 for (i
= ppd
->num_groups
, group
= ppd
->groups
;
968 printf("%s (%s):\n", group
->name
, group
->text
);
970 for (j
= group
->num_options
, option
= group
->options
;
974 printf(" %s (%s):\n", option
->keyword
, option
->text
);
976 for (k
= 0; k
< option
->num_choices
; k
++)
977 printf(" - %s%s (%s)\n",
978 option
->choices
[k
].marked
? "*" : "",
979 option
->choices
[k
].choice
, option
->choices
[k
].text
);
981 if ((coption
= ppdFindCustomOption(ppd
, option
->keyword
)) != NULL
)
983 for (cparam
= (ppd_cparam_t
*)cupsArrayFirst(coption
->params
);
985 cparam
= (ppd_cparam_t
*)cupsArrayNext(coption
->params
))
987 switch (cparam
->type
)
989 case PPD_CUSTOM_CURVE
:
990 printf(" %s(%s): PPD_CUSTOM_CURVE (%g to %g)\n",
991 cparam
->name
, cparam
->text
,
992 cparam
->minimum
.custom_curve
,
993 cparam
->maximum
.custom_curve
);
996 case PPD_CUSTOM_INT
:
997 printf(" %s(%s): PPD_CUSTOM_INT (%d to %d)\n",
998 cparam
->name
, cparam
->text
,
999 cparam
->minimum
.custom_int
,
1000 cparam
->maximum
.custom_int
);
1003 case PPD_CUSTOM_INVCURVE
:
1004 printf(" %s(%s): PPD_CUSTOM_INVCURVE (%g to %g)\n",
1005 cparam
->name
, cparam
->text
,
1006 cparam
->minimum
.custom_invcurve
,
1007 cparam
->maximum
.custom_invcurve
);
1010 case PPD_CUSTOM_PASSCODE
:
1011 printf(" %s(%s): PPD_CUSTOM_PASSCODE (%d to %d)\n",
1012 cparam
->name
, cparam
->text
,
1013 cparam
->minimum
.custom_passcode
,
1014 cparam
->maximum
.custom_passcode
);
1017 case PPD_CUSTOM_PASSWORD
:
1018 printf(" %s(%s): PPD_CUSTOM_PASSWORD (%d to %d)\n",
1019 cparam
->name
, cparam
->text
,
1020 cparam
->minimum
.custom_password
,
1021 cparam
->maximum
.custom_password
);
1024 case PPD_CUSTOM_POINTS
:
1025 printf(" %s(%s): PPD_CUSTOM_POINTS (%g to %g)\n",
1026 cparam
->name
, cparam
->text
,
1027 cparam
->minimum
.custom_points
,
1028 cparam
->maximum
.custom_points
);
1031 case PPD_CUSTOM_REAL
:
1032 printf(" %s(%s): PPD_CUSTOM_REAL (%g to %g)\n",
1033 cparam
->name
, cparam
->text
,
1034 cparam
->minimum
.custom_real
,
1035 cparam
->maximum
.custom_real
);
1038 case PPD_CUSTOM_STRING
:
1039 printf(" %s(%s): PPD_CUSTOM_STRING (%d to %d)\n",
1040 cparam
->name
, cparam
->text
,
1041 cparam
->minimum
.custom_string
,
1042 cparam
->maximum
.custom_string
);
1051 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
1052 printf(" %s = %gx%g, [%g %g %g %g]\n", size
->name
, size
->width
,
1053 size
->length
, size
->left
, size
->bottom
, size
->right
, size
->top
);
1055 puts("\nConstraints:");
1057 for (i
= ppd
->num_consts
, c
= ppd
->consts
; i
> 0; i
--, c
++)
1058 printf(" *UIConstraints: *%s %s *%s %s\n", c
->option1
, c
->choice1
,
1059 c
->option2
, c
->choice2
);
1060 if (ppd
->num_consts
== 0)
1061 puts(" NO CONSTRAINTS");
1065 for (i
= 0; i
< ppd
->num_filters
; i
++)
1066 printf(" %s\n", ppd
->filters
[i
]);
1068 if (ppd
->num_filters
== 0)
1069 puts(" NO FILTERS");
1071 puts("\nAttributes:");
1073 for (attr
= (ppd_attr_t
*)cupsArrayFirst(ppd
->sorted_attrs
);
1075 attr
= (ppd_attr_t
*)cupsArrayNext(ppd
->sorted_attrs
))
1076 printf(" *%s %s/%s: \"%s\"\n", attr
->name
, attr
->spec
,
1077 attr
->text
, attr
->value
? attr
->value
: "");
1079 puts("\nPPD Cache:");
1080 if ((pc
= _ppdCacheCreateWithPPD(ppd
)) == NULL
)
1081 printf(" Unable to create: %s\n", cupsLastErrorString());
1084 _ppdCacheWriteFile(pc
, "t.cache", NULL
);
1085 puts(" Wrote t.cache.");
1089 if (!strncmp(argv
[1], "-d", 2))
1094 if (getenv("MallocStackLogging") && getenv("MallocStackLoggingNoCompact"))
1096 char command
[1024]; /* malloc_history command */
1098 snprintf(command
, sizeof(command
), "malloc_history %d -all_by_size",
1103 #endif /* __APPLE__ */