/*
- * "$Id: ipp-var.c 7940 2008-09-16 00:45:16Z mike $"
+ * "$Id$"
*
- * CGI <-> IPP variable routines for CUPS.
+ * CGI <-> IPP variable routines for CUPS.
*
- * Copyright 2007-2012 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products.
*
- * These coded instructions, statements, and computer programs are the
- * property of Apple Inc. and are protected by Federal copyright
- * law. Distribution and use rights are outlined in the file "LICENSE.txt"
- * which should have been included with this file. If this file is
- * file is missing or damaged, see the license at "http://www.cups.org/".
- *
- * Contents:
- *
- * cgiGetAttributes() - Get the list of attributes that are needed by the
- * template file.
- * cgiGetIPPObjects() - Get the objects in an IPP response.
- * cgiMoveJobs() - Move one or more jobs.
- * cgiPrintCommand() - Print a CUPS command job.
- * cgiPrintTestPage() - Print a test page.
- * cgiRewriteURL() - Rewrite a printer URI into a web browser URL...
- * cgiSetIPPObjectVars() - Set CGI variables from an IPP object.
- * cgiSetIPPVars() - Set CGI variables from an IPP response.
- * cgiShowIPPError() - Show the last IPP error message.
- * cgiShowJobs() - Show print jobs.
- * cgiText() - Return localized text.
+ * These coded instructions, statements, and computer programs are the
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*/
/*
{
for (i = 0; lang[i] && i < 15; i ++)
if (isalnum(lang[i] & 255))
- locale[i] = tolower(lang[i]);
+ locale[i] = (char)tolower(lang[i]);
else
locale[i] = '_';
while ((ch = getc(in)) != EOF)
if (ch == '\\')
getc(in);
- else if (ch == '{' && num_attrs < (sizeof(attrs) / sizeof(attrs[0])))
+ else if (ch == '{' && num_attrs < (int)(sizeof(attrs) / sizeof(attrs[0])))
{
/*
* Grab the name...
if (ch == '_')
*nameptr++ = '-';
else
- *nameptr++ = ch;
+ *nameptr++ = (char)ch;
}
*nameptr = '\0';
if (!strncmp(name, "printer_state_history", 21))
- strcpy(name, "printer_state_history");
+ strlcpy(name, "printer_state_history", sizeof(name));
/*
* Possibly add it to the list of attributes...
ipp_t *request, /* Get-Job-Attributes request */
*response; /* Get-Job-Attributes response */
ipp_attribute_t *attr; /* Current job attribute */
- static const char const *job_attrs[] =/* Job attributes we want */
+ static const char * const job_attrs[] =/* Job attributes we want */
{
"job-state",
"job-printer-state-message"
* Make URI relative to the current server...
*/
- strlcpy(url, resource, urlsize);
+ strlcpy(url, resource, (size_t)urlsize);
}
else
{
*/
if (userpass[0])
- snprintf(url, urlsize, "%s://%s@%s:%d%s",
- ishttps ? "https" : "http",
- userpass, hostname, port, resource);
+ snprintf(url, (size_t)urlsize, "%s://%s@%s:%d%s", ishttps ? "https" : "http", userpass, hostname, port, resource);
else
- snprintf(url, urlsize, "%s://%s:%d%s",
- ishttps ? "https" : "http",
- hostname, port, resource);
+ snprintf(url, (size_t)urlsize, "%s://%s:%d%s", ishttps ? "https" : "http", hostname, port, resource);
}
}
else
- strlcpy(url, uri, urlsize);
+ strlcpy(url, uri, (size_t)urlsize);
return (url);
}
*valptr++ = ' ';
}
- remaining = sizeof(value) - (valptr - value);
+ remaining = sizeof(value) - (size_t)(valptr - value);
if (!strcmp(attr->values[i].string.text, "printer-stopped"))
strlcpy(valptr, _("Printer Paused"), remaining);
for (i = 0; i < attr->num_values; i ++)
{
if (i)
- strlcat(valptr, ", ", sizeof(value) - (valptr - value));
+ strlcat(valptr, ", ", sizeof(value) - (size_t)(valptr - value));
valptr += strlen(valptr);
t = (time_t)attr->values[i].integer;
date = localtime(&t);
- strftime(valptr, sizeof(value) - (valptr - value), "%c", date);
+ strftime(valptr, sizeof(value) - (size_t)(valptr - value), "%c", date);
}
else
- snprintf(valptr, sizeof(value) - (valptr - value),
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
"%d", attr->values[i].integer);
break;
case IPP_TAG_BOOLEAN :
- snprintf(valptr, sizeof(value) - (valptr - value),
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
"%d", attr->values[i].boolean);
break;
case IPP_TAG_NOVALUE :
- strlcat(valptr, "novalue", sizeof(value) - (valptr - value));
+ strlcat(valptr, "novalue", sizeof(value) - (size_t)(valptr - value));
break;
case IPP_TAG_RANGE :
- snprintf(valptr, sizeof(value) - (valptr - value),
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
"%d-%d", attr->values[i].range.lower,
attr->values[i].range.upper);
break;
case IPP_TAG_RESOLUTION :
- snprintf(valptr, sizeof(value) - (valptr - value),
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
"%dx%d%s", attr->values[i].resolution.xres,
attr->values[i].resolution.yres,
attr->values[i].resolution.units == IPP_RES_PER_INCH ?
cgiRewriteURL(attr->values[i].string.text, url,
sizeof(url), NULL);
- snprintf(valptr, sizeof(value) - (valptr - value),
+ snprintf(valptr, sizeof(value) - (size_t)(valptr - value),
"<A HREF=\"%s\">%s</A>", url,
strrchr(attr->values[i].string.text, '/') + 1);
}
else
cgiRewriteURL(attr->values[i].string.text, valptr,
- sizeof(value) - (valptr - value), NULL);
+ (int)(sizeof(value) - (size_t)(valptr - value)), NULL);
break;
}
case IPP_TAG_LANGUAGE :
case IPP_TAG_MIMETYPE :
strlcat(valptr, attr->values[i].string.text,
- sizeof(value) - (valptr - value));
+ sizeof(value) - (size_t)(valptr - value));
break;
case IPP_TAG_BEGIN_COLLECTION :
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL,
"ipp://localhost/");
- if ((which_jobs = cgiGetVariable("which_jobs")) != NULL)
+ if ((which_jobs = cgiGetVariable("which_jobs")) != NULL && *which_jobs)
ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "which-jobs",
NULL, which_jobs);
if (first < 0)
first = 0;
- if ((var = cgiGetVariable("ORDER")) != NULL)
+ if ((var = cgiGetVariable("ORDER")) != NULL && *var)
ascending = !_cups_strcasecmp(var, "asc");
else
- ascending = !which_jobs || !_cups_strcasecmp(which_jobs, "not-completed");
+ ascending = !which_jobs || !*which_jobs ||
+ !_cups_strcasecmp(which_jobs, "not-completed");
section = cgiGetVariable("SECTION");
/*
- * End of "$Id: ipp-var.c 7940 2008-09-16 00:45:16Z mike $".
+ * End of "$Id$".
*/