]>
Commit | Line | Data |
---|---|---|
b2b9911d MS |
1 | /* |
2 | * "$Id$" | |
3 | * | |
4 | * PPD cache testing program for CUPS. | |
5 | * | |
6 | * Copyright 2009-2014 by Apple Inc. | |
7 | * | |
8 | * These coded instructions, statements, and computer programs are the | |
9 | * property of Apple Inc. and are protected by Federal copyright | |
10 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
11 | * which should have been included with this file. If this file is | |
12 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
13 | * | |
14 | * This file is subject to the Apple OS-Developed Software exception. | |
15 | */ | |
16 | ||
17 | /* | |
18 | * Include necessary headers... | |
19 | */ | |
20 | ||
21 | #include "ppd-private.h" | |
22 | #include "file-private.h" | |
23 | ||
24 | ||
25 | /* | |
26 | * 'main()' - Main entry. | |
27 | */ | |
28 | ||
29 | int /* O - Exit status */ | |
30 | main(int argc, /* I - Number of command-line args */ | |
31 | char *argv[]) /* I - Command-line arguments */ | |
32 | { | |
33 | int i; /* Looping var */ | |
34 | const char *ppdfile = NULL;/* PPD filename */ | |
35 | ppd_file_t *ppd; /* PPD file */ | |
36 | int num_options = 0;/* Number of options */ | |
37 | cups_option_t *options = NULL;/* Options */ | |
38 | _ppd_cache_t *pc; /* PPD cache and PWG mapping data */ | |
39 | int num_finishings, /* Number of finishing options */ | |
40 | finishings[20]; /* Finishing options */ | |
d489df6a MS |
41 | ppd_choice_t *ppd_bin; /* OutputBin value */ |
42 | const char *output_bin; /* output-bin value */ | |
b2b9911d MS |
43 | |
44 | if (argc < 2) | |
45 | { | |
46 | puts("Usage: ./testcache filename.ppd [name=value ... name=value]"); | |
47 | return (1); | |
48 | } | |
49 | ||
50 | ppdfile = argv[1]; | |
51 | if ((ppd = ppdOpenFile(ppdfile)) == NULL) | |
52 | { | |
53 | ppd_status_t err; /* Last error in file */ | |
54 | int line; /* Line number in file */ | |
55 | ||
56 | ||
57 | err = ppdLastError(&line); | |
58 | ||
59 | fprintf(stderr, "Unable to open \"%s\": %s on line %d\n", ppdfile, ppdErrorString(err), line); | |
60 | return (1); | |
61 | } | |
62 | ||
63 | if ((pc = _ppdCacheCreateWithPPD(ppd)) == NULL) | |
64 | { | |
65 | fprintf(stderr, "Unable to create PPD cache from \"%s\".\n", ppdfile); | |
66 | return (1); | |
67 | } | |
68 | ||
69 | for (i = 2; i < argc; i ++) | |
70 | num_options = cupsParseOptions(argv[i], num_options, &options); | |
71 | ||
72 | ppdMarkDefaults(ppd); | |
73 | cupsMarkOptions(ppd, num_options, options); | |
74 | ||
75 | num_finishings = _ppdCacheGetFinishingValues(pc, num_options, options, (int)sizeof(finishings) / sizeof(finishings[0]), finishings); | |
76 | ||
d489df6a MS |
77 | if (num_finishings > 0) |
78 | { | |
79 | fputs("finishings=", stdout); | |
80 | for (i = 0; i < num_finishings; i ++) | |
81 | if (i) | |
82 | printf(",%d", finishings[i]); | |
83 | else | |
84 | printf("%d", finishings[i]); | |
85 | fputs("\n", stdout); | |
86 | } | |
87 | ||
88 | if ((ppd_bin = ppdFindMarkedChoice(ppd, "OutputBin")) != NULL && | |
89 | (output_bin = _ppdCacheGetBin(pc, ppd_bin->choice)) != NULL) | |
90 | printf("output-bin=\"%s\"\n", output_bin); | |
b2b9911d MS |
91 | |
92 | return (0); | |
93 | } | |
94 | ||
95 | ||
96 | /* | |
97 | * End of "$Id$". | |
98 | */ |