MCPcopy Create free account
hub / github.com/OpenPrinting/cups / main

Function main

cups/testconflicts.c:23–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21 */
22
23int /* O - Exit status */
24main(int argc, /* I - Number of command-line arguments */
25 char *argv[]) /* I - Command-line arguments */
26{
27 int i; /* Looping var */
28 ppd_file_t *ppd; /* PPD file loaded from disk */
29 char line[256], /* Input buffer */
30 *ptr, /* Pointer into buffer */
31 *optr, /* Pointer to first option name */
32 *cptr; /* Pointer to first choice */
33 int num_options; /* Number of options */
34 cups_option_t *options; /* Options */
35 char *option, /* Current option */
36 *choice; /* Current choice */
37
38
39 if (argc != 2)
40 {
41 puts("Usage: testconflicts filename.ppd");
42 return (1);
43 }
44
45 if ((ppd = ppdOpenFile(argv[1])) == NULL)
46 {
47 ppd_status_t err; /* Last error in file */
48 int linenum; /* Line number in file */
49
50 err = ppdLastError(&linenum);
51
52 printf("Unable to open PPD file \"%s\": %s on line %d\n", argv[1],
53 ppdErrorString(err), linenum);
54 return (1);
55 }
56
57 ppdMarkDefaults(ppd);
58
59 option = NULL;
60 choice = NULL;
61
62 for (;;)
63 {
64 num_options = 0;
65 options = NULL;
66
67 if (!cupsResolveConflicts(ppd, option, choice, &num_options, &options))
68 puts("Unable to resolve conflicts!");
69 else if ((!option && num_options > 0) || (option && num_options > 1))
70 {
71 fputs("Resolved conflicts with the following options:\n ", stdout);
72 for (i = 0; i < num_options; i ++)
73 if (!option || _cups_strcasecmp(option, options[i].name))
74 printf(" %s=%s", options[i].name, options[i].value);
75 putchar('\n');
76
77 cupsFreeOptions(num_options, options);
78 }
79
80 if (option)

Callers

nothing calls this directly

Calls 10

ppdOpenFileFunction · 0.85
ppdLastErrorFunction · 0.85
ppdErrorStringFunction · 0.85
ppdMarkDefaultsFunction · 0.85
cupsResolveConflictsFunction · 0.85
_cups_strcasecmpFunction · 0.85
cupsFreeOptionsFunction · 0.85
cupsParseOptionsFunction · 0.85
ppdMarkOptionFunction · 0.85
cupsMarkOptionsFunction · 0.85

Tested by

no test coverage detected