]>
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 CUPS.
6 * Copyright 2007-2011 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 */
160 * Setup directories for locale stuff...
163 if (access("locale", 0))
165 mkdir("locale", 0777);
166 mkdir("locale/fr", 0777);
167 symlink("../../../locale/cups_fr.po", "locale/fr/cups_fr.po");
168 mkdir("locale/zh_TW", 0777);
169 symlink("../../../locale/cups_zh_TW.po", "locale/zh_TW/cups_zh_TW.po");
172 putenv("LOCALEDIR=locale");
173 putenv("SOFTWARE=CUPS");
176 * Do tests with test.ppd...
179 fputs("ppdOpenFile(test.ppd): ", stdout
);
181 if ((ppd
= _ppdOpenFile("test.ppd", _PPD_LOCALIZATION_ALL
)) != NULL
)
185 ppd_status_t err
; /* Last error in file */
186 int line
; /* Line number in file */
190 err
= ppdLastError(&line
);
192 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
195 fputs("ppdFindAttr(wildcard): ", stdout
);
196 if ((attr
= ppdFindAttr(ppd
, "cupsTest", NULL
)) == NULL
)
199 puts("FAIL (not found)");
201 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
204 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
209 fputs("ppdFindNextAttr(wildcard): ", stdout
);
210 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", NULL
)) == NULL
)
213 puts("FAIL (not found)");
215 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Bar"))
218 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
223 fputs("ppdFindAttr(Foo): ", stdout
);
224 if ((attr
= ppdFindAttr(ppd
, "cupsTest", "Foo")) == NULL
)
227 puts("FAIL (not found)");
229 else if (strcmp(attr
->name
, "cupsTest") || strcmp(attr
->spec
, "Foo"))
232 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
237 fputs("ppdFindNextAttr(Foo): ", stdout
);
238 if ((attr
= ppdFindNextAttr(ppd
, "cupsTest", "Foo")) != NULL
)
241 printf("FAIL (got \"%s %s\")\n", attr
->name
, attr
->spec
);
246 fputs("ppdMarkDefaults: ", stdout
);
247 ppdMarkDefaults(ppd
);
249 if ((conflicts
= ppdConflicts(ppd
)) == 0)
254 printf("FAIL (%d conflicts)\n", conflicts
);
257 fputs("ppdEmitString (defaults): ", stdout
);
258 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
259 !strcmp(s
, default_code
))
264 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
265 (int)strlen(default_code
));
274 fputs("ppdEmitString (custom size and string): ", stdout
);
275 ppdMarkOption(ppd
, "PageSize", "Custom.400x500");
276 ppdMarkOption(ppd
, "StringOption", "{String1=\"value 1\" String2=value(2)}");
278 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
279 !strcmp(s
, custom_code
))
284 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
285 (int)strlen(custom_code
));
295 * Test constraints...
298 fputs("cupsGetConflicts(InputSlot=Envelope): ", stdout
);
299 ppdMarkOption(ppd
, "PageSize", "Letter");
301 num_options
= cupsGetConflicts(ppd
, "InputSlot", "Envelope", &options
);
302 if (num_options
!= 2 ||
303 (val
= cupsGetOption("PageRegion", num_options
, options
)) == NULL
||
304 _cups_strcasecmp(val
, "Letter") ||
305 (val
= cupsGetOption("PageSize", num_options
, options
)) == NULL
||
306 _cups_strcasecmp(val
, "Letter"))
308 printf("FAIL (%d options:", num_options
);
309 for (i
= 0; i
< num_options
; i
++)
310 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
317 fputs("ppdConflicts(): ", stdout
);
318 ppdMarkOption(ppd
, "InputSlot", "Envelope");
320 if ((conflicts
= ppdConflicts(ppd
)) == 2)
324 printf("FAIL (%d)\n", conflicts
);
328 fputs("cupsResolveConflicts(InputSlot=Envelope): ", stdout
);
331 if (!cupsResolveConflicts(ppd
, "InputSlot", "Envelope", &num_options
,
334 puts("FAIL (Unable to resolve)");
337 else if (num_options
!= 2 ||
338 !cupsGetOption("PageSize", num_options
, options
))
340 printf("FAIL (%d options:", num_options
);
341 for (i
= 0; i
< num_options
; i
++)
342 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
347 puts("PASS (Resolved by changing PageSize)");
349 cupsFreeOptions(num_options
, options
);
351 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
354 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
355 num_options
== 1 && !_cups_strcasecmp(options
[0].name
, "InputSlot") &&
356 !_cups_strcasecmp(options
[0].value
, "Tray"))
357 puts("PASS (Resolved by changing InputSlot)");
358 else if (num_options
> 0)
360 printf("FAIL (%d options:", num_options
);
361 for (i
= 0; i
< num_options
; i
++)
362 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
368 puts("FAIL (Unable to resolve)");
371 cupsFreeOptions(num_options
, options
);
373 fputs("ppdInstallableConflict(): ", stdout
);
374 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
375 !ppdInstallableConflict(ppd
, "Duplex", "None"))
377 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
379 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
384 puts("FAIL (Duplex=None conflicted)");
392 fputs("ppdPageSizeLimits: ", stdout
);
393 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
395 if (minsize
.width
!= 36 || minsize
.length
!= 36 ||
396 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
398 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
399 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
400 minsize
.length
, maxsize
.width
, maxsize
.length
);
408 puts("FAIL (returned 0)");
413 * cupsMarkOptions with PWG and IPP size names.
416 fputs("cupsMarkOptions(media=iso-a4): ", stdout
);
417 num_options
= cupsAddOption("media", "iso-a4", 0, &options
);
418 cupsMarkOptions(ppd
, num_options
, options
);
419 cupsFreeOptions(num_options
, options
);
421 size
= ppdPageSize(ppd
, NULL
);
422 if (!size
|| strcmp(size
->name
, "A4"))
424 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
430 fputs("cupsMarkOptions(media=na_letter_8.5x11in): ", stdout
);
431 num_options
= cupsAddOption("media", "na_letter_8.5x11in", 0, &options
);
432 cupsMarkOptions(ppd
, num_options
, options
);
433 cupsFreeOptions(num_options
, options
);
435 size
= ppdPageSize(ppd
, NULL
);
436 if (!size
|| strcmp(size
->name
, "Letter"))
438 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
444 fputs("cupsMarkOptions(media=oe_letter-fullbleed_8.5x11in): ", stdout
);
445 num_options
= cupsAddOption("media", "oe_letter-fullbleed_8.5x11in", 0,
447 cupsMarkOptions(ppd
, num_options
, options
);
448 cupsFreeOptions(num_options
, options
);
450 size
= ppdPageSize(ppd
, NULL
);
451 if (!size
|| strcmp(size
->name
, "Letter.Fullbleed"))
453 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
459 fputs("cupsMarkOptions(media=A4): ", stdout
);
460 num_options
= cupsAddOption("media", "A4", 0, &options
);
461 cupsMarkOptions(ppd
, num_options
, options
);
462 cupsFreeOptions(num_options
, options
);
464 size
= ppdPageSize(ppd
, NULL
);
465 if (!size
|| strcmp(size
->name
, "A4"))
467 printf("FAIL (%s)\n", size
? size
->name
: "unknown");
477 fputs("cupsMarkOptions(media=Custom.8x10in): ", stdout
);
478 num_options
= cupsAddOption("media", "Custom.8x10in", 0, &options
);
479 cupsMarkOptions(ppd
, num_options
, options
);
480 cupsFreeOptions(num_options
, options
);
482 size
= ppdPageSize(ppd
, NULL
);
483 if (!size
|| strcmp(size
->name
, "Custom") ||
484 size
->width
!= 576 || size
->length
!= 720)
486 printf("FAIL (%s - %gx%g)\n", size
? size
->name
: "unknown",
487 size
? size
->width
: 0.0, size
? size
->length
: 0.0);
494 * Test localization...
497 fputs("ppdLocalizeIPPReason(text): ", stdout
);
498 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
499 !strcmp(buffer
, "Foo Reason"))
504 printf("FAIL (\"%s\" instead of \"Foo Reason\")\n", buffer
);
507 fputs("ppdLocalizeIPPReason(http): ", stdout
);
508 if (ppdLocalizeIPPReason(ppd
, "foo", "http", buffer
, sizeof(buffer
)) &&
509 !strcmp(buffer
, "http://foo/bar.html"))
514 printf("FAIL (\"%s\" instead of \"http://foo/bar.html\")\n", buffer
);
517 fputs("ppdLocalizeIPPReason(help): ", stdout
);
518 if (ppdLocalizeIPPReason(ppd
, "foo", "help", buffer
, sizeof(buffer
)) &&
519 !strcmp(buffer
, "help:anchor='foo'%20bookID=Vendor%20Help"))
524 printf("FAIL (\"%s\" instead of \"help:anchor='foo'%%20bookID=Vendor%%20Help\")\n", buffer
);
527 fputs("ppdLocalizeIPPReason(file): ", stdout
);
528 if (ppdLocalizeIPPReason(ppd
, "foo", "file", buffer
, sizeof(buffer
)) &&
529 !strcmp(buffer
, "/help/foo/bar.html"))
534 printf("FAIL (\"%s\" instead of \"/help/foo/bar.html\")\n", buffer
);
539 putenv("LC_CTYPE=fr");
540 putenv("LC_MESSAGES=fr");
542 fputs("ppdLocalizeIPPReason(fr text): ", stdout
);
543 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
544 !strcmp(buffer
, "La Long Foo Reason"))
549 printf("FAIL (\"%s\" instead of \"La Long Foo Reason\")\n", buffer
);
552 putenv("LANG=zh_TW");
553 putenv("LC_ALL=zh_TW");
554 putenv("LC_CTYPE=zh_TW");
555 putenv("LC_MESSAGES=zh_TW");
557 fputs("ppdLocalizeIPPReason(zh_TW text): ", stdout
);
558 if (ppdLocalizeIPPReason(ppd
, "foo", NULL
, buffer
, sizeof(buffer
)) &&
559 !strcmp(buffer
, "Number 1 Foo Reason"))
564 printf("FAIL (\"%s\" instead of \"Number 1 Foo Reason\")\n", buffer
);
568 * cupsMarkerName localization...
573 putenv("LC_CTYPE=en");
574 putenv("LC_MESSAGES=en");
576 fputs("ppdLocalizeMarkerName(bogus): ", stdout
);
578 if ((text
= ppdLocalizeMarkerName(ppd
, "bogus")) != NULL
)
581 printf("FAIL (\"%s\" instead of NULL)\n", text
);
586 fputs("ppdLocalizeMarkerName(cyan): ", stdout
);
588 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
589 !strcmp(text
, "Cyan Toner"))
594 printf("FAIL (\"%s\" instead of \"Cyan Toner\")\n",
595 text
? text
: "(null)");
600 putenv("LC_CTYPE=fr");
601 putenv("LC_MESSAGES=fr");
603 fputs("ppdLocalizeMarkerName(fr cyan): ", stdout
);
604 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
605 !strcmp(text
, "La Toner Cyan"))
610 printf("FAIL (\"%s\" instead of \"La Toner Cyan\")\n",
611 text
? text
: "(null)");
614 putenv("LANG=zh_TW");
615 putenv("LC_ALL=zh_TW");
616 putenv("LC_CTYPE=zh_TW");
617 putenv("LC_MESSAGES=zh_TW");
619 fputs("ppdLocalizeMarkerName(zh_TW cyan): ", stdout
);
620 if ((text
= ppdLocalizeMarkerName(ppd
, "cyan")) != NULL
&&
621 !strcmp(text
, "Number 1 Cyan Toner"))
626 printf("FAIL (\"%s\" instead of \"Number 1 Cyan Toner\")\n",
627 text
? text
: "(null)");
633 * Test new constraints...
636 fputs("ppdOpenFile(test2.ppd): ", stdout
);
638 if ((ppd
= ppdOpenFile("test2.ppd")) != NULL
)
642 ppd_status_t err
; /* Last error in file */
643 int line
; /* Line number in file */
647 err
= ppdLastError(&line
);
649 printf("FAIL (%s on line %d)\n", ppdErrorString(err
), line
);
652 fputs("ppdMarkDefaults: ", stdout
);
653 ppdMarkDefaults(ppd
);
655 if ((conflicts
= ppdConflicts(ppd
)) == 0)
660 printf("FAIL (%d conflicts)\n", conflicts
);
663 fputs("ppdEmitString (defaults): ", stdout
);
664 if ((s
= ppdEmitString(ppd
, PPD_ORDER_ANY
, 0.0)) != NULL
&&
665 !strcmp(s
, default2_code
))
670 printf("FAIL (%d bytes instead of %d)\n", s
? (int)strlen(s
) : 0,
671 (int)strlen(default2_code
));
680 fputs("ppdConflicts(): ", stdout
);
681 ppdMarkOption(ppd
, "PageSize", "Env10");
682 ppdMarkOption(ppd
, "InputSlot", "Envelope");
683 ppdMarkOption(ppd
, "Quality", "Photo");
685 if ((conflicts
= ppdConflicts(ppd
)) == 1)
689 printf("FAIL (%d)\n", conflicts
);
693 fputs("cupsResolveConflicts(Quality=Photo): ", stdout
);
696 if (cupsResolveConflicts(ppd
, "Quality", "Photo", &num_options
,
699 printf("FAIL (%d options:", num_options
);
700 for (i
= 0; i
< num_options
; i
++)
701 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
706 puts("PASS (Unable to resolve)");
707 cupsFreeOptions(num_options
, options
);
709 fputs("cupsResolveConflicts(No option/choice): ", stdout
);
712 if (cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
) &&
713 num_options
== 1 && !_cups_strcasecmp(options
->name
, "Quality") &&
714 !_cups_strcasecmp(options
->value
, "Normal"))
716 else if (num_options
> 0)
718 printf("FAIL (%d options:", num_options
);
719 for (i
= 0; i
< num_options
; i
++)
720 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
726 puts("FAIL (Unable to resolve!)");
729 cupsFreeOptions(num_options
, options
);
731 fputs("cupsResolveConflicts(loop test): ", stdout
);
732 ppdMarkOption(ppd
, "PageSize", "A4");
733 ppdMarkOption(ppd
, "InputSlot", "Tray");
734 ppdMarkOption(ppd
, "Quality", "Photo");
737 if (!cupsResolveConflicts(ppd
, NULL
, NULL
, &num_options
, &options
))
739 else if (num_options
> 0)
741 printf("FAIL (%d options:", num_options
);
742 for (i
= 0; i
< num_options
; i
++)
743 printf(" %s=%s", options
[i
].name
, options
[i
].value
);
747 puts("FAIL (No conflicts!)");
749 fputs("ppdInstallableConflict(): ", stdout
);
750 if (ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble") &&
751 !ppdInstallableConflict(ppd
, "Duplex", "None"))
753 else if (!ppdInstallableConflict(ppd
, "Duplex", "DuplexNoTumble"))
755 puts("FAIL (Duplex=DuplexNoTumble did not conflict)");
760 puts("FAIL (Duplex=None conflicted)");
768 ppdMarkDefaults(ppd
);
770 fputs("ppdPageSizeLimits(default): ", stdout
);
771 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
773 if (minsize
.width
!= 36 || minsize
.length
!= 36 ||
774 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
776 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
777 "expected min=36x36, max=1080x86400)\n", minsize
.width
,
778 minsize
.length
, maxsize
.width
, maxsize
.length
);
786 puts("FAIL (returned 0)");
790 ppdMarkOption(ppd
, "InputSlot", "Manual");
792 fputs("ppdPageSizeLimits(InputSlot=Manual): ", stdout
);
793 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
795 if (minsize
.width
!= 100 || minsize
.length
!= 100 ||
796 maxsize
.width
!= 1000 || maxsize
.length
!= 1000)
798 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
799 "expected min=100x100, max=1000x1000)\n", minsize
.width
,
800 minsize
.length
, maxsize
.width
, maxsize
.length
);
808 puts("FAIL (returned 0)");
812 ppdMarkOption(ppd
, "Quality", "Photo");
814 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
815 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
817 if (minsize
.width
!= 200 || minsize
.length
!= 200 ||
818 maxsize
.width
!= 1000 || maxsize
.length
!= 1000)
820 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
821 "expected min=200x200, max=1000x1000)\n", minsize
.width
,
822 minsize
.length
, maxsize
.width
, maxsize
.length
);
830 puts("FAIL (returned 0)");
834 ppdMarkOption(ppd
, "InputSlot", "Tray");
836 fputs("ppdPageSizeLimits(Quality=Photo): ", stdout
);
837 if (ppdPageSizeLimits(ppd
, &minsize
, &maxsize
))
839 if (minsize
.width
!= 300 || minsize
.length
!= 300 ||
840 maxsize
.width
!= 1080 || maxsize
.length
!= 86400)
842 printf("FAIL (got min=%.0fx%.0f, max=%.0fx%.0f, "
843 "expected min=300x300, max=1080x86400)\n", minsize
.width
,
844 minsize
.length
, maxsize
.width
, maxsize
.length
);
852 puts("FAIL (returned 0)");
858 const char *filename
; /* PPD filename */
859 struct stat fileinfo
; /* File information */
862 if (!strncmp(argv
[1], "-d", 2))
864 const char *printer
; /* Printer name */
867 printer
= argv
[1] + 2;
872 puts("Usage: ./testppd -d printer");
876 filename
= cupsGetPPD(printer
);
880 printf("%s: %s\n", printer
, cupsLastErrorString());
887 if (lstat(filename
, &fileinfo
))
889 printf("%s: %s\n", filename
, strerror(errno
));
893 if (S_ISLNK(fileinfo
.st_mode
))
895 char realfile
[1024]; /* Real file path */
896 ssize_t realsize
; /* Size of real file path */
899 if ((realsize
= readlink(filename
, realfile
, sizeof(realfile
) - 1)) < 0)
900 strcpy(realfile
, "Unknown");
902 realfile
[realsize
] = '\0';
904 if (stat(realfile
, &fileinfo
))
905 printf("%s: symlink to \"%s\", %s\n", filename
, realfile
,
908 printf("%s: symlink to \"%s\", %ld bytes\n", filename
, realfile
,
909 (long)fileinfo
.st_size
);
912 printf("%s: regular file, %ld bytes\n", filename
, (long)fileinfo
.st_size
);
914 if ((ppd
= ppdOpenFile(filename
)) == NULL
)
916 ppd_status_t err
; /* Last error in file */
917 int line
; /* Line number in file */
921 err
= ppdLastError(&line
);
923 printf("%s: %s on line %d\n", argv
[1], ppdErrorString(err
), line
);
927 int j
, k
; /* Looping vars */
928 ppd_group_t
*group
; /* Option group */
929 ppd_option_t
*option
; /* Option */
930 ppd_coption_t
*coption
; /* Custom option */
931 ppd_cparam_t
*cparam
; /* Custom parameter */
932 ppd_const_t
*c
; /* UIConstraints */
933 char lang
[255], /* LANG environment variable */
934 lc_all
[255], /* LC_ALL environment variable */
935 lc_ctype
[255], /* LC_CTYPE environment variable */
936 lc_messages
[255];/* LC_MESSAGES environment variable */
941 snprintf(lang
, sizeof(lang
), "LANG=%s", argv
[2]);
943 snprintf(lc_all
, sizeof(lc_all
), "LC_ALL=%s", argv
[2]);
945 snprintf(lc_ctype
, sizeof(lc_ctype
), "LC_CTYPE=%s", argv
[2]);
947 snprintf(lc_messages
, sizeof(lc_messages
), "LC_MESSAGES=%s", argv
[2]);
952 ppdMarkDefaults(ppd
);
956 text
= ppdLocalizeIPPReason(ppd
, argv
[3], NULL
, buffer
, sizeof(buffer
));
957 printf("ppdLocalizeIPPReason(%s)=%s\n", argv
[3],
958 text
? text
: "(null)");
959 return (text
== NULL
);
962 for (i
= ppd
->num_groups
, group
= ppd
->groups
;
966 printf("%s (%s):\n", group
->name
, group
->text
);
968 for (j
= group
->num_options
, option
= group
->options
;
972 printf(" %s (%s):\n", option
->keyword
, option
->text
);
974 for (k
= 0; k
< option
->num_choices
; k
++)
975 printf(" - %s%s (%s)\n",
976 option
->choices
[k
].marked
? "*" : "",
977 option
->choices
[k
].choice
, option
->choices
[k
].text
);
979 if ((coption
= ppdFindCustomOption(ppd
, option
->keyword
)) != NULL
)
981 for (cparam
= (ppd_cparam_t
*)cupsArrayFirst(coption
->params
);
983 cparam
= (ppd_cparam_t
*)cupsArrayNext(coption
->params
))
985 switch (cparam
->type
)
987 case PPD_CUSTOM_CURVE
:
988 printf(" %s(%s): PPD_CUSTOM_CURVE (%g to %g)\n",
989 cparam
->name
, cparam
->text
,
990 cparam
->minimum
.custom_curve
,
991 cparam
->maximum
.custom_curve
);
994 case PPD_CUSTOM_INT
:
995 printf(" %s(%s): PPD_CUSTOM_INT (%d to %d)\n",
996 cparam
->name
, cparam
->text
,
997 cparam
->minimum
.custom_int
,
998 cparam
->maximum
.custom_int
);
1001 case PPD_CUSTOM_INVCURVE
:
1002 printf(" %s(%s): PPD_CUSTOM_INVCURVE (%g to %g)\n",
1003 cparam
->name
, cparam
->text
,
1004 cparam
->minimum
.custom_invcurve
,
1005 cparam
->maximum
.custom_invcurve
);
1008 case PPD_CUSTOM_PASSCODE
:
1009 printf(" %s(%s): PPD_CUSTOM_PASSCODE (%d to %d)\n",
1010 cparam
->name
, cparam
->text
,
1011 cparam
->minimum
.custom_passcode
,
1012 cparam
->maximum
.custom_passcode
);
1015 case PPD_CUSTOM_PASSWORD
:
1016 printf(" %s(%s): PPD_CUSTOM_PASSWORD (%d to %d)\n",
1017 cparam
->name
, cparam
->text
,
1018 cparam
->minimum
.custom_password
,
1019 cparam
->maximum
.custom_password
);
1022 case PPD_CUSTOM_POINTS
:
1023 printf(" %s(%s): PPD_CUSTOM_POINTS (%g to %g)\n",
1024 cparam
->name
, cparam
->text
,
1025 cparam
->minimum
.custom_points
,
1026 cparam
->maximum
.custom_points
);
1029 case PPD_CUSTOM_REAL
:
1030 printf(" %s(%s): PPD_CUSTOM_REAL (%g to %g)\n",
1031 cparam
->name
, cparam
->text
,
1032 cparam
->minimum
.custom_real
,
1033 cparam
->maximum
.custom_real
);
1036 case PPD_CUSTOM_STRING
:
1037 printf(" %s(%s): PPD_CUSTOM_STRING (%d to %d)\n",
1038 cparam
->name
, cparam
->text
,
1039 cparam
->minimum
.custom_string
,
1040 cparam
->maximum
.custom_string
);
1049 for (i
= ppd
->num_sizes
, size
= ppd
->sizes
; i
> 0; i
--, size
++)
1050 printf(" %s = %gx%g, [%g %g %g %g]\n", size
->name
, size
->width
,
1051 size
->length
, size
->left
, size
->bottom
, size
->right
, size
->top
);
1053 puts("\nConstraints:");
1055 for (i
= ppd
->num_consts
, c
= ppd
->consts
; i
> 0; i
--, c
++)
1056 printf(" *UIConstraints: *%s %s *%s %s\n", c
->option1
, c
->choice1
,
1057 c
->option2
, c
->choice2
);
1058 if (ppd
->num_consts
== 0)
1059 puts(" NO CONSTRAINTS");
1063 for (i
= 0; i
< ppd
->num_filters
; i
++)
1064 printf(" %s\n", ppd
->filters
[i
]);
1066 if (ppd
->num_filters
== 0)
1067 puts(" NO FILTERS");
1069 puts("\nAttributes:");
1071 for (attr
= (ppd_attr_t
*)cupsArrayFirst(ppd
->sorted_attrs
);
1073 attr
= (ppd_attr_t
*)cupsArrayNext(ppd
->sorted_attrs
))
1074 printf(" *%s %s/%s: \"%s\"\n", attr
->name
, attr
->spec
,
1075 attr
->text
, attr
->value
? attr
->value
: "");
1078 if (!strncmp(argv
[1], "-d", 2))
1083 if (getenv("MallocStackLogging") && getenv("MallocStackLoggingNoCompact"))
1085 char command
[1024]; /* malloc_history command */
1087 snprintf(command
, sizeof(command
), "malloc_history %d -all_by_size",
1092 #endif /* __APPLE__ */
1101 * End of "$Id: testppd.c 7897 2008-09-02 19:33:19Z mike $".