]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testcache.c
4 * PPD cache testing program for CUPS.
6 * Copyright 2009-2014 by Apple Inc.
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/".
14 * This file is subject to the Apple OS-Developed Software exception.
18 * Include necessary headers...
21 #include "ppd-private.h"
22 #include "file-private.h"
26 * 'main()' - Main entry.
29 int /* O - Exit status */
30 main(int argc
, /* I - Number of command-line args */
31 char *argv
[]) /* I - Command-line arguments */
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 ppd_choice_t
*ppd_bin
; /* OutputBin value */
42 const char *output_bin
; /* output-bin value */
46 puts("Usage: ./testcache filename.ppd [name=value ... name=value]");
51 if ((ppd
= ppdOpenFile(ppdfile
)) == NULL
)
53 ppd_status_t err
; /* Last error in file */
54 int line
; /* Line number in file */
57 err
= ppdLastError(&line
);
59 fprintf(stderr
, "Unable to open \"%s\": %s on line %d\n", ppdfile
, ppdErrorString(err
), line
);
63 if ((pc
= _ppdCacheCreateWithPPD(ppd
)) == NULL
)
65 fprintf(stderr
, "Unable to create PPD cache from \"%s\".\n", ppdfile
);
69 for (i
= 2; i
< argc
; i
++)
70 num_options
= cupsParseOptions(argv
[i
], num_options
, &options
);
73 cupsMarkOptions(ppd
, num_options
, options
);
75 num_finishings
= _ppdCacheGetFinishingValues(pc
, num_options
, options
, (int)sizeof(finishings
) / sizeof(finishings
[0]), finishings
);
77 if (num_finishings
> 0)
79 fputs("finishings=", stdout
);
80 for (i
= 0; i
< num_finishings
; i
++)
82 printf(",%d", finishings
[i
]);
84 printf("%d", finishings
[i
]);
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
);