]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testcache.c
2 * PPD cache testing program for CUPS.
4 * Copyright 2009-2014 by Apple Inc.
6 * These coded instructions, statements, and computer programs are the
7 * property of Apple Inc. and are protected by Federal copyright
8 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
9 * which should have been included with this file. If this file is
10 * missing or damaged, see the license at "http://www.cups.org/".
12 * This file is subject to the Apple OS-Developed Software exception.
16 * Include necessary headers...
19 #include "ppd-private.h"
20 #include "file-private.h"
24 * 'main()' - Main entry.
27 int /* O - Exit status */
28 main(int argc
, /* I - Number of command-line args */
29 char *argv
[]) /* I - Command-line arguments */
31 int i
; /* Looping var */
32 const char *ppdfile
= NULL
;/* PPD filename */
33 ppd_file_t
*ppd
; /* PPD file */
34 int num_options
= 0;/* Number of options */
35 cups_option_t
*options
= NULL
;/* Options */
36 _ppd_cache_t
*pc
; /* PPD cache and PWG mapping data */
37 int num_finishings
, /* Number of finishing options */
38 finishings
[20]; /* Finishing options */
39 ppd_choice_t
*ppd_bin
; /* OutputBin value */
40 const char *output_bin
; /* output-bin value */
44 puts("Usage: ./testcache filename.ppd [name=value ... name=value]");
49 if ((ppd
= ppdOpenFile(ppdfile
)) == NULL
)
51 ppd_status_t err
; /* Last error in file */
52 int line
; /* Line number in file */
55 err
= ppdLastError(&line
);
57 fprintf(stderr
, "Unable to open \"%s\": %s on line %d\n", ppdfile
, ppdErrorString(err
), line
);
61 if ((pc
= _ppdCacheCreateWithPPD(ppd
)) == NULL
)
63 fprintf(stderr
, "Unable to create PPD cache from \"%s\".\n", ppdfile
);
67 for (i
= 2; i
< argc
; i
++)
68 num_options
= cupsParseOptions(argv
[i
], num_options
, &options
);
71 cupsMarkOptions(ppd
, num_options
, options
);
73 num_finishings
= _ppdCacheGetFinishingValues(pc
, num_options
, options
, (int)sizeof(finishings
) / sizeof(finishings
[0]), finishings
);
75 if (num_finishings
> 0)
77 fputs("finishings=", stdout
);
78 for (i
= 0; i
< num_finishings
; i
++)
80 printf(",%d", finishings
[i
]);
82 printf("%d", finishings
[i
]);
86 if ((ppd_bin
= ppdFindMarkedChoice(ppd
, "OutputBin")) != NULL
&&
87 (output_bin
= _ppdCacheGetBin(pc
, ppd_bin
->choice
)) != NULL
)
88 printf("output-bin=\"%s\"\n", output_bin
);