]>
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");
171 * Do tests with test.ppd...
174 fputs("ppdOpenFile(test.ppd): ", stdout
);
176 if ((ppd
= ppdOpenFile("test.ppd")) != NULL
)
180 ppd_status_t err
; /* Last error in file */
181 int line
; /* Line number in file */
185 err
= ppdLastError(&line
);
187 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
190 fputs("ppdFindAttr(wildcard): ", stdout
);
191 if ((attr
= ppdFindAttr(ppd
, "cupsTest", NULL
)) == NULL
)
194 puts("FAIL (not found)");
196 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
199 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
204 fputs("ppdFindNextAttr(wildcard): ", stdout
);
205 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", NULL
)) == NULL
)
208 puts("FAIL (not found)");
210 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Bar"))
213 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
218 fputs("ppdFindAttr(Foo): ", stdout
);
219 if ((attr
= ppdFindAttr(ppd
, "cupsTest", "Foo")) == NULL
)
222 puts("FAIL (not found)");
224 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
227 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
232 fputs("ppdFindNextAttr(Foo): ", stdout
);
233 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", "Foo")) != NULL
)
236 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
241 fputs("ppdMarkDefaults: ", stdout
);
242 ppdMarkDefaults(ppd
);
244 if ((conflicts
= ppdConflicts(ppd
)) == 0)
249 printf("FAIL (%d conflicts)\n", conflicts
);
252 fputs("ppdEmitString (defaults): ", stdout
);
253 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
254 !strcmp(s
, default_code
))
259 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
260 (int)strlen(default_code
));
269 fputs("ppdEmitString (custom size and string): ", stdout
);
270 ppdMarkOption(ppd
, "PageSize", "Custom.400x500");
271 ppdMarkOption(ppd
, "StringOption", "{String1=\"value 1\" String2=value(2)}");
273 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
274 !strcmp(s
, custom_code
))
279 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
280 (int)strlen(custom_code
));
290 * Test constraints...
293 fputs("cupsGetConflicts(InputSlot=Envelope): ", stdout
);
294 ppdMarkOption(ppd
, "PageSize", "Letter");
296 num_options
= cupsGetConflicts(ppd
, "InputSlot", "Envelope", &options
);
297 if (num_options
!= 2 ||
298 (val
= cupsGetOption("PageRegion", num_options
, options
)) == NULL
||
299 strcasecmp(val
, "Letter") ||
300 (val
= cupsGetOption("PageSize", num_options
, options
)) == NULL
||
301 strcasecmp(val
, "Letter"))
303 printf("FAIL (%d options:", num_options
);
304 for (i
= 0; i
< num_options
; i
++)
305 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
312 fputs("ppdConflicts(): ", stdout
);
313 ppdMarkOption(ppd
, "InputSlot", "Envelope");
315 if ((conflicts
= ppdConflicts(ppd
)) == 2)
319 printf("FAIL (%d)\n", conflicts
);
323 fputs("cupsResolveConflicts(InputSlot=Envelope): ", stdout
);
326 if (!cupsResolveConflicts(ppd
, "InputSlot", "Envelope", &num_options
,
329 puts("FAIL (Unable to resolve)");
332 else if (num_options
!= 2 ||
333 !cupsGetOption("PageSize", num_options
, options
))
335 printf("FAIL (%d options:", num_options
);
336 for (i
= 0; i
< num_options
; i
++)
337 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
342 puts("PASS (Resolved by changing PageSize)");
344 cupsFreeOptions(num_options
, options
);
346 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
349 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
350 num_options
== 1 && !strcasecmp(options
[0].name
, "InputSlot") &&
351 !strcasecmp(options
[0].value
, "Tray"))
352 puts("PASS (Resolved by changing InputSlot)");
353 else if (num_options
> 0)
355 printf("FAIL (%d options:", num_options
);
356 for (i
= 0; i
< num_options
; i
++)
357 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
363 puts("FAIL (Unable to resolve)");
366 cupsFreeOptions(num_options
, options
);
368 fputs("ppdInstallableConflict(): ", stdout
);
369 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
370 !ppdInstallableConflict(ppd
, "Duplex", "None"))
372 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
374 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
379 puts("FAIL (Duplex=None conflicted)");
387 fputs("ppdPageSizeLimits: ", stdout
);
388 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
390 if (minsize
.width
!= 36 || minsize
.length
!= 36 ||
391 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
393 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
394 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
395 minsize
.length
, maxsize
.width
, maxsize
.length
);
403 puts("FAIL (returned 0)");
408 * cupsMarkOptions with PWG and IPP size names.
411 fputs("cupsMarkOptions(media=iso-a4): ", stdout
);
412 num_options
= cupsAddOption("media", "iso-a4", 0, &options
);
413 cupsMarkOptions(ppd
, num_options
, options
);
414 cupsFreeOptions(num_options
, options
);
416 size
= ppdPageSize(ppd
, NULL
);
417 if (!size
|| strcmp(size
->name
, "A4"))
419 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
425 fputs("cupsMarkOptions(media=na_letter_8.5x11in): ", stdout
);
426 num_options
= cupsAddOption("media", "na_letter_8.5x11in", 0, &options
);
427 cupsMarkOptions(ppd
, num_options
, options
);
428 cupsFreeOptions(num_options
, options
);
430 size
= ppdPageSize(ppd
, NULL
);
431 if (!size
|| strcmp(size
->name
, "Letter"))
433 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
439 fputs("_cupsPWGMediaBySize(842, 1191): ", stdout
);
440 if ((pwgmedia
= _cupsPWGMediaBySize(842, 1191)) == NULL
)
442 puts("FAIL (not found)");
445 else if (strcmp(pwgmedia
->pwg
, "iso_a3_297x420mm"))
447 printf("FAIL (%s)\n", pwgmedia
->pwg
);
454 * Test localization...
457 fputs("ppdLocalizeIPPReason(text): ", stdout
);
458 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
459 !strcmp(buffer
, "Foo Reason"))
464 printf("FAIL (\"%s\" instead of \"Foo Reason\")\n", buffer
);
467 fputs("ppdLocalizeIPPReason(http): ", stdout
);
468 if (ppdLocalizeIPPReason(ppd
, "foo", "http", buffer
, sizeof(buffer
)) &&
469 !strcmp(buffer
, "http://foo/bar.html"))
474 printf("FAIL (\"%s\" instead of \"http://foo/bar.html\")\n", buffer
);
477 fputs("ppdLocalizeIPPReason(help): ", stdout
);
478 if (ppdLocalizeIPPReason(ppd
, "foo", "help", buffer
, sizeof(buffer
)) &&
479 !strcmp(buffer
, "help:anchor='foo'%20bookID=Vendor%20Help"))
484 printf("FAIL (\"%s\" instead of \"help:anchor='foo'%%20bookID=Vendor%%20Help\")\n", buffer
);
487 fputs("ppdLocalizeIPPReason(file): ", stdout
);
488 if (ppdLocalizeIPPReason(ppd
, "foo", "file", buffer
, sizeof(buffer
)) &&
489 !strcmp(buffer
, "/help/foo/bar.html"))
494 printf("FAIL (\"%s\" instead of \"/help/foo/bar.html\")\n", buffer
);
499 putenv("LC_CTYPE=fr");
500 putenv("LC_MESSAGES=fr");
502 fputs("ppdLocalizeIPPReason(fr text): ", stdout
);
503 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
504 !strcmp(buffer
, "La Long Foo Reason"))
509 printf("FAIL (\"%s\" instead of \"La Long Foo Reason\")\n", buffer
);
512 putenv("LANG=zh_TW");
513 putenv("LC_ALL=zh_TW");
514 putenv("LC_CTYPE=zh_TW");
515 putenv("LC_MESSAGES=zh_TW");
517 fputs("ppdLocalizeIPPReason(zh_TW text): ", stdout
);
518 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
519 !strcmp(buffer
, "Number 1 Foo Reason"))
524 printf("FAIL (\"%s\" instead of \"Number 1 Foo Reason\")\n", buffer
);
528 * cupsMarkerName localization...
533 putenv("LC_CTYPE=en");
534 putenv("LC_MESSAGES=en");
536 fputs("ppdLocalizeMarkerName(bogus): ", stdout
);
538 if ((text
= ppdLocalizeMarkerName(ppd
, "bogus")) != NULL
)
541 printf("FAIL (\"%s\" instead of NULL)\n", text
);
546 fputs("ppdLocalizeMarkerName(cyan): ", stdout
);
548 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
549 !strcmp(text
, "Cyan Toner"))
554 printf("FAIL (\"%s\" instead of \"Cyan Toner\")\n",
555 text
? text
: "(null)");
560 putenv("LC_CTYPE=fr");
561 putenv("LC_MESSAGES=fr");
563 fputs("ppdLocalizeMarkerName(fr cyan): ", stdout
);
564 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
565 !strcmp(text
, "La Toner Cyan"))
570 printf("FAIL (\"%s\" instead of \"La Toner Cyan\")\n",
571 text
? text
: "(null)");
574 putenv("LANG=zh_TW");
575 putenv("LC_ALL=zh_TW");
576 putenv("LC_CTYPE=zh_TW");
577 putenv("LC_MESSAGES=zh_TW");
579 fputs("ppdLocalizeMarkerName(zh_TW cyan): ", stdout
);
580 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
581 !strcmp(text
, "Number 1 Cyan Toner"))
586 printf("FAIL (\"%s\" instead of \"Number 1 Cyan Toner\")\n",
587 text
? text
: "(null)");
593 * Test new constraints...
596 fputs("ppdOpenFile(test2.ppd): ", stdout
);
598 if ((ppd
= ppdOpenFile("test2.ppd")) != NULL
)
602 ppd_status_t err
; /* Last error in file */
603 int line
; /* Line number in file */
607 err
= ppdLastError(&line
);
609 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
612 fputs("ppdMarkDefaults: ", stdout
);
613 ppdMarkDefaults(ppd
);
615 if ((conflicts
= ppdConflicts(ppd
)) == 0)
620 printf("FAIL (%d conflicts)\n", conflicts
);
623 fputs("ppdEmitString (defaults): ", stdout
);
624 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
625 !strcmp(s
, default2_code
))
630 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
631 (int)strlen(default2_code
));
640 fputs("ppdConflicts(): ", stdout
);
641 ppdMarkOption(ppd
, "PageSize", "Env10");
642 ppdMarkOption(ppd
, "InputSlot", "Envelope");
643 ppdMarkOption(ppd
, "Quality", "Photo");
645 if ((conflicts
= ppdConflicts(ppd
)) == 1)
649 printf("FAIL (%d)\n", conflicts
);
653 fputs("cupsResolveConflicts(Quality=Photo): ", stdout
);
656 if (cupsResolveConflicts(ppd
, "Quality", "Photo", &num_options
,
659 printf("FAIL (%d options:", num_options
);
660 for (i
= 0; i
< num_options
; i
++)
661 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
666 puts("PASS (Unable to resolve)");
667 cupsFreeOptions(num_options
, options
);
669 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
672 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
673 num_options
== 1 && !strcasecmp(options
->name
, "Quality") &&
674 !strcasecmp(options
->value
, "Normal"))
676 else if (num_options
> 0)
678 printf("FAIL (%d options:", num_options
);
679 for (i
= 0; i
< num_options
; i
++)
680 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
686 puts("FAIL (Unable to resolve!)");
689 cupsFreeOptions(num_options
, options
);
691 fputs("cupsResolveConflicts(loop test): ", stdout
);
692 ppdMarkOption(ppd
, "PageSize", "A4");
693 ppdMarkOption(ppd
, "InputSlot", "Tray");
694 ppdMarkOption(ppd
, "Quality", "Photo");
697 if (!cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
))
699 else if (num_options
> 0)
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
);
707 puts("FAIL (No conflicts!)");
709 fputs("ppdInstallableConflict(): ", stdout
);
710 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
711 !ppdInstallableConflict(ppd
, "Duplex", "None"))
713 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
715 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
720 puts("FAIL (Duplex=None conflicted)");
728 ppdMarkDefaults(ppd
);
730 fputs("ppdPageSizeLimits(default): ", stdout
);
731 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
733 if (minsize
.width
!= 36 || minsize
.length
!= 36 ||
734 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
736 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
737 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
738 minsize
.length
, maxsize
.width
, maxsize
.length
);
746 puts("FAIL (returned 0)");
750 ppdMarkOption(ppd
, "InputSlot", "Manual");
752 fputs("ppdPageSizeLimits(InputSlot=Manual): ", stdout
);
753 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
755 if (minsize
.width
!= 100 || minsize
.length
!= 100 ||
756 maxsize
.width
!= 1000 || maxsize
.length
!= 1000)
758 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
759 "expected min=100x100, max=1000x1000)\n", minsize
.width
,
760 minsize
.length
, maxsize
.width
, maxsize
.length
);
768 puts("FAIL (returned 0)");
772 ppdMarkOption(ppd
, "Quality", "Photo");
774 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
775 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
777 if (minsize
.width
!= 200 || minsize
.length
!= 200 ||
778 maxsize
.width
!= 1000 || maxsize
.length
!= 1000)
780 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
781 "expected min=200x200, max=1000x1000)\n", minsize
.width
,
782 minsize
.length
, maxsize
.width
, maxsize
.length
);
790 puts("FAIL (returned 0)");
794 ppdMarkOption(ppd
, "InputSlot", "Tray");
796 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
797 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
799 if (minsize
.width
!= 300 || minsize
.length
!= 300 ||
800 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
802 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
803 "expected min=300x300, max=1080x86400)\n", minsize
.width
,
804 minsize
.length
, maxsize
.width
, maxsize
.length
);
812 puts("FAIL (returned 0)");
818 const char *filename
; /* PPD filename */
819 struct stat fileinfo
; /* File information */
822 if (!strncmp(argv
[1], "-d", 2))
824 filename
= cupsGetPPD(argv
[1] + 2);
827 printf("%s: %s\n", argv
[1], cupsLastErrorString());
834 if (lstat(filename
, &fileinfo
))
836 printf("%s: %s\n", filename
, strerror(errno
));
840 if (S_ISLNK(fileinfo
.st_mode
))
842 char realfile
[1024]; /* Real file path */
843 ssize_t realsize
; /* Size of real file path */
846 if ((realsize
= readlink(filename
, realfile
, sizeof(realfile
) - 1)) < 0)
847 strcpy(realfile
, "Unknown");
849 realfile
[realsize
] = '\0';
851 if (stat(realfile
, &fileinfo
))
852 printf("%s: symlink to \"%s\", %s\n", filename
, realfile
,
855 printf("%s: symlink to \"%s\", %ld bytes\n", filename
, realfile
,
856 (long)fileinfo
.st_size
);
859 printf("%s: regular file, %ld bytes\n", filename
, (long)fileinfo
.st_size
);
861 if ((ppd
= ppdOpenFile(filename
)) == NULL
)
863 ppd_status_t err
; /* Last error in file */
864 int line
; /* Line number in file */
868 err
= ppdLastError(&line
);
870 printf("%s: %s on line %d\n", argv
[1], ppdErrorString(err
), line
);
874 int j
, k
; /* Looping vars */
875 ppd_group_t
*group
; /* Option group */
876 ppd_option_t
*option
; /* Option */
877 ppd_coption_t
*coption
; /* Custom option */
878 ppd_cparam_t
*cparam
; /* Custom parameter */
879 ppd_const_t
*c
; /* UIConstraints */
880 char lang
[255], /* LANG environment variable */
881 lc_all
[255], /* LC_ALL environment variable */
882 lc_ctype
[255], /* LC_CTYPE environment variable */
883 lc_messages
[255];/* LC_MESSAGES environment variable */
888 snprintf(lang
, sizeof(lang
), "LANG=%s", argv
[2]);
890 snprintf(lc_all
, sizeof(lc_all
), "LC_ALL=%s", argv
[2]);
892 snprintf(lc_ctype
, sizeof(lc_ctype
), "LC_CTYPE=%s", argv
[2]);
894 snprintf(lc_messages
, sizeof(lc_messages
), "LC_MESSAGES=%s", argv
[2]);
899 ppdMarkDefaults(ppd
);
903 text
= ppdLocalizeIPPReason(ppd
, argv
[3], NULL
, buffer
, sizeof(buffer
));
904 printf("ppdLocalizeIPPReason(%s)=%s\n", argv
[3],
905 text
? text
: "(null)");
906 return (text
== NULL
);
909 for (i
= ppd
->num_groups
, group
= ppd
->groups
;
913 printf("%s (%s):\n", group
->name
, group
->text
);
915 for (j
= group
->num_options
, option
= group
->options
;
919 printf(" %s (%s):\n", option
->keyword
, option
->text
);
921 for (k
= 0; k
< option
->num_choices
; k
++)
922 printf(" - %s%s (%s)\n",
923 option
->choices
[k
].marked
? "*" : "",
924 option
->choices
[k
].choice
, option
->choices
[k
].text
);
926 if ((coption
= ppdFindCustomOption(ppd
, option
->keyword
)) != NULL
)
928 for (cparam
= (ppd_cparam_t
*)cupsArrayFirst(coption
->params
);
930 cparam
= (ppd_cparam_t
*)cupsArrayNext(coption
->params
))
932 switch (cparam
->type
)
934 case PPD_CUSTOM_CURVE
:
935 printf(" %s(%s): PPD_CUSTOM_CURVE (%g to %g)\n",
936 cparam
->name
, cparam
->text
,
937 cparam
->minimum
.custom_curve
,
938 cparam
->maximum
.custom_curve
);
941 case PPD_CUSTOM_INT
:
942 printf(" %s(%s): PPD_CUSTOM_INT (%d to %d)\n",
943 cparam
->name
, cparam
->text
,
944 cparam
->minimum
.custom_int
,
945 cparam
->maximum
.custom_int
);
948 case PPD_CUSTOM_INVCURVE
:
949 printf(" %s(%s): PPD_CUSTOM_INVCURVE (%g to %g)\n",
950 cparam
->name
, cparam
->text
,
951 cparam
->minimum
.custom_invcurve
,
952 cparam
->maximum
.custom_invcurve
);
955 case PPD_CUSTOM_PASSCODE
:
956 printf(" %s(%s): PPD_CUSTOM_PASSCODE (%d to %d)\n",
957 cparam
->name
, cparam
->text
,
958 cparam
->minimum
.custom_passcode
,
959 cparam
->maximum
.custom_passcode
);
962 case PPD_CUSTOM_PASSWORD
:
963 printf(" %s(%s): PPD_CUSTOM_PASSWORD (%d to %d)\n",
964 cparam
->name
, cparam
->text
,
965 cparam
->minimum
.custom_password
,
966 cparam
->maximum
.custom_password
);
969 case PPD_CUSTOM_POINTS
:
970 printf(" %s(%s): PPD_CUSTOM_POINTS (%g to %g)\n",
971 cparam
->name
, cparam
->text
,
972 cparam
->minimum
.custom_points
,
973 cparam
->maximum
.custom_points
);
976 case PPD_CUSTOM_REAL
:
977 printf(" %s(%s): PPD_CUSTOM_REAL (%g to %g)\n",
978 cparam
->name
, cparam
->text
,
979 cparam
->minimum
.custom_real
,
980 cparam
->maximum
.custom_real
);
983 case PPD_CUSTOM_STRING
:
984 printf(" %s(%s): PPD_CUSTOM_STRING (%d to %d)\n",
985 cparam
->name
, cparam
->text
,
986 cparam
->minimum
.custom_string
,
987 cparam
->maximum
.custom_string
);
995 puts("\nConstraints:");
997 for (i
= ppd
->num_consts
, c
= ppd
->consts
; i
> 0; i
--, c
++)
998 printf(" *UIConstraints: *%s %s *%s %s\n", c
->option1
, c
->choice1
,
999 c
->option2
, c
->choice2
);
1000 if (ppd
->num_consts
== 0)
1001 puts(" NO CONSTRAINTS");
1005 for (i
= 0; i
< ppd
->num_filters
; i
++)
1006 printf(" %s\n", ppd
->filters
[i
]);
1008 if (ppd
->num_filters
== 0)
1009 puts(" NO FILTERS");
1011 puts("\nAttributes:");
1013 for (attr
= (ppd_attr_t
*)cupsArrayFirst(ppd
->sorted_attrs
);
1015 attr
= (ppd_attr_t
*)cupsArrayNext(ppd
->sorted_attrs
))
1016 printf(" *%s %s/%s: \"%s\"\n", attr
->name
, attr
->spec
,
1017 attr
->text
, attr
->value
? attr
->value
: "");
1020 if (!strncmp(argv
[1], "-d", 2))
1025 if (getenv("MallocStackLogging") && getenv("MallocStackLoggingNoCompact"))
1027 char command
[1024]; /* malloc_history command */
1029 snprintf(command
, sizeof(command
), "malloc_history %d -all_by_size",
1034 #endif /* __APPLE__ */
1043 * End of "$Id: testppd.c 7897 2008-09-02 19:33:19Z mike $".