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

Function cgiSetArray

cgi-bin/var.c:445–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443 */
444
445void
446cgiSetArray(const char *name, /* I - Name of variable */
447 int element, /* I - Element number (0 to N) */
448 const char *value) /* I - Value of variable */
449{
450 int i; /* Looping var */
451 _cgi_var_t *var; /* Returned variable */
452
453
454 if (name == NULL || value == NULL || element < 0 || element > 100000)
455 return;
456
457 fprintf(stderr, "DEBUG: cgiSetArray: %s[%d]=\"%s\"\n", name, element, value);
458
459 if ((var = cgi_find_variable(name)) == NULL)
460 {
461 cgi_add_variable(name, element, value);
462 cgi_sort_variables();
463 }
464 else
465 {
466 if (element >= var->avalues)
467 {
468 char **temp; /* Temporary pointer */
469
470 temp = (char **)realloc((void *)(var->values), sizeof(char *) * (size_t)(element + 16));
471 if (!temp)
472 return;
473
474 var->avalues = element + 16;
475 var->values = temp;
476 }
477
478 if (element >= var->nvalues)
479 {
480 for (i = var->nvalues; i < element; i ++)
481 var->values[i] = NULL;
482
483 var->nvalues = element + 1;
484 }
485 else if (var->values[element])
486 free((char *)var->values[element]);
487
488 var->values[element] = strdup(value);
489 }
490}
491
492
493/*

Callers 10

mainFunction · 0.85
cgiMoveJobsFunction · 0.85
cgiSetIPPObjectVarsFunction · 0.85
cgi_initialize_multipartFunction · 0.85
cgi_initialize_stringFunction · 0.85
choose_device_cbFunction · 0.85
do_am_classFunction · 0.85
do_am_printerFunction · 0.85
do_list_printersFunction · 0.85
do_set_optionsFunction · 0.85

Calls 3

cgi_find_variableFunction · 0.85
cgi_add_variableFunction · 0.85
cgi_sort_variablesFunction · 0.85

Tested by

no test coverage detected