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

Function cupsRemoveOption

cups/options.c:483–537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481 */
482
483int /* O - New number of options */
484cupsRemoveOption(
485 const char *name, /* I - Option name */
486 int num_options, /* I - Current number of options */
487 cups_option_t **options) /* IO - Options */
488{
489 int i; /* Looping var */
490 cups_option_t *option; /* Current option */
491
492
493 DEBUG_printf(("2cupsRemoveOption(name=\"%s\", num_options=%d, options=%p)", name, num_options, (void *)options));
494
495 /*
496 * Range check input...
497 */
498
499 if (!name || num_options < 1 || !options)
500 {
501 DEBUG_printf(("3cupsRemoveOption: Returning %d", num_options));
502 return (num_options);
503 }
504
505 /*
506 * Loop for the option...
507 */
508
509 for (i = num_options, option = *options; i > 0; i --, option ++)
510 if (!_cups_strcasecmp(name, option->name))
511 break;
512
513 if (i)
514 {
515 /*
516 * Remove this option from the array...
517 */
518
519 DEBUG_puts("4cupsRemoveOption: Found option, removing it...");
520
521 num_options --;
522 i --;
523
524 _cupsStrFree(option->name);
525 _cupsStrFree(option->value);
526
527 if (i > 0)
528 memmove(option, option + 1, (size_t)i * sizeof(cups_option_t));
529 }
530
531 /*
532 * Return the new number of options...
533 */
534
535 DEBUG_printf(("3cupsRemoveOption: Returning %d", num_options));
536 return (num_options);
537}
538
539
540/*

Callers 5

set_printer_defaultsFunction · 0.85
new_requestFunction · 0.85
mainFunction · 0.85
cupsAddOptionFunction · 0.85
cupsResolveConflictsFunction · 0.85

Calls 2

_cups_strcasecmpFunction · 0.85
_cupsStrFreeFunction · 0.85

Tested by

no test coverage detected