attr = ippAddStrings(request, IPP_TAG_PRINTER, IPP_TAG_URI, "member-uris",
num_printers, NULL, NULL);
for (i = 0; i < num_printers; i ++)
- attr->values[i].string.text = _cupsStrAlloc(cgiGetArray("MEMBER_URIS", i));
+ ippSetString(request, &attr, i, cgiGetArray("MEMBER_URIS", i));
}
/*
attr;
attr = ippFindNextAttribute(response, "device-uri", IPP_TAG_URI))
{
- cupsArrayAdd(printer_devices, _cupsStrAlloc(attr->values[0].string.text));
+ cupsArrayAdd(printer_devices, strdup(attr->values[0].string.text));
}
/*
for (printer_device = (char *)cupsArrayFirst(printer_devices);
printer_device;
printer_device = (char *)cupsArrayNext(printer_devices))
- _cupsStrFree(printer_device);
+ free(printer_device);
cupsArrayDelete(printer_devices);
}
* Add the name...
*/
- attr->values[i].string.text = _cupsStrAlloc(ptr);
+ ippSetString(request, &attr, i, ptr);
/*
* Advance to the next name...
attr = ippAddStrings(request, IPP_TAG_PRINTER, IPP_TAG_NAME,
"job-sheets-default", 2, NULL, NULL);
- attr->values[0].string.text = _cupsStrAlloc(cgiGetVariable("job_sheets_start"));
- attr->values[1].string.text = _cupsStrAlloc(cgiGetVariable("job_sheets_end"));
+ ippSetString(request, &attr, 0, cgiGetVariable("job_sheets_start"));
+ ippSetString(request, &attr, 1, cgiGetVariable("job_sheets_end"));
if ((var = cgiGetVariable("printer_error_policy")) != NULL)
ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_NAME,
/*
* CGI form variable and array functions for CUPS.
*
- * Copyright 2007-2015 by Apple Inc.
- * Copyright 1997-2005 by Easy Software Products.
+ * Copyright © 2007-2019 by Apple Inc.
+ * Copyright © 1997-2005 by Easy Software Products.
*
* Licensed under Apache License v2.0. See the file "LICENSE" for more information.
*/
typedef struct /**** Form variable structure ****/
{
- const char *name; /* Name of variable */
+ char *name; /* Name of variable */
int nvalues, /* Number of values */
avalues; /* Number of values allocated */
- const char **values; /* Value(s) of variable */
+ char **values; /* Value(s) of variable */
} _cgi_var_t;
for (v = form_vars, i = form_count; i > 0; v ++, i --)
{
- _cupsStrFree(v->name);
+ free(v->name);
for (j = 0; j < v->nvalues; j ++)
if (v->values[j])
- _cupsStrFree(v->values[j]);
+ free(v->values[j]);
}
form_count = 0;
if (element < 0 || element >= var->nvalues)
return (NULL);
- return (_cupsStrRetain(var->values[element]));
+ return (strdup(var->values[element]));
}
var = cgi_find_variable(name);
- return ((var == NULL) ? NULL : _cupsStrRetain(var->values[var->nvalues - 1]));
+ return ((var == NULL) ? NULL : strdup(var->values[var->nvalues - 1]));
}
{
if (element >= var->avalues)
{
- const char **temp; /* Temporary pointer */
+ char **temp; /* Temporary pointer */
- temp = (const char **)realloc((void *)(var->values),
- sizeof(char *) * (size_t)(element + 16));
+ temp = (char **)realloc((void *)(var->values), sizeof(char *) * (size_t)(element + 16));
if (!temp)
return;
var->nvalues = element + 1;
}
else if (var->values[element])
- _cupsStrFree((char *)var->values[element]);
+ free((char *)var->values[element]);
- var->values[element] = _cupsStrAlloc(value);
+ var->values[element] = strdup(value);
}
}
if (size >= var->avalues)
{
- const char **temp; /* Temporary pointer */
+ char **temp; /* Temporary pointer */
- temp = (const char **)realloc((void *)(var->values),
- sizeof(char *) * (size_t)(size + 16));
+ temp = (char **)realloc((void *)(var->values), sizeof(char *) * (size_t)(size + 16));
if (!temp)
return;
{
for (i = size; i < var->nvalues; i ++)
if (var->values[i])
- _cupsStrFree((void *)(var->values[i]));
+ free((void *)(var->values[i]));
}
var->nvalues = size;
{
for (i = 0; i < var->nvalues; i ++)
if (var->values[i])
- _cupsStrFree((char *)var->values[i]);
+ free((char *)var->values[i]);
- var->values[0] = _cupsStrAlloc(value);
+ var->values[0] = strdup(value);
var->nvalues = 1;
}
}
if ((var->values = calloc((size_t)element + 1, sizeof(char *))) == NULL)
return;
- var->name = _cupsStrAlloc(name);
+ var->name = strdup(name);
var->nvalues = element + 1;
var->avalues = element + 1;
- var->values[element] = _cupsStrAlloc(value);
+ var->values[element] = strdup(value);
form_count ++;
}
if (form_count < 1 || name == NULL)
return (NULL);
- key.name = name;
+ key.name = (char *)name;
return ((_cgi_var_t *)bsearch(&key, form_vars, (size_t)form_count, sizeof(_cgi_var_t),
(int (*)(const void *, const void *))cgi_compare_variables));
/*
* String functions for CUPS.
*
- * Copyright 2007-2014 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright © 2007-2019 by Apple Inc.
+ * Copyright © 1997-2007 by Easy Software Products.
*
- * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more
+ * information.
*/
/*
key = (_cups_sp_item_t *)(s - offsetof(_cups_sp_item_t, str));
-#ifdef DEBUG_GUARDS
- if (key->guard != _CUPS_STR_GUARD)
- {
- DEBUG_printf(("5_cupsStrFree: Freeing string %p(%s), guard=%08x, "
- "ref_count=%d", key, key->str, key->guard, key->ref_count));
- abort();
- }
-#endif /* DEBUG_GUARDS */
-
if ((item = (_cups_sp_item_t *)cupsArrayFind(stringpool, key)) != NULL &&
item == key)
{
* Found it, dereference...
*/
+#ifdef DEBUG_GUARDS
+ if (key->guard != _CUPS_STR_GUARD)
+ {
+ DEBUG_printf(("5_cupsStrFree: Freeing string %p(%s), guard=%08x, ref_count=%d", key, key->str, key->guard, key->ref_count));
+ abort();
+ }
+#endif /* DEBUG_GUARDS */
+
item->ref_count --;
if (!item->ref_count)
if (!strcmp(attr->values[i].string.text, "none"))
continue;
- printer->reasons[printer->num_reasons] =
- _cupsStrRetain(attr->values[i].string.text);
+ printer->reasons[printer->num_reasons] = _cupsStrAlloc(attr->values[i].string.text);
printer->num_reasons ++;
if (!strcmp(attr->values[i].string.text, "paused") &&
if ((p2_uri = ippFindAttribute(p2->attrs, "printer-uri-supported", IPP_TAG_URI)) != NULL)
{
- member_uris->values[i].string.text = _cupsStrRetain(p2_uri->values[0].string.text);
+ member_uris->values[i].string.text = _cupsStrAlloc(p2_uri->values[0].string.text);
}
else
{