* Extract the scheme from the URI...
*/
- strlcpy(scheme, resolved_uri, sizeof(scheme));
+ cupsCopyString(scheme, resolved_uri, sizeof(scheme));
if ((ptr = strchr(scheme, ':')) != NULL)
*ptr = '\0';
make_and_model[0] = '\0';
pdl[0] = '\0';
- strlcpy(model, "Unknown", sizeof(model));
+ cupsCopyString(model, "Unknown", sizeof(model));
for (data = rdata, dataend = data + rdlen;
data < dataend;
if (!_cups_strcasecmp(key, "usb_MFG") || !_cups_strcasecmp(key, "usb_MANU") ||
!_cups_strcasecmp(key, "usb_MANUFACTURER"))
- strlcpy(make_and_model, value, sizeof(make_and_model));
+ cupsCopyString(make_and_model, value, sizeof(make_and_model));
else if (!_cups_strcasecmp(key, "usb_MDL") || !_cups_strcasecmp(key, "usb_MODEL"))
- strlcpy(model, value, sizeof(model));
+ cupsCopyString(model, value, sizeof(model));
else if (!_cups_strcasecmp(key, "product") && !strstr(value, "Ghostscript"))
{
if (value[0] == '(')
if ((ptr = value + strlen(value) - 1) > value && *ptr == ')')
*ptr = '\0';
- strlcpy(model, value + 1, sizeof(model));
+ cupsCopyString(model, value + 1, sizeof(model));
}
else
- strlcpy(model, value, sizeof(model));
+ cupsCopyString(model, value, sizeof(model));
}
else if (!_cups_strcasecmp(key, "ty"))
{
- strlcpy(model, value, sizeof(model));
+ cupsCopyString(model, value, sizeof(model));
if ((ptr = strchr(model, ',')) != NULL)
*ptr = '\0';
}
else if (!_cups_strcasecmp(key, "pdl"))
- strlcpy(pdl, value, sizeof(pdl));
+ cupsCopyString(pdl, value, sizeof(pdl));
else if (!_cups_strcasecmp(key, "priority"))
device->priority = atoi(value);
else if ((device->type == CUPS_DEVICE_IPP ||
{
value[0] = '\0';
if (strstr(pdl, "application/pdf"))
- strlcat(value, ",PDF", sizeof(value));
+ cupsConcatString(value, ",PDF", sizeof(value));
if (strstr(pdl, "application/postscript"))
- strlcat(value, ",PS", sizeof(value));
+ cupsConcatString(value, ",PS", sizeof(value));
if (strstr(pdl, "application/vnd.hp-PCL"))
- strlcat(value, ",PCL", sizeof(value));
+ cupsConcatString(value, ",PCL", sizeof(value));
for (ptr = strstr(pdl, "image/"); ptr; ptr = strstr(ptr, "image/"))
{
char *valptr = value + strlen(value);
if (make_and_model[0])
{
- strlcat(make_and_model, " ", sizeof(make_and_model));
- strlcat(make_and_model, model, sizeof(make_and_model));
+ cupsConcatString(make_and_model, " ", sizeof(make_and_model));
+ cupsConcatString(make_and_model, model, sizeof(make_and_model));
if (!_cups_strncasecmp(make_and_model, "EPSON EPSON ", 12))
_cups_strcpy(make_and_model, make_and_model + 6);
}
else
{
- strlcpy(temp, make_model, sizeof(temp));
+ cupsCopyString(temp, make_model, sizeof(temp));
if ((tempptr = strchr(temp, ' ')) != NULL)
*tempptr = '\0';
* Use "Unknown" as the printer make and model...
*/
- strlcpy(make_model, "Unknown", make_model_size);
+ cupsCopyString(make_model, "Unknown", make_model_size);
}
cupsFreeOptions(num_values, values);
if (ptr)
{
- strlcpy(username, ptr, sizeof(username));
+ cupsCopyString(username, ptr, sizeof(username));
cupsSetUser(ptr);
}
cupsMarkOptions(ppd, num_options, options);
if ((mandatory = ppdFindAttr(ppd, "cupsMandatory", NULL)) != NULL)
- strlcpy(mandatory_attrs, mandatory->value, sizeof(mandatory_attrs));
+ cupsCopyString(mandatory_attrs, mandatory->value, sizeof(mandatory_attrs));
}
/*
}
if (!strcmp(name, "job-password"))
- strlcpy(buffer, "---", sizeof(buffer));
+ cupsCopyString(buffer, "---", sizeof(buffer));
else
ippAttributeString(attr, buffer, sizeof(buffer));
if (i)
snprintf(valptr, sizeof(value) - (size_t)(valptr - value), " %s", ippGetString(pmja, i, NULL));
else
- strlcpy(value, ippGetString(pmja, i, NULL), sizeof(value));
+ cupsCopyString(value, ippGetString(pmja, i, NULL), sizeof(value));
}
if (strcmp(value, mandatory_attrs))
{
- strlcpy(mandatory_attrs, value, sizeof(mandatory_attrs));
+ cupsCopyString(mandatory_attrs, value, sizeof(mandatory_attrs));
fprintf(stderr, "PPD: cupsMandatory=\"%s\"\n", value);
}
}
char *ptr; /* Pointer into message */
- strlcpy(value, "INFO: ", sizeof(value));
+ cupsCopyString(value, "INFO: ", sizeof(value));
for (ptr = psm->values[0].string.text, valptr = value + 6;
*ptr && valptr < (value + sizeof(value) - 6);
ptr ++)
* If no username is in the device URI, then use the print job user...
*/
- strlcpy(username, argv[2], sizeof(username));
+ cupsCopyString(username, argv[2], sizeof(username));
}
/*
* Sanitize the document title...
*/
- strlcpy(title, argv[3], sizeof(title));
+ cupsCopyString(title, argv[3], sizeof(title));
if (sanitize_title)
{
}
if (orighost && _cups_strcasecmp(orighost, "localhost"))
- strlcpy(localhost, orighost, sizeof(localhost));
+ cupsCopyString(localhost, orighost, sizeof(localhost));
else
httpGetHostname(NULL, localhost, sizeof(localhost));
for (dataptr = data + strlen(data) + 1;
count > 0 && dataptr < (data + sizeof(data) - 1);
count --, dataptr += strlen(dataptr))
- strlcpy(dataptr, snmp_value, sizeof(data) - (size_t)(dataptr - data));
+ cupsCopyString(dataptr, snmp_value, sizeof(data) - (size_t)(dataptr - data));
fprintf(stderr, "DEBUG: Returning %s %s\n", data,
data + strlen(data) + 1);
if (_cupsSNMPRead(snmp_fd, &packet, 1.0) &&
packet.object_type == CUPS_ASN1_OCTET_STRING)
{
- strlcpy(data, (char *)packet.object_value.string.bytes,
+ cupsCopyString(data, (char *)packet.object_value.string.bytes,
sizeof(data));
datalen = (int)strlen(data);
status = CUPS_SC_STATUS_OK;
if ((device_id = getenv("1284DEVICEID")) != NULL)
{
- strlcpy(data, device_id, sizeof(data));
+ cupsCopyString(data, device_id, sizeof(data));
datalen = (int)strlen(data);
status = CUPS_SC_STATUS_OK;
break;
supplies[i].level >= 0)
snprintf(ptr, sizeof(value) - (size_t)(ptr - value), "%d", percent);
else
- strlcpy(ptr, "-1", sizeof(value) - (size_t)(ptr - value));
+ cupsCopyString(ptr, "-1", sizeof(value) - (size_t)(ptr - value));
}
fprintf(stderr, "ATTR: marker-levels=%s\n", value);
if (!_cupsSNMPRead(snmp_fd, &packet, CUPS_SUPPLY_TIMEOUT) ||
packet.object_type != CUPS_ASN1_OCTET_STRING)
{
- strlcpy(description, "Unknown", sizeof(description));
+ cupsCopyString(description, "Unknown", sizeof(description));
num_supplies = 0;
}
else
- strlcpy(description, (char *)packet.object_value.string.bytes,
+ cupsCopyString(description, (char *)packet.object_value.string.bytes,
sizeof(description));
fprintf(stderr, "DEBUG2: hrDeviceDesc=\"%s\"\n", description);
*/
for (i = 0; i < num_supplies; i ++)
- strlcpy(supplies[i].color, "none", sizeof(supplies[i].color));
+ cupsCopyString(supplies[i].color, "none", sizeof(supplies[i].color));
_cupsSNMPWalk(snmp_fd, ¤t_addr, CUPS_SNMP_VERSION_1,
community, prtMarkerColorantValue,
if (i)
*ptr++ = ',';
- strlcpy(ptr, supplies[i].color, sizeof(value) - (size_t)(ptr - value));
+ cupsCopyString(ptr, supplies[i].color, sizeof(value) - (size_t)(ptr - value));
}
fprintf(stderr, "ATTR: marker-colors=%s\n", value);
type = supplies[i].type;
if (type < CUPS_TC_other || type > CUPS_TC_covers)
- strlcpy(ptr, "unknown", sizeof(value) - (size_t)(ptr - value));
+ cupsCopyString(ptr, "unknown", sizeof(value) - (size_t)(ptr - value));
else
- strlcpy(ptr, types[type - CUPS_TC_other], sizeof(value) - (size_t)(ptr - value));
+ cupsCopyString(ptr, types[type - CUPS_TC_other], sizeof(value) - (size_t)(ptr - value));
}
fprintf(stderr, "ATTR: marker-types=%s\n", value);
if (!_cups_strcasecmp(colors[k][0],
(char *)packet->object_value.string.bytes))
{
- strlcpy(supplies[j].color, colors[k][1], sizeof(supplies[j].color));
+ cupsCopyString(supplies[j].color, colors[k][1], sizeof(supplies[j].color));
break;
}
}
case CUPS_TC_csASCII :
case CUPS_TC_csUTF8 :
case CUPS_TC_csUnicodeASCII :
- strlcpy(supplies[i - 1].name,
+ cupsCopyString(supplies[i - 1].name,
(char *)packet->object_value.string.bytes,
sizeof(supplies[0].name));
break;
make_model[0] = 'H';
make_model[1] = 'P';
make_model[2] = ' ';
- strlcpy(make_model + 3, mmptr, (size_t)make_model_size - 3);
+ cupsCopyString(make_model + 3, mmptr, (size_t)make_model_size - 3);
}
else if (!_cups_strncasecmp(old_make_model, "deskjet", 7))
snprintf(make_model, (size_t)make_model_size, "HP DeskJet%s", old_make_model + 7);
else if (!_cups_strncasecmp(old_make_model, "stylus_pro_", 11))
snprintf(make_model, (size_t)make_model_size, "EPSON Stylus Pro %s", old_make_model + 11);
else
- strlcpy(make_model, old_make_model, (size_t)make_model_size);
+ cupsCopyString(make_model, old_make_model, (size_t)make_model_size);
if ((mmptr = strstr(make_model, ", Inc.,")) != NULL)
{
* Insert hostname/address...
*/
- strlcpy(uriptr, device->addrname, sizeof(uri) - (size_t)(uriptr - uri));
+ cupsCopyString(uriptr, device->addrname, sizeof(uri) - (size_t)(uriptr - uri));
uriptr += strlen(uriptr);
format += 2;
}
{
char ifname[255]; /* Interface name */
- strlcpy(ifname, address + 4, sizeof(ifname));
+ cupsCopyString(ifname, address + 4, sizeof(ifname));
if (ifname[0])
ifname[strlen(ifname) - 1] = '\0';
if (getcwd(libpath, sizeof(libpath)) &&
(ptr = strrchr(libpath, '/')) != NULL && !strcmp(ptr, "/backend"))
{
- strlcpy(ptr, "/cups", sizeof(libpath) - (size_t)(ptr - libpath));
+ cupsCopyString(ptr, "/cups", sizeof(libpath) - (size_t)(ptr - libpath));
if (!access(libpath, 0))
{
#ifdef __APPLE__
}
if (!access(scheme, X_OK))
- strlcpy(backend, scheme, sizeof(backend));
+ cupsCopyString(backend, scheme, sizeof(backend));
else
{
if ((serverbin = getenv("CUPS_SERVERBIN")) == NULL)
*/
if (driverBundlePath == NULL || !CFStringGetCString(driverBundlePath, print_buffer, sizeof(print_buffer), kCFStringEncodingUTF8))
- strlcpy(print_buffer, "USB class driver", sizeof(print_buffer));
+ cupsCopyString(print_buffer, "USB class driver", sizeof(print_buffer));
fputs("STATE: +apple-missing-usbclassdriver-error\n", stderr);
_cupsLangPrintFilter(stderr, "ERROR",
modelstr[0] = '/';
if (make == NULL || !CFStringGetCString(make, makestr, sizeof(makestr), kCFStringEncodingUTF8))
- strlcpy(makestr, "Unknown", sizeof(makestr));
+ cupsCopyString(makestr, "Unknown", sizeof(makestr));
if (model == NULL || !CFStringGetCString(model, &modelstr[1], sizeof(modelstr)-1, kCFStringEncodingUTF8))
- strlcpy(modelstr + 1, "Printer", sizeof(modelstr) - 1);
+ cupsCopyString(modelstr + 1, "Printer", sizeof(modelstr) - 1);
optionsstr[0] = '\0';
if (serial != NULL && CFStringGetCString(serial, serialstr, sizeof(serialstr), kCFStringEncodingUTF8))
snprintf(optionsstr, sizeof(optionsstr), "?location=%x", (unsigned)intfLocation);
httpAssembleURI(HTTP_URI_CODING_ALL, uristr, sizeof(uristr), "usb", NULL, makestr, 0, modelstr);
- strlcat(uristr, optionsstr, sizeof(uristr));
+ cupsConcatString(uristr, optionsstr, sizeof(uristr));
cupsBackendReport("direct", uristr, make_modelstr, make_modelstr, idstr,
NULL);
value);
}
else if (!_cups_strcasecmp(name, "serial"))
- strlcpy(serial, value, (size_t)serial_size);
+ cupsCopyString(serial, value, (size_t)serial_size);
else if (!_cups_strcasecmp(name, "location") && location)
*location = (UInt32)strtoul(value, NULL, 16);
}
}
/* move everything over... */
- strlcpy(gErrorBuffer, pLineEnd, sizeof(gErrorBuffer));
+ cupsCopyString(gErrorBuffer, pLineEnd, sizeof(gErrorBuffer));
gErrorBufferPtr = gErrorBuffer;
pLineEnd = (char *)next_line((const char *)gErrorBuffer);
}
*/
if (backendGetMakeModel(device_id, make_model, sizeof(make_model)))
- strlcpy(make_model, "Unknown", sizeof(make_model));
+ cupsCopyString(make_model, "Unknown", sizeof(make_model));
/*
* Report the printer...
(des = cupsGetOption("DES", num_values, values)) != NULL)
_ppdNormalizeMakeAndModel(des, tempmfg, sizeof(tempmfg));
else
- strlcpy(tempmfg, "Unknown", sizeof(tempmfg));
+ cupsCopyString(tempmfg, "Unknown", sizeof(tempmfg));
if ((tempptr = strchr(tempmfg, ' ')) != NULL)
*tempptr = '\0';
* Work on copies of the URIs...
*/
- strlcpy(requested_uri, (char *)data, sizeof(requested_uri));
- strlcpy(detected_uri, device_uri, sizeof(detected_uri));
+ cupsCopyString(requested_uri, (char *)data, sizeof(requested_uri));
+ cupsCopyString(detected_uri, device_uri, sizeof(detected_uri));
/*
* libusb-discovered URIs can have an "interface" specification and this
*/
if (jobstate == IPP_JOB_PROCESSING)
- strlcpy(rankstr, "active", sizeof(rankstr));
+ cupsCopyString(rankstr, "active", sizeof(rankstr));
else
{
/*
snprintf(namestr, sizeof(namestr), "%d copies of %s", jobcopies,
jobname);
else
- strlcpy(namestr, jobname, sizeof(namestr));
+ cupsCopyString(namestr, jobname, sizeof(namestr));
_cupsLangPrintf(stdout, _("%s: %-33.33s [job %d localhost]"),
jobuser, rankstr, jobid);
*uriptr++ = '\0';
- strlcpy(make, uriptr, sizeof(make));
+ cupsCopyString(make, uriptr, sizeof(make));
if ((makeptr = strchr(make, ' ')) != NULL)
*makeptr = '\0';
else if (!_cups_strncasecmp(make, "laserjet", 8) ||
!_cups_strncasecmp(make, "deskjet", 7) ||
!_cups_strncasecmp(make, "designjet", 9))
- strlcpy(make, "HP", sizeof(make));
+ cupsCopyString(make, "HP", sizeof(make));
else if (!_cups_strncasecmp(make, "phaser", 6))
- strlcpy(make, "Xerox", sizeof(make));
+ cupsCopyString(make, "Xerox", sizeof(make));
else if (!_cups_strncasecmp(make, "stylus", 6))
- strlcpy(make, "Epson", sizeof(make));
+ cupsCopyString(make, "Epson", sizeof(make));
else
- strlcpy(make, "Generic", sizeof(make));
+ cupsCopyString(make, "Generic", sizeof(make));
if (!cgiGetVariable("CURRENT_MAKE"))
cgiSetVariable("CURRENT_MAKE", make);
if ((attr = ippFindAttribute(oldinfo, "device-uri", IPP_TAG_URI)) != NULL)
{
- strlcpy(uri, attr->values[0].string.text, sizeof(uri));
+ cupsCopyString(uri, attr->values[0].string.text, sizeof(uri));
if ((uriptr = strchr(uri, ':')) != NULL && strncmp(uriptr, "://", 3) == 0)
*uriptr = '\0';
ippAddString(request, IPP_TAG_PRINTER, IPP_TAG_TEXT, "printer-info",
NULL, cgiGetVariable("PRINTER_INFO"));
- strlcpy(uri, cgiGetVariable("DEVICE_URI"), sizeof(uri));
+ cupsCopyString(uri, cgiGetVariable("DEVICE_URI"), sizeof(uri));
/*
* Strip make and model from URI...
*/
if (cgiGetVariable("KERBEROS"))
- strlcpy(default_auth_type, "Negotiate", sizeof(default_auth_type));
+ cupsCopyString(default_auth_type, "Negotiate", sizeof(default_auth_type));
else
{
val = cupsGetOption("DefaultAuthType", num_settings, settings);
if (!val || !_cups_strcasecmp(val, "Negotiate"))
- strlcpy(default_auth_type, "Basic", sizeof(default_auth_type));
+ cupsCopyString(default_auth_type, "Basic", sizeof(default_auth_type));
else
- strlcpy(default_auth_type, val, sizeof(default_auth_type));
+ cupsCopyString(default_auth_type, val, sizeof(default_auth_type));
}
fprintf(stderr, "DEBUG: DefaultAuthType %s\n", default_auth_type);
* well...
*/
- strlcat(filename, ".default", sizeof(filename));
+ cupsConcatString(filename, ".default", sizeof(filename));
if (!stat(filename, &info) && info.st_size < (1024 * 1024) &&
(cupsd = cupsFileOpen(filename, "r")) != NULL)
* Get default option name...
*/
- strlcpy(keyword, line + 8, sizeof(keyword));
+ cupsCopyString(keyword, line + 8, sizeof(keyword));
for (keyptr = keyword; *keyptr; keyptr ++)
if (*keyptr == ':' || isspace(*keyptr & 255))
* Not a custom choice...
*/
- strlcpy(buffer, val, bufsize);
+ cupsCopyString(buffer, val, bufsize);
return (buffer);
}
*ptr++ = '\0';
- strlcpy(section, sectptr, sizeof(section));
+ cupsCopyString(section, sectptr, sizeof(section));
while (isspace(*ptr & 255))
ptr ++;
if (relative)
snprintf(relname, sizeof(relname), "%s/%s", relative, dent->filename);
else
- strlcpy(relname, dent->filename, sizeof(relname));
+ cupsCopyString(relname, dent->filename, sizeof(relname));
/*
* Check if we have a HTML file...
node = NULL;
offset = 0;
- strlcpy(section, "Other", sizeof(section));
+ cupsCopyString(section, "Other", sizeof(section));
while (cupsFileGets(fp, line, sizeof(line)))
{
for (ptr += 13; isspace(*ptr & 255); ptr ++);
- strlcpy(section, ptr, sizeof(section));
+ cupsCopyString(section, ptr, sizeof(section));
if ((ptr = strstr(section, "-->")) != NULL)
{
/*
*nameptr = '\0';
if (!strncmp(name, "printer_state_history", 21))
- strlcpy(name, "printer_state_history", sizeof(name));
+ cupsCopyString(name, "printer_state_history", sizeof(name));
/*
* Possibly add it to the list of attributes...
* Pull the name from the URI...
*/
- strlcpy(current_dest, strrchr(attr->values[0].string.text, '/') + 1,
+ cupsCopyString(current_dest, strrchr(attr->values[0].string.text, '/') + 1,
sizeof(current_dest));
dest = current_dest;
}
* Force the specified resource name instead of the one in the URL...
*/
- strlcpy(resource, newresource, sizeof(resource));
+ cupsCopyString(resource, newresource, sizeof(resource));
}
else
{
* Make URI relative to the current server...
*/
- strlcpy(url, resource, (size_t)urlsize);
+ cupsCopyString(url, resource, (size_t)urlsize);
}
else
{
}
}
else
- strlcpy(url, uri, (size_t)urlsize);
+ cupsCopyString(url, uri, (size_t)urlsize);
return (url);
}
remaining = sizeof(value) - (size_t)(valptr - value);
if (!strcmp(attr->values[i].string.text, "printer-stopped"))
- strlcpy(valptr, _("Printer Paused"), remaining);
+ cupsCopyString(valptr, _("Printer Paused"), remaining);
else if (!strcmp(attr->values[i].string.text, "printer-added"))
- strlcpy(valptr, _("Printer Added"), remaining);
+ cupsCopyString(valptr, _("Printer Added"), remaining);
else if (!strcmp(attr->values[i].string.text, "printer-modified"))
- strlcpy(valptr, _("Printer Modified"), remaining);
+ cupsCopyString(valptr, _("Printer Modified"), remaining);
else if (!strcmp(attr->values[i].string.text, "printer-deleted"))
- strlcpy(valptr, _("Printer Deleted"), remaining);
+ cupsCopyString(valptr, _("Printer Deleted"), remaining);
else if (!strcmp(attr->values[i].string.text, "job-created"))
- strlcpy(valptr, _("Job Created"), remaining);
+ cupsCopyString(valptr, _("Job Created"), remaining);
else if (!strcmp(attr->values[i].string.text, "job-completed"))
- strlcpy(valptr, _("Job Completed"), remaining);
+ cupsCopyString(valptr, _("Job Completed"), remaining);
else if (!strcmp(attr->values[i].string.text, "job-stopped"))
- strlcpy(valptr, _("Job Stopped"), remaining);
+ cupsCopyString(valptr, _("Job Stopped"), remaining);
else if (!strcmp(attr->values[i].string.text, "job-config-changed"))
- strlcpy(valptr, _("Job Options Changed"), remaining);
+ cupsCopyString(valptr, _("Job Options Changed"), remaining);
else if (!strcmp(attr->values[i].string.text, "server-restarted"))
- strlcpy(valptr, _("Server Restarted"), remaining);
+ cupsCopyString(valptr, _("Server Restarted"), remaining);
else if (!strcmp(attr->values[i].string.text, "server-started"))
- strlcpy(valptr, _("Server Started"), remaining);
+ cupsCopyString(valptr, _("Server Started"), remaining);
else if (!strcmp(attr->values[i].string.text, "server-stopped"))
- strlcpy(valptr, _("Server Stopped"), remaining);
+ cupsCopyString(valptr, _("Server Stopped"), remaining);
else if (!strcmp(attr->values[i].string.text, "server-audit"))
- strlcpy(valptr, _("Server Security Auditing"), remaining);
+ cupsCopyString(valptr, _("Server Security Auditing"), remaining);
else
- strlcpy(valptr, attr->values[i].string.text, remaining);
+ cupsCopyString(valptr, attr->values[i].string.text, remaining);
valptr += strlen(valptr);
}
httpAssembleURI(HTTP_URI_CODING_ALL, uri, sizeof(uri), "http",
userpass, host, port, resource);
- strlcpy(name, uri, sizeof(name));
+ cupsCopyString(name, uri, sizeof(name));
}
else
{
*/
snprintf(uri, sizeof(uri), "/rss%s", resource);
- strlcpy(name, resource + 1, sizeof(name));
+ cupsCopyString(name, resource + 1, sizeof(name));
}
}
else
* Other...
*/
- strlcpy(uri, attr->values[0].string.text, sizeof(uri));
- strlcpy(name, resource, sizeof(name));
+ cupsCopyString(uri, attr->values[0].string.text, sizeof(uri));
+ cupsCopyString(name, resource, sizeof(name));
}
cgiSetArray("notify_recipient_uri", element, uri);
for (i = 0; i < attr->num_values; i ++)
{
if (i)
- strlcat(valptr, ", ", sizeof(value) - (size_t)(valptr - value));
+ cupsConcatString(valptr, ", ", sizeof(value) - (size_t)(valptr - value));
valptr += strlen(valptr);
break;
case IPP_TAG_NOVALUE :
- strlcat(valptr, "novalue", sizeof(value) - (size_t)(valptr - value));
+ cupsConcatString(valptr, "novalue", sizeof(value) - (size_t)(valptr - value));
break;
case IPP_TAG_RANGE :
case IPP_TAG_CHARSET :
case IPP_TAG_LANGUAGE :
case IPP_TAG_MIMETYPE :
- strlcat(valptr, attr->values[i].string.text,
+ cupsConcatString(valptr, attr->values[i].string.text,
sizeof(value) - (size_t)(valptr - value));
break;
cgiSetVariable("PRINTER_URI_SUPPORTED", val);
}
else
- strlcpy(val, "/jobs/", sizeof(val));
+ cupsCopyString(val, "/jobs/", sizeof(val));
cgiSetVariable("THISURL", val);
char url[1024]; /* Encoded URL */
- strlcpy(url, "5;URL=", sizeof(url));
+ cupsCopyString(url, "5;URL=", sizeof(url));
cgiFormEncode(url + 6, getenv("HTTP_REFERER"), sizeof(url) - 6);
cgiSetVariable("refresh_page", url);
}
if ((lang = getenv("LANG")) != NULL)
{
locale[0] = '/';
- strlcpy(locale + 1, lang, sizeof(locale) - 1);
+ cupsCopyString(locale + 1, lang, sizeof(locale) - 1);
if ((locptr = strchr(locale, '.')) != NULL)
*locptr = '\0'; /* Strip charset */
if ((innerval = cgiGetArray(innername, atoi(innerptr) - 1)) == NULL)
*s = '\0';
else
- strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
+ cupsCopyString(s, innerval, sizeof(compare) - (size_t)(s - compare));
}
else if (innername[0] == '?')
{
if ((innerval = cgiGetArray(innername + 1, element)) == NULL)
*s = '\0';
else
- strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
+ cupsCopyString(s, innerval, sizeof(compare) - (size_t)(s - compare));
}
else if ((innerval = cgiGetArray(innername, element)) == NULL)
snprintf(s, sizeof(compare) - (size_t)(s - compare), "{%s}", innername);
else
- strlcpy(s, innerval, sizeof(compare) - (size_t)(s - compare));
+ cupsCopyString(s, innerval, sizeof(compare) - (size_t)(s - compare));
s += strlen(s);
}
if ((var->values = calloc((size_t)element + 1, sizeof(char *))) == NULL)
{
- /*
+ /*
* Rollback changes
*/
{
if ((ptr = strstr(line + 20, " name=\"")) != NULL)
{
- strlcpy(name, ptr + 7, sizeof(name));
+ cupsCopyString(name, ptr + 7, sizeof(name));
if ((ptr = strchr(name, '\"')) != NULL)
*ptr = '\0';
if ((ptr = strstr(line + 20, " filename=\"")) != NULL)
{
- strlcpy(filename, ptr + 11, sizeof(filename));
+ cupsCopyString(filename, ptr + 11, sizeof(filename));
if ((ptr = strchr(filename, '\"')) != NULL)
*ptr = '\0';
{
for (ptr = line + 13; isspace(*ptr & 255); ptr ++);
- strlcpy(mimetype, ptr, sizeof(mimetype));
+ cupsCopyString(mimetype, ptr, sizeof(mimetype));
for (ptr = mimetype + strlen(mimetype) - 1;
ptr > mimetype && isspace(*ptr & 255);
dnl Checks for string functions.
dnl TODO: Remove strdup, snprintf, and vsnprintf checks since they are C99?
AC_CHECK_FUNCS([strdup snprintf vsnprintf])
-AC_CHECK_FUNCS([strlcat strlcpy])
+AC_CHECK_FUNCS([cupsConcatString cupsCopyString])
dnl Check for random number functions...
AC_CHECK_FUNCS([random lrand48 arc4random])
fi
-ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
-if test "x$ac_cv_func_strlcat" = xyes
+ac_fn_c_check_func "$LINENO" "cupsConcatString" "ac_cv_func_cupsConcatString"
+if test "x$ac_cv_func_cupsConcatString" = xyes
then :
printf "%s\n" "#define HAVE_STRLCAT 1" >>confdefs.h
fi
-ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy"
-if test "x$ac_cv_func_strlcpy" = xyes
+ac_fn_c_check_func "$LINENO" "cupsCopyString" "ac_cv_func_cupsCopyString"
+if test "x$ac_cv_func_cupsCopyString" = xyes
then :
printf "%s\n" "#define HAVE_STRLCPY 1" >>confdefs.h
echo "VERSION 2.15" >>libcups2.def
echo "EXPORTS" >>libcups2.def
(nm $(LIBOBJS) $(IMAGEOBJS) 2>/dev/null | grep "T _" | awk '{print $$3}'; \
- echo __cups_strcpy; echo __cups_strlcat; echo __cups_strlcpy; \
+ echo __cups_strcpy; echo __cups_cupsConcatString; echo __cups_cupsCopyString; \
echo __cups_snprintf; echo __cups_vsnprintf; echo __cups_gettimeofday) | \
grep -v -E \
-e 'cups_debug|Apple|BackChannel|Backend|FileCheck|Filter|GSSService|SetNegotiate|SideChannel|SNMP' \
authsize = sizeof(http->_authstring);
}
- strlcpy(http->authstring, "Negotiate ", (size_t)authsize);
+ cupsCopyString(http->authstring, "Negotiate ", (size_t)authsize);
httpEncode64_2(http->authstring + 10, authsize - 10, output_token.value,
(int)output_token.length);
* Use the resolved hostname...
*/
- strlcpy(http->gsshost, host->h_name, sizeof(http->gsshost));
+ cupsCopyString(http->gsshost, host->h_name, sizeof(http->gsshost));
}
else
{
if (bufptr)
{
- strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
+ cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr));
bufptr += strlen(bufptr);
}
break;
if (bufptr)
{
- strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
+ cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr));
bufptr += strlen(bufptr);
}
break;
if (bufptr)
{
- strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
+ cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr));
bufptr += strlen(bufptr);
}
break;
if (!size->bottom && !size->left && !size->right && !size->top)
snprintf(lstr, sizeof(lstr), _cupsLangString(lang, _("%s (Borderless)")), lsize);
else
- strlcpy(lstr, lsize, sizeof(lstr));
+ cupsCopyString(lstr, lsize, sizeof(lstr));
}
else if (!lsource)
{
pwg_media_t *media = pwgMediaForPWG(value);
cups_size_t size;
- strlcpy(size.media, value, sizeof(size.media));
+ cupsCopyString(size.media, value, sizeof(size.media));
size.width = media ? media->width : 0;
size.length = media ? media->length : 0;
size.left = 0;
}
if (nsize->key)
- strlcpy(size->media, nsize->key, sizeof(size->media));
+ cupsCopyString(size->media, nsize->key, sizeof(size->media));
else if (nsize->size_name)
- strlcpy(size->media, nsize->size_name, sizeof(size->media));
+ cupsCopyString(size->media, nsize->size_name, sizeof(size->media));
else if ((pwg = pwgMediaForSize(nsize->width, nsize->length)) != NULL)
- strlcpy(size->media, pwg->pwg, sizeof(size->media));
+ cupsCopyString(size->media, pwg->pwg, sizeof(size->media));
else
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
if (!ippGetBoolean(member, 0))
{
if (bufptr < bufend)
- strlcpy(bufptr, "no", (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, "no", (size_t)(bufend - bufptr + 1));
bufptr += 2;
}
if (bufptr < bufend)
- strlcpy(bufptr, mname, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, mname, (size_t)(bufend - bufptr + 1));
bufptr += strlen(mname);
continue;
}
if (bufptr < bufend)
- strlcpy(bufptr, mname, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, mname, (size_t)(bufend - bufptr + 1));
bufptr += strlen(mname);
if (bufptr < bufend)
snprintf(temp, sizeof(temp), "%04u-%02u-%02uT%02u:%02u:%02u%c%02u%02u", year, date[2], date[3], date[4], date[5], date[6], date[8], date[9], date[10]);
if (bufptr < bufend)
- strlcpy(bufptr, temp, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr + 1));
bufptr += strlen(temp);
}
snprintf(temp, sizeof(temp), "%dx%d%s", xres, yres, units == IPP_RES_PER_INCH ? "dpi" : "dpcm");
if (bufptr < bufend)
- strlcpy(bufptr, temp, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr + 1));
bufptr += strlen(temp);
}
snprintf(temp, sizeof(temp), "%d-%d", lower, upper);
if (bufptr < bufend)
- strlcpy(bufptr, temp, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr + 1));
bufptr += strlen(temp);
}
if (!ippGetName(attr) || ippGetGroupTag(attr) != IPP_TAG_PRINTER)
continue;
- strlcpy(name, ippGetName(attr), sizeof(name));
+ cupsCopyString(name, ippGetName(attr), sizeof(name));
if ((nameptr = name + strlen(name) - 8) <= name || strcmp(nameptr, "-default"))
continue;
* Key is just the size name...
*/
- strlcpy(media_key, mdb.size_name, sizeof(media_key));
+ cupsCopyString(media_key, mdb.size_name, sizeof(media_key));
}
/*
*/
if (!mdb.bottom && !mdb.left && !mdb.right && !mdb.top)
- strlcat(media_key, "_borderless", sizeof(media_key));
+ cupsConcatString(media_key, "_borderless", sizeof(media_key));
mdb.key = media_key;
}
response = cupsDoRequest(http, request, "/");
if ((attr = ippFindAttribute(response, "printer-uri-supported", IPP_TAG_URI)) != NULL)
- strlcpy(uri, ippGetString(attr, 0, NULL), urisize);
+ cupsCopyString(uri, ippGetString(attr, 0, NULL), urisize);
else
{
ippDelete(response);
* Add a default option...
*/
- strlcpy(optname, attr->name, sizeof(optname));
+ cupsCopyString(optname, attr->name, sizeof(optname));
optname[ptr - attr->name] = '\0';
if (_cups_strcasecmp(optname, "media") || !cupsGetOption("media", num_options, options))
if (env)
{
- strlcpy(name, env, namesize);
+ cupsCopyString(name, env, namesize);
return (name);
}
!CFStringGetCString(defaultPaperID, name, (CFIndex)namesize, kCFStringEncodingUTF8))
name[0] = '\0';
else if ((pwgmedia = pwgMediaForLegacy(name)) != NULL)
- strlcpy(name, pwgmedia->pwg, namesize);
+ cupsCopyString(name, pwgmedia->pwg, namesize);
if (defaultPaperID)
CFRelease(defaultPaperID);
device->state = _CUPS_DNSSD_PENDING;
make_and_model[0] = '\0';
- strlcpy(model, "Unknown", sizeof(model));
+ cupsCopyString(model, "Unknown", sizeof(model));
for (txt = rdata, txtend = txt + rdlen;
txt < txtend;
if (!_cups_strcasecmp(key, "usb_MFG") ||
!_cups_strcasecmp(key, "usb_MANU") ||
!_cups_strcasecmp(key, "usb_MANUFACTURER"))
- strlcpy(make_and_model, value, sizeof(make_and_model));
+ cupsCopyString(make_and_model, value, sizeof(make_and_model));
else if (!_cups_strcasecmp(key, "usb_MDL") ||
!_cups_strcasecmp(key, "usb_MODEL"))
- strlcpy(model, value, sizeof(model));
+ cupsCopyString(model, value, sizeof(model));
else if (!_cups_strcasecmp(key, "product") && !strstr(value, "Ghostscript"))
{
if (value[0] == '(')
if ((ptr = value + strlen(value) - 1) > value && *ptr == ')')
*ptr = '\0';
- strlcpy(model, value + 1, sizeof(model));
+ cupsCopyString(model, value + 1, sizeof(model));
}
else
- strlcpy(model, value, sizeof(model));
+ cupsCopyString(model, value, sizeof(model));
}
else if (!_cups_strcasecmp(key, "ty"))
{
- strlcpy(model, value, sizeof(model));
+ cupsCopyString(model, value, sizeof(model));
if ((ptr = strchr(model, ',')) != NULL)
*ptr = '\0';
if (make_and_model[0])
{
- strlcat(make_and_model, " ", sizeof(make_and_model));
- strlcat(make_and_model, model, sizeof(make_and_model));
+ cupsConcatString(make_and_model, " ", sizeof(make_and_model));
+ cupsConcatString(make_and_model, model, sizeof(make_and_model));
device->dest.num_options = cupsAddOption("printer-make-and-model", make_and_model, device->dest.num_options, &device->dest.options);
}
if (dest->instance)
snprintf(data.def_name, sizeof(data.def_name), "%s/%s", dest->name, dest->instance);
else
- strlcpy(data.def_name, dest->name, sizeof(data.def_name));
+ cupsCopyString(data.def_name, dest->name, sizeof(data.def_name));
}
else
{
const char *default_printer; /* Server default printer */
if ((default_printer = cupsGetDefault2(http)) != NULL)
- strlcpy(data.def_name, default_printer, sizeof(data.def_name));
+ cupsCopyString(data.def_name, default_printer, sizeof(data.def_name));
}
if (data.def_name[0])
{
if (!_cups_strcasecmp(line, "default") && value)
{
- strlcpy(namebuf, value, namesize);
+ cupsCopyString(namebuf, value, namesize);
if ((nameptr = strchr(namebuf, ' ')) != NULL)
*nameptr = '\0';
case IPP_TAG_BOOLEAN :
if (attr->values[i].boolean)
- strlcpy(ptr, "true", (size_t)(end - ptr + 1));
+ cupsCopyString(ptr, "true", (size_t)(end - ptr + 1));
else
- strlcpy(ptr, "false", (size_t)(end - ptr + 1));
+ cupsCopyString(ptr, "false", (size_t)(end - ptr + 1));
break;
case IPP_TAG_RANGE :
* Include necessary headers...
*/
+#include "cups.h"
#include "string-private.h"
#include "debug-internal.h"
#include "dir.h"
* Copy the name over and convert the file information...
*/
- strlcpy(dp->entry.filename, entry.cFileName, sizeof(dp->entry.filename));
+ cupsCopyString(dp->entry.filename, entry.cFileName, sizeof(dp->entry.filename));
if (entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
dp->entry.fileinfo.st_mode = 0755 | S_IFDIR;
* Copy the directory name for later use...
*/
- strlcpy(dp->directory, directory, sizeof(dp->directory));
+ cupsCopyString(dp->directory, directory, sizeof(dp->directory));
/*
* Return the new directory structure...
* Copy the name over and get the file information...
*/
- strlcpy(dp->entry.filename, entry->d_name, sizeof(dp->entry.filename));
+ cupsCopyString(dp->entry.filename, entry->d_name, sizeof(dp->entry.filename));
snprintf(filename, sizeof(filename), "%s/%s", dp->directory, entry->d_name);
* Now check the containing directory...
*/
- strlcpy(temp, filename, sizeof(temp));
+ cupsCopyString(temp, filename, sizeof(temp));
if ((ptr = strrchr(temp, '/')) != NULL)
{
if (ptr == temp)
if (!access(filename, 0))
{
- strlcpy(buffer, filename, (size_t)bufsize);
+ cupsCopyString(buffer, filename, (size_t)bufsize);
return (buffer);
}
else
if (bufptr > buffer && bufptr[-1] != '/' && bufptr < bufend)
*bufptr++ = '/';
- strlcpy(bufptr, filename, (size_t)(bufend - bufptr));
+ cupsCopyString(bufptr, filename, (size_t)(bufend - bufptr));
#ifdef _WIN32
if (!access(buffer, 0))
if (bufptr > buffer && bufptr[-1] != '/' && bufptr < bufend)
*bufptr++ = '/';
- strlcpy(bufptr, filename, (size_t)(bufend - bufptr));
+ cupsCopyString(bufptr, filename, (size_t)(bufend - bufptr));
if (!access(buffer, 0))
{
break;
case 's' : /* Read/write socket */
- strlcpy(hostname, filename, sizeof(hostname));
+ cupsCopyString(hostname, filename, sizeof(hostname));
if ((portname = strrchr(hostname, ':')) != NULL)
*portname++ = '\0';
else
* Then send GET requests to the HTTP server...
*/
- strlcpy(if_modified_since, httpGetField(http, HTTP_FIELD_IF_MODIFIED_SINCE),
+ cupsCopyString(if_modified_since, httpGetField(http, HTTP_FIELD_IF_MODIFIED_SINCE),
sizeof(if_modified_since));
do
* Open the registry...
*/
- strlcpy(installdir, "C:/Program Files/cups.org", sizeof(installdir));
+ cupsCopyString(installdir, "C:/Program Files/cups.org", sizeof(installdir));
if (!RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\cups.org", 0, KEY_READ, &key))
{
if (!strncmp(userprofile, "C:\\", 3))
userprofile += 2;
- strlcpy(homedir, userprofile, sizeof(homedir));
+ cupsCopyString(homedir, userprofile, sizeof(homedir));
for (homeptr = homedir; *homeptr; homeptr ++)
{
// Convert back slashes to forward slashes
{
addr = first;
first->addr.un.sun_family = AF_LOCAL;
- strlcpy(first->addr.un.sun_path, hostname, sizeof(first->addr.un.sun_path));
+ cupsCopyString(first->addr.un.sun_path, hostname, sizeof(first->addr.un.sun_path));
}
}
else
* Copy the newer address format which supports link-local addresses...
*/
- strlcpy(ipv6, hostname + 4, sizeof(ipv6));
+ cupsCopyString(ipv6, hostname + 4, sizeof(ipv6));
if ((ipv6len = (int)strlen(ipv6) - 1) >= 0 && ipv6[ipv6len] == ']')
{
ipv6[ipv6len] = '\0';
* Copy the regular non-link-local IPv6 address...
*/
- strlcpy(ipv6, hostname + 1, sizeof(ipv6));
+ cupsCopyString(ipv6, hostname + 1, sizeof(ipv6));
if ((ipv6len = (int)strlen(ipv6) - 1) >= 0 && ipv6[ipv6len] == ']')
{
ipv6[ipv6len] = '\0';
if (!strncmp(uri, "//", 2))
{
// Workaround for HP IPP client bug...
- strlcpy(scheme, "ipp", (size_t)schemelen);
+ cupsCopyString(scheme, "ipp", (size_t)schemelen);
status = HTTP_URI_STATUS_MISSING_SCHEME;
}
else if (*uri == '/')
{
// Filename...
- strlcpy(scheme, "file", (size_t)schemelen);
+ cupsCopyString(scheme, "file", (size_t)schemelen);
status = HTTP_URI_STATUS_MISSING_SCHEME;
}
else
if (nonce && *nonce && strcmp(nonce, http->nonce))
{
- strlcpy(http->nonce, nonce, sizeof(http->nonce));
+ cupsCopyString(http->nonce, nonce, sizeof(http->nonce));
if (nonce == http->nextnonce)
http->nextnonce[0] = '\0';
http->nonce_count ++;
}
- strlcpy(username, http->userpass, sizeof(username));
+ cupsCopyString(username, http->userpass, sizeof(username));
if ((password = strchr(username, ':')) != NULL)
*password++ = '\0';
else
ptr = ippEnumString(attr->name, val->integer);
if (buffer && bufptr < bufend)
- strlcpy(bufptr, ptr, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, ptr, (size_t)(bufend - bufptr + 1));
bufptr += strlen(ptr);
break;
case IPP_TAG_BOOLEAN :
if (buffer && bufptr < bufend)
- strlcpy(bufptr, val->boolean ? "true" : "false", (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, val->boolean ? "true" : "false", (size_t)(bufend - bufptr + 1));
bufptr += val->boolean ? 4 : 5;
break;
val->date[10]);
if (buffer && bufptr < bufend)
- strlcpy(bufptr, temp, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr + 1));
bufptr += strlen(temp);
}
bufptr ++;
if (buffer && bufptr < bufend)
- strlcpy(bufptr, val->string.language, (size_t)(bufend - bufptr));
+ cupsCopyString(bufptr, val->string.language, (size_t)(bufend - bufptr));
bufptr += strlen(val->string.language);
if (buffer && bufptr < bufend)
default :
ptr = ippTagString(attr->value_tag);
if (buffer && bufptr < bufend)
- strlcpy(bufptr, ptr, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, ptr, (size_t)(bufend - bufptr + 1));
bufptr += strlen(ptr);
break;
}
}
else if (!strncmp(src, "$ENV[", 5))
{
- strlcpy(temp, src + 5, sizeof(temp));
+ cupsCopyString(temp, src + 5, sizeof(temp));
for (tempptr = temp; *tempptr; tempptr ++)
if (*tempptr == ']')
if (src[1] == '{')
{
src += 2;
- strlcpy(temp, src, sizeof(temp));
+ cupsCopyString(temp, src, sizeof(temp));
if ((tempptr = strchr(temp, '}')) != NULL)
*tempptr = '\0';
else
}
else
{
- strlcpy(temp, src + 1, sizeof(temp));
+ cupsCopyString(temp, src + 1, sizeof(temp));
for (tempptr = temp; *tempptr; tempptr ++)
if (!isalnum(*tempptr & 255) && *tempptr != '-' && *tempptr != '_')
if (value)
{
- strlcpy(dstptr, value, (size_t)(dstend - dstptr + 1));
+ cupsCopyString(dstptr, value, (size_t)(dstend - dstptr + 1));
dstptr += strlen(dstptr);
}
}
s = "(null)";
bytes = (ssize_t)strlen(s);
- strlcpy(buffer, s, sizeof(buffer));
+ cupsCopyString(buffer, s, sizeof(buffer));
}
else
{
* Search for child attribute...
*/
- strlcpy(parent, name, sizeof(parent));
+ cupsCopyString(parent, name, sizeof(parent));
if ((child = strchr(parent, '/')) == NULL)
{
DEBUG_puts("3ippFindNextAttribute: Attribute name too long.");
s = "(null)";
bytes = (ssize_t)strlen(s);
- strlcpy(buffer, s, sizeof(buffer));
+ cupsCopyString(buffer, s, sizeof(buffer));
}
else
{
if (!_cups_strcasecmp(locale, "c"))
{
- strlcpy(buffer, "en", bufsize);
+ cupsCopyString(buffer, "en", bufsize);
return (buffer);
}
else
/* TRANSLATORS: Message is "subject: error" */
_cupsLangString(cg->lang_default, _("%s: %s")),
_cupsLangString(cg->lang_default, message), strerror(last_errno));
- strlcat(buffer, "\n", sizeof(buffer));
+ cupsConcatString(buffer, "\n", sizeof(buffer));
/*
* Convert and write to stderr...
_cupsLangString(cg->lang_default, message), ap);
va_end(ap);
- strlcat(buffer, "\n", sizeof(buffer));
+ cupsConcatString(buffer, "\n", sizeof(buffer));
/*
* Transcode to the destination charset...
if (lc_time)
{
- strlcpy(new_lc_time, lc_time, sizeof(new_lc_time));
+ cupsCopyString(new_lc_time, lc_time, sizeof(new_lc_time));
if ((charset = strchr(new_lc_time, '.')) == NULL)
charset = new_lc_time + strlen(new_lc_time);
- strlcpy(charset, ".UTF-8", sizeof(new_lc_time) - (size_t)(charset - new_lc_time));
+ cupsCopyString(charset, ".UTF-8", sizeof(new_lc_time) - (size_t)(charset - new_lc_time));
}
else
- strlcpy(new_lc_time, "C", sizeof(new_lc_time));
+ cupsCopyString(new_lc_time, "C", sizeof(new_lc_time));
setlocale(LC_TIME, new_lc_time);
#endif /* LC_TIME */
* Invalid locale...
*/
- strlcpy(language, "en", langsize);
+ cupsCopyString(language, "en", langsize);
break;
case 2 :
- strlcpy(language, locale, langsize);
+ cupsCopyString(language, locale, langsize);
break;
case 5 :
- strlcpy(language, locale, langsize);
+ cupsCopyString(language, locale, langsize);
if (language[2] == '-')
{
i ++)
if (!strcmp(locale, apple_language_locale[i].locale))
{
- strlcpy(language, apple_language_locale[i].language, sizeof(language));
+ cupsCopyString(language, apple_language_locale[i].language, sizeof(language));
break;
}
(!strncmp(locale, apple_language_locale[i].language, len) && (locale[len] == '_' || locale[len] == '-')))
{
DEBUG_printf("_cupsAppleLocale: Updating locale to \"%s\".", apple_language_locale[i].locale);
- strlcpy(locale, apple_language_locale[i].locale, localesize);
+ cupsCopyString(locale, apple_language_locale[i].locale, localesize);
break;
}
}
locale[3] = '_';
if (!strchr(locale, '.'))
- strlcat(locale, ".UTF-8", localesize);
+ cupsConcatString(locale, ".UTF-8", localesize);
DEBUG_printf("_cupsAppleLocale: Returning \"%s\".", locale);
* Set the character set to UTF-8...
*/
- strlcpy(charset, "UTF8", sizeof(charset));
+ cupsCopyString(charset, "UTF8", sizeof(charset));
/*
* Apple's setlocale doesn't give us the user's localization
if (ptr)
{
- strlcpy(locale, ptr, sizeof(locale));
+ cupsCopyString(locale, ptr, sizeof(locale));
language = locale;
/*
*/
if (!charset[0])
- strlcpy(charset, "UTF8", sizeof(charset));
+ cupsCopyString(charset, "UTF8", sizeof(charset));
/*
* Parse the language string passed in to a locale string. "C" is the
if (language == NULL || !language[0] ||
!strcmp(language, "POSIX"))
- strlcpy(langname, "C", sizeof(langname));
+ cupsCopyString(langname, "C", sizeof(langname));
else
{
/*
*/
if (!strcmp(language, "zh") && !strcmp(country, "HANS"))
- strlcpy(country, "CN", sizeof(country));
+ cupsCopyString(country, "CN", sizeof(country));
if (!strcmp(language, "zh") && !strcmp(country, "HANT"))
- strlcpy(country, "TW", sizeof(country));
+ cupsCopyString(country, "TW", sizeof(country));
}
if (*language == '.' && !charset[0])
if (strlen(langname) != 2 && strlen(langname) != 3)
{
- strlcpy(langname, "C", sizeof(langname));
+ cupsCopyString(langname, "C", sizeof(langname));
country[0] = '\0';
charset[0] = '\0';
}
if (country[0])
snprintf(real, sizeof(real), "%s_%s", langname, country);
else
- strlcpy(real, langname, sizeof(real));
+ cupsCopyString(real, langname, sizeof(real));
cupsMutexLock(&lang_mutex);
*/
lang->used ++;
- strlcpy(lang->language, real, sizeof(lang->language));
+ cupsCopyString(lang->language, real, sizeof(lang->language));
if (encoding != CUPS_AUTO_ENCODING)
lang->encoding = encoding;
if (getenv("SOFTWARE") != NULL && (lang = getenv("LANG")) != NULL)
{
DEBUG_printf("3appleLangDefault: Using LANG=%s", lang);
- strlcpy(cg->language, lang, sizeof(cg->language));
+ cupsCopyString(cg->language, lang, sizeof(cg->language));
return (cg->language);
}
else if ((bundle = CFBundleGetMainBundle()) != NULL &&
CFStringGetCString(cfpath, path, sizeof(path), kCFStringEncodingUTF8);
DEBUG_printf("3appleLangDefault: Got a resource URL (\"%s\")", path);
- strlcat(path, "Contents/Info.plist", sizeof(path));
+ cupsConcatString(path, "Contents/Info.plist", sizeof(path));
if (!access(path, R_OK))
localizationList = CFBundleCopyPreferredLocalizationsFromArray(bundleList);
if (!cg->language[0])
{
DEBUG_puts("3appleLangDefault: Defaulting to en_US.");
- strlcpy(cg->language, "en_US.UTF-8", sizeof(cg->language));
+ cupsCopyString(cg->language, "en_US.UTF-8", sizeof(cg->language));
}
}
else
if (cups_strings)
{
DEBUG_puts("1appleMessageLoad: Using debug CUPS_STRINGS file.");
- strlcpy(filename, cups_strings, sizeof(filename));
+ cupsCopyString(filename, cups_strings, sizeof(filename));
}
else
#endif /* DEBUG */
DEBUG_printf("1appleMessageLoad: \"%s\": %s", filename, strerror(errno));
- strlcpy(baselang, locale, sizeof(baselang));
+ cupsCopyString(baselang, locale, sizeof(baselang));
if (baselang[3] == '-' || baselang[3] == '_')
baselang[3] = '\0';
* Drop country code, just try language...
*/
- strlcpy(baselang, locale, sizeof(baselang));
+ cupsCopyString(baselang, locale, sizeof(baselang));
if (baselang[2] == '-' || baselang[2] == '_')
baselang[2] = '\0';
_cups_strcasecmp
_cups_strcpy
_cups_strcpy
-_cups_strlcat
-_cups_strlcpy
+_cups_cupsConcatString
+_cups_cupsCopyString
_cups_strncasecmp
_cups_vsnprintf
_httpAddrSetPort
state);
}
else if (subscribed)
- strlcpy(buffer, subscribed->values[0].string.text, sizeof(buffer));
+ cupsCopyString(buffer, subscribed->values[0].string.text, sizeof(buffer));
else
return (NULL);
*/
memset(&key, 0, sizeof(key));
- strlcpy(key.name, name, sizeof(key.name));
+ cupsCopyString(key.name, name, sizeof(key.name));
/*
* Return the first matching attribute, if any...
if (make_and_model[0] == '(')
{
- strlcpy(buffer, make_and_model + 1, bufsize);
+ cupsCopyString(buffer, make_and_model + 1, bufsize);
if ((bufptr = strrchr(buffer, ')')) != NULL)
*bufptr = '\0';
snprintf(buffer, bufsize, "HP %s", make_and_model);
}
else
- strlcpy(buffer, make_and_model, bufsize);
+ cupsCopyString(buffer, make_and_model, bufsize);
/*
* Clean up the make...
cupsFilePuts(fp, "*PCFileName: \"ippeve.ppd\"\n");
if ((attr = ippFindAttribute(supported, "printer-make-and-model", IPP_TAG_TEXT)) != NULL)
- strlcpy(make, ippGetString(attr, 0, NULL), sizeof(make));
+ cupsCopyString(make, ippGetString(attr, 0, NULL), sizeof(make));
else
- strlcpy(make, "Unknown Printer", sizeof(make));
+ cupsCopyString(make, "Unknown Printer", sizeof(make));
if (!_cups_strncasecmp(make, "Hewlett Packard ", 16) || !_cups_strncasecmp(make, "Hewlett-Packard ", 16))
{
model = make + 16;
- strlcpy(make, "HP", sizeof(make));
+ cupsCopyString(make, "HP", sizeof(make));
}
else if ((model = strchr(make, ' ')) != NULL)
*model++ = '\0';
y_dim = ippFindAttribute(media_size, "y-dimension", IPP_TAG_INTEGER);
if (x_dim && y_dim && (pwg = pwgMediaForSize(ippGetInteger(x_dim, 0), ippGetInteger(y_dim, 0))) != NULL)
- strlcpy(ppdname, pwg->ppd, sizeof(ppdname));
+ cupsCopyString(ppdname, pwg->ppd, sizeof(ppdname));
else
- strlcpy(ppdname, "Unknown", sizeof(ppdname));
+ cupsCopyString(ppdname, "Unknown", sizeof(ppdname));
}
else
- strlcpy(ppdname, "Unknown", sizeof(ppdname));
+ cupsCopyString(ppdname, "Unknown", sizeof(ppdname));
}
else if ((pwg = pwgMediaForPWG(ippGetString(ippFindAttribute(supported, "media-default", IPP_TAG_ZERO), 0, NULL))) != NULL)
- strlcpy(ppdname, pwg->ppd, sizeof(ppdname));
+ cupsCopyString(ppdname, pwg->ppd, sizeof(ppdname));
else
- strlcpy(ppdname, "Unknown", sizeof(ppdname));
+ cupsCopyString(ppdname, "Unknown", sizeof(ppdname));
sizes = cupsArrayNew3((cups_array_func_t)pwg_compare_sizes, NULL, NULL, 0, (cups_acopy_func_t)pwg_copy_size, (cups_afree_func_t)free);
if (temp.bottom == 0 && temp.left == 0 && temp.right == 0 && temp.top == 0)
snprintf(temp.media, sizeof(temp.media), "%s.Borderless", pwg->ppd);
else
- strlcpy(temp.media, pwg->ppd, sizeof(temp.media));
+ cupsCopyString(temp.media, pwg->ppd, sizeof(temp.media));
if (!cupsArrayFind(sizes, &temp))
cupsArrayAdd(sizes, &temp);
if (temp.bottom == 0 && temp.left == 0 && temp.right == 0 && temp.top == 0)
snprintf(temp.media, sizeof(temp.media), "%s.Borderless", pwg->ppd);
else
- strlcpy(temp.media, pwg->ppd, sizeof(temp.media));
+ cupsCopyString(temp.media, pwg->ppd, sizeof(temp.media));
if (!cupsArrayFind(sizes, &temp))
cupsArrayAdd(sizes, &temp);
if (temp.bottom == 0 && temp.left == 0 && temp.right == 0 && temp.top == 0)
snprintf(temp.media, sizeof(temp.media), "%s.Borderless", pwg->ppd);
else
- strlcpy(temp.media, pwg->ppd, sizeof(temp.media));
+ cupsCopyString(temp.media, pwg->ppd, sizeof(temp.media));
if (!cupsArrayFind(sizes, &temp))
cupsArrayAdd(sizes, &temp);
if ((attr = ippFindAttribute(ippGetCollection(defattr, 0), "media-type", IPP_TAG_ZERO)) != NULL)
pwg_ppdize_name(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname));
else
- strlcpy(ppdname, "Unknown", sizeof(ppdname));
+ cupsCopyString(ppdname, "Unknown", sizeof(ppdname));
if ((attr = ippFindAttribute(supported, "media-type-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 1)
{
else
{
xres = yres = 300;
- strlcpy(ppdname, "300dpi", sizeof(ppdname));
+ cupsCopyString(ppdname, "300dpi", sizeof(ppdname));
}
cupsFilePrintf(fp, "*DefaultResolution: %s\n", ppdname);
if ((attr = ippFindAttribute(supported, "output-bin-default", IPP_TAG_ZERO)) != NULL)
pwg_ppdize_name(ippGetString(attr, 0, NULL), ppdname, sizeof(ppdname));
else
- strlcpy(ppdname, "Unknown", sizeof(ppdname));
+ cupsCopyString(ppdname, "Unknown", sizeof(ppdname));
if ((attr = ippFindAttribute(supported, "output-bin-supported", IPP_TAG_ZERO)) != NULL && (count = ippGetCount(attr)) > 0)
{
return (NULL);
if (_cups_strcasecmp(media_source, "main"))
- strlcpy(name, "Cassette", namesize);
+ cupsCopyString(name, "Cassette", namesize);
else if (_cups_strcasecmp(media_source, "alternate"))
- strlcpy(name, "Multipurpose", namesize);
+ cupsCopyString(name, "Multipurpose", namesize);
else if (_cups_strcasecmp(media_source, "large-capacity"))
- strlcpy(name, "LargeCapacity", namesize);
+ cupsCopyString(name, "LargeCapacity", namesize);
else if (_cups_strcasecmp(media_source, "bottom"))
- strlcpy(name, "Lower", namesize);
+ cupsCopyString(name, "Lower", namesize);
else if (_cups_strcasecmp(media_source, "middle"))
- strlcpy(name, "Middle", namesize);
+ cupsCopyString(name, "Middle", namesize);
else if (_cups_strcasecmp(media_source, "top"))
- strlcpy(name, "Upper", namesize);
+ cupsCopyString(name, "Upper", namesize);
else if (_cups_strcasecmp(media_source, "rear"))
- strlcpy(name, "Rear", namesize);
+ cupsCopyString(name, "Rear", namesize);
else if (_cups_strcasecmp(media_source, "side"))
- strlcpy(name, "Side", namesize);
+ cupsCopyString(name, "Side", namesize);
else if (_cups_strcasecmp(media_source, "envelope"))
- strlcpy(name, "Envelope", namesize);
+ cupsCopyString(name, "Envelope", namesize);
else if (_cups_strcasecmp(media_source, "main-roll"))
- strlcpy(name, "Roll", namesize);
+ cupsCopyString(name, "Roll", namesize);
else if (_cups_strcasecmp(media_source, "alternate-roll"))
- strlcpy(name, "Roll2", namesize);
+ cupsCopyString(name, "Roll2", namesize);
else
pwg_ppdize_name(media_source, name, namesize);
return (NULL);
if (_cups_strcasecmp(media_type, "auto"))
- strlcpy(name, "Auto", namesize);
+ cupsCopyString(name, "Auto", namesize);
else if (_cups_strcasecmp(media_type, "cardstock"))
- strlcpy(name, "Cardstock", namesize);
+ cupsCopyString(name, "Cardstock", namesize);
else if (_cups_strcasecmp(media_type, "envelope"))
- strlcpy(name, "Envelope", namesize);
+ cupsCopyString(name, "Envelope", namesize);
else if (_cups_strcasecmp(media_type, "photographic-glossy"))
- strlcpy(name, "Glossy", namesize);
+ cupsCopyString(name, "Glossy", namesize);
else if (_cups_strcasecmp(media_type, "photographic-high-gloss"))
- strlcpy(name, "HighGloss", namesize);
+ cupsCopyString(name, "HighGloss", namesize);
else if (_cups_strcasecmp(media_type, "photographic-matte"))
- strlcpy(name, "Matte", namesize);
+ cupsCopyString(name, "Matte", namesize);
else if (_cups_strcasecmp(media_type, "stationery"))
- strlcpy(name, "Plain", namesize);
+ cupsCopyString(name, "Plain", namesize);
else if (_cups_strcasecmp(media_type, "stationery-coated"))
- strlcpy(name, "Coated", namesize);
+ cupsCopyString(name, "Coated", namesize);
else if (_cups_strcasecmp(media_type, "stationery-inkjet"))
- strlcpy(name, "Inkjet", namesize);
+ cupsCopyString(name, "Inkjet", namesize);
else if (_cups_strcasecmp(media_type, "stationery-letterhead"))
- strlcpy(name, "Letterhead", namesize);
+ cupsCopyString(name, "Letterhead", namesize);
else if (_cups_strcasecmp(media_type, "stationery-preprinted"))
- strlcpy(name, "Preprinted", namesize);
+ cupsCopyString(name, "Preprinted", namesize);
else if (_cups_strcasecmp(media_type, "transparency"))
- strlcpy(name, "Transparency", namesize);
+ cupsCopyString(name, "Transparency", namesize);
else
pwg_ppdize_name(media_type, name, namesize);
* Use a standard Adobe name...
*/
- strlcpy(name, media->ppd, namesize);
+ cupsCopyString(name, media->ppd, namesize);
}
else if (!media->pwg || !strncmp(media->pwg, "custom_", 7) ||
(sizeptr = strchr(media->pwg, '_')) == NULL ||
if (!*ppdptr)
{
- strlcpy(name, ppd, namesize);
+ cupsCopyString(name, ppd, namesize);
return;
}
}
consts->num_constraints = i;
consts->constraints = constptr;
- strlcpy(consts->resolver, constattr->spec, sizeof(consts->resolver));
+ cupsCopyString(consts->resolver, constattr->spec, sizeof(consts->resolver));
for (i = 0, vptr = strchr(constattr->value, '*');
vptr;
if (!_cups_strncasecmp(option, "Custom", 6) && !_cups_strcasecmp(choice, "True"))
{
_cups_strcpy(option, option + 6);
- strlcpy(choice, "Custom", sizeof(choice));
+ cupsCopyString(choice, "Custom", sizeof(choice));
}
constptr->option = ppdFindOption(ppd, option);
if (!ppd)
return (NULL);
- strlcpy(key.keyword, keyword, sizeof(key.keyword));
+ cupsCopyString(key.keyword, keyword, sizeof(key.keyword));
return ((ppd_coption_t *)cupsArrayFind(ppd->coptions, &key));
}
* question marks so that the title does not cause a PJL syntax error.
*/
- strlcpy(temp, title, sizeof(temp));
+ cupsCopyString(temp, title, sizeof(temp));
for (ptr = temp; *ptr; ptr ++)
if (*ptr == '\"')
* question marks so that the user does not cause a PJL syntax error.
*/
- strlcpy(temp, user, sizeof(temp));
+ cupsCopyString(temp, user, sizeof(temp));
for (ptr = temp; *ptr; ptr ++)
if (*ptr == '\"')
case PPD_CUSTOM_STRING :
if (cparam->current.custom_string)
{
- strlcpy(bufptr, cparam->current.custom_string, (size_t)(bufend - bufptr));
+ cupsCopyString(bufptr, cparam->current.custom_string, (size_t)(bufend - bufptr));
bufptr += strlen(bufptr);
}
break;
* Otherwise just copy the option code directly...
*/
- strlcpy(bufptr, choices[i]->code, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, choices[i]->code, (size_t)(bufend - bufptr + 1));
bufptr += strlen(bufptr);
}
}
* options...
*/
- strlcpy(bufptr, "[{\n", (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, "[{\n", (size_t)(bufend - bufptr + 1));
bufptr += 3;
/*
float values[5]; /* Values for custom command */
- strlcpy(bufptr, "%%BeginFeature: *CustomPageSize True\n", (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, "%%BeginFeature: *CustomPageSize True\n", (size_t)(bufend - bufptr + 1));
bufptr += 37;
size = ppdPageSize(ppd, "Custom");
* Level 2 command sequence...
*/
- strlcpy(bufptr, ppd_custom_code, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, ppd_custom_code, (size_t)(bufend - bufptr + 1));
bufptr += strlen(bufptr);
}
}
*bufptr++ = '\n';
}
- strlcpy(bufptr, "%%EndFeature\n"
+ cupsCopyString(bufptr, "%%EndFeature\n"
"} stopped cleartomark\n", (size_t)(bufend - bufptr + 1));
bufptr += strlen(bufptr);
}
else if (choices[i]->code)
{
- strlcpy(bufptr, choices[i]->code, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, choices[i]->code, (size_t)(bufend - bufptr + 1));
bufptr += strlen(bufptr);
}
{
if ((locattr = _ppdLocalizedAttr(ppd, "Translation", group->name,
ll_CC)) != NULL)
- strlcpy(group->text, locattr->text, sizeof(group->text));
+ cupsCopyString(group->text, locattr->text, sizeof(group->text));
for (j = group->num_options, option = group->options; j > 0; j --, option ++)
{
if ((locattr = _ppdLocalizedAttr(ppd, "Translation", option->keyword,
ll_CC)) != NULL)
- strlcpy(option->text, locattr->text, sizeof(option->text));
+ cupsCopyString(option->text, locattr->text, sizeof(option->text));
for (k = option->num_choices, choice = option->choices;
k > 0;
}
if (locattr)
- strlcpy(choice->text, locattr->text, sizeof(choice->text));
+ cupsCopyString(choice->text, locattr->text, sizeof(choice->text));
}
}
}
if ((locattr = _ppdLocalizedAttr(ppd, ckeyword, cparam->name,
ll_CC)) != NULL)
- strlcpy(cparam->text, locattr->text, sizeof(cparam->text));
+ cupsCopyString(cparam->text, locattr->text, sizeof(cparam->text));
}
}
{
if ((locattr = _ppdLocalizedAttr(ppd, "APCustomColorMatchingName",
attr->spec, ll_CC)) != NULL)
- strlcpy(attr->text, locattr->text, sizeof(attr->text));
+ cupsCopyString(attr->text, locattr->text, sizeof(attr->text));
}
for (attr = ppdFindAttr(ppd, "cupsICCProfile", NULL);
if ((locattr = _ppdLocalizedAttr(ppd, "cupsICCProfile", attr->spec,
ll_CC)) != NULL)
- strlcpy(attr->text, locattr->text, sizeof(attr->text));
+ cupsCopyString(attr->text, locattr->text, sizeof(attr->text));
cupsArrayRestore(ppd->sorted_attrs);
}
if ((locattr = _ppdLocalizedAttr(ppd, "APPrinterPreset", attr->spec,
ll_CC)) != NULL)
- strlcpy(attr->text, locattr->text, sizeof(attr->text));
+ cupsCopyString(attr->text, locattr->text, sizeof(attr->text));
cupsArrayRestore(ppd->sorted_attrs);
}
if (message && strcmp(message, msgid))
{
- strlcpy(buffer, _cupsLangString(lang, message), bufsize);
+ cupsCopyString(buffer, _cupsLangString(lang, message), bufsize);
return (buffer);
}
}
* the value...
*/
- strlcpy(buffer, locattr->text, bufsize);
+ cupsCopyString(buffer, locattr->text, bufsize);
for (valptr = locattr->value, bufptr = buffer; *valptr && bufptr < bufend;)
{
if ((lang = cupsLangDefault()) == NULL)
{
- strlcpy(ll_CC, "en_US", ll_CC_size);
+ cupsCopyString(ll_CC, "en_US", ll_CC_size);
return (NULL);
}
* Copy the locale name...
*/
- strlcpy(ll_CC, lang->language, ll_CC_size);
+ cupsCopyString(ll_CC, lang->language, ll_CC_size);
if (strlen(ll_CC) == 2)
{
*/
if (!strcmp(ll_CC, "cs"))
- strlcpy(ll_CC, "cs_CZ", ll_CC_size);
+ cupsCopyString(ll_CC, "cs_CZ", ll_CC_size);
else if (!strcmp(ll_CC, "en"))
- strlcpy(ll_CC, "en_US", ll_CC_size);
+ cupsCopyString(ll_CC, "en_US", ll_CC_size);
else if (!strcmp(ll_CC, "ja"))
- strlcpy(ll_CC, "ja_JP", ll_CC_size);
+ cupsCopyString(ll_CC, "ja_JP", ll_CC_size);
else if (!strcmp(ll_CC, "sv"))
- strlcpy(ll_CC, "sv_SE", ll_CC_size);
+ cupsCopyString(ll_CC, "sv_SE", ll_CC_size);
else if (!strcmp(ll_CC, "zh")) /* Simplified Chinese */
- strlcpy(ll_CC, "zh_CN", ll_CC_size);
+ cupsCopyString(ll_CC, "zh_CN", ll_CC_size);
}
DEBUG_printf("8ppd_ll_CC: lang->language=\"%s\", ll_CC=\"%s\"...", lang->language, ll_CC);
ppd_option_t key; /* Option search key */
- strlcpy(key.keyword, option, sizeof(key.keyword));
+ cupsCopyString(key.keyword, option, sizeof(key.keyword));
return ((ppd_option_t *)cupsArrayFind(ppd->options, &key));
}
httpGetHostname(http, hostname, sizeof(hostname));
else
{
- strlcpy(hostname, cupsServer(), sizeof(hostname));
+ cupsCopyString(hostname, cupsServer(), sizeof(hostname));
if (hostname[0] == '/')
- strlcpy(hostname, "localhost", sizeof(hostname));
+ cupsCopyString(hostname, "localhost", sizeof(hostname));
}
if (!_cups_strcasecmp(hostname, "localhost"))
* Redirect localhost to domain socket...
*/
- strlcpy(hostname, cupsServer(), sizeof(hostname));
+ cupsCopyString(hostname, cupsServer(), sizeof(hostname));
port = 0;
DEBUG_printf("2cupsGetPPD3: Redirecting to \"%s\".", hostname);
DEBUG_printf("2cupsGetPPD3: Local hostname=\"%s\"", localhost);
if (!_cups_strcasecmp(localhost, hostname))
- strlcpy(hostname, "localhost", sizeof(hostname));
+ cupsCopyString(hostname, "localhost", sizeof(hostname));
/*
* Get the hostname and port number we are connected to...
* And send a request to the HTTP server...
*/
- strlcat(resource, ".ppd", sizeof(resource));
+ cupsConcatString(resource, ".ppd", sizeof(resource));
if (*modtime > 0)
httpSetField(http2, HTTP_FIELD_IF_MODIFIED_SINCE,
*modtime = httpGetDateTime(httpGetField(http2, HTTP_FIELD_DATE));
if (tempfile[0])
- strlcpy(buffer, tempfile, bufsize);
+ cupsCopyString(buffer, tempfile, bufsize);
}
else if (status != HTTP_STATUS_NOT_MODIFIED)
{
if (!strcmp(lang->language, "zh_HK"))
{ /* Traditional Chinese + variants */
- strlcpy(ll_CC, "zh_TW.", sizeof(ll_CC));
- strlcpy(ll, "zh_", sizeof(ll));
+ cupsCopyString(ll_CC, "zh_TW.", sizeof(ll_CC));
+ cupsCopyString(ll, "zh_", sizeof(ll));
}
else if (!strncmp(lang->language, "zh", 2))
- strlcpy(ll, "zh_", sizeof(ll)); /* Any Chinese variant */
+ cupsCopyString(ll, "zh_", sizeof(ll)); /* Any Chinese variant */
else if (!strncmp(lang->language, "jp", 2))
{ /* Any Japanese variant */
- strlcpy(ll_CC, "ja", sizeof(ll_CC));
- strlcpy(ll, "jp", sizeof(ll));
+ cupsCopyString(ll_CC, "ja", sizeof(ll_CC));
+ cupsCopyString(ll, "jp", sizeof(ll));
}
else if (!strncmp(lang->language, "nb", 2) || !strncmp(lang->language, "no", 2))
{ /* Any Norwegian variant */
- strlcpy(ll_CC, "nb", sizeof(ll_CC));
- strlcpy(ll, "no", sizeof(ll));
+ cupsCopyString(ll_CC, "nb", sizeof(ll_CC));
+ cupsCopyString(ll, "no", sizeof(ll));
}
else
snprintf(ll, sizeof(ll), "%2.2s.", lang->language);
ppd->attrs[j]->value)
{
DEBUG_printf("2_ppdOpen: Setting Default%s to %s via attribute...", option->keyword, ppd->attrs[j]->value);
- strlcpy(option->defchoice, ppd->attrs[j]->value,
+ cupsCopyString(option->defchoice, ppd->attrs[j]->value,
sizeof(option->defchoice));
break;
}
if (!strcmp(keyword, "PageSize"))
- strlcpy(option->text, _("Media Size"), sizeof(option->text));
+ cupsCopyString(option->text, _("Media Size"), sizeof(option->text));
else if (!strcmp(keyword, "MediaType"))
- strlcpy(option->text, _("Media Type"), sizeof(option->text));
+ cupsCopyString(option->text, _("Media Type"), sizeof(option->text));
else if (!strcmp(keyword, "InputSlot"))
- strlcpy(option->text, _("Media Source"), sizeof(option->text));
+ cupsCopyString(option->text, _("Media Source"), sizeof(option->text));
else if (!strcmp(keyword, "ColorModel"))
- strlcpy(option->text, _("Output Mode"), sizeof(option->text));
+ cupsCopyString(option->text, _("Output Mode"), sizeof(option->text));
else if (!strcmp(keyword, "Resolution"))
- strlcpy(option->text, _("Resolution"), sizeof(option->text));
+ cupsCopyString(option->text, _("Resolution"), sizeof(option->text));
else
- strlcpy(option->text, keyword, sizeof(option->text));
+ cupsCopyString(option->text, keyword, sizeof(option->text));
}
}
ppd->num_profiles ++;
memset(profile, 0, sizeof(ppd_profile_t));
- strlcpy(profile->resolution, name, sizeof(profile->resolution));
- strlcpy(profile->media_type, text, sizeof(profile->media_type));
+ cupsCopyString(profile->resolution, name, sizeof(profile->resolution));
+ cupsCopyString(profile->media_type, text, sizeof(profile->media_type));
profile->density = (float)_cupsStrScand(string, &sptr, loc);
profile->gamma = (float)_cupsStrScand(sptr, &sptr, loc);
goto error;
}
- strlcpy(choice->text, text[0] ? text : _("Custom"),
+ cupsCopyString(choice->text, text[0] ? text : _("Custom"),
sizeof(choice->text));
choice->code = strdup(string);
goto error;
}
- strlcpy(choice->text, text[0] ? text : _("Custom"),
+ cupsCopyString(choice->text, text[0] ? text : _("Custom"),
sizeof(choice->text));
}
}
ppd->num_emulations = 1;
ppd->emulations = calloc(1, sizeof(ppd_emul_t));
- strlcpy(ppd->emulations[0].name, string, sizeof(ppd->emulations[0].name));
+ cupsCopyString(ppd->emulations[0].name, string, sizeof(ppd->emulations[0].name));
}
else if (!strcmp(keyword, "JobPatchFile"))
{
ppd->attrs[j]->value)
{
DEBUG_printf("2_ppdOpen: Setting Default%s to %s via attribute...", option->keyword, ppd->attrs[j]->value);
- strlcpy(option->defchoice, ppd->attrs[j]->value,
+ cupsCopyString(option->defchoice, ppd->attrs[j]->value,
sizeof(option->defchoice));
break;
}
else
{
if (!strcmp(name, "PageSize"))
- strlcpy(option->text, _("Media Size"), sizeof(option->text));
+ cupsCopyString(option->text, _("Media Size"), sizeof(option->text));
else if (!strcmp(name, "MediaType"))
- strlcpy(option->text, _("Media Type"), sizeof(option->text));
+ cupsCopyString(option->text, _("Media Type"), sizeof(option->text));
else if (!strcmp(name, "InputSlot"))
- strlcpy(option->text, _("Media Source"), sizeof(option->text));
+ cupsCopyString(option->text, _("Media Source"), sizeof(option->text));
else if (!strcmp(name, "ColorModel"))
- strlcpy(option->text, _("Output Mode"), sizeof(option->text));
+ cupsCopyString(option->text, _("Output Mode"), sizeof(option->text));
else if (!strcmp(name, "Resolution"))
- strlcpy(option->text, _("Resolution"), sizeof(option->text));
+ cupsCopyString(option->text, _("Resolution"), sizeof(option->text));
else
- strlcpy(option->text, name, sizeof(option->text));
+ cupsCopyString(option->text, name, sizeof(option->text));
}
option->section = PPD_ORDER_ANY;
*/
if (!_cups_strcasecmp(name, "PageRegion"))
- strlcpy(custom_name, "CustomPageSize", sizeof(custom_name));
+ cupsCopyString(custom_name, "CustomPageSize", sizeof(custom_name));
else
snprintf(custom_name, sizeof(custom_name), "Custom%s", name);
goto error;
}
- strlcpy(choice->text,
+ cupsCopyString(choice->text,
custom_attr->text[0] ? custom_attr->text : _("Custom"),
sizeof(choice->text));
choice->code = strdup(custom_attr->value);
ppd->attrs[j]->value)
{
DEBUG_printf("2_ppdOpen: Setting Default%s to %s via attribute...", option->keyword, ppd->attrs[j]->value);
- strlcpy(option->defchoice, ppd->attrs[j]->value,
+ cupsCopyString(option->defchoice, ppd->attrs[j]->value,
sizeof(option->defchoice));
break;
}
cupsCharsetToUTF8((cups_utf8_t *)option->text, text,
sizeof(option->text), encoding);
else
- strlcpy(option->text, name, sizeof(option->text));
+ cupsCopyString(option->text, name, sizeof(option->text));
option->section = PPD_ORDER_JCL;
group = NULL;
goto error;
}
- strlcpy(choice->text,
+ cupsCopyString(choice->text,
custom_attr->text[0] ? custom_attr->text : _("Custom"),
sizeof(choice->text));
choice->code = strdup(custom_attr->value);
if (ppdFindChoice(option, tchoice))
{
- strlcpy(option->defchoice, tchoice, sizeof(option->defchoice));
+ cupsCopyString(option->defchoice, tchoice, sizeof(option->defchoice));
DEBUG_printf("2_ppdOpen: Reset Default%s to %s...", option->keyword, tchoice);
}
if (ppdFindChoice(option, tchoice))
{
- strlcpy(option->defchoice, tchoice, sizeof(option->defchoice));
+ cupsCopyString(option->defchoice, tchoice, sizeof(option->defchoice));
DEBUG_printf("2_ppdOpen: Reset Default%s to %s...", option->keyword, tchoice);
}
* Set the default as part of the current option...
*/
- strlcpy(option->defchoice, string, sizeof(option->defchoice));
+ cupsCopyString(option->defchoice, string, sizeof(option->defchoice));
DEBUG_printf("2_ppdOpen: Set %s to %s...", keyword, option->defchoice);
}
snprintf(toption->defchoice, sizeof(toption->defchoice), "_%s", string);
if (!ppdFindChoice(toption, toption->defchoice))
- strlcpy(toption->defchoice, string, sizeof(toption->defchoice));
+ cupsCopyString(toption->defchoice, string, sizeof(toption->defchoice));
}
else
{
- strlcpy(toption->defchoice, string, sizeof(toption->defchoice));
+ cupsCopyString(toption->defchoice, string, sizeof(toption->defchoice));
}
DEBUG_printf("2_ppdOpen: Set %s to %s...", keyword, toption->defchoice);
{
char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */
snprintf(cname, sizeof(cname), "_%s", name);
- strlcpy(name, cname, sizeof(name));
+ cupsCopyString(name, cname, sizeof(name));
}
if ((size = ppdPageSize(ppd, name)) == NULL)
{
char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */
snprintf(cname, sizeof(cname), "_%s", name);
- strlcpy(name, cname, sizeof(name));
+ cupsCopyString(name, cname, sizeof(name));
}
if ((size = ppdPageSize(ppd, name)) == NULL)
{
char cname[PPD_MAX_NAME]; /* Rewrite with a leading underscore */
snprintf(cname, sizeof(cname), "_%s", name);
- strlcpy(name, cname, sizeof(name));
+ cupsCopyString(name, cname, sizeof(name));
}
if (!strcmp(keyword, "PageSize"))
cupsCharsetToUTF8((cups_utf8_t *)choice->text, text,
sizeof(choice->text), encoding);
else if (!strcmp(name, "True"))
- strlcpy(choice->text, _("Yes"), sizeof(choice->text));
+ cupsCopyString(choice->text, _("Yes"), sizeof(choice->text));
else if (!strcmp(name, "False"))
- strlcpy(choice->text, _("No"), sizeof(choice->text));
+ cupsCopyString(choice->text, _("No"), sizeof(choice->text));
else
- strlcpy(choice->text, name, sizeof(choice->text));
+ cupsCopyString(choice->text, name, sizeof(choice->text));
if (option->section == PPD_ORDER_JCL)
ppd_decode(string); /* Decode quoted string */
if (!_cups_strcasecmp(spec, "custom") || !_cups_strncasecmp(spec, "custom.", 7))
{
temp->spec[0] = '_';
- strlcpy(temp->spec + 1, spec, sizeof(temp->spec) - 1);
+ cupsCopyString(temp->spec + 1, spec, sizeof(temp->spec) - 1);
}
else {
- strlcpy(temp->spec, spec, sizeof(temp->spec));
+ cupsCopyString(temp->spec, spec, sizeof(temp->spec));
}
- strlcpy(temp->name, name, sizeof(temp->name));
- strlcpy(temp->text, text, sizeof(temp->text));
+ cupsCopyString(temp->name, name, sizeof(temp->name));
+ cupsCopyString(temp->text, text, sizeof(temp->text));
temp->value = (char *)value;
/*
option->num_choices ++;
memset(choice, 0, sizeof(ppd_choice_t));
- strlcpy(choice->choice, name, sizeof(choice->choice));
+ cupsCopyString(choice->choice, name, sizeof(choice->choice));
return (choice);
}
ppd->num_sizes ++;
memset(size, 0, sizeof(ppd_size_t));
- strlcpy(size->name, name, sizeof(size->name));
+ cupsCopyString(size->name, name, sizeof(size->name));
return (size);
}
if ((copt = calloc(1, sizeof(ppd_coption_t))) == NULL)
return (NULL);
- strlcpy(copt->keyword, name, sizeof(copt->keyword));
+ cupsCopyString(copt->keyword, name, sizeof(copt->keyword));
copt->params = cupsArrayNew((cups_array_func_t)NULL, NULL);
return (NULL);
cparam->type = PPD_CUSTOM_UNKNOWN;
- strlcpy(cparam->name, param, sizeof(cparam->name));
- strlcpy(cparam->text, text[0] ? text : param, sizeof(cparam->text));
+ cupsCopyString(cparam->name, param, sizeof(cparam->name));
+ cupsCopyString(cparam->text, text[0] ? text : param, sizeof(cparam->text));
/*
* Add this record to the array...
ppd->num_groups ++;
memset(group, 0, sizeof(ppd_group_t));
- strlcpy(group->name, name, sizeof(group->name));
+ cupsCopyString(group->name, name, sizeof(group->name));
cupsCharsetToUTF8((cups_utf8_t *)group->text, text,
sizeof(group->text), encoding);
group->num_options ++;
memset(option, 0, sizeof(ppd_option_t));
- strlcpy(option->keyword, name, sizeof(option->keyword));
+ cupsCopyString(option->keyword, name, sizeof(option->keyword));
}
return (option);
size->width = w;
size->length = l;
- strlcpy(cg->pwg_name, pwg, sizeof(cg->pwg_name));
+ cupsCopyString(cg->pwg_name, pwg, sizeof(cg->pwg_name));
size->pwg = cg->pwg_name;
if (numer == 100)
h->cupsImagingBBox[2] = 612.0f;
h->cupsImagingBBox[3] = 792.0f;
- strlcpy(h->cupsPageSizeName, "Letter", sizeof(h->cupsPageSizeName));
+ cupsCopyString(h->cupsPageSizeName, "Letter", sizeof(h->cupsPageSizeName));
#ifdef __APPLE__
/*
right = size->right;
top = size->top;
- strlcpy(h->cupsPageSizeName, size->name, sizeof(h->cupsPageSizeName));
+ cupsCopyString(h->cupsPageSizeName, size->name, sizeof(h->cupsPageSizeName));
h->cupsPageSize[0] = size->width;
h->cupsPageSize[1] = size->length;
*/
if (!strcmp(name, "MediaClass") && obj->type == CUPS_PS_STRING)
- strlcpy(h->MediaClass, obj->value.string, sizeof(h->MediaClass));
+ cupsCopyString(h->MediaClass, obj->value.string, sizeof(h->MediaClass));
else if (!strcmp(name, "MediaColor") && obj->type == CUPS_PS_STRING)
- strlcpy(h->MediaColor, obj->value.string, sizeof(h->MediaColor));
+ cupsCopyString(h->MediaColor, obj->value.string, sizeof(h->MediaColor));
else if (!strcmp(name, "MediaType") && obj->type == CUPS_PS_STRING)
- strlcpy(h->MediaType, obj->value.string, sizeof(h->MediaType));
+ cupsCopyString(h->MediaType, obj->value.string, sizeof(h->MediaType));
else if (!strcmp(name, "OutputType") && obj->type == CUPS_PS_STRING)
- strlcpy(h->OutputType, obj->value.string, sizeof(h->OutputType));
+ cupsCopyString(h->OutputType, obj->value.string, sizeof(h->OutputType));
else if (!strcmp(name, "AdvanceDistance") && obj->type == CUPS_PS_NUMBER)
h->AdvanceDistance = (unsigned)obj->value.number;
else if (!strcmp(name, "AdvanceMedia") && obj->type == CUPS_PS_NUMBER)
if ((i = atoi(name + 10)) < 0 || i > 15)
return (-1);
- strlcpy(h->cupsString[i], obj->value.string, sizeof(h->cupsString[i]));
+ cupsCopyString(h->cupsString[i], obj->value.string, sizeof(h->cupsString[i]));
}
else if (!strcmp(name, "cupsMarkerType") && obj->type == CUPS_PS_STRING)
- strlcpy(h->cupsMarkerType, obj->value.string, sizeof(h->cupsMarkerType));
+ cupsCopyString(h->cupsMarkerType, obj->value.string, sizeof(h->cupsMarkerType));
else if (!strcmp(name, "cupsPageSizeName") && obj->type == CUPS_PS_STRING)
- strlcpy(h->cupsPageSizeName, obj->value.string,
+ cupsCopyString(h->cupsPageSizeName, obj->value.string,
sizeof(h->cupsPageSizeName));
else if (!strcmp(name, "cupsRenderingIntent") &&
obj->type == CUPS_PS_STRING)
- strlcpy(h->cupsRenderingIntent, obj->value.string,
+ cupsCopyString(h->cupsRenderingIntent, obj->value.string,
sizeof(h->cupsRenderingIntent));
else
{
memset(h, 0, sizeof(cups_page_header2_t));
- strlcpy(h->cupsPageSizeName, media->pwg, sizeof(h->cupsPageSizeName));
+ cupsCopyString(h->cupsPageSizeName, media->pwg, sizeof(h->cupsPageSizeName));
h->PageSize[0] = (unsigned)(72 * media->width / 2540);
h->PageSize[1] = (unsigned)(72 * media->length / 2540);
return (0);
}
- strlcpy(r->header.MediaClass, "PwgRaster", sizeof(r->header.MediaClass));
+ cupsCopyString(r->header.MediaClass, "PwgRaster", sizeof(r->header.MediaClass));
/* PwgRaster */
r->header.cupsBitsPerPixel = appleheader[0];
r->header.cupsColorSpace = appleheader[1] >= (sizeof(rawcspace) / sizeof(rawcspace[0])) ? CUPS_CSPACE_DEVICE1 : rawcspace[appleheader[1]];
r->header.MediaPosition = appleheader[5];
if (appleheader[4] < (int)(sizeof(apple_media_types) / sizeof(apple_media_types[0])))
- strlcpy(r->header.MediaType, apple_media_types[appleheader[4]], sizeof(r->header.MediaType));
+ cupsCopyString(r->header.MediaType, apple_media_types[appleheader[4]], sizeof(r->header.MediaType));
else
- strlcpy(r->header.MediaType, "other", sizeof(r->header.MediaType));
+ cupsCopyString(r->header.MediaType, "other", sizeof(r->header.MediaType));
}
break;
}
cups_page_header2_t fh; /* File page header */
memset(&fh, 0, sizeof(fh));
- strlcpy(fh.MediaClass, "PwgRaster", sizeof(fh.MediaClass));
- strlcpy(fh.MediaColor, r->header.MediaColor, sizeof(fh.MediaColor));
- strlcpy(fh.MediaType, r->header.MediaType, sizeof(fh.MediaType));
- strlcpy(fh.OutputType, r->header.OutputType, sizeof(fh.OutputType));
- strlcpy(fh.cupsRenderingIntent, r->header.cupsRenderingIntent,
+ cupsCopyString(fh.MediaClass, "PwgRaster", sizeof(fh.MediaClass));
+ cupsCopyString(fh.MediaColor, r->header.MediaColor, sizeof(fh.MediaColor));
+ cupsCopyString(fh.MediaType, r->header.MediaType, sizeof(fh.MediaType));
+ cupsCopyString(fh.OutputType, r->header.OutputType, sizeof(fh.OutputType));
+ cupsCopyString(fh.cupsRenderingIntent, r->header.cupsRenderingIntent,
sizeof(fh.cupsRenderingIntent));
- strlcpy(fh.cupsPageSizeName, r->header.cupsPageSizeName,
+ cupsCopyString(fh.cupsPageSizeName, r->header.cupsPageSizeName,
sizeof(fh.cupsPageSizeName));
fh.CutMedia = htonl(r->header.CutMedia);
*/
current_oid = real_data;
- strlcpy(last_oid, current_oid, sizeof(last_oid));
+ cupsCopyString(last_oid, current_oid, sizeof(last_oid));
}
}
while (status == CUPS_SC_STATUS_OK);
if (!cg->snmp_community[0])
{
- strlcpy(cg->snmp_community, "public", sizeof(cg->snmp_community));
+ cupsCopyString(cg->snmp_community, "public", sizeof(cg->snmp_community));
snprintf(line, sizeof(line), "%s/snmp.conf", cg->cups_serverroot);
if ((fp = cupsFileOpen(line, "r")) != NULL)
if (!_cups_strcasecmp(line, "Community"))
{
if (value)
- strlcpy(cg->snmp_community, value, sizeof(cg->snmp_community));
+ cupsCopyString(cg->snmp_community, value, sizeof(cg->snmp_community));
else
cg->snmp_community[0] = '\0';
packet.request_id = request_id;
packet.object_type = CUPS_ASN1_NULL_VALUE;
- strlcpy(packet.community, community, sizeof(packet.community));
+ cupsCopyString(packet.community, community, sizeof(packet.community));
for (i = 0; oid[i] >= 0 && i < (CUPS_SNMP_MAX_OID - 1); i ++)
packet.object_name[i] = oid[i];
{
if ((bufptr + templen) > bufend)
{
- strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
+ cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr));
bufptr = bufend;
}
else
{
if ((bufptr + templen) > bufend)
{
- strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
+ cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr));
bufptr = bufend;
}
else
{
if ((bufptr + templen) > bufend)
{
- strlcpy(bufptr, temp, (size_t)(bufend - bufptr));
+ cupsCopyString(bufptr, temp, (size_t)(bufend - bufptr));
bufptr = bufend;
}
else
}
else
{
- strlcpy(buf, temp, (size_t)(bufend - buf + 1));
+ cupsCopyString(buf, temp, (size_t)(bufend - buf + 1));
bufptr = buf + strlen(buf);
}
if (loc && loc->decimal_point)
{
- strlcpy(tempptr, loc->decimal_point, sizeof(temp) - (size_t)(tempptr - temp));
+ cupsCopyString(tempptr, loc->decimal_point, sizeof(temp) - (size_t)(tempptr - temp));
tempptr += strlen(tempptr);
}
else if (tempptr < (temp + sizeof(temp) - 1))
#ifndef HAVE_STRLCAT
/*
- * '_cups_strlcat()' - Safely concatenate two strings.
+ * '_cups_cupsConcatString()' - Safely concatenate two strings.
*/
size_t /* O - Length of string */
-_cups_strlcat(char *dst, /* O - Destination string */
+_cups_cupsConcatString(char *dst, /* O - Destination string */
const char *src, /* I - Source string */
size_t size) /* I - Size of destination string buffer */
{
#ifndef HAVE_STRLCPY
/*
- * '_cups_strlcpy()' - Safely copy two strings.
+ * '_cups_cupsCopyString()' - Safely copy two strings.
*/
size_t /* O - Length of string */
-_cups_strlcpy(char *dst, /* O - Destination string */
+_cups_cupsCopyString(char *dst, /* O - Destination string */
const char *src, /* I - Source string */
size_t size) /* I - Size of destination string buffer */
{
* the same buffer in the first place... :)
*/
- strlcpy(word, text, sizeof(word));
+ cupsCopyString(word, text, sizeof(word));
/*
* Grab the next word and compare...
printf("PRINTER: %s (%s)\n", ippEnumString("printer-state", (int)printer_state), printer_state_reasons);
data->printer_state = printer_state;
- strlcpy(data->printer_state_reasons, printer_state_reasons, sizeof(data->printer_state_reasons));
+ cupsCopyString(data->printer_state_reasons, printer_state_reasons, sizeof(data->printer_state_reasons));
}
ippDelete(response);
printf("JOB %d: %s (%s)\n", data->job_id, ippEnumString("job-state", (int)job_state), job_state_reasons);
data->job_state = job_state;
- strlcpy(data->job_state_reasons, job_state_reasons, sizeof(data->job_state_reasons));
+ cupsCopyString(data->job_state_reasons, job_state_reasons, sizeof(data->job_state_reasons));
}
ippDelete(response);
fputs("cupsCharsetToUTF8(CUPS_ISO8859_1): ", stdout);
- strlcpy(legsrc, legdest, sizeof(legsrc));
+ cupsCopyString(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_1);
if ((size_t)len != strlen((char *)utf8latin))
fputs("cupsCharsetToUTF8(CUPS_ISO8859_7): ", stdout);
- strlcpy(legsrc, legdest, sizeof(legsrc));
+ cupsCopyString(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_ISO8859_7);
if ((size_t)len != strlen((char *)utf8greek))
fputs("cupsCharsetToUTF8(CUPS_WINDOWS_932): ", stdout);
- strlcpy(legsrc, legdest, sizeof(legsrc));
+ cupsCopyString(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_932);
if ((size_t)len != strlen((char *)utf8japan))
#if !defined(__linux__) && !defined(__GLIBC__)
fputs("cupsCharsetToUTF8(CUPS_EUC_JP): ", stdout);
- strlcpy(legsrc, legdest, sizeof(legsrc));
+ cupsCopyString(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_JP);
if ((size_t)len != strlen((char *)utf8japan))
fputs("cupsCharsetToUTF8(CUPS_WINDOWS_950): ", stdout);
- strlcpy(legsrc, legdest, sizeof(legsrc));
+ cupsCopyString(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_WINDOWS_950);
if ((size_t)len != strlen((char *)utf8taiwan))
fputs("cupsCharsetToUTF8(CUPS_EUC_TW): ", stdout);
- strlcpy(legsrc, legdest, sizeof(legsrc));
+ cupsCopyString(legsrc, legdest, sizeof(legsrc));
len = cupsCharsetToUTF8(utf8dest, legsrc, 1024, CUPS_EUC_TW);
if ((size_t)len != strlen((char *)utf8taiwan))
if ((realsize = readlink(filename, realfile, sizeof(realfile) - 1)) < 0)
- strlcpy(realfile, "Unknown", sizeof(realfile));
+ cupsCopyString(realfile, "Unknown", sizeof(realfile));
else
realfile[realsize] = '\0';
header.cupsPageSize[0] = 288.0f;
header.cupsPageSize[1] = 288.0f;
- strlcpy(header.MediaType, "auto", sizeof(header.MediaType));
+ cupsCopyString(header.MediaType, "auto", sizeof(header.MediaType));
if (page & 1)
{
expected.PageSize[0] = 288;
expected.PageSize[1] = 288;
- strlcpy(expected.MediaType, "auto", sizeof(expected.MediaType));
+ cupsCopyString(expected.MediaType, "auto", sizeof(expected.MediaType));
if (mode != CUPS_RASTER_WRITE_PWG)
{
if (mode >= CUPS_RASTER_WRITE_PWG)
{
- strlcpy(expected.MediaClass, "PwgRaster", sizeof(expected.MediaClass));
+ cupsCopyString(expected.MediaClass, "PwgRaster", sizeof(expected.MediaClass));
expected.cupsInteger[7] = 0xffffff;
}
if (encoding == CUPS_UTF8 || encoding <= CUPS_US_ASCII ||
encoding >= CUPS_ENCODING_VBCS_END)
{
- strlcpy((char *)dest, src, (size_t)maxout);
+ cupsCopyString((char *)dest, src, (size_t)maxout);
return ((int)strlen((char *)dest));
}
if (encoding == CUPS_UTF8 ||
encoding >= CUPS_ENCODING_VBCS_END)
{
- strlcpy(dest, (char *)src, (size_t)maxout);
+ cupsCopyString(dest, (char *)src, (size_t)maxout);
return ((int)strlen(dest));
}
if (server)
{
- strlcpy(cg->server, server, sizeof(cg->server));
+ cupsCopyString(cg->server, server, sizeof(cg->server));
if (cg->server[0] != '/' && (options = strrchr(cg->server, '/')) != NULL)
{
cups_set_default_ipp_port(cg);
if (cg->server[0] == '/')
- strlcpy(cg->servername, "localhost", sizeof(cg->servername));
+ cupsCopyString(cg->servername, "localhost", sizeof(cg->servername));
else
- strlcpy(cg->servername, cg->server, sizeof(cg->servername));
+ cupsCopyString(cg->servername, cg->server, sizeof(cg->servername));
}
else
{
if (user)
- strlcpy(cg->user, user, sizeof(cg->user));
+ cupsCopyString(cg->user, user, sizeof(cg->user));
else
cg->user[0] = '\0';
}
if (user_agent)
{
- strlcpy(cg->user_agent, user_agent, sizeof(cg->user_agent));
+ cupsCopyString(cg->user_agent, user_agent, sizeof(cg->user_agent));
return;
}
cg->user_agent[0] = '\0';
break;
case _CUPS_UATOKENS_PRODUCT_ONLY :
- strlcpy(cg->user_agent, "CUPS IPP", sizeof(cg->user_agent));
+ cupsCopyString(cg->user_agent, "CUPS IPP", sizeof(cg->user_agent));
break;
case _CUPS_UATOKENS_MAJOR :
snprintf(cg->user_agent, sizeof(cg->user_agent), "CUPS/%d IPP/2", CUPS_VERSION_MAJOR);
snprintf(cg->user_agent, sizeof(cg->user_agent), "CUPS/%d.%d IPP/2.1", CUPS_VERSION_MAJOR, CUPS_VERSION_MINOR);
break;
case _CUPS_UATOKENS_MINIMAL :
- strlcpy(cg->user_agent, CUPS_MINIMAL " IPP/2.1", sizeof(cg->user_agent));
+ cupsCopyString(cg->user_agent, CUPS_MINIMAL " IPP/2.1", sizeof(cg->user_agent));
break;
}
}
if (!sysctlbyname("kern.osproductversion", version, &len, NULL, 0))
version[len] = '\0';
else
- strlcpy(version, "unknown", sizeof(version));
+ cupsCopyString(version, "unknown", sizeof(version));
# if TARGET_OS_OSX
if (cg->uatokens == _CUPS_UATOKENS_OS)
cups_set_default_ipp_port(cg);
if (!cg->user[0])
- strlcpy(cg->user, cc.user, sizeof(cg->user));
+ cupsCopyString(cg->user, cc.user, sizeof(cg->user));
#ifdef HAVE_GSSAPI
if (!cg->gss_service_name[0])
- strlcpy(cg->gss_service_name, cc.gss_service_name, sizeof(cg->gss_service_name));
+ cupsCopyString(cg->gss_service_name, cc.gss_service_name, sizeof(cg->gss_service_name));
#endif /* HAVE_GSSAPI */
if (cg->trust_first < 0)
getpwuid_r(getuid(), &pw, cg->pw_buf, PW_BUF_SIZE, &result);
if (result)
- strlcpy(cc->user, pw.pw_name, sizeof(cc->user));
+ cupsCopyString(cc->user, pw.pw_name, sizeof(cc->user));
else
#endif /* _WIN32 */
{
* Use the default "unknown" user name...
*/
- strlcpy(cc->user, "unknown", sizeof(cc->user));
+ cupsCopyString(cc->user, "unknown", sizeof(cc->user));
}
}
sval[0] = '\0';
if (cups_apple_get_boolean(kAllowRC4, &bval) && bval)
- strlcat(sval, " AllowRC4", sizeof(sval));
+ cupsConcatString(sval, " AllowRC4", sizeof(sval));
if (cups_apple_get_boolean(kAllowSSL3, &bval) && bval)
- strlcat(sval, " AllowSSL3", sizeof(sval));
+ cupsConcatString(sval, " AllowSSL3", sizeof(sval));
if (cups_apple_get_boolean(kAllowDH, &bval) && bval)
- strlcat(sval, " AllowDH", sizeof(sval));
+ cupsConcatString(sval, " AllowDH", sizeof(sval));
if (sval[0])
cups_set_ssl_options(cc, sval);
cups_set_digestoptions(cc, sval);
if (cups_apple_get_string(kUserKey, sval, sizeof(sval)))
- strlcpy(cc->user, sval, sizeof(cc->user));
+ cupsCopyString(cc->user, sval, sizeof(cc->user));
if (cups_apple_get_string(kUserAgentTokensKey, sval, sizeof(sval)))
cups_set_uatokens(cc, sval);
_cups_client_conf_t *cc, /* I - client.conf values */
const char *value) /* I - Value */
{
- strlcpy(cc->gss_service_name, value, sizeof(cc->gss_service_name));
+ cupsCopyString(cc->gss_service_name, value, sizeof(cc->gss_service_name));
}
#endif /* HAVE_GSSAPI */
_cups_client_conf_t *cc, /* I - client.conf values */
const char *value) /* I - Value */
{
- strlcpy(cc->server_name, value, sizeof(cc->server_name));
+ cupsCopyString(cc->server_name, value, sizeof(cc->server_name));
}
*end; /* End of option */
- strlcpy(temp, value, sizeof(temp));
+ cupsCopyString(temp, value, sizeof(temp));
for (start = temp; *start; start = end)
{
_cups_client_conf_t *cc, /* I - client.conf values */
const char *value) /* I - Value */
{
- strlcpy(cc->user, value, sizeof(cc->user));
+ cupsCopyString(cc->user, value, sizeof(cc->user));
}
if ((attr = ippFindAttribute(response, "printer-name",
IPP_TAG_NAME)) != NULL)
{
- strlcpy(cg->def_printer, attr->values[0].string.text,
+ cupsCopyString(cg->def_printer, attr->values[0].string.text,
sizeof(cg->def_printer));
ippDelete(response);
return (cg->def_printer);
}
}
else
- strlcpy(uri, "ipp://localhost/", sizeof(uri));
+ cupsCopyString(uri, "ipp://localhost/", sizeof(uri));
if (!http)
if ((http = _cupsConnect()) == NULL)
if (!name || (!data && datasize > 0) || datasize > PPDX_MAX_DATA)
return;
- strlcpy(line, "PPD:", sizeof(line));
+ cupsCopyString(line, "PPD:", sizeof(line));
lineptr = line + 4;
lineend = line + sizeof(line) - 2;
lineptr = line + 4;
}
- strlcpy(lineptr, pair, lineend - lineptr);
+ cupsCopyString(lineptr, pair, lineend - lineptr);
lineptr += len;
/*
lineptr = line + 4;
}
- strlcpy(lineptr, pair, lineend - lineptr);
+ cupsCopyString(lineptr, pair, lineend - lineptr);
lineptr += len;
*lineptr++ = '\n';
options)) != NULL)
{
if (!strcmp(val, "automatic"))
- strlcpy(outheader.OutputType, "Automatic",
+ cupsCopyString(outheader.OutputType, "Automatic",
sizeof(outheader.OutputType));
else if (!strcmp(val, "graphics"))
- strlcpy(outheader.OutputType, "Graphics", sizeof(outheader.OutputType));
+ cupsCopyString(outheader.OutputType, "Graphics", sizeof(outheader.OutputType));
else if (!strcmp(val, "photo"))
- strlcpy(outheader.OutputType, "Photo", sizeof(outheader.OutputType));
+ cupsCopyString(outheader.OutputType, "Photo", sizeof(outheader.OutputType));
else if (!strcmp(val, "text"))
- strlcpy(outheader.OutputType, "Text", sizeof(outheader.OutputType));
+ cupsCopyString(outheader.OutputType, "Text", sizeof(outheader.OutputType));
else if (!strcmp(val, "text-and-graphics"))
- strlcpy(outheader.OutputType, "TextAndGraphics",
+ cupsCopyString(outheader.OutputType, "TextAndGraphics",
sizeof(outheader.OutputType));
else
{
options)) != NULL)
{
if (!strcmp(val, "absolute"))
- strlcpy(outheader.cupsRenderingIntent, "Absolute",
+ cupsCopyString(outheader.cupsRenderingIntent, "Absolute",
sizeof(outheader.cupsRenderingIntent));
else if (!strcmp(val, "automatic"))
- strlcpy(outheader.cupsRenderingIntent, "Automatic",
+ cupsCopyString(outheader.cupsRenderingIntent, "Automatic",
sizeof(outheader.cupsRenderingIntent));
else if (!strcmp(val, "perceptual"))
- strlcpy(outheader.cupsRenderingIntent, "Perceptual",
+ cupsCopyString(outheader.cupsRenderingIntent, "Perceptual",
sizeof(outheader.cupsRenderingIntent));
else if (!strcmp(val, "relative"))
- strlcpy(outheader.cupsRenderingIntent, "Relative",
+ cupsCopyString(outheader.cupsRenderingIntent, "Relative",
sizeof(outheader.cupsRenderingIntent));
else if (!strcmp(val, "relative-bpc"))
- strlcpy(outheader.cupsRenderingIntent, "RelativeBpc",
+ cupsCopyString(outheader.cupsRenderingIntent, "RelativeBpc",
sizeof(outheader.cupsRenderingIntent));
else if (!strcmp(val, "saturation"))
- strlcpy(outheader.cupsRenderingIntent, "Saturation",
+ cupsCopyString(outheader.cupsRenderingIntent, "Saturation",
sizeof(outheader.cupsRenderingIntent));
else
{
if (inheader.cupsPageSizeName[0] && (pwg_size = _ppdCacheGetSize(cache, inheader.cupsPageSizeName)) != NULL && pwg_size->map.pwg)
{
- strlcpy(outheader.cupsPageSizeName, pwg_size->map.pwg,
+ cupsCopyString(outheader.cupsPageSizeName, pwg_size->map.pwg,
sizeof(outheader.cupsPageSizeName));
}
else
(int)(2540.0 * inheader.cupsPageSize[1] / 72.0));
if (pwg_media)
- strlcpy(outheader.cupsPageSizeName, pwg_media->pwg,
+ cupsCopyString(outheader.cupsPageSizeName, pwg_media->pwg,
sizeof(outheader.cupsPageSizeName));
else
{
* Anchor for HTML output...
*/
- strlcpy(anchor, line + 4, sizeof(anchor));
+ cupsCopyString(anchor, line + 4, sizeof(anchor));
}
else if (strncmp(line, ".\\\"", 3))
{
if (!line[0])
continue; // Skip initial blank line
}
-
+
html_fputs(line, &font, outfile);
putc('\n', outfile);
manfile[1024], // Man page filename
manurl[1024]; // Man page URL
- strlcpy(name, s, sizeof(name));
+ cupsCopyString(name, s, sizeof(name));
if ((size_t)(end - s) < sizeof(name))
name[end - s] = '\0';
if (i)
*p++ = ',';
- strlcpy(p, ippGetString(attr, i, NULL), reasons_length - (size_t)(p - printer_reasons));
+ cupsCopyString(p, ippGetString(attr, i, NULL), reasons_length - (size_t)(p - printer_reasons));
p += strlen(p);
}
if (!dbus_message_iter_append_string(&iter, &printer_reasons))
if (i)
*p++ = ',';
- strlcpy(p, ippGetString(attr, i, NULL), reasons_length - (size_t)(p - job_reasons));
+ cupsCopyString(p, ippGetString(attr, i, NULL), reasons_length - (size_t)(p - job_reasons));
p += strlen(p);
}
if (!dbus_message_iter_append_string(&iter, &job_reasons))
httpDecode64_2(temp, &templen, argv[2]);
if (!strncmp(temp, "mailto:", 7))
- strlcpy(mailtoReplyTo, temp + 7, sizeof(mailtoReplyTo));
+ cupsCopyString(mailtoReplyTo, temp + 7, sizeof(mailtoReplyTo));
else if (temp[0])
fprintf(stderr, "WARNING: Bad notify-user-data value (%d bytes) ignored!\n",
templen);
mailtoCc[0] = '\0';
if ((server_admin = getenv("SERVER_ADMIN")) != NULL)
- strlcpy(mailtoFrom, server_admin, sizeof(mailtoFrom));
+ cupsCopyString(mailtoFrom, server_admin, sizeof(mailtoFrom));
else
snprintf(mailtoFrom, sizeof(mailtoFrom), "root@%s",
httpGetHostname(NULL, line, sizeof(line)));
- strlcpy(mailtoSendmail, "/usr/sbin/sendmail", sizeof(mailtoSendmail));
+ cupsCopyString(mailtoSendmail, "/usr/sbin/sendmail", sizeof(mailtoSendmail));
mailtoSMTPServer[0] = '\0';
}
if (!_cups_strcasecmp(line, "Cc"))
- strlcpy(mailtoCc, value, sizeof(mailtoCc));
+ cupsCopyString(mailtoCc, value, sizeof(mailtoCc));
else if (!_cups_strcasecmp(line, "From"))
- strlcpy(mailtoFrom, value, sizeof(mailtoFrom));
+ cupsCopyString(mailtoFrom, value, sizeof(mailtoFrom));
else if (!_cups_strcasecmp(line, "Sendmail"))
{
- strlcpy(mailtoSendmail, value, sizeof(mailtoSendmail));
+ cupsCopyString(mailtoSendmail, value, sizeof(mailtoSendmail));
mailtoSMTPServer[0] = '\0';
}
else if (!_cups_strcasecmp(line, "SMTPServer"))
{
mailtoSendmail[0] = '\0';
- strlcpy(mailtoSMTPServer, value, sizeof(mailtoSMTPServer));
+ cupsCopyString(mailtoSMTPServer, value, sizeof(mailtoSMTPServer));
}
else if (!_cups_strcasecmp(line, "Subject"))
- strlcpy(mailtoSubject, value, sizeof(mailtoSubject));
+ cupsCopyString(mailtoSubject, value, sizeof(mailtoSubject));
else
{
fprintf(stderr,
* First break the mailtoSendmail string into arguments...
*/
- strlcpy(line, mailtoSendmail, sizeof(line));
+ cupsCopyString(line, mailtoSendmail, sizeof(line));
argv[0] = line;
argc = 1;
return (1);
}
- strlcpy(newname, filename, sizeof(newname));
+ cupsCopyString(newname, filename, sizeof(newname));
httpAssembleURI(HTTP_URI_CODING_ALL, baseurl, sizeof(baseurl), "http",
NULL, host, port, resource);
char baseloc[3]; // Base locale...
- strlcpy(baseloc, l, sizeof(baseloc));
+ cupsCopyString(baseloc, l, sizeof(baseloc));
snprintf(pofile, sizeof(pofile), "%s/%s/cups_%s.po", cg->localedir,
baseloc, baseloc);
if (haveid && havestr)
add_message(id, str);
- strlcpy(id, ptr, sizeof(id));
+ cupsCopyString(id, ptr, sizeof(id));
str[0] = '\0';
haveid = 1;
havestr = 0;
return (-1);
}
- strlcpy(str, ptr, sizeof(str));
+ cupsCopyString(str, ptr, sizeof(str));
havestr = 1;
which = 2;
}
else if (line[0] == '\"' && which == 2)
- strlcat(str, ptr, sizeof(str));
+ cupsConcatString(str, ptr, sizeof(str));
else if (line[0] == '\"' && which == 1)
- strlcat(id, ptr, sizeof(id));
+ cupsConcatString(id, ptr, sizeof(id));
else
{
_cupsLangPrintf(stderr, _("ppdc: Unexpected text on line %d of %s."),
for (i = 0; i < ppd->num_filters; i ++)
{
- strlcpy(line, ppd->filters[i], sizeof(line));
+ cupsCopyString(line, ppd->filters[i], sizeof(line));
for (ptr = line; *ptr; ptr ++)
if (isspace(*ptr & 255))
if (*f == '<')
{
// Remove the surrounding <> from the name...
- strlcpy(temp, f + 1, sizeof(temp));
+ cupsCopyString(temp, f + 1, sizeof(temp));
ptr = temp + strlen(temp) - 1;
if (*ptr != '>')
if (base && *base && f[0] != '/')
snprintf(n, (size_t)nlen, "%s/%s", base, f);
else
- strlcpy(n, f, (size_t)nlen);
+ cupsCopyString(n, f, (size_t)nlen);
if (!access(n, 0))
return (n);
while (isspace(*ptr))
ptr ++;
- strlcpy(program, ptr, sizeof(program));
+ cupsCopyString(program, ptr, sizeof(program));
}
else
{
}
// Figure out the current directory...
- strlcpy(basedir, fp->filename, sizeof(basedir));
+ cupsCopyString(basedir, fp->filename, sizeof(basedir));
if ((baseptr = strrchr(basedir, '/')) != NULL)
*baseptr = '\0';
else
- strlcpy(basedir, ".", sizeof(basedir));
+ cupsCopyString(basedir, ".", sizeof(basedir));
// Find the po file...
pofilename[0] = '\0';
var = find_variable(name);
if (var)
{
- strlcpy(bufptr, var->value->value, (size_t)(bufend - bufptr + 1));
+ cupsCopyString(bufptr, var->value->value, (size_t)(bufend - bufptr + 1));
bufptr += strlen(bufptr);
}
else
continue;
// Figure out the current directory...
- strlcpy(basedir, fp->filename, sizeof(basedir));
+ cupsCopyString(basedir, fp->filename, sizeof(basedir));
if ((baseptr = strrchr(basedir, '/')) != NULL)
*baseptr = '\0';
else
- strlcpy(basedir, ".", sizeof(basedir));
+ cupsCopyString(basedir, ".", sizeof(basedir));
// Find the include file...
if (find_include(inctemp, basedir, incname, sizeof(incname)))
locales = new ppdcArray();
- strlcpy(temp, argv[i], sizeof(temp));
+ cupsCopyString(temp, argv[i], sizeof(temp));
for (start = temp; *start; start = end)
{
if ((end = strchr(start, ',')) != NULL)
else
{
// Leave PCFileName as-is...
- strlcpy(pcfilename, outname, sizeof(pcfilename));
+ cupsCopyString(pcfilename, outname, sizeof(pcfilename));
}
// Open the PPD file for writing...
snprintf(locale, sizeof(locale), "%s_%s", languages[i].language,
ppd->lang_version + vlen + 1);
else
- strlcpy(locale, languages[i].language, sizeof(locale));
+ cupsCopyString(locale, languages[i].language, sizeof(locale));
return (locale);
}
* Deny *interface*...
*/
- strlcpy(ifname, name + 4, sizeof(ifname));
+ cupsCopyString(ifname, name + 4, sizeof(ifname));
ifptr = ifname + strlen(ifname) - 1;
if (authinfo->count == 1 && authinfo->items[0].value &&
authinfo->items[0].valueLength >= 2)
{
- strlcpy(username, authinfo->items[0].value, sizeof(username));
+ cupsCopyString(username, authinfo->items[0].value, sizeof(username));
cupsdLogClient(con, CUPSD_LOG_DEBUG, "Authorized as \"%s\" using AuthRef.", username);
}
return;
}
- strlcpy(username, pwd->pw_name, sizeof(username));
+ cupsCopyString(username, pwd->pw_name, sizeof(username));
cupsdLogClient(con, CUPSD_LOG_DEBUG, "Authorized as \"%s\" using AuthRef + PeerCred.", username);
}
return;
}
- strlcpy(username, authorization + 9, sizeof(username));
+ cupsCopyString(username, authorization + 9, sizeof(username));
# ifdef HAVE_GSSAPI
con->gss_uid = CUPSD_UCRED_UID(peercred);
return;
}
- strlcpy(username, localuser->username, sizeof(username));
+ cupsCopyString(username, localuser->username, sizeof(username));
con->type = localuser->type;
cupsdLogClient(con, CUPSD_LOG_DEBUG, "Authorized as %s using Local.", username);
return;
}
- strlcpy(password, ptr, sizeof(password));
+ cupsCopyString(password, ptr, sizeof(password));
/*
* Validate the username and password...
cupsd_authdata_t data; /* Authentication data */
- strlcpy(data.username, username, sizeof(data.username));
- strlcpy(data.password, password, sizeof(data.password));
+ cupsCopyString(data.username, username, sizeof(data.username));
+ cupsCopyString(data.password, password, sizeof(data.password));
# ifdef __sun
pamdata.conv = (int (*)(int, struct pam_message **,
return;
}
- strlcpy(username, output_token.value, sizeof(username));
+ cupsCopyString(username, output_token.value, sizeof(username));
cupsdLogClient(con, CUPSD_LOG_DEBUG, "Authorized as \"%s\" using Negotiate.", username);
if (sscanf(authorization, "%255s", scheme) != 1)
- strlcpy(scheme, "UNKNOWN", sizeof(scheme));
+ cupsCopyString(scheme, "UNKNOWN", sizeof(scheme));
cupsdLogClient(con, CUPSD_LOG_ERROR, "Bad authentication data \"%s ...\".", scheme);
return;
* data and return...
*/
- strlcpy(con->username, username, sizeof(con->username));
- strlcpy(con->password, password, sizeof(con->password));
+ cupsCopyString(con->username, username, sizeof(con->username));
+ cupsCopyString(con->password, password, sizeof(con->password));
}
* URIs...
*/
- strlcpy(uri, path, sizeof(uri));
+ cupsCopyString(uri, path, sizeof(uri));
if ((uriptr = strchr(uri, '?')) != NULL)
*uriptr = '\0'; /* Drop trailing query string */
cupsdLogMessage(CUPSD_LOG_DEBUG,
"cupsdIsAuthorized: requesting-user-name=\"%s\"",
attr->values[0].string.text);
- strlcpy(username, attr->values[0].string.text, sizeof(username));
+ cupsCopyString(username, attr->values[0].string.text, sizeof(username));
}
else if (best->satisfy == CUPSD_AUTH_SATISFY_ALL || auth == CUPSD_AUTH_DENY)
return (HTTP_STATUS_UNAUTHORIZED); /* Non-anonymous needs user/pass */
return (HTTP_STATUS_UNAUTHORIZED);
}
- strlcpy(username, con->username, sizeof(username));
+ cupsCopyString(username, con->username, sizeof(username));
}
/*
if (owner)
{
- strlcpy(ownername, owner, sizeof(ownername));
+ cupsCopyString(ownername, owner, sizeof(ownername));
if ((ptr = strchr(ownername, '@')) != NULL)
*ptr = '\0';
cert->pid = pid;
cert->type = type;
- strlcpy(cert->username, username, sizeof(cert->username));
+ cupsCopyString(cert->username, username, sizeof(cert->username));
for (i = 0; i < 32; i ++)
cert->certificate[i] = hex[CUPS_RAND() & 15];
*/
if (value)
- strlcpy(p->state_message, value, sizeof(p->state_message));
+ cupsCopyString(p->state_message, value, sizeof(p->state_message));
}
else if (!_cups_strcasecmp(line, "StateTime"))
{
switch (pclass->num_auth_info_required)
{
case 1 :
- strlcpy(value, pclass->auth_info_required[0], sizeof(value));
+ cupsCopyString(value, pclass->auth_info_required[0], sizeof(value));
break;
case 2 :
cupsdLogClient(con, CUPSD_LOG_ERROR, "Unable to get local address - %s",
strerror(errno));
- strlcpy(con->servername, "localhost", sizeof(con->servername));
+ cupsCopyString(con->servername, "localhost", sizeof(con->servername));
con->serverport = LocalPort;
}
#ifdef AF_LOCAL
else if (httpAddrGetFamily(&temp) == AF_LOCAL)
{
- strlcpy(con->servername, "localhost", sizeof(con->servername));
+ cupsCopyString(con->servername, "localhost", sizeof(con->servername));
con->serverport = LocalPort;
}
#endif /* AF_LOCAL */
else
{
if (httpAddrIsLocalhost(&temp))
- strlcpy(con->servername, "localhost", sizeof(con->servername));
+ cupsCopyString(con->servername, "localhost", sizeof(con->servername));
else if (HostNameLookups)
httpAddrLookup(&temp, con->servername, sizeof(con->servername));
else
* con->uri are HTTP_MAX_URI bytes in size...
*/
- strlcpy(con->uri, resource, sizeof(con->uri));
+ cupsCopyString(con->uri, resource, sizeof(con->uri));
}
/*
else
{
if (type == NULL)
- strlcpy(line, "text/plain", sizeof(line));
+ cupsCopyString(line, "text/plain", sizeof(line));
else
snprintf(line, sizeof(line), "%s/%s", type->super, type->type);
type = mimeFileType(MimeDatabase, filename, NULL, NULL);
if (type == NULL)
- strlcpy(line, "text/plain", sizeof(line));
+ cupsCopyString(line, "text/plain", sizeof(line));
else
snprintf(line, sizeof(line), "%s/%s", type->super, type->type);
* never disable it in that case.
*/
- strlcpy(location, httpGetField(con->http, HTTP_FIELD_LOCATION), sizeof(location));
+ cupsCopyString(location, httpGetField(con->http, HTTP_FIELD_LOCATION), sizeof(location));
httpClearFields(con->http);
httpClearCookie(con->http);
if (auth_type == CUPSD_AUTH_BASIC)
{
- strlcpy(auth_str, "Basic realm=\"CUPS\"", sizeof(auth_str));
+ cupsCopyString(auth_str, "Basic realm=\"CUPS\"", sizeof(auth_str));
}
else if (auth_type == CUPSD_AUTH_NEGOTIATE)
{
- strlcpy(auth_str, "Negotiate", sizeof(auth_str));
+ cupsCopyString(auth_str, "Negotiate", sizeof(auth_str));
}
if (con->best && !con->is_browser && !_cups_strcasecmp(httpGetHostname(con->http, NULL, 0), "localhost"))
#if defined(SO_PEERCRED) && defined(AF_LOCAL)
if (httpAddrGetFamily(httpGetAddress(con->http)) == AF_LOCAL)
{
- strlcpy(auth_key, ", PeerCred", auth_size);
+ cupsCopyString(auth_key, ", PeerCred", auth_size);
auth_key += 10;
auth_size -= 10;
}
snprintf(auth_key, auth_size, ", AuthRef key=\"%s\", Local trc=\"y\"", SystemGroupAuthKey);
else
#endif /* HAVE_AUTHORIZATION_H */
- strlcpy(auth_key, ", Local trc=\"y\"", auth_size);
+ cupsCopyString(auth_key, ", Local trc=\"y\"", auth_size);
need_local = 0;
break;
}
}
if (need_local)
- strlcat(auth_key, ", Local", auth_size);
+ cupsConcatString(auth_key, ", Local", auth_size);
}
if (auth_str[0])
}
else if ((!strncmp(con->uri, "/ppd/", 5) || !strncmp(con->uri, "/printers/", 10) || !strncmp(con->uri, "/classes/", 9)) && !strcmp(con->uri + strlen(con->uri) - 4, ".ppd"))
{
- strlcpy(dest, strchr(con->uri + 1, '/') + 1, sizeof(dest));
+ cupsCopyString(dest, strchr(con->uri + 1, '/') + 1, sizeof(dest));
dest[strlen(dest) - 4] = '\0'; /* Strip .ppd */
if ((p = cupsdFindDest(dest)) == NULL)
{
- strlcpy(filename, "/", len);
+ cupsCopyString(filename, "/", len);
cupsdLogClient(con, CUPSD_LOG_INFO, "No destination \"%s\" found.", dest);
return (NULL);
}
}
else if ((!strncmp(con->uri, "/icons/", 7) || !strncmp(con->uri, "/printers/", 10) || !strncmp(con->uri, "/classes/", 9)) && !strcmp(con->uri + strlen(con->uri) - 4, ".png"))
{
- strlcpy(dest, strchr(con->uri + 1, '/') + 1, sizeof(dest));
+ cupsCopyString(dest, strchr(con->uri + 1, '/') + 1, sizeof(dest));
dest[strlen(dest) - 4] = '\0'; /* Strip .png */
if ((p = cupsdFindDest(dest)) == NULL)
{
- strlcpy(filename, "/", len);
+ cupsCopyString(filename, "/", len);
cupsdLogClient(con, CUPSD_LOG_INFO, "No destination \"%s\" found.", dest);
return (NULL);
}
}
else if (!strcmp(con->uri, "/admin/conf/cupsd.conf"))
{
- strlcpy(filename, ConfigurationFile, len);
+ cupsCopyString(filename, ConfigurationFile, len);
perm_check = 0;
}
else if (!strncmp(con->uri, "/admin/log/", 11))
{
if (!strncmp(con->uri + 11, "access_log", 10) && AccessLog[0] == '/')
- strlcpy(filename, AccessLog, len);
+ cupsCopyString(filename, AccessLog, len);
else if (!strncmp(con->uri + 11, "error_log", 9) && ErrorLog[0] == '/')
- strlcpy(filename, ErrorLog, len);
+ cupsCopyString(filename, ErrorLog, len);
else if (!strncmp(con->uri + 11, "page_log", 8) && PageLog[0] == '/')
- strlcpy(filename, PageLog, len);
+ cupsCopyString(filename, PageLog, len);
else
return (NULL);
snprintf(filename, len, "%s/rss/%s", CacheDir, con->uri + 5);
else if (!strncmp(con->uri, "/strings/", 9) && !strcmp(con->uri + strlen(con->uri) - 8, ".strings"))
{
- strlcpy(dest, con->uri + 9, sizeof(dest));
+ cupsCopyString(dest, con->uri + 9, sizeof(dest));
dest[strlen(dest) - 8] = '\0';
if ((p = cupsdFindDest(dest)) == NULL)
{
- strlcpy(filename, "/", len);
+ cupsCopyString(filename, "/", len);
cupsdLogClient(con, CUPSD_LOG_INFO, "No destination \"%s\" found.", dest);
return (NULL);
}
if (!p->strings)
{
- strlcpy(filename, "/", len);
+ cupsCopyString(filename, "/", len);
cupsdLogClient(con, CUPSD_LOG_INFO, "No strings files for \"%s\".", dest);
return (NULL);
}
- strlcpy(filename, p->strings, len);
+ cupsCopyString(filename, p->strings, len);
perm_check = 0;
}
*/
if (con->uri[strlen(con->uri) - 1] != '/')
- strlcat(con->uri, "/", sizeof(con->uri));
+ cupsConcatString(con->uri, "/", sizeof(con->uri));
/*
* Find the directory index file, trying every language...
ptr = filename + strlen(filename);
plen = len - (size_t)(ptr - filename);
- strlcpy(ptr, "index.html", plen);
+ cupsCopyString(ptr, "index.html", plen);
status = lstat(filename, filestats);
}
while (status && language[0]);
argv[0] = command;
if (options)
- strlcpy(argbuf, options, sizeof(argbuf));
+ cupsCopyString(argbuf, options, sizeof(argbuf));
else
argbuf[0] = '\0';
else if (con->language)
snprintf(lang, sizeof(lang), "LANG=%s.UTF8", con->language->language);
else
- strlcpy(lang, "LANG=C", sizeof(lang));
+ cupsCopyString(lang, "LANG=C", sizeof(lang));
- strlcpy(remote_addr, "REMOTE_ADDR=", sizeof(remote_addr));
+ cupsCopyString(remote_addr, "REMOTE_ADDR=", sizeof(remote_addr));
httpAddrGetString(httpGetAddress(con->http), remote_addr + 12,
sizeof(remote_addr) - 12);
* Copy the Host: header for later use...
*/
- strlcpy(con->clientname, httpGetField(con->http, HTTP_FIELD_HOST),
+ cupsCopyString(con->clientname, httpGetField(con->http, HTTP_FIELD_HOST),
sizeof(con->clientname));
if ((ptr = strrchr(con->clientname, ':')) != NULL && !strchr(ptr, ']'))
{
snprintf(iccfile, sizeof(iccfile), "%s/profiles/%s", DataDir,
attr->value);
else
- strlcpy(iccfile, attr->value, sizeof(iccfile));
+ cupsCopyString(iccfile, attr->value, sizeof(iccfile));
if (access(iccfile, 0))
{
snprintf(iccfile, sizeof(iccfile), "%s/profiles/%s", DataDir,
attr->value);
else
- strlcpy(iccfile, attr->value, sizeof(iccfile));
+ cupsCopyString(iccfile, attr->value, sizeof(iccfile));
if (_cupsFileCheck(iccfile, _CUPS_FILE_CHECK_FILE, !RunUser,
cupsdLogFCMessage, p))
snprintf(iccfile, sizeof(iccfile), "%s/profiles/%s", DataDir,
attr->value);
else
- strlcpy(iccfile, attr->value, sizeof(iccfile));
+ cupsCopyString(iccfile, attr->value, sizeof(iccfile));
if (_cupsFileCheck(iccfile, _CUPS_FILE_CHECK_FILE, !RunUser,
cupsdLogFCMessage, p))
else
PrintcapFormat = PRINTCAP_BSD;
- strlcpy(temp, ConfigurationFile, sizeof(temp));
+ cupsCopyString(temp, ConfigurationFile, sizeof(temp));
if ((slash = strrchr(temp, '/')) != NULL)
*slash = '\0';
{
cupsdLogMessage(CUPSD_LOG_ERROR, "Unable to get hostname: %s",
strerror(errno));
- strlcpy(temp, "localhost", sizeof(temp));
+ cupsCopyString(temp, "localhost", sizeof(temp));
}
cupsdSetString(&ServerName, temp);
* is only digits, then we have a port number by itself...
*/
- strlcpy(buffer, value, sizeof(buffer));
+ cupsCopyString(buffer, value, sizeof(buffer));
if ((portname = strrchr(buffer, ':')) != NULL && !strchr(portname, ']'))
{
* Loop through the value string,...
*/
- strlcpy(value, s, sizeof(value));
+ cupsCopyString(value, s, sizeof(value));
fatal = CUPSD_FATAL_NONE;
* Make a copy of the string and parse out the groups...
*/
- strlcpy(value, s, sizeof(value));
+ cupsCopyString(value, s, sizeof(value));
status = 1;
valstart = value;
* Loop through the value string,...
*/
- strlcpy(value, s, sizeof(value));
+ cupsCopyString(value, s, sizeof(value));
protocols = 0;
}
if (value[0] == '/')
- strlcpy(temp, value, sizeof(temp));
+ cupsCopyString(temp, value, sizeof(temp));
else
snprintf(temp, sizeof(temp), "%s/%s", ServerRoot, value);
* Copy the strings over...
*/
- strlcpy(device->device_class, device_class, sizeof(device->device_class));
- strlcpy(device->device_info, device_info, sizeof(device->device_info));
- strlcpy(device->device_uri, device_uri, sizeof(device->device_uri));
+ cupsCopyString(device->device_class, device_class, sizeof(device->device_class));
+ cupsCopyString(device->device_info, device_info, sizeof(device->device_info));
+ cupsCopyString(device->device_uri, device_uri, sizeof(device->device_uri));
/*
* Add the device to the array and return...
* class URI "make model" "name" ["1284 device ID"] ["location"]
*/
- strlcpy(temp, line, sizeof(temp));
+ cupsCopyString(temp, line, sizeof(temp));
/*
* device-class
ppd->record.model_number = model_number;
ppd->record.type = type;
- strlcpy(ppd->record.filename, filename, sizeof(ppd->record.filename));
- strlcpy(ppd->record.name, name, sizeof(ppd->record.name));
- strlcpy(ppd->record.languages[0], language,
+ cupsCopyString(ppd->record.filename, filename, sizeof(ppd->record.filename));
+ cupsCopyString(ppd->record.name, name, sizeof(ppd->record.name));
+ cupsCopyString(ppd->record.languages[0], language,
sizeof(ppd->record.languages[0]));
- strlcpy(ppd->record.products[0], product, sizeof(ppd->record.products[0]));
- strlcpy(ppd->record.psversions[0], psversion,
+ cupsCopyString(ppd->record.products[0], product, sizeof(ppd->record.products[0]));
+ cupsCopyString(ppd->record.psversions[0], psversion,
sizeof(ppd->record.psversions[0]));
- strlcpy(ppd->record.make, make, sizeof(ppd->record.make));
- strlcpy(ppd->record.make_and_model, make_and_model,
+ cupsCopyString(ppd->record.make, make, sizeof(ppd->record.make));
+ cupsCopyString(ppd->record.make_and_model, make_and_model,
sizeof(ppd->record.make_and_model));
- strlcpy(ppd->record.device_id, device_id, sizeof(ppd->record.device_id));
- strlcpy(ppd->record.scheme, scheme, sizeof(ppd->record.scheme));
+ cupsCopyString(ppd->record.device_id, device_id, sizeof(ppd->record.device_id));
+ cupsCopyString(ppd->record.scheme, scheme, sizeof(ppd->record.scheme));
/*
* Strip confusing (and often wrong) "recommended" suffix added by
exit(1);
}
- strlcpy(scheme, name, sizeof(scheme));
+ cupsCopyString(scheme, name, sizeof(scheme));
if ((sptr = strchr(scheme, ':')) != NULL)
{
*sptr = '\0';
*/
if (filename)
- strlcpy(temp, filename, sizeof(temp));
+ cupsCopyString(temp, filename, sizeof(temp));
else
temp[0] = '\0';
nick_name = d->find_attr("NickName", NULL);
if (nick_name)
- strlcpy(make_model, nick_name->value->value, sizeof(make_model));
+ cupsCopyString(make_model, nick_name->value->value, sizeof(make_model));
else if (_cups_strncasecmp(d->model_name->value, d->manufacturer->value,
strlen(d->manufacturer->value)))
snprintf(make_model, sizeof(make_model), "%s %s, %s",
ppd = add_ppd(name, uri, "en", d->manufacturer->value, make_model, device_id ? device_id->value->value : "", product->value->value,
ps_version ? ps_version->value->value : "(3010) 0", mtime, (size_t)size, d->model_number, type, "drv");
else if (products_found < PPD_MAX_PROD)
- strlcpy(ppd->record.products[products_found], product->value->value, sizeof(ppd->record.products[0]));
+ cupsCopyString(ppd->record.products[products_found], product->value->value, sizeof(ppd->record.products[0]));
else
break;
device_id[0] = '\0';
product[0] = '\0';
psversion[0] = '\0';
- strlcpy(type_str, "postscript", sizeof(type_str));
+ cupsCopyString(type_str, "postscript", sizeof(type_str));
if (sscanf(line, "\"%255[^\"]\"%127s%*[ \t]\"%127[^\"]\""
"%*[ \t]\"%127[^\"]\"%*[ \t]\"%255[^\"]\""
else
ptr = start + strlen(start);
- strlcpy(ppd->record.languages[i], start,
+ cupsCopyString(ppd->record.languages[i], start,
sizeof(ppd->record.languages[0]));
start = ptr;
manufacturer[0] = '\0';
device_id[0] = '\0';
lang_encoding[0] = '\0';
- strlcpy(lang_version, "en", sizeof(lang_version));
+ cupsCopyString(lang_version, "en", sizeof(lang_version));
model_number = 0;
install_group = 0;
type = PPD_TYPE_POSTSCRIPT;
// Make sure device ID ends with a semicolon...
if (device_id[0] && device_id[strlen(device_id) - 1] != ';')
- strlcat(device_id, ";", sizeof(device_id));
+ cupsConcatString(device_id, ";", sizeof(device_id));
}
else if (!strncmp(line, "*Product:", 9))
{
cupsCharsetToUTF8((cups_utf8_t *)make_model, nick_name,
sizeof(make_model), _ppdGetEncoding(lang_encoding));
else
- strlcpy(make_model, model_name, sizeof(make_model));
+ cupsCopyString(make_model, model_name, sizeof(make_model));
while (isspace(make_model[0] & 255))
_cups_strcpy(make_model, make_model + 1);
_cups_strcpy(manufacturer, manufacturer + 1);
if (!_cups_strncasecmp(make_model, manufacturer, strlen(manufacturer)))
- strlcpy(temp, make_model, sizeof(temp));
+ cupsCopyString(temp, make_model, sizeof(temp));
else
snprintf(temp, sizeof(temp), "%s %s", manufacturer, make_model);
* Nope, copy the first part of the make and model then...
*/
- strlcpy(manufacturer, make_model, sizeof(manufacturer));
+ cupsCopyString(manufacturer, make_model, sizeof(manufacturer));
/*
* Truncate at the first space, dash, or slash, or make the
if (*ptr && ptr > manufacturer)
*ptr = '\0';
else
- strlcpy(manufacturer, "Other", sizeof(manufacturer));
+ cupsCopyString(manufacturer, "Other", sizeof(manufacturer));
}
else if (!_cups_strncasecmp(manufacturer, "LHAG", 4) ||
!_cups_strncasecmp(manufacturer, "linotype", 8))
- strlcpy(manufacturer, "LHAG", sizeof(manufacturer));
+ cupsCopyString(manufacturer, "LHAG", sizeof(manufacturer));
else if (!_cups_strncasecmp(manufacturer, "Hewlett", 7))
- strlcpy(manufacturer, "HP", sizeof(manufacturer));
+ cupsCopyString(manufacturer, "HP", sizeof(manufacturer));
/*
* Fix the lang_version as needed...
* Unknown language; use "xx"...
*/
- strlcpy(lang_version, "xx", sizeof(lang_version));
+ cupsCopyString(lang_version, "xx", sizeof(lang_version));
}
/*
ppd->record.model_number = model_number;
ppd->record.type = type;
- strlcpy(ppd->record.filename, name, sizeof(ppd->record.filename));
- strlcpy(ppd->record.name, name, sizeof(ppd->record.name));
- strlcpy(ppd->record.languages[0], lang_version,
+ cupsCopyString(ppd->record.filename, name, sizeof(ppd->record.filename));
+ cupsCopyString(ppd->record.name, name, sizeof(ppd->record.name));
+ cupsCopyString(ppd->record.languages[0], lang_version,
sizeof(ppd->record.languages[0]));
- strlcpy(ppd->record.products[0], (char *)cupsArrayFirst(products),
+ cupsCopyString(ppd->record.products[0], (char *)cupsArrayFirst(products),
sizeof(ppd->record.products[0]));
- strlcpy(ppd->record.psversions[0], (char *)cupsArrayFirst(psversions),
+ cupsCopyString(ppd->record.psversions[0], (char *)cupsArrayFirst(psversions),
sizeof(ppd->record.psversions[0]));
- strlcpy(ppd->record.make, manufacturer, sizeof(ppd->record.make));
- strlcpy(ppd->record.make_and_model, make_model,
+ cupsCopyString(ppd->record.make, manufacturer, sizeof(ppd->record.make));
+ cupsCopyString(ppd->record.make_and_model, make_model,
sizeof(ppd->record.make_and_model));
- strlcpy(ppd->record.device_id, device_id, sizeof(ppd->record.device_id));
- strlcpy(ppd->record.scheme, scheme, sizeof(ppd->record.scheme));
+ cupsCopyString(ppd->record.device_id, device_id, sizeof(ppd->record.device_id));
+ cupsCopyString(ppd->record.scheme, scheme, sizeof(ppd->record.scheme));
}
/*
for (i = 1;
i < PPD_MAX_PROD && (ptr = (char *)cupsArrayNext(products)) != NULL;
i ++)
- strlcpy(ppd->record.products[i], ptr,
+ cupsCopyString(ppd->record.products[i], ptr,
sizeof(ppd->record.products[0]));
for (i = 1;
i < PPD_MAX_VERS && (ptr = (char *)cupsArrayNext(psversions)) != NULL;
i ++)
- strlcpy(ppd->record.psversions[i], ptr,
+ cupsCopyString(ppd->record.psversions[i], ptr,
sizeof(ppd->record.psversions[0]));
for (i = 1, ptr = (char *)cupsArrayFirst(cups_languages);
i < PPD_MAX_LANG && ptr;
i ++, ptr = (char *)cupsArrayNext(cups_languages))
- strlcpy(ppd->record.languages[i], ptr,
+ cupsCopyString(ppd->record.languages[i], ptr,
sizeof(ppd->record.languages[0]));
/*
if (p[0])
snprintf(name, sizeof(name), "%s/%s", p, dent->filename);
else
- strlcpy(name, dent->filename, sizeof(name));
+ cupsCopyString(name, dent->filename, sizeof(name));
if (S_ISDIR(dent->fileinfo.st_mode))
{
_cupsFileCheckFilter, NULL))
continue;
- strlcat(filename, "/Contents/Resources/PPDs", sizeof(filename));
- strlcat(name, "/Contents/Resources/PPDs", sizeof(name));
+ cupsConcatString(filename, "/Contents/Resources/PPDs", sizeof(filename));
+ cupsConcatString(name, "/Contents/Resources/PPDs", sizeof(name));
load_ppds(filename, name, 0);
}
* See if this file has been scanned before...
*/
- strlcpy(key.record.filename, name, sizeof(key.record.filename));
- strlcpy(key.record.name, name, sizeof(key.record.name));
+ cupsCopyString(key.record.filename, name, sizeof(key.record.filename));
+ cupsCopyString(key.record.name, name, sizeof(key.record.name));
ppd = (ppd_info_t *)cupsArrayFind(PPDsByName, &key);
snprintf(name, namesize, "%s/%s", record.header.prefix,
record.header.pathname);
else
- strlcpy(name, record.header.pathname, namesize);
+ cupsCopyString(name, record.header.pathname, namesize);
info->st_mtime = strtol(record.header.mtime, NULL, 8);
info->st_size = strtoll(record.header.size, NULL, 8);
if (!strcmp(command, "convert"))
num_options = cupsAddOption("copies", argv[i], num_options, &options);
else
- strlcpy(cupsfilesconf, argv[i], sizeof(cupsfilesconf));
+ cupsCopyString(cupsfilesconf, argv[i], sizeof(cupsfilesconf));
}
else
{
char filename[1024]; /* Full path to program */
if (program[0] == '/')
- strlcpy(filename, program, sizeof(filename));
+ cupsCopyString(filename, program, sizeof(filename));
else
snprintf(filename, sizeof(filename), "%s/filter/%s", ServerBin, program);
if (sptr > s)
*sptr++ = ' ';
- strlcpy(sptr, option->name, bytes - (size_t)(sptr - s));
+ cupsCopyString(sptr, option->name, bytes - (size_t)(sptr - s));
sptr += strlen(sptr);
*sptr++ = '=';
if (!access("/System/Library/Frameworks/ApplicationServices.framework/"
"Versions/A/Frameworks/PrintCore.framework/Versions/A/"
"Resources/English.lproj/Generic.ppd", 0))
- strlcpy(ppd, "PPD=/System/Library/Frameworks/ApplicationServices.framework/"
+ cupsCopyString(ppd, "PPD=/System/Library/Frameworks/ApplicationServices.framework/"
"Versions/A/Frameworks/PrintCore.framework/Versions/A/"
"Resources/English.lproj/Generic.ppd", sizeof(ppd));
else
- strlcpy(ppd, "PPD=/System/Library/Frameworks/ApplicationServices.framework/"
+ cupsCopyString(ppd, "PPD=/System/Library/Frameworks/ApplicationServices.framework/"
"Versions/A/Frameworks/PrintCore.framework/Versions/A/"
"Resources/Generic.ppd", sizeof(ppd));
#else
snprintf(printer_location, sizeof(printer_location),
"PRINTER_LOCATION=%s", temp);
else
- strlcpy(printer_location, "PRINTER_LOCATION=Unknown",
+ cupsCopyString(printer_location, "PRINTER_LOCATION=Unknown",
sizeof(printer_location));
}
else
{
snprintf(printer_info, sizeof(printer_info), "PRINTER_INFO=%s",
printer ? printer : "Unknown");
- strlcpy(printer_location, "PRINTER_LOCATION=Unknown",
+ cupsCopyString(printer_location, "PRINTER_LOCATION=Unknown",
sizeof(printer_location));
}
next = (mime_filter_t *)cupsArrayNext(filters);
if (filter->filter[0] == '/')
- strlcpy(program, filter->filter, sizeof(program));
+ cupsCopyString(program, filter->filter, sizeof(program));
else
snprintf(program, sizeof(program), "%s/filter/%s", ServerBin,
filter->filter);
else
set_string(&ServerBin, CUPS_SERVERBIN);
- strlcpy(line, filename, sizeof(line));
+ cupsCopyString(line, filename, sizeof(line));
if ((ptr = strrchr(line, '/')) != NULL)
*ptr = '\0';
else
*/
if ((ptr = DNSSDHostName + strlen(DNSSDHostName) - 1) >= DNSSDHostName && *ptr == '.')
- strlcpy(admin_hostname, DNSSDHostName, sizeof(admin_hostname));
+ cupsCopyString(admin_hostname, DNSSDHostName, sizeof(admin_hostname));
else
snprintf(admin_hostname, sizeof(admin_hostname), "%s.", DNSSDHostName);
}
if (ptr > urf_str && ptr < (urf_str + sizeof(urf_str) - 1))
*ptr++ = ',';
- strlcpy(ptr, value, sizeof(urf_str) - (size_t)(ptr - urf_str));
+ cupsCopyString(ptr, value, sizeof(urf_str) - (size_t)(ptr - urf_str));
ptr += strlen(ptr);
if (ptr >= (urf_str + sizeof(urf_str) - 1))
if (subtypes)
snprintf(temp, sizeof(temp), "%s,%s", type, subtypes);
else
- strlcpy(temp, type, sizeof(temp));
+ cupsCopyString(temp, type, sizeof(temp));
*srv = DNSSDMaster;
error = DNSServiceRegister(srv, kDNSServiceFlagsShareConnection,
char *start, /* Start of subtype */
subtype[256]; /* Subtype string */
- strlcpy(temp, subtypes, sizeof(temp));
+ cupsCopyString(temp, subtypes, sizeof(temp));
for (start = temp; *start; start = ptr)
{
if (DNSSDComputerName)
snprintf(name, sizeof(name), "%s @ %s", p->info, DNSSDComputerName);
else
- strlcpy(name, p->info, sizeof(name));
+ cupsCopyString(name, p->info, sizeof(name));
}
else if (DNSSDComputerName)
snprintf(name, sizeof(name), "%s @ %s", p->name, DNSSDComputerName);
else
- strlcpy(name, p->name, sizeof(name));
+ cupsCopyString(name, p->name, sizeof(name));
}
else
- strlcpy(name, p->reg_name, sizeof(name));
+ cupsCopyString(name, p->reg_name, sizeof(name));
/*
* Register IPP and LPD...
if (DNSSDComputerName)
snprintf(webif, sizeof(webif), "CUPS @ %s", DNSSDComputerName);
else
- strlcpy(webif, "CUPS", sizeof(webif));
+ cupsCopyString(webif, "CUPS", sizeof(webif));
dnssdDeregisterInstance(&WebIFSrv, from_callback);
dnssdRegisterInstance(&WebIFSrv, NULL, webif, "_http._tcp", "_printer", DNSSDPort, NULL, 1, from_callback);
if (i)
*bufptr++ = ',';
- strlcpy(bufptr, p->auth_info_required[i], bufsize - (size_t)(bufptr - buffer));
+ cupsCopyString(bufptr, p->auth_info_required[i], bufsize - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
}
return (NULL);
case CUPSD_AUTH_NEGOTIATE :
- strlcpy(buffer, "negotiate", bufsize);
+ cupsCopyString(buffer, "negotiate", bufsize);
break;
default :
- strlcpy(buffer, "username,password", bufsize);
+ cupsCopyString(buffer, "username,password", bufsize);
break;
}
* Include necessary headers...
*/
+#include <cups/cups.h>
#include <cups/string-private.h>
#include "mime.h"
DEBUG_printf(("1mimeAddFilter: Replacing filter \"%s\", cost %d.",
temp->filter, temp->cost));
temp->cost = cost;
- strlcpy(temp->filter, filter, sizeof(temp->filter));
+ cupsCopyString(temp->filter, filter, sizeof(temp->filter));
}
}
else
temp->src = src;
temp->dst = dst;
temp->cost = cost;
- strlcpy(temp->filter, filter, sizeof(temp->filter));
+ cupsCopyString(temp->filter, filter, sizeof(temp->filter));
DEBUG_puts("1mimeAddFilter: Adding new filter.");
cupsArrayAdd(mime->filters, temp);
if ((attr = ippFindAttribute(con->request, "printer-state-message",
IPP_TAG_TEXT)) != NULL)
{
- strlcpy(pclass->state_message, attr->values[0].string.text,
+ cupsCopyString(pclass->state_message, attr->values[0].string.text,
sizeof(pclass->state_message));
cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, pclass, NULL, "%s",
}
if (printer->sanitized_device_uri)
- strlcpy(old_device_uri, printer->sanitized_device_uri,
+ cupsCopyString(old_device_uri, printer->sanitized_device_uri,
sizeof(old_device_uri));
else
old_device_uri[0] = '\0';
if ((attr = ippFindAttribute(con->request, "printer-state-message",
IPP_TAG_TEXT)) != NULL)
{
- strlcpy(printer->state_message, attr->values[0].string.text,
+ cupsCopyString(printer->state_message, attr->values[0].string.text,
sizeof(printer->state_message));
cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, printer, NULL, "%s",
need_restart_job = 1;
changed_driver = 1;
- strlcpy(srcfile, con->filename, sizeof(srcfile));
+ cupsCopyString(srcfile, con->filename, sizeof(srcfile));
if ((fp = cupsFileOpen(srcfile, "rb")))
{
* Figure out who is printing...
*/
- strlcpy(username, get_username(con), sizeof(username));
+ cupsCopyString(username, get_username(con), sizeof(username));
if ((name = strchr(username, '@')) != NULL)
*name = '\0'; /* Strip @REALM */
* Try the localized banner file under the subdirectory...
*/
- strlcpy(attrname, job->attrs->attrs->next->values[0].string.text,
+ cupsCopyString(attrname, job->attrs->attrs->next->values[0].string.text,
sizeof(attrname));
if (strlen(attrname) > 2 && attrname[2] == '-')
{
}
}
else if (!strncmp(buffer, "*cupsProtocol:", 14))
- strlcpy(cups_protocol, buffer, sizeof(cups_protocol));
+ cupsCopyString(cups_protocol, buffer, sizeof(cups_protocol));
cupsFileClose(dst);
}
if (requested)
url_encode_attr(requested, requested_str, sizeof(requested_str));
else
- strlcpy(requested_str, "requested-attributes=all", sizeof(requested_str));
+ cupsCopyString(requested_str, "requested-attributes=all", sizeof(requested_str));
if (exclude)
url_encode_attr(exclude, exclude_str, sizeof(exclude_str));
return;
}
else if (attr && attr->values[0].boolean)
- strlcpy(username, get_username(con), sizeof(username));
+ cupsCopyString(username, get_username(con), sizeof(username));
else
username[0] = '\0';
if (requested)
url_encode_attr(requested, requested_str, sizeof(requested_str));
else
- strlcpy(requested_str, "requested-attributes=all", sizeof(requested_str));
+ cupsCopyString(requested_str, "requested-attributes=all", sizeof(requested_str));
if (device)
url_encode_attr(device, device_str, sizeof(device_str));
if ((attr = ippFindAttribute(con->request, "my-subscriptions",
IPP_TAG_BOOLEAN)) != NULL &&
attr->values[0].boolean)
- strlcpy(username, get_username(con), sizeof(username));
+ cupsCopyString(username, get_username(con), sizeof(username));
else
username[0] = '\0';
* Auto-type it!
*/
- strlcpy(super, "application", sizeof(super));
- strlcpy(type, "octet-stream", sizeof(type));
+ cupsCopyString(super, "application", sizeof(super));
+ cupsCopyString(type, "octet-stream", sizeof(type));
}
cupsRWLockRead(&MimeDatabase->lock);
if ((attr = ippFindAttribute(con->request, "printer-state-message",
IPP_TAG_TEXT)) == NULL)
- strlcpy(printer->state_message, "Rejecting Jobs",
+ cupsCopyString(printer->state_message, "Rejecting Jobs",
sizeof(printer->state_message));
else
- strlcpy(printer->state_message, attr->values[0].string.text,
+ cupsCopyString(printer->state_message, attr->values[0].string.text,
sizeof(printer->state_message));
cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, printer, NULL,
* No document format attribute? Auto-type it!
*/
- strlcpy(super, "application", sizeof(super));
- strlcpy(type, "octet-stream", sizeof(type));
+ cupsCopyString(super, "application", sizeof(super));
+ cupsCopyString(type, "octet-stream", sizeof(type));
}
cupsRWLockRead(&MimeDatabase->lock);
* OK, anything else must be a user-defined default...
*/
- strlcpy(name, attr->name, sizeof(name));
+ cupsCopyString(name, attr->name, sizeof(name));
name[namelen - 8] = '\0'; /* Strip "-default" */
switch (attr->value_tag)
if ((attr = ippFindAttribute(con->request, "printer-state-message",
IPP_TAG_TEXT)) == NULL)
- strlcpy(printer->state_message, "Paused", sizeof(printer->state_message));
+ cupsCopyString(printer->state_message, "Paused", sizeof(printer->state_message));
else
{
- strlcpy(printer->state_message, attr->values[0].string.text,
+ cupsCopyString(printer->state_message, attr->values[0].string.text,
sizeof(printer->state_message));
}
*bufend; /* End of buffer */
- strlcpy(buffer, attr->name, bufsize);
+ cupsCopyString(buffer, attr->name, bufsize);
bufptr = buffer + strlen(buffer);
bufend = buffer + bufsize - 1;
* Strip @REALM for username check...
*/
- strlcpy(baseuser, username, sizeof(baseuser));
+ cupsCopyString(baseuser, username, sizeof(baseuser));
if ((baseptr = strchr(baseuser, '@')) != NULL)
*baseptr = '\0';
* Get the best authenticated username that is available.
*/
- strlcpy(username, get_username(con), userlen);
+ cupsCopyString(username, get_username(con), userlen);
/*
* Check the username against the owner...
IPP_TAG_LANGUAGE);
#ifdef __APPLE__
- strlcpy(apple_language, "APPLE_LANGUAGE=", sizeof(apple_language));
+ cupsCopyString(apple_language, "APPLE_LANGUAGE=", sizeof(apple_language));
_cupsAppleLanguage(attr->values[0].string.text,
apple_language + 15, sizeof(apple_language) - 15);
#endif /* __APPLE__ */
* the POSIX locale...
*/
- strlcpy(lang, "LANG=C", sizeof(lang));
+ cupsCopyString(lang, "LANG=C", sizeof(lang));
break;
case 2 :
(ptr = strstr(attr->values[0].string.text, "charset=")) != NULL)
snprintf(charset, sizeof(charset), "CHARSET=%s", ptr + 8);
else
- strlcpy(charset, "CHARSET=utf-8", sizeof(charset));
+ cupsCopyString(charset, "CHARSET=utf-8", sizeof(charset));
snprintf(content_type, sizeof(content_type), "CONTENT_TYPE=%s/%s",
job->filetypes[job->current_file]->super,
* All of these strcpy's are safe because we allocated the psr string...
*/
- strlcpy(printer_state_reasons, "PRINTER_STATE_REASONS=", psrlen);
+ cupsCopyString(printer_state_reasons, "PRINTER_STATE_REASONS=", psrlen);
for (psrptr = printer_state_reasons + 22, i = 0;
i < job->printer->num_reasons;
i ++)
{
if (i)
*psrptr++ = ',';
- strlcpy(psrptr, job->printer->reasons[i], psrlen - (size_t)(psrptr - printer_state_reasons));
+ cupsCopyString(psrptr, job->printer->reasons[i], psrlen - (size_t)(psrptr - printer_state_reasons));
psrptr += strlen(psrptr);
}
}
job->printer->auth_info_required[2],
job->printer->auth_info_required[3]);
else
- strlcpy(auth_info_required, "AUTH_INFO_REQUIRED=none",
+ cupsCopyString(auth_info_required, "AUTH_INFO_REQUIRED=none",
sizeof(auth_info_required));
envc = cupsdLoadEnv(envp, (int)(sizeof(envp) / sizeof(envp[0])));
snprintf(command, sizeof(command), "%s/filter/%s", ServerBin,
filter->filter);
else
- strlcpy(command, filter->filter, sizeof(command));
+ cupsCopyString(command, filter->filter, sizeof(command));
if (i < (cupsArrayCount(filters) - 1))
{
* Remove backup file and mark this job as clean...
*/
- strlcat(filename, ".O", sizeof(filename));
+ cupsConcatString(filename, ".O", sizeof(filename));
unlink(filename);
job->dirty = 0;
snprintf(temp, sizeof(temp), "[Job %d] printer-state-reasons=", job->id);
ptr = temp + strlen(temp);
if (printer->num_reasons == 0)
- strlcpy(ptr, "none", sizeof(temp) - (size_t)(ptr - temp));
+ cupsCopyString(ptr, "none", sizeof(temp) - (size_t)(ptr - temp));
else
{
for (i = 0;
if (i)
*ptr++ = ',';
- strlcpy(ptr, printer->reasons[i], sizeof(temp) - (size_t)(ptr - temp));
+ cupsCopyString(ptr, printer->reasons[i], sizeof(temp) - (size_t)(ptr - temp));
ptr += strlen(ptr);
}
}
*optptr = '\0';
snprintf(title, title_size, "%s-%d", job->printer->name, job->id);
- strlcpy(copies, "1", copies_size);
+ cupsCopyString(copies, "1", copies_size);
for (attr = job->attrs->attrs; attr != NULL; attr = attr->next)
{
else if (!strcmp(attr->name, "job-name") &&
(attr->value_tag == IPP_TAG_NAME ||
attr->value_tag == IPP_TAG_NAMELANG))
- strlcpy(title, attr->values[0].string.text, title_size);
+ cupsCopyString(title, attr->values[0].string.text, title_size);
else if (attr->group_tag == IPP_TAG_JOB)
{
/*
*/
if (optptr > options)
- strlcat(optptr, " ", optlength - (size_t)(optptr - options));
+ cupsConcatString(optptr, " ", optlength - (size_t)(optptr - options));
if (attr->value_tag != IPP_TAG_BOOLEAN)
{
- strlcat(optptr, attr->name, optlength - (size_t)(optptr - options));
- strlcat(optptr, "=", optlength - (size_t)(optptr - options));
+ cupsConcatString(optptr, attr->name, optlength - (size_t)(optptr - options));
+ cupsConcatString(optptr, "=", optlength - (size_t)(optptr - options));
}
for (i = 0; i < attr->num_values; i ++)
{
if (i)
- strlcat(optptr, ",", optlength - (size_t)(optptr - options));
+ cupsConcatString(optptr, ",", optlength - (size_t)(optptr - options));
optptr += strlen(optptr);
case IPP_TAG_BOOLEAN :
if (!attr->values[i].boolean)
- strlcat(optptr, "no", optlength - (size_t)(optptr - options));
+ cupsConcatString(optptr, "no", optlength - (size_t)(optptr - options));
- strlcat(optptr, attr->name, optlength - (size_t)(optptr - options));
+ cupsConcatString(optptr, attr->name, optlength - (size_t)(optptr - options));
break;
case IPP_TAG_RANGE :
for (i = num_pwgppds, pwgppd = pwgppds; i > 0; i --, pwgppd ++)
{
*optptr++ = ' ';
- strlcpy(optptr, pwgppd->name, optlength - (size_t)(optptr - options));
+ cupsCopyString(optptr, pwgppd->name, optlength - (size_t)(optptr - options));
optptr += strlen(optptr);
*optptr++ = '=';
- strlcpy(optptr, pwgppd->value, optlength - (size_t)(optptr - options));
+ cupsCopyString(optptr, pwgppd->value, optlength - (size_t)(optptr - options));
optptr += strlen(optptr);
}
if (loglevel < CUPSD_LOG_DEBUG &&
strcmp(job->printer->state_message, ptr))
{
- strlcpy(job->printer->state_message, ptr,
+ cupsCopyString(job->printer->state_message, ptr,
sizeof(job->printer->state_message));
event |= CUPSD_EVENT_PRINTER_STATE | CUPSD_EVENT_JOB_PROGRESS;
if (logname[0] != '/')
{
- strlcpy(filename, ServerRoot, sizeof(filename));
- strlcat(filename, "/", sizeof(filename));
+ cupsCopyString(filename, ServerRoot, sizeof(filename));
+ cupsConcatString(filename, "/", sizeof(filename));
}
else
filename[0] = '\0';
* Insert the server name...
*/
- strlcpy(ptr, ServerName, sizeof(filename) - (size_t)(ptr - filename));
+ cupsCopyString(ptr, ServerName, sizeof(filename) - (size_t)(ptr - filename));
ptr += strlen(ptr);
}
else
cupsFileClose(*lf);
- strlcpy(backname, filename, sizeof(backname));
- strlcat(backname, ".O", sizeof(backname));
+ cupsCopyString(backname, filename, sizeof(backname));
+ cupsConcatString(backname, ".O", sizeof(backname));
unlink(backname);
rename(filename, backname);
if (result == _CUPS_FILE_CHECK_MISSING ||
result == _CUPS_FILE_CHECK_WRONG_TYPE)
{
- strlcpy(p->state_message, message, sizeof(p->state_message));
+ cupsCopyString(p->state_message, message, sizeof(p->state_message));
if (cupsdSetPrinterReasons(p, "+cups-missing-filter-warning"))
cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, p, NULL, "%s", message);
else if (result == _CUPS_FILE_CHECK_PERMISSIONS ||
result == _CUPS_FILE_CHECK_RELATIVE_PATH)
{
- strlcpy(p->state_message, message, sizeof(p->state_message));
+ cupsCopyString(p->state_message, message, sizeof(p->state_message));
if (cupsdSetPrinterReasons(p, "+cups-insecure-filter-warning"))
cupsdAddEvent(CUPSD_EVENT_PRINTER_STATE, p, NULL, "%s", message);
snprintf(clientmsg, sizeof(clientmsg), "[Client %d] %s", con->number,
message);
else
- strlcpy(clientmsg, message, sizeof(clientmsg));
+ cupsCopyString(clientmsg, message, sizeof(clientmsg));
va_start(ap, message);
if (job)
snprintf(jobmsg, sizeof(jobmsg), "[Job %d] %s", job->id, message);
else
- strlcpy(jobmsg, message, sizeof(jobmsg));
+ cupsCopyString(jobmsg, message, sizeof(jobmsg));
va_start(ap, message);
if (!PageLogFormat)
return (1);
- strlcpy(number, "1", sizeof(number));
+ cupsCopyString(number, "1", sizeof(number));
copies = 1;
sscanf(page, "%255s%d", number, &copies);
break;
case 'p' : /* Printer name */
- strlcpy(bufptr, job->dest, sizeof(buffer) - (size_t)(bufptr - buffer));
+ cupsCopyString(bufptr, job->dest, sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
break;
case 'u' : /* Username */
- strlcpy(bufptr, job->username ? job->username : "-", sizeof(buffer) - (size_t)(bufptr - buffer));
+ cupsCopyString(bufptr, job->username ? job->username : "-", sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
case 'T' : /* Date and time */
- strlcpy(bufptr, cupsdGetDateTime(NULL, LogTimeFormat), sizeof(buffer) - (size_t)(bufptr - buffer));
+ cupsCopyString(bufptr, cupsdGetDateTime(NULL, LogTimeFormat), sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
case 'P' : /* Page number */
- strlcpy(bufptr, number, sizeof(buffer) - (size_t)(bufptr - buffer));
+ cupsCopyString(bufptr, number, sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
case IPP_TAG_CHARSET :
case IPP_TAG_LANGUAGE :
case IPP_TAG_MIMETYPE :
- strlcpy(bufptr, attr->values[i].string.text, sizeof(buffer) - (size_t)(bufptr - buffer));
+ cupsCopyString(bufptr, attr->values[i].string.text, sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
/* PWG media name */
if (pwg)
{
- strlcpy(bufptr, pwg->pwg, sizeof(buffer) - (size_t)(bufptr - buffer));
+ cupsCopyString(bufptr, pwg->pwg, sizeof(buffer) - (size_t)(bufptr - buffer));
break;
}
}
}
default :
- strlcpy(bufptr, "???", sizeof(buffer) - (size_t)(bufptr - buffer));
+ cupsCopyString(bufptr, "???", sizeof(buffer) - (size_t)(bufptr - buffer));
bufptr += strlen(bufptr);
break;
}
return (1);
}
- strlcpy(filename, ConfigurationFile, len);
+ cupsCopyString(filename, ConfigurationFile, len);
if ((slash = strrchr(filename, '/')) == NULL)
{
free(filename);
return (1);
}
- strlcpy(slash, "/cups-files.conf", len - (size_t)(slash - filename));
+ cupsCopyString(slash, "/cups-files.conf", len - (size_t)(slash - filename));
cupsdSetString(&CupsFilesFile, filename);
free(filename);
}
if (job->printer)
{
- strlcpy(job->printer->state_message, message,
+ cupsCopyString(job->printer->state_message, message,
sizeof(job->printer->state_message));
}
{
int shared_printers = 0; /* Do we have shared printers? */
- strlcpy(pidfile, CUPS_KEEPALIVE, sizeof(pidfile));
+ cupsCopyString(pidfile, CUPS_KEEPALIVE, sizeof(pidfile));
/*
* If printer sharing is on see if there are any actual shared printers...
* Include necessary headers...
*/
+#include <cups/cups.h>
#include <cups/string-private.h>
#include <cups/dir.h>
#include "mime-private.h"
* Force * / * to be "application/octet-stream"...
*/
- strlcpy(super, "application", sizeof(super));
- strlcpy(type, "octet-stream", sizeof(type));
+ cupsCopyString(super, "application", sizeof(super));
+ cupsCopyString(type, "octet-stream", sizeof(type));
}
/*
* Search for the named interface...
*/
- strlcpy(key.name, name, sizeof(key.name));
+ cupsCopyString(key.name, name, sizeof(key.name));
return ((cupsd_netif_t *)cupsArrayFind(NetIFList, &key));
}
*/
if (httpAddrLocalhost((http_addr_t *)(addr->ifa_addr)))
- strlcpy(hostname, "localhost", sizeof(hostname));
+ cupsCopyString(hostname, "localhost", sizeof(hostname));
else
httpAddrString((http_addr_t *)(addr->ifa_addr), hostname,
sizeof(hostname));
* Copy all of the information...
*/
- strlcpy(temp->name, addr->ifa_name, sizeof(temp->name));
+ cupsCopyString(temp->name, addr->ifa_name, sizeof(temp->name));
temp->hostlen = hostlen;
memcpy(temp->hostname, hostname, hostlen + 1);
*/
if (value)
- strlcpy(p->state_message, value, sizeof(p->state_message));
+ cupsCopyString(p->state_message, value, sizeof(p->state_message));
}
else if (!_cups_strcasecmp(line, "StateTime"))
{
switch (printer->num_auth_info_required)
{
case 1 :
- strlcpy(value, printer->auth_info_required[0], sizeof(value));
+ cupsCopyString(value, printer->auth_info_required[0], sizeof(value));
break;
case 2 :
if (i)
*ptr++ = ',';
- strlcpy(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr));
+ cupsCopyString(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr));
ptr += strlen(ptr);
}
if (i)
*ptr++ = ',';
- strlcpy(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr));
+ cupsCopyString(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr));
ptr += strlen(ptr);
}
if (i)
*ptr++ = ',';
- strlcpy(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr));
+ cupsCopyString(ptr, marker->values[i].string.text, (size_t)(value + sizeof(value) - ptr));
ptr += strlen(ptr);
}
* info in it...
*/
- strlcpy(buffer, uri, sizeof(buffer));
+ cupsCopyString(buffer, uri, sizeof(buffer));
/*
* Find the end of the scheme:// part...
*/
if (!_cups_strcasecmp(hostname, "localhost"))
- strlcpy(hostname, ServerName, sizeof(hostname));
+ cupsCopyString(hostname, ServerName, sizeof(hostname));
- strlcpy(localname, hostname, sizeof(localname));
+ cupsCopyString(localname, hostname, sizeof(localname));
if (!_cups_strcasecmp(hostname, ServerName))
{
if (strcmp(program, "-"))
{
if (program[0] == '/')
- strlcpy(filename, program, sizeof(filename));
+ cupsCopyString(filename, program, sizeof(filename));
else
snprintf(filename, sizeof(filename), "%s/filter/%s", ServerBin, program);
if (!_cups_strcasecmp(type->super, "application"))
{
if (!_cups_strcasecmp(type->type, "pdf"))
- strlcat(pdl, "application/pdf,", sizeof(pdl));
+ cupsConcatString(pdl, "application/pdf,", sizeof(pdl));
else if (!_cups_strcasecmp(type->type, "postscript"))
- strlcat(pdl, "application/postscript,", sizeof(pdl));
+ cupsConcatString(pdl, "application/postscript,", sizeof(pdl));
}
else if (!_cups_strcasecmp(type->super, "image"))
{
if (!_cups_strcasecmp(type->type, "jpeg"))
- strlcat(pdl, "image/jpeg,", sizeof(pdl));
+ cupsConcatString(pdl, "image/jpeg,", sizeof(pdl));
else if (!_cups_strcasecmp(type->type, "png"))
- strlcat(pdl, "image/png,", sizeof(pdl));
+ cupsConcatString(pdl, "image/png,", sizeof(pdl));
else if (!_cups_strcasecmp(type->type, "pwg-raster"))
- strlcat(pdl, "image/pwg-raster,", sizeof(pdl));
+ cupsConcatString(pdl, "image/pwg-raster,", sizeof(pdl));
else if (!_cups_strcasecmp(type->type, "urf"))
- strlcat(pdl, "image/urf,", sizeof(pdl));
+ cupsConcatString(pdl, "image/urf,", sizeof(pdl));
}
}
"printer-resolution-supported", IPP_RES_PER_INCH,
300, 300);
ippAddResolution(p->ppd_attrs, IPP_TAG_PRINTER, "pwg-raster-document-resolution-supported", IPP_RES_PER_INCH, 300, 300);
- strlcpy(urf_rs, "RS300", sizeof(urf_rs));
+ cupsCopyString(urf_rs, "RS300", sizeof(urf_rs));
urf[num_urf ++] = urf_rs;
}
if (job_id)
*job_id = proc->job_id;
- strlcpy(name, proc->name, namelen);
+ cupsCopyString(name, proc->name, namelen);
cupsArrayRemove(process_array, proc);
free(proc);
}
if (job_id)
*job_id = 0;
- strlcpy(name, "unknown", namelen);
+ cupsCopyString(name, "unknown", namelen);
}
cupsdLogMessage(CUPSD_LOG_DEBUG2, "cupsdFinishProcess(pid=%d, name=%p, namelen=" CUPS_LLFMT ", job_id=%p(%d)) = \"%s\"", pid, name, CUPS_LLCAST namelen, job_id, job_id ? *job_id : 0, name);
if (!p || !username)
return (NULL);
- strlcpy(match.username, username, sizeof(match.username));
+ cupsCopyString(match.username, username, sizeof(match.username));
if ((ptr = strchr(match.username, '@')) != NULL)
*ptr = '\0'; /* Strip @domain/@KDC */
if ((q = calloc(1, sizeof(cupsd_quota_t))) == NULL)
return (NULL);
- strlcpy(q->username, username, sizeof(q->username));
+ cupsCopyString(q->username, username, sizeof(q->username));
if ((ptr = strchr(q->username, '@')) != NULL)
*ptr = '\0'; /* Strip @domain/@KDC */
* Copy the message to the line buffer...
*/
- strlcpy(line, message, (size_t)linelen);
+ cupsCopyString(line, message, (size_t)linelen);
/*
* Copy over the buffer data we've used up...
* notifier program...
*/
- strlcpy(scheme, sub->recipient, sizeof(scheme));
+ cupsCopyString(scheme, sub->recipient, sizeof(scheme));
if ((ptr = strchr(scheme, ':')) != NULL)
*ptr = '\0';
snprintf(reqstr, sizeof(reqstr), "%d", requests);
if (port == 631 || server[0] == '/')
- strlcpy(serverstr, server, sizeof(serverstr));
+ cupsCopyString(serverstr, server, sizeof(serverstr));
else
snprintf(serverstr, sizeof(serverstr), "%s:%d", server, port);
- strlcpy(options, "-cr", sizeof(options));
+ cupsCopyString(options, "-cr", sizeof(options));
if (encryption == HTTP_ENCRYPTION_REQUIRED)
- strlcat(options, "E", sizeof(options));
+ cupsConcatString(options, "E", sizeof(options));
if (verbose)
- strlcat(options, "v", sizeof(options));
+ cupsConcatString(options, "v", sizeof(options));
for (i = 0; i < children; i ++)
{
* Include necessary headers...
*/
+#include <cups/cups.h>
#include <cups/string-private.h>
#include <locale.h>
#include "mime.h"
return (NULL);
}
- strlcpy(temp->super, super, sizeof(temp->super));
+ cupsCopyString(temp->super, super, sizeof(temp->super));
memcpy(temp->type, type, typelen);
temp->priority = 100;
case MIME_MAGIC_MATCH :
if ((size_t)length[0] > (sizeof(temp->value.matchv) - 1))
return (-1);
- strlcpy(temp->value.matchv, value[0], sizeof(temp->value.matchv));
+ cupsCopyString(temp->value.matchv, value[0], sizeof(temp->value.matchv));
break;
case MIME_MAGIC_ASCII :
case MIME_MAGIC_PRINTABLE :
if ((size_t)length[0] > (sizeof(temp->value.localev) - 1))
return (-1);
- strlcpy(temp->value.localev, value[0], sizeof(temp->value.localev));
+ cupsCopyString(temp->value.localev, value[0], sizeof(temp->value.localev));
break;
case MIME_MAGIC_CONTAINS :
temp->offset = strtol(value[0], NULL, 0);
* Lookup the type in the array...
*/
- strlcpy(key.super, super, sizeof(key.super));
- strlcpy(key.type, type, sizeof(key.type));
+ cupsCopyString(key.super, super, sizeof(key.super));
+ cupsCopyString(key.type, type, sizeof(key.type));
mt = (mime_type_t *)cupsArrayFind(mime->types, &key);
DEBUG_printf("1mimeType: Returning %p.", mt);
if (!_cups_strncasecmp(option, "Custom", 6) && !_cups_strcasecmp(choice, "True"))
{
_cups_strcpy(option, option + 6);
- strlcpy(choice, "Custom", sizeof(choice));
+ cupsCopyString(choice, "Custom", sizeof(choice));
}
if ((o = ppdFindOption(ppd, option)) == NULL)
if (!_cups_strncasecmp(c->option1, "Custom", 6) &&
!_cups_strcasecmp(c->choice1, "True"))
{
- strlcpy(option, c->option1 + 6, sizeof(option));
- strlcpy(choice, "Custom", sizeof(choice));
+ cupsCopyString(option, c->option1 + 6, sizeof(option));
+ cupsCopyString(choice, "Custom", sizeof(choice));
}
else
{
- strlcpy(option, c->option1, sizeof(option));
- strlcpy(choice, c->choice1, sizeof(choice));
+ cupsCopyString(option, c->option1, sizeof(option));
+ cupsCopyString(choice, c->choice1, sizeof(choice));
}
if ((o = ppdFindOption(ppd, option)) == NULL)
if (!_cups_strncasecmp(c->option2, "Custom", 6) &&
!_cups_strcasecmp(c->choice2, "True"))
{
- strlcpy(option, c->option2 + 6, sizeof(option));
- strlcpy(choice, "Custom", sizeof(choice));
+ cupsCopyString(option, c->option2 + 6, sizeof(option));
+ cupsCopyString(choice, "Custom", sizeof(choice));
}
else
{
- strlcpy(option, c->option2, sizeof(option));
- strlcpy(choice, c->choice2, sizeof(choice));
+ cupsCopyString(option, c->option2, sizeof(option));
+ cupsCopyString(choice, c->choice2, sizeof(choice));
}
if ((o = ppdFindOption(ppd, option)) == NULL)
size_t ppdlen = strlen(pwg_media->ppd);
/* Length of standard PPD name */
- strlcpy(buf, pwg_media->ppd, sizeof(buf));
+ cupsCopyString(buf, pwg_media->ppd, sizeof(buf));
if (strcmp(size->name, buf) && size->width > size->length)
{
if (!strcmp(pwg_media->ppd, "DoublePostcardRotated"))
- strlcpy(buf, "DoublePostcard", sizeof(buf));
+ cupsCopyString(buf, "DoublePostcard", sizeof(buf));
else if (strstr(size->name, ".Transverse"))
snprintf(buf, sizeof(buf), "%s.Transverse", pwg_media->ppd);
else
if (size->left == 0 && size->bottom == 0 &&
size->right == size->width && size->top == size->length)
{
- strlcat(buf, ".Fullbleed", sizeof(buf) - strlen(buf));
+ cupsConcatString(buf, ".Fullbleed", sizeof(buf) - strlen(buf));
if (_cups_strcasecmp(size->name, buf))
{
/*
if (size->left == 0 && size->bottom == 0 &&
size->right == size->width && size->top == size->length)
- strlcat(buf, ".Fullbleed", sizeof(buf));
+ cupsConcatString(buf, ".Fullbleed", sizeof(buf));
else if (size->width > size->length)
- strlcat(buf, ".Transverse", sizeof(buf));
+ cupsConcatString(buf, ".Transverse", sizeof(buf));
if (_cups_strcasecmp(size->name, buf))
{
if (!strcmp(language, "en"))
continue;
- strlcpy(ll, language, sizeof(ll));
+ cupsCopyString(ll, language, sizeof(ll));
/*
* Loop through all options and choices...
cupsArraySave(languages);
- strlcpy(ll, language, sizeof(ll));
+ cupsCopyString(ll, language, sizeof(ll));
if (!cupsArrayFind(languages, ll) &&
strcmp(ll, "zh") && strcmp(ll, "en"))
* the same capitalization...
*/
- strlcpy(temp, path, sizeof(temp));
+ cupsCopyString(temp, path, sizeof(temp));
while ((ptr = strrchr(temp, '/')) != NULL)
{
* Get default option name...
*/
- strlcpy(keyword, line + 8, sizeof(keyword));
+ cupsCopyString(keyword, line + 8, sizeof(keyword));
for (keyptr = keyword; *keyptr; keyptr ++)
if (*keyptr == ':' || isspace(*keyptr & 255))
*ptr++ = ' ';
if (!options[i].value[0])
- strlcpy(ptr, options[i].name, sizeof(buffer) - (size_t)(ptr - buffer));
+ cupsCopyString(ptr, options[i].name, sizeof(buffer) - (size_t)(ptr - buffer));
else if (strchr(options[i].value, ' ') != NULL ||
strchr(options[i].value, '\t') != NULL)
snprintf(ptr, sizeof(buffer) - (size_t)(ptr - buffer), "%s=\'%s\'", options[i].name, options[i].value);
}
if (ptr < (buffer + sizeof(buffer) - 1))
- strlcpy(ptr, "}", sizeof(buffer) - (size_t)(ptr - buffer));
+ cupsCopyString(ptr, "}", sizeof(buffer) - (size_t)(ptr - buffer));
}
}
}
*num_dests = cupsGetDests(dests);
else
{
- strlcpy(printer, name, sizeof(printer));
+ cupsCopyString(printer, name, sizeof(printer));
if ((pptr = strchr(printer, '/')) != NULL)
*pptr++ = '\0';
if (i)
snprintf(aptr, sizeof(alerts) - (size_t)(aptr - alerts), " %s", reasons->values[i].string.text);
else
- strlcpy(alerts, reasons->values[i].string.text, sizeof(alerts));
+ cupsCopyString(alerts, reasons->values[i].string.text, sizeof(alerts));
aptr += strlen(aptr);
}
if (i)
snprintf(aptr, sizeof(alerts) - (size_t)(aptr - alerts), " %s", reasons->values[i].string.text);
else
- strlcpy(alerts, reasons->values[i].string.text, sizeof(alerts));
+ cupsCopyString(alerts, reasons->values[i].string.text, sizeof(alerts));
aptr += strlen(aptr);
}
if (i)
snprintf(aptr, sizeof(alerts) - (size_t)(aptr - alerts), " %s", reasons->values[i].string.text);
else
- strlcpy(alerts, reasons->values[i].string.text, sizeof(alerts));
+ cupsCopyString(alerts, reasons->values[i].string.text, sizeof(alerts));
aptr += strlen(aptr);
}
if (i >= argc)
usage(1);
- strlcpy(directory, argv[i], sizeof(directory));
+ cupsCopyString(directory, argv[i], sizeof(directory));
break;
case 'f' : /* -f type/subtype[,...] */
return (HTTP_STATUS_SERVER_ERROR);
}
- strlcpy(client->username, data.username, sizeof(client->username));
+ cupsCopyString(client->username, data.username, sizeof(client->username));
pam_end(pamh, PAM_SUCCESS);
const char *avahi_name = avahi_client_get_host_name_fqdn(DNSSDClient);
if (avahi_name)
- strlcpy(temp, avahi_name, sizeof(temp));
+ cupsCopyString(temp, avahi_name, sizeof(temp));
else
#endif /* HAVE_AVAHI */
if ((tempptr = strstr(httpGetHostname(NULL, temp, sizeof(temp)), ".lan")) != NULL && !tempptr[5])
- strlcpy(tempptr, ".local", sizeof(temp) - (size_t)(tempptr - temp));
+ cupsCopyString(tempptr, ".local", sizeof(temp) - (size_t)(tempptr - temp));
printer->hostname = strdup(temp);
}
return (0);
}
- strlcpy(client->host_field, httpGetField(client->http, HTTP_FIELD_HOST), sizeof(client->host_field));
+ cupsCopyString(client->host_field, httpGetField(client->http, HTTP_FIELD_HOST), sizeof(client->host_field));
if ((ptr = strrchr(client->host_field, ':')) != NULL)
{
/*
if (ptr > formats && ptr < (formats + sizeof(formats) - 1))
*ptr++ = ',';
- strlcpy(ptr, value, sizeof(formats) - (size_t)(ptr - formats));
+ cupsCopyString(ptr, value, sizeof(formats) - (size_t)(ptr - formats));
ptr += strlen(ptr);
if (ptr >= (formats + sizeof(formats) - 1))
if (ptr > urf && ptr < (urf + sizeof(urf) - 1))
*ptr++ = ',';
- strlcpy(ptr, value, sizeof(urf) - (size_t)(ptr - urf));
+ cupsCopyString(ptr, value, sizeof(urf) - (size_t)(ptr - urf));
ptr += strlen(ptr);
if (ptr >= (urf + sizeof(urf) - 1))
if (printer->dnssd_subtypes && *(printer->dnssd_subtypes))
snprintf(regtype, sizeof(regtype), "_ipp._tcp,%s", printer->dnssd_subtypes);
else
- strlcpy(regtype, "_ipp._tcp", sizeof(regtype));
+ cupsCopyString(regtype, "_ipp._tcp", sizeof(regtype));
if ((error = DNSServiceRegister(&(printer->ipp_ref), kDNSServiceFlagsShareConnection | kDNSServiceFlagsNoAutoRename, ifindex, printer->dnssd_name, regtype, NULL /* domain */, NULL /* host */, htons(printer->port), TXTRecordGetLength(&ipp_txt), TXTRecordGetBytesPtr(&ipp_txt), (DNSServiceRegisterReply)dnssd_callback, printer)) != kDNSServiceErr_NoError)
{
if (printer->dnssd_subtypes && *(printer->dnssd_subtypes))
snprintf(regtype, sizeof(regtype), "_ipps._tcp,%s", printer->dnssd_subtypes);
else
- strlcpy(regtype, "_ipps._tcp", sizeof(regtype));
+ cupsCopyString(regtype, "_ipps._tcp", sizeof(regtype));
if ((error = DNSServiceRegister(&(printer->ipps_ref), kDNSServiceFlagsShareConnection | kDNSServiceFlagsNoAutoRename, ifindex, printer->dnssd_name, regtype, NULL /* domain */, NULL /* host */, htons(printer->port), TXTRecordGetLength(&ipp_txt), TXTRecordGetBytesPtr(&ipp_txt), (DNSServiceRegisterReply)dnssd_callback, printer)) != kDNSServiceErr_NoError)
{
*regtype, /* Registration type */
*domain; /* Domain, if any */
- strlcpy(buf, search, sizeof(buf));
+ cupsCopyString(buf, search, sizeof(buf));
if (!strncmp(buf, "_http._", 7) || !strncmp(buf, "_https._", 8) || !strncmp(buf, "_ipp._", 6) || !strncmp(buf, "_ipps._", 7))
{
*kptr = '\0';
if (!keyword[0] || !strcmp(keyword, "service_uri"))
- strlcpy(tptr, service->uri, sizeof(temp) - (size_t)(tptr - temp));
+ cupsCopyString(tptr, service->uri, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_domain"))
- strlcpy(tptr, service->domain, sizeof(temp) - (size_t)(tptr - temp));
+ cupsCopyString(tptr, service->domain, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_hostname"))
- strlcpy(tptr, service->host, sizeof(temp) - (size_t)(tptr - temp));
+ cupsCopyString(tptr, service->host, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_name"))
- strlcpy(tptr, service->name, sizeof(temp) - (size_t)(tptr - temp));
+ cupsCopyString(tptr, service->name, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_path"))
- strlcpy(tptr, service->resource, sizeof(temp) - (size_t)(tptr - temp));
+ cupsCopyString(tptr, service->resource, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_port"))
- strlcpy(tptr, port + 21, sizeof(temp) - (size_t)(tptr - temp));
+ cupsCopyString(tptr, port + 21, sizeof(temp) - (size_t)(tptr - temp));
else if (!strcmp(keyword, "service_scheme"))
- strlcpy(tptr, scheme + 22, sizeof(temp) - (size_t)(tptr - temp));
+ cupsCopyString(tptr, scheme + 22, sizeof(temp) - (size_t)(tptr - temp));
else if (!strncmp(keyword, "txt_", 4))
{
const char *val = cupsGetOption(keyword + 4, service->num_txt, service->txt);
if (val)
- strlcpy(tptr, val, sizeof(temp) - (size_t)(tptr - temp));
+ cupsCopyString(tptr, val, sizeof(temp) - (size_t)(tptr - temp));
else
*tptr = '\0';
}
*/
if (strchr(args[0], '/') && !access(args[0], X_OK))
- strlcpy(program, args[0], sizeof(program));
+ cupsCopyString(program, args[0], sizeof(program));
else if (!cupsFileFind(args[0], getenv("PATH"), 1, program, sizeof(program)))
{
_cupsLangPrintf(stderr, _("ippfind: Unable to execute \"%s\": %s"),
if ((attr = ippFindAttribute(response, "printer-state-reasons",
IPP_TAG_KEYWORD)) != NULL)
{
- strlcpy(preasons, ippGetString(attr, 0, NULL), sizeof(preasons));
+ cupsCopyString(preasons, ippGetString(attr, 0, NULL), sizeof(preasons));
for (i = 1, count = ippGetCount(attr), ptr = preasons + strlen(preasons),
end = preasons + sizeof(preasons) - 1;
i ++, ptr += strlen(ptr))
{
*ptr++ = ',';
- strlcpy(ptr, ippGetString(attr, i, NULL), (size_t)(end - ptr + 1));
+ cupsCopyString(ptr, ippGetString(attr, i, NULL), (size_t)(end - ptr + 1));
}
}
else
- strlcpy(preasons, "none", sizeof(preasons));
+ cupsCopyString(preasons, "none", sizeof(preasons));
ippDelete(response);
httpClose(http);
usage();
}
- strlcpy(name, argv[i], sizeof(name));
+ cupsCopyString(name, argv[i], sizeof(name));
if ((value = strchr(name, '=')) != NULL)
*value++ = '\0';
else
{
snprintf(filename, sizeof(filename), "%s/ipptool/%s.gz", cg->cups_datadir, argv[i]);
if (access(filename, 0))
- strlcpy(filename, argv[i], sizeof(filename));
+ cupsCopyString(filename, argv[i], sizeof(filename));
}
}
}
else
- strlcpy(filename, argv[i], sizeof(filename));
+ cupsCopyString(filename, argv[i], sizeof(filename));
_ippVarsSet(data.vars, "filename", filename);
case IPP_TAG_BOOLEAN :
if (ippGetBoolean(found, last))
- strlcpy(buffer, "true", sizeof(buffer));
+ cupsCopyString(buffer, "true", sizeof(buffer));
else
- strlcpy(buffer, "false", sizeof(buffer));
+ cupsCopyString(buffer, "false", sizeof(buffer));
break;
case IPP_TAG_CHARSET :
case IPP_TAG_TEXTLANG :
case IPP_TAG_URI :
case IPP_TAG_URISCHEME :
- strlcpy(buffer, ippGetString(found, last, NULL), sizeof(buffer));
+ cupsCopyString(buffer, ippGetString(found, last, NULL), sizeof(buffer));
break;
default :
char group_name[256],/* Parent attribute name */
*group_ptr; /* Pointer into parent attribute name */
- strlcpy(group_name, expect->name, sizeof(group_name));
+ cupsCopyString(group_name, expect->name, sizeof(group_name));
if ((group_ptr = strchr(group_name, '/')) != NULL)
*group_ptr = '\0';
case IPP_TAG_BOOLEAN :
if (ippGetBoolean(found, last))
- strlcpy(buffer, "true", sizeof(buffer));
+ cupsCopyString(buffer, "true", sizeof(buffer));
else
- strlcpy(buffer, "false", sizeof(buffer));
+ cupsCopyString(buffer, "false", sizeof(buffer));
break;
case IPP_TAG_RESOLUTION :
case IPP_TAG_TEXTLANG :
case IPP_TAG_URI :
case IPP_TAG_URISCHEME :
- strlcpy(buffer, ippGetString(found, last, NULL), sizeof(buffer));
+ cupsCopyString(buffer, ippGetString(found, last, NULL), sizeof(buffer));
break;
default :
* Use the path as-is...
*/
- strlcpy(dst, src, dstsize);
+ cupsCopyString(dst, src, dstsize);
}
else
{
* Make path relative to testfile...
*/
- strlcpy(dst, testfile, dstsize);
+ cupsCopyString(dst, testfile, dstsize);
if ((dstptr = strrchr(dst, '/')) != NULL)
dstptr ++;
else
dstptr = dst; /* Should never happen */
- strlcpy(dstptr, src, dstsize - (size_t)(dstptr - dst));
+ cupsCopyString(dstptr, src, dstsize - (size_t)(dstptr - dst));
#if _WIN32
if (_access(dst, 0))
if (_ippFileReadToken(f, temp, sizeof(temp)))
{
- strlcpy(data->pause, temp, sizeof(data->pause));
+ cupsCopyString(data->pause, temp, sizeof(data->pause));
}
else
{
data->last_expect = NULL;
data->file[0] = '\0';
data->ignore_errors = data->def_ignore_errors;
- strlcpy(data->name, f->filename, sizeof(data->name));
+ cupsCopyString(data->name, f->filename, sizeof(data->name));
if ((ptr = strrchr(data->name, '.')) != NULL)
*ptr = '\0';
data->repeat_interval = 5000000;
- strlcpy(data->resource, data->vars->resource, sizeof(data->resource));
+ cupsCopyString(data->resource, data->vars->resource, sizeof(data->resource));
data->skip_previous = 0;
data->pass_test = 0;
data->skip_test = 0;
if ((!strcmp(value, "true") || !strcmp(value, "1")) == ippGetBoolean(attr, i))
{
if (!matchbuf[0])
- strlcpy(matchbuf, value, matchlen);
+ cupsCopyString(matchbuf, value, matchlen);
if (!(flags & IPPTOOL_WITH_ALL))
{
if (!strcmp(value, temp))
{
if (!matchbuf[0])
- strlcpy(matchbuf, value, matchlen);
+ cupsCopyString(matchbuf, value, matchlen);
if (!(flags & IPPTOOL_WITH_ALL))
{
0, NULL, 0))
{
if (!matchbuf[0])
- strlcpy(matchbuf, get_string(attr, i, flags, temp, sizeof(temp)), matchlen);
+ cupsCopyString(matchbuf, get_string(attr, i, flags, temp, sizeof(temp)), matchlen);
if (!(flags & IPPTOOL_WITH_ALL))
{
if (!compare_uris(value, get_string(attr, i, flags, temp, sizeof(temp))))
{
if (!matchbuf[0])
- strlcpy(matchbuf, get_string(attr, i, flags, temp, sizeof(temp)), matchlen);
+ cupsCopyString(matchbuf, get_string(attr, i, flags, temp, sizeof(temp)), matchlen);
if (!(flags & IPPTOOL_WITH_ALL))
{
if (!result)
{
if (!matchbuf[0])
- strlcpy(matchbuf, get_string(attr, i, flags, temp, sizeof(temp)), matchlen);
+ cupsCopyString(matchbuf, get_string(attr, i, flags, temp, sizeof(temp)), matchlen);
if (!(flags & IPPTOOL_WITH_ALL))
{
if (!regexec(&re, temp, 0, NULL, 0))
{
if (!matchbuf[0])
- strlcpy(matchbuf, temp, matchlen);
+ cupsCopyString(matchbuf, temp, matchlen);
if (!(flags & IPPTOOL_WITH_ALL))
{
if (ippContainsString(fromattr, value))
{
if (!matchbuf[0])
- strlcpy(matchbuf, value, matchlen);
+ cupsCopyString(matchbuf, value, matchlen);
}
else
{
if (!compare_uris(value, ippGetString(fromattr, j, NULL)))
{
if (!matchbuf[0])
- strlcpy(matchbuf, value, matchlen);
+ cupsCopyString(matchbuf, value, matchlen);
break;
}
}