]>
Commit | Line | Data |
---|---|---|
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 */ | |
41 | ||
42 | ||
43 | if (argc < 2) | |
44 | { | |
45 | puts("Usage: ./testcache filename.ppd [name=value ... name=value]"); | |
46 | return (1); | |
47 | } | |
48 | ||
49 | ppdfile = argv[1]; | |
50 | if ((ppd = ppdOpenFile(ppdfile)) == NULL) | |
51 | { | |
52 | ppd_status_t err; /* Last error in file */ | |
53 | int line; /* Line number in file */ | |
54 | ||
55 | ||
56 | err = ppdLastError(&line); | |
57 | ||
58 | fprintf(stderr, "Unable to open \"%s\": %s on line %d\n", ppdfile, ppdErrorString(err), line); | |
59 | return (1); | |
60 | } | |
61 | ||
62 | if ((pc = _ppdCacheCreateWithPPD(ppd)) == NULL) | |
63 | { | |
64 | fprintf(stderr, "Unable to create PPD cache from \"%s\".\n", ppdfile); | |
65 | return (1); | |
66 | } | |
67 | ||
68 | for (i = 2; i < argc; i ++) | |
69 | num_options = cupsParseOptions(argv[i], num_options, &options); | |
70 | ||
71 | ppdMarkDefaults(ppd); | |
72 | cupsMarkOptions(ppd, num_options, options); | |
73 | ||
74 | num_finishings = _ppdCacheGetFinishingValues(pc, num_options, options, (int)sizeof(finishings) / sizeof(finishings[0]), finishings); | |
75 | ||
76 | fputs("finishings=", stdout); | |
77 | for (i = 0; i < num_finishings; i ++) | |
78 | if (i) | |
79 | printf(",%d", finishings[i]); | |
80 | else | |
81 | printf("%d", finishings[i]); | |
82 | fputs("\n", stdout); | |
83 | ||
84 | return (0); | |
85 | } | |
86 | ||
87 | ||
88 | /* | |
89 | * End of "$Id$". | |
90 | */ |