]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testppd.c
2 * "$Id: testppd.c 7897 2008-09-02 19:33:19Z mike $"
4 * PPD test program for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2009 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...
28 #include <cups/string.h>
45 static const char *default_code
=
47 "%%BeginFeature: *InstalledDuplexer False\n"
49 "} stopped cleartomark\n"
51 "%%BeginFeature: *PageRegion Letter\n"
54 "} stopped cleartomark\n"
56 "%%BeginFeature: *InputSlot Tray\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: *IntOption None\n"
82 "} stopped cleartomark\n"
84 "%%BeginFeature: *CustomStringOption True\n"
85 "(value\\0502\\051)\n"
87 "StringOption=Custom\n"
89 "} stopped cleartomark\n"
91 "%%BeginFeature: *CustomPageSize True\n"
99 "} stopped cleartomark\n";
101 static const char *default2_code
=
103 "%%BeginFeature: *InstalledDuplexer False\n"
105 "} stopped cleartomark\n"
107 "%%BeginFeature: *InputSlot Tray\n"
110 "} stopped cleartomark\n"
112 "%%BeginFeature: *Quality Normal\n"
115 "} stopped cleartomark\n"
117 "%%BeginFeature: *IntOption None\n"
119 "} stopped cleartomark\n"
121 "%%BeginFeature: *StringOption None\n"
123 "} stopped cleartomark\n";
127 * 'main()' - Main entry.
130 int /* O - Exit status */
131 main(int argc
, /* I - Number of command-line arguments */
132 char *argv
[]) /* I - Command-line arguments */
134 int i
; /* Looping var */
135 ppd_file_t
*ppd
; /* PPD file loaded from disk */
136 int status
; /* Status of tests (0 = success, 1 = fail) */
137 int conflicts
; /* Number of conflicts */
138 char *s
; /* String */
139 char buffer
[8192]; /* String buffer */
140 const char *text
, /* Localized text */
141 *val
; /* Option value */
142 int num_options
; /* Number of options */
143 cups_option_t
*options
; /* Options */
144 ppd_size_t minsize
, /* Minimum size */
145 maxsize
, /* Maximum size */
146 *size
; /* Current size */
147 ppd_attr_t
*attr
; /* Current attribute */
148 _cups_pwg_media_t
*pwgmedia
; /* PWG media size */
156 * Setup directories for locale stuff...
159 if (access("locale", 0))
161 mkdir("locale", 0777);
162 mkdir("locale/fr", 0777);
163 symlink("../../../locale/cups_fr.po", "locale/fr/cups_fr.po");
164 mkdir("locale/zh_TW", 0777);
165 symlink("../../../locale/cups_zh_TW.po", "locale/zh_TW/cups_zh_TW.po");
168 putenv("LOCALEDIR=locale");
169 putenv("SOFTWARE=CUPS");
172 * Do tests with test.ppd...
175 fputs("ppdOpenFile(test.ppd): ", stdout
);
177 if ((ppd
= ppdOpenFile("test.ppd")) != NULL
)
181 ppd_status_t err
; /* Last error in file */
182 int line
; /* Line number in file */
186 err
= ppdLastError(&line
);
188 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
191 fputs("ppdFindAttr(wildcard): ", stdout
);
192 if ((attr
= ppdFindAttr(ppd
, "cupsTest", NULL
)) == NULL
)
195 puts("FAIL (not found)");
197 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
200 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
205 fputs("ppdFindNextAttr(wildcard): ", stdout
);
206 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", NULL
)) == NULL
)
209 puts("FAIL (not found)");
211 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Bar"))
214 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
219 fputs("ppdFindAttr(Foo): ", stdout
);
220 if ((attr
= ppdFindAttr(ppd
, "cupsTest", "Foo")) == NULL
)
223 puts("FAIL (not found)");
225 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
228 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
233 fputs("ppdFindNextAttr(Foo): ", stdout
);
234 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", "Foo")) != NULL
)
237 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
242 fputs("ppdMarkDefaults: ", stdout
);
243 ppdMarkDefaults(ppd
);
245 if ((conflicts
= ppdConflicts(ppd
)) == 0)
250 printf("FAIL (%d conflicts)\n", conflicts
);
253 fputs("ppdEmitString (defaults): ", stdout
);
254 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
255 !strcmp(s
, default_code
))
260 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
261 (int)strlen(default_code
));
270 fputs("ppdEmitString (custom size and string): ", stdout
);
271 ppdMarkOption(ppd
, "PageSize", "Custom.400x500");
272 ppdMarkOption(ppd
, "StringOption", "{String1=\"value 1\" String2=value(2)}");
274 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
275 !strcmp(s
, custom_code
))
280 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
281 (int)strlen(custom_code
));
291 * Test constraints...
294 fputs("cupsGetConflicts(InputSlot=Envelope): ", stdout
);
295 ppdMarkOption(ppd
, "PageSize", "Letter");
297 num_options
= cupsGetConflicts(ppd
, "InputSlot", "Envelope", &options
);
298 if (num_options
!= 2 ||
299 (val
= cupsGetOption("PageRegion", num_options
, options
)) == NULL
||
300 strcasecmp(val
, "Letter") ||
301 (val
= cupsGetOption("PageSize", num_options
, options
)) == NULL
||
302 strcasecmp(val
, "Letter"))
304 printf("FAIL (%d options:", num_options
);
305 for (i
= 0; i
< num_options
; i
++)
306 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
313 fputs("ppdConflicts(): ", stdout
);
314 ppdMarkOption(ppd
, "InputSlot", "Envelope");
316 if ((conflicts
= ppdConflicts(ppd
)) == 2)
320 printf("FAIL (%d)\n", conflicts
);
324 fputs("cupsResolveConflicts(InputSlot=Envelope): ", stdout
);
327 if (!cupsResolveConflicts(ppd
, "InputSlot", "Envelope", &num_options
,
330 puts("FAIL (Unable to resolve)");
333 else if (num_options
!= 2 ||
334 !cupsGetOption("PageSize", num_options
, options
))
336 printf("FAIL (%d options:", num_options
);
337 for (i
= 0; i
< num_options
; i
++)
338 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
343 puts("PASS (Resolved by changing PageSize)");
345 cupsFreeOptions(num_options
, options
);
347 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
350 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
351 num_options
== 1 && !strcasecmp(options
[0].name
, "InputSlot") &&
352 !strcasecmp(options
[0].value
, "Tray"))
353 puts("PASS (Resolved by changing InputSlot)");
354 else if (num_options
> 0)
356 printf("FAIL (%d options:", num_options
);
357 for (i
= 0; i
< num_options
; i
++)
358 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
364 puts("FAIL (Unable to resolve)");
367 cupsFreeOptions(num_options
, options
);
369 fputs("ppdInstallableConflict(): ", stdout
);
370 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
371 !ppdInstallableConflict(ppd
, "Duplex", "None"))
373 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
375 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
380 puts("FAIL (Duplex=None conflicted)");
388 fputs("ppdPageSizeLimits: ", stdout
);
389 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
391 if (minsize
.width
!= 36 || minsize
.length
!= 36 ||
392 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
394 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
395 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
396 minsize
.length
, maxsize
.width
, maxsize
.length
);
404 puts("FAIL (returned 0)");
409 * cupsMarkOptions with PWG and IPP size names.
412 fputs("cupsMarkOptions(media=iso-a4): ", stdout
);
413 num_options
= cupsAddOption("media", "iso-a4", 0, &options
);
414 cupsMarkOptions(ppd
, num_options
, options
);
415 cupsFreeOptions(num_options
, options
);
417 size
= ppdPageSize(ppd
, NULL
);
418 if (!size
|| strcmp(size
->name
, "A4"))
420 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
426 fputs("cupsMarkOptions(media=na_letter_8.5x11in): ", stdout
);
427 num_options
= cupsAddOption("media", "na_letter_8.5x11in", 0, &options
);
428 cupsMarkOptions(ppd
, num_options
, options
);
429 cupsFreeOptions(num_options
, options
);
431 size
= ppdPageSize(ppd
, NULL
);
432 if (!size
|| strcmp(size
->name
, "Letter"))
434 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
440 fputs("_cupsPWGMediaBySize(842, 1191): ", stdout
);
441 if ((pwgmedia
= _cupsPWGMediaBySize(842, 1191)) == NULL
)
443 puts("FAIL (not found)");
446 else if (strcmp(pwgmedia
->pwg
, "iso_a3_297x420mm"))
448 printf("FAIL (%s)\n", pwgmedia
->pwg
);
455 * Test localization...
458 fputs("ppdLocalizeIPPReason(text): ", stdout
);
459 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
460 !strcmp(buffer
, "Foo Reason"))
465 printf("FAIL (\"%s\" instead of \"Foo Reason\")\n", buffer
);
468 fputs("ppdLocalizeIPPReason(http): ", stdout
);
469 if (ppdLocalizeIPPReason(ppd
, "foo", "http", buffer
, sizeof(buffer
)) &&
470 !strcmp(buffer
, "http://foo/bar.html"))
475 printf("FAIL (\"%s\" instead of \"http://foo/bar.html\")\n", buffer
);
478 fputs("ppdLocalizeIPPReason(help): ", stdout
);
479 if (ppdLocalizeIPPReason(ppd
, "foo", "help", buffer
, sizeof(buffer
)) &&
480 !strcmp(buffer
, "help:anchor='foo'%20bookID=Vendor%20Help"))
485 printf("FAIL (\"%s\" instead of \"help:anchor='foo'%%20bookID=Vendor%%20Help\")\n", buffer
);
488 fputs("ppdLocalizeIPPReason(file): ", stdout
);
489 if (ppdLocalizeIPPReason(ppd
, "foo", "file", buffer
, sizeof(buffer
)) &&
490 !strcmp(buffer
, "/help/foo/bar.html"))
495 printf("FAIL (\"%s\" instead of \"/help/foo/bar.html\")\n", buffer
);
500 putenv("LC_CTYPE=fr");
501 putenv("LC_MESSAGES=fr");
503 fputs("ppdLocalizeIPPReason(fr text): ", stdout
);
504 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
505 !strcmp(buffer
, "La Long Foo Reason"))
510 printf("FAIL (\"%s\" instead of \"La Long Foo Reason\")\n", buffer
);
513 putenv("LANG=zh_TW");
514 putenv("LC_ALL=zh_TW");
515 putenv("LC_CTYPE=zh_TW");
516 putenv("LC_MESSAGES=zh_TW");
518 fputs("ppdLocalizeIPPReason(zh_TW text): ", stdout
);
519 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
520 !strcmp(buffer
, "Number 1 Foo Reason"))
525 printf("FAIL (\"%s\" instead of \"Number 1 Foo Reason\")\n", buffer
);
529 * cupsMarkerName localization...
534 putenv("LC_CTYPE=en");
535 putenv("LC_MESSAGES=en");
537 fputs("ppdLocalizeMarkerName(bogus): ", stdout
);
539 if ((text
= ppdLocalizeMarkerName(ppd
, "bogus")) != NULL
)
542 printf("FAIL (\"%s\" instead of NULL)\n", text
);
547 fputs("ppdLocalizeMarkerName(cyan): ", stdout
);
549 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
550 !strcmp(text
, "Cyan Toner"))
555 printf("FAIL (\"%s\" instead of \"Cyan Toner\")\n",
556 text
? text
: "(null)");
561 putenv("LC_CTYPE=fr");
562 putenv("LC_MESSAGES=fr");
564 fputs("ppdLocalizeMarkerName(fr cyan): ", stdout
);
565 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
566 !strcmp(text
, "La Toner Cyan"))
571 printf("FAIL (\"%s\" instead of \"La Toner Cyan\")\n",
572 text
? text
: "(null)");
575 putenv("LANG=zh_TW");
576 putenv("LC_ALL=zh_TW");
577 putenv("LC_CTYPE=zh_TW");
578 putenv("LC_MESSAGES=zh_TW");
580 fputs("ppdLocalizeMarkerName(zh_TW cyan): ", stdout
);
581 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
582 !strcmp(text
, "Number 1 Cyan Toner"))
587 printf("FAIL (\"%s\" instead of \"Number 1 Cyan Toner\")\n",
588 text
? text
: "(null)");
594 * Test new constraints...
597 fputs("ppdOpenFile(test2.ppd): ", stdout
);
599 if ((ppd
= ppdOpenFile("test2.ppd")) != NULL
)
603 ppd_status_t err
; /* Last error in file */
604 int line
; /* Line number in file */
608 err
= ppdLastError(&line
);
610 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
613 fputs("ppdMarkDefaults: ", stdout
);
614 ppdMarkDefaults(ppd
);
616 if ((conflicts
= ppdConflicts(ppd
)) == 0)
621 printf("FAIL (%d conflicts)\n", conflicts
);
624 fputs("ppdEmitString (defaults): ", stdout
);
625 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
626 !strcmp(s
, default2_code
))
631 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
632 (int)strlen(default2_code
));
641 fputs("ppdConflicts(): ", stdout
);
642 ppdMarkOption(ppd
, "PageSize", "Env10");
643 ppdMarkOption(ppd
, "InputSlot", "Envelope");
644 ppdMarkOption(ppd
, "Quality", "Photo");
646 if ((conflicts
= ppdConflicts(ppd
)) == 1)
650 printf("FAIL (%d)\n", conflicts
);
654 fputs("cupsResolveConflicts(Quality=Photo): ", stdout
);
657 if (cupsResolveConflicts(ppd
, "Quality", "Photo", &num_options
,
660 printf("FAIL (%d options:", num_options
);
661 for (i
= 0; i
< num_options
; i
++)
662 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
667 puts("PASS (Unable to resolve)");
668 cupsFreeOptions(num_options
, options
);
670 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
673 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
674 num_options
== 1 && !strcasecmp(options
->name
, "Quality") &&
675 !strcasecmp(options
->value
, "Normal"))
677 else if (num_options
> 0)
679 printf("FAIL (%d options:", num_options
);
680 for (i
= 0; i
< num_options
; i
++)
681 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
687 puts("FAIL (Unable to resolve!)");
690 cupsFreeOptions(num_options
, options
);
692 fputs("cupsResolveConflicts(loop test): ", stdout
);
693 ppdMarkOption(ppd
, "PageSize", "A4");
694 ppdMarkOption(ppd
, "InputSlot", "Tray");
695 ppdMarkOption(ppd
, "Quality", "Photo");
698 if (!cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
))
700 else if (num_options
> 0)
702 printf("FAIL (%d options:", num_options
);
703 for (i
= 0; i
< num_options
; i
++)
704 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
708 puts("FAIL (No conflicts!)");
710 fputs("ppdInstallableConflict(): ", stdout
);
711 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
712 !ppdInstallableConflict(ppd
, "Duplex", "None"))
714 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
716 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
721 puts("FAIL (Duplex=None conflicted)");
729 ppdMarkDefaults(ppd
);
731 fputs("ppdPageSizeLimits(default): ", stdout
);
732 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
734 if (minsize
.width
!= 36 || minsize
.length
!= 36 ||
735 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
737 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
738 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
739 minsize
.length
, maxsize
.width
, maxsize
.length
);
747 puts("FAIL (returned 0)");
751 ppdMarkOption(ppd
, "InputSlot", "Manual");
753 fputs("ppdPageSizeLimits(InputSlot=Manual): ", stdout
);
754 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
756 if (minsize
.width
!= 100 || minsize
.length
!= 100 ||
757 maxsize
.width
!= 1000 || maxsize
.length
!= 1000)
759 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
760 "expected min=100x100, max=1000x1000)\n", minsize
.width
,
761 minsize
.length
, maxsize
.width
, maxsize
.length
);
769 puts("FAIL (returned 0)");
773 ppdMarkOption(ppd
, "Quality", "Photo");
775 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
776 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
778 if (minsize
.width
!= 200 || minsize
.length
!= 200 ||
779 maxsize
.width
!= 1000 || maxsize
.length
!= 1000)
781 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
782 "expected min=200x200, max=1000x1000)\n", minsize
.width
,
783 minsize
.length
, maxsize
.width
, maxsize
.length
);
791 puts("FAIL (returned 0)");
795 ppdMarkOption(ppd
, "InputSlot", "Tray");
797 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
798 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
800 if (minsize
.width
!= 300 || minsize
.length
!= 300 ||
801 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
803 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
804 "expected min=300x300, max=1080x86400)\n", minsize
.width
,
805 minsize
.length
, maxsize
.width
, maxsize
.length
);
813 puts("FAIL (returned 0)");
819 const char *filename
; /* PPD filename */
820 struct stat fileinfo
; /* File information */
823 if (!strncmp(argv
[1], "-d", 2))
825 filename
= cupsGetPPD(argv
[1] + 2);
828 printf("%s: %s\n", argv
[1], cupsLastErrorString());
835 if (lstat(filename
, &fileinfo
))
837 printf("%s: %s\n", filename
, strerror(errno
));
841 if (S_ISLNK(fileinfo
.st_mode
))
843 char realfile
[1024]; /* Real file path */
844 ssize_t realsize
; /* Size of real file path */
847 if ((realsize
= readlink(filename
, realfile
, sizeof(realfile
) - 1)) < 0)
848 strcpy(realfile
, "Unknown");
850 realfile
[realsize
] = '\0';
852 if (stat(realfile
, &fileinfo
))
853 printf("%s: symlink to \"%s\", %s\n", filename
, realfile
,
856 printf("%s: symlink to \"%s\", %ld bytes\n", filename
, realfile
,
857 (long)fileinfo
.st_size
);
860 printf("%s: regular file, %ld bytes\n", filename
, (long)fileinfo
.st_size
);
862 if ((ppd
= ppdOpenFile(filename
)) == NULL
)
864 ppd_status_t err
; /* Last error in file */
865 int line
; /* Line number in file */
869 err
= ppdLastError(&line
);
871 printf("%s: %s on line %d\n", argv
[1], ppdErrorString(err
), line
);
875 int j
, k
; /* Looping vars */
876 ppd_group_t
*group
; /* Option group */
877 ppd_option_t
*option
; /* Option */
878 ppd_coption_t
*coption
; /* Custom option */
879 ppd_cparam_t
*cparam
; /* Custom parameter */
880 ppd_const_t
*c
; /* UIConstraints */
881 char lang
[255], /* LANG environment variable */
882 lc_all
[255], /* LC_ALL environment variable */
883 lc_ctype
[255], /* LC_CTYPE environment variable */
884 lc_messages
[255];/* LC_MESSAGES environment variable */
889 snprintf(lang
, sizeof(lang
), "LANG=%s", argv
[2]);
891 snprintf(lc_all
, sizeof(lc_all
), "LC_ALL=%s", argv
[2]);
893 snprintf(lc_ctype
, sizeof(lc_ctype
), "LC_CTYPE=%s", argv
[2]);
895 snprintf(lc_messages
, sizeof(lc_messages
), "LC_MESSAGES=%s", argv
[2]);
900 ppdMarkDefaults(ppd
);
904 text
= ppdLocalizeIPPReason(ppd
, argv
[3], NULL
, buffer
, sizeof(buffer
));
905 printf("ppdLocalizeIPPReason(%s)=%s\n", argv
[3],
906 text
? text
: "(null)");
907 return (text
== NULL
);
910 for (i
= ppd
->num_groups
, group
= ppd
->groups
;
914 printf("%s (%s):\n", group
->name
, group
->text
);
916 for (j
= group
->num_options
, option
= group
->options
;
920 printf(" %s (%s):\n", option
->keyword
, option
->text
);
922 for (k
= 0; k
< option
->num_choices
; k
++)
923 printf(" - %s%s (%s)\n",
924 option
->choices
[k
].marked
? "*" : "",
925 option
->choices
[k
].choice
, option
->choices
[k
].text
);
927 if ((coption
= ppdFindCustomOption(ppd
, option
->keyword
)) != NULL
)
929 for (cparam
= (ppd_cparam_t
*)cupsArrayFirst(coption
->params
);
931 cparam
= (ppd_cparam_t
*)cupsArrayNext(coption
->params
))
933 switch (cparam
->type
)
935 case PPD_CUSTOM_CURVE
:
936 printf(" %s(%s): PPD_CUSTOM_CURVE (%g to %g)\n",
937 cparam
->name
, cparam
->text
,
938 cparam
->minimum
.custom_curve
,
939 cparam
->maximum
.custom_curve
);
942 case PPD_CUSTOM_INT
:
943 printf(" %s(%s): PPD_CUSTOM_INT (%d to %d)\n",
944 cparam
->name
, cparam
->text
,
945 cparam
->minimum
.custom_int
,
946 cparam
->maximum
.custom_int
);
949 case PPD_CUSTOM_INVCURVE
:
950 printf(" %s(%s): PPD_CUSTOM_INVCURVE (%g to %g)\n",
951 cparam
->name
, cparam
->text
,
952 cparam
->minimum
.custom_invcurve
,
953 cparam
->maximum
.custom_invcurve
);
956 case PPD_CUSTOM_PASSCODE
:
957 printf(" %s(%s): PPD_CUSTOM_PASSCODE (%d to %d)\n",
958 cparam
->name
, cparam
->text
,
959 cparam
->minimum
.custom_passcode
,
960 cparam
->maximum
.custom_passcode
);
963 case PPD_CUSTOM_PASSWORD
:
964 printf(" %s(%s): PPD_CUSTOM_PASSWORD (%d to %d)\n",
965 cparam
->name
, cparam
->text
,
966 cparam
->minimum
.custom_password
,
967 cparam
->maximum
.custom_password
);
970 case PPD_CUSTOM_POINTS
:
971 printf(" %s(%s): PPD_CUSTOM_POINTS (%g to %g)\n",
972 cparam
->name
, cparam
->text
,
973 cparam
->minimum
.custom_points
,
974 cparam
->maximum
.custom_points
);
977 case PPD_CUSTOM_REAL
:
978 printf(" %s(%s): PPD_CUSTOM_REAL (%g to %g)\n",
979 cparam
->name
, cparam
->text
,
980 cparam
->minimum
.custom_real
,
981 cparam
->maximum
.custom_real
);
984 case PPD_CUSTOM_STRING
:
985 printf(" %s(%s): PPD_CUSTOM_STRING (%d to %d)\n",
986 cparam
->name
, cparam
->text
,
987 cparam
->minimum
.custom_string
,
988 cparam
->maximum
.custom_string
);
996 puts("\nConstraints:");
998 for (i
= ppd
->num_consts
, c
= ppd
->consts
; i
> 0; i
--, c
++)
999 printf(" *UIConstraints: *%s %s *%s %s\n", c
->option1
, c
->choice1
,
1000 c
->option2
, c
->choice2
);
1001 if (ppd
->num_consts
== 0)
1002 puts(" NO CONSTRAINTS");
1006 for (i
= 0; i
< ppd
->num_filters
; i
++)
1007 printf(" %s\n", ppd
->filters
[i
]);
1009 if (ppd
->num_filters
== 0)
1010 puts(" NO FILTERS");
1012 puts("\nAttributes:");
1014 for (attr
= (ppd_attr_t
*)cupsArrayFirst(ppd
->sorted_attrs
);
1016 attr
= (ppd_attr_t
*)cupsArrayNext(ppd
->sorted_attrs
))
1017 printf(" *%s %s/%s: \"%s\"\n", attr
->name
, attr
->spec
,
1018 attr
->text
, attr
->value
? attr
->value
: "");
1021 if (!strncmp(argv
[1], "-d", 2))
1026 if (getenv("MallocStackLogging") && getenv("MallocStackLoggingNoCompact"))
1028 char command
[1024]; /* malloc_history command */
1030 snprintf(command
, sizeof(command
), "malloc_history %d -all_by_size",
1035 #endif /* __APPLE__ */
1044 * End of "$Id: testppd.c 7897 2008-09-02 19:33:19Z mike $".