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

Function cgi_add_variable

cgi-bin/var.c:611–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

609 */
610
611static void
612cgi_add_variable(const char *name, /* I - Variable name */
613 int element, /* I - Array element number */
614 const char *value) /* I - Variable value */
615{
616 _cgi_var_t *var; /* New variable */
617
618
619 if (name == NULL || value == NULL || element < 0 || element > 100000)
620 return;
621
622 if (form_count >= form_alloc)
623 {
624 _cgi_var_t *temp_vars; /* Temporary form pointer */
625
626
627 if (form_alloc == 0)
628 temp_vars = malloc(sizeof(_cgi_var_t) * 16);
629 else
630 temp_vars = realloc(form_vars, (size_t)(form_alloc + 16) * sizeof(_cgi_var_t));
631
632 if (!temp_vars)
633 return;
634
635 var = temp_vars + form_count;
636
637 if ((var->values = calloc((size_t)element + 1, sizeof(char *))) == NULL)
638 {
639 /*
640 * Rollback changes
641 */
642
643 if (form_alloc == 0)
644 free(temp_vars);
645 return;
646 }
647 form_vars = temp_vars;
648 form_alloc += 16;
649 }
650 else
651 {
652 var = form_vars + form_count;
653 if ((var->values = calloc((size_t)element + 1, sizeof(char *))) == NULL)
654 return;
655 }
656
657 var->name = strdup(name);
658 var->nvalues = element + 1;
659 var->avalues = element + 1;
660 var->values[element] = strdup(value);
661
662 form_count ++;
663}
664
665
666/*

Callers 2

cgiSetArrayFunction · 0.85
cgiSetVariableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected