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

Function cupsAddOption

cups/options.c:60–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

58 */
59
60int /* O - Number of options */
61cupsAddOption(const char *name, /* I - Name of option */
62 const char *value, /* I - Value of option */
63 int num_options,/* I - Number of options */
64 cups_option_t **options) /* IO - Pointer to options */
65{
66 cups_option_t *temp; /* Pointer to new option */
67 int insert, /* Insertion point */
68 diff; /* Result of search */
69
70
71 DEBUG_printf(("2cupsAddOption(name=\"%s\", value=\"%s\", num_options=%d, options=%p)", name, value, num_options, (void *)options));
72
73 if (!name || !name[0] || !value || !options || num_options < 0)
74 {
75 DEBUG_printf(("3cupsAddOption: Returning %d", num_options));
76 return (num_options);
77 }
78
79 if (!_cups_strcasecmp(name, "cupsPrintQuality"))
80 num_options = cupsRemoveOption("print-quality", num_options, options);
81 else if (!_cups_strcasecmp(name, "print-quality"))
82 num_options = cupsRemoveOption("cupsPrintQuality", num_options, options);
83
84 /*
85 * Look for an existing option with the same name...
86 */
87
88 if (num_options == 0)
89 {
90 insert = 0;
91 diff = 1;
92 }
93 else
94 {
95 insert = cups_find_option(name, num_options, *options, num_options - 1,
96 &diff);
97
98 if (diff > 0)
99 insert ++;
100 }
101
102 if (diff)
103 {
104 /*
105 * No matching option name...
106 */
107
108 DEBUG_printf(("4cupsAddOption: New option inserted at index %d...",
109 insert));
110
111 if (num_options == 0)
112 temp = (cups_option_t *)malloc(sizeof(cups_option_t));
113 else
114 temp = (cups_option_t *)realloc(*options, sizeof(cups_option_t) * (size_t)(num_options + 1));
115
116 if (!temp)
117 {

Callers 15

get_optionsFunction · 0.85
resolve_callbackFunction · 0.85
parse_optionsFunction · 0.85
mainFunction · 0.85
add_printerFunction · 0.85
apply_printer_defaultsFunction · 0.85
copy_modelFunction · 0.85
set_printer_defaultsFunction · 0.85
get_optionsFunction · 0.85
update_jobFunction · 0.85
cupsdLoadAllClassesFunction · 0.85
mainFunction · 0.85

Calls 5

_cups_strcasecmpFunction · 0.85
cupsRemoveOptionFunction · 0.85
cups_find_optionFunction · 0.85
_cupsStrAllocFunction · 0.85
_cupsStrFreeFunction · 0.85

Tested by 2

check_constraintsFunction · 0.68
mainFunction · 0.68