]>
git.ipfire.org Git - thirdparty/cups.git/blob - cups/testcache.c
2 * PPD cache testing program for CUPS.
4 * Copyright 2009-2018 by Apple Inc.
6 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
10 * Include necessary headers...
13 #include "ppd-private.h"
14 #include "file-private.h"
18 * 'main()' - Main entry.
21 int /* O - Exit status */
22 main(int argc
, /* I - Number of command-line args */
23 char *argv
[]) /* I - Command-line arguments */
25 int i
; /* Looping var */
26 const char *ppdfile
= NULL
;/* PPD filename */
27 ppd_file_t
*ppd
; /* PPD file */
28 int num_options
= 0;/* Number of options */
29 cups_option_t
*options
= NULL
;/* Options */
30 _ppd_cache_t
*pc
; /* PPD cache and PWG mapping data */
31 int num_finishings
, /* Number of finishing options */
32 finishings
[20]; /* Finishing options */
33 ppd_choice_t
*ppd_bin
; /* OutputBin value */
34 const char *output_bin
; /* output-bin value */
38 puts("Usage: ./testcache filename.ppd [name=value ... name=value]");
43 if ((ppd
= ppdOpenFile(ppdfile
)) == NULL
)
45 ppd_status_t err
; /* Last error in file */
46 int line
; /* Line number in file */
49 err
= ppdLastError(&line
);
51 fprintf(stderr
, "Unable to open \"%s\": %s on line %d\n", ppdfile
, ppdErrorString(err
), line
);
55 if ((pc
= _ppdCacheCreateWithPPD(ppd
)) == NULL
)
57 fprintf(stderr
, "Unable to create PPD cache from \"%s\".\n", ppdfile
);
61 for (i
= 2; i
< argc
; i
++)
62 num_options
= cupsParseOptions(argv
[i
], num_options
, &options
);
65 cupsMarkOptions(ppd
, num_options
, options
);
67 num_finishings
= _ppdCacheGetFinishingValues(ppd
, pc
, (int)sizeof(finishings
) / sizeof(finishings
[0]), finishings
);
69 if (num_finishings
> 0)
71 fputs("finishings=", stdout
);
72 for (i
= 0; i
< num_finishings
; i
++)
74 printf(",%d", finishings
[i
]);
76 printf("%d", finishings
[i
]);
80 if ((ppd_bin
= ppdFindMarkedChoice(ppd
, "OutputBin")) != NULL
&&
81 (output_bin
= _ppdCacheGetBin(pc
, ppd_bin
->choice
)) != NULL
)
82 printf("output-bin=\"%s\"\n", output_bin
);