*
* ipptool command for CUPS.
*
- * Copyright 2007-2013 by Apple Inc.
+ * Copyright 2007-2014 by Apple Inc.
* Copyright 1997-2007 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
* Globals...
*/
-_cups_transfer_t Transfer = _CUPS_TRANSFER_AUTO;
+static _cups_transfer_t Transfer = _CUPS_TRANSFER_AUTO;
/* How to transfer requests */
-_cups_output_t Output = _CUPS_OUTPUT_LIST;
+static _cups_output_t Output = _CUPS_OUTPUT_LIST;
/* Output mode */
-int Cancel = 0, /* Cancel test? */
+static int Cancel = 0, /* Cancel test? */
IgnoreErrors = 0, /* Ignore errors? */
StopAfterIncludeError = 0,
/* Stop after include errors? */
PassCount = 0, /* Number of passing tests */
FailCount = 0, /* Number of failing tests */
SkipCount = 0; /* Number of skipped tests */
-char *Password = NULL; /* Password from URI */
-const char * const URIStatusStrings[] = /* URI status strings */
-{
- "URI too large",
- "Bad arguments to function",
- "Bad resource in URI",
- "Bad port number in URI",
- "Bad hostname/address in URI",
- "Bad username in URI",
- "Bad scheme in URI",
- "Bad/empty URI",
- "OK",
- "Missing scheme in URI",
- "Unknown scheme in URI",
- "Missing resource in URI"
-};
+static char *Password = NULL; /* Password from URI */
/*
_cupsLangPrintf(stderr, _("ipptool: Unknown option \"-%c\"."),
*opt);
usage();
- break;
}
}
}
if (uri_status != HTTP_URI_OK)
{
- _cupsLangPrintf(stderr, _("ipptool: Bad URI - %s."),
- URIStatusStrings[uri_status - HTTP_URI_OVERFLOW]);
+ _cupsLangPrintf(stderr, _("ipptool: Bad URI - %s."), httpURIStatusString(uri_status));
return (1);
}
{
while (repeat > 1)
{
- usleep(interval);
+ usleep((useconds_t)interval);
do_tests(&vars, testfile);
repeat --;
}
{
for (;;)
{
- usleep(interval);
+ usleep((useconds_t)interval);
do_tests(&vars, testfile);
}
}
expand_variables(vars, token, temp, sizeof(token));
if ((op = ippOpValue(token)) == (ipp_op_t)-1 &&
- (op = strtol(token, NULL, 0)) == 0)
+ (op = (ipp_op_t)strtol(token, NULL, 0)) == 0)
{
print_fatal_error("Bad OPERATION code \"%s\" on line %d.", token,
linenum);
if (Output == _CUPS_OUTPUT_TEST)
printf(" [%g second delay]\n", delay);
- usleep((int)(1000000.0 * delay));
+ usleep((useconds_t)(1000000.0 * delay));
}
}
else if (!_cups_strcasecmp(token, "ATTR"))
if (!_cups_strcasecmp(token, "true"))
attrptr = ippAddBoolean(request, group, attr, 1);
else
- attrptr = ippAddBoolean(request, group, attr, atoi(token));
+ attrptr = ippAddBoolean(request, group, attr, (char)atoi(token));
break;
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
if (!strchr(token, ','))
- attrptr = ippAddInteger(request, group, value, attr,
- strtol(token, &tokenptr, 0));
+ attrptr = ippAddInteger(request, group, value, attr, (int)strtol(token, &tokenptr, 0));
else
{
int values[100], /* Values */
num_values = 1; /* Number of values */
- values[0] = strtol(token, &tokenptr, 10);
+ values[0] = (int)strtol(token, &tokenptr, 10);
while (tokenptr && *tokenptr &&
num_values < (int)(sizeof(values) / sizeof(values[0])))
{
else if (!isdigit(*tokenptr & 255) && *tokenptr != '-')
break;
- values[num_values] = strtol(tokenptr, &tokenptr, 0);
+ values[num_values] = (int)strtol(tokenptr, &tokenptr, 0);
num_values ++;
}
yres; /* Y resolution */
char *ptr; /* Pointer into value */
- xres = yres = strtol(token, (char **)&ptr, 10);
+ xres = yres = (int)strtol(token, (char **)&ptr, 10);
if (ptr > token && xres > 0)
{
if (*ptr == 'x')
- yres = strtol(ptr + 1, (char **)&ptr, 10);
+ yres = (int)strtol(ptr + 1, (char **)&ptr, 10);
}
if (ptr <= token || xres <= 0 || yres <= 0 || !ptr ||
}
if (!_cups_strcasecmp(ptr, "dpi"))
- attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_INCH,
- xres, yres);
+ attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_INCH, xres, yres);
else if (!_cups_strcasecmp(ptr, "dpc") ||
!_cups_strcasecmp(ptr, "dpcm"))
- attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_CM,
- xres, yres);
+ attrptr = ippAddResolution(request, group, attr, IPP_RES_PER_CM, xres, yres);
else
- attrptr = ippAddResolution(request, group, attr, (ipp_res_t)0,
- xres, yres);
+ attrptr = ippAddResolution(request, group, attr, (ipp_res_t)0, xres, yres);
}
break;
break;
case IPP_TAG_STRING :
- attrptr = ippAddOctetString(request, group, attr, token,
- strlen(token));
+ attrptr = ippAddOctetString(request, group, attr, token, (int)strlen(token));
break;
default :
if ((statuses[num_statuses].status = ippErrorValue(token))
== (ipp_status_t)-1 &&
- (statuses[num_statuses].status = strtol(token, NULL, 0)) == 0)
+ (statuses[num_statuses].status = (ipp_status_t)strtol(token, NULL, 0)) == 0)
{
print_fatal_error("Bad STATUS code \"%s\" on line %d.", token,
linenum);
* WITH-VALUE is a POSIX extended regular expression.
*/
- last_expect->with_value = calloc(1, tokenptr - token);
+ last_expect->with_value = calloc(1, (size_t)(tokenptr - token));
last_expect->with_flags |= _CUPS_WITH_REGEX;
if (last_expect->with_value)
TestCount ++;
- request->request.op.version[0] = version / 10;
- request->request.op.version[1] = version % 10;
- request->request.op.operation_id = op;
- request->request.op.request_id = request_id;
+ ippSetVersion(request, version / 10, version % 10);
+ ippSetOperation(request, op);
+ ippSetRequestId(request, request_id);
if (Output == _CUPS_OUTPUT_PLIST)
{
*/
while ((bytes = cupsFileRead(reqfile, buffer, sizeof(buffer))) > 0)
- length += bytes;
+ length += (size_t)bytes;
cupsFileClose(reqfile);
}
if ((reqfile = cupsFileOpen(filename, "r")) != NULL)
{
while (!Cancel &&
- (bytes = cupsFileRead(reqfile, buffer,
- sizeof(buffer))) > 0)
- if ((status = cupsWriteRequestData(http, buffer,
- bytes)) != HTTP_CONTINUE)
+ (bytes = cupsFileRead(reqfile, buffer, sizeof(buffer))) > 0)
+ if ((status = cupsWriteRequestData(http, buffer, (size_t)bytes)) != HTTP_CONTINUE)
break;
cupsFileClose(reqfile);
fflush(stdout);
}
- sleep(repeat_interval);
+ sleep((unsigned)repeat_interval);
repeat_interval = _cupsNextDelay(repeat_interval, &repeat_prev);
if (Output == _CUPS_OUTPUT_TEST)
if (!_cups_strcasecmp(token, "true"))
ippAddBoolean(col, IPP_TAG_ZERO, attr, 1);
else
- ippAddBoolean(col, IPP_TAG_ZERO, attr, atoi(token));
+ ippAddBoolean(col, IPP_TAG_ZERO, attr, (char)atoi(token));
break;
case IPP_TAG_INTEGER :
}
if (!_cups_strcasecmp(units, "dpi"))
- ippAddResolution(col, IPP_TAG_ZERO, attr, xres, yres,
- IPP_RES_PER_INCH);
+ ippAddResolution(col, IPP_TAG_ZERO, attr, IPP_RES_PER_INCH, xres, yres);
else if (!_cups_strcasecmp(units, "dpc") ||
!_cups_strcasecmp(units, "dpcm"))
- ippAddResolution(col, IPP_TAG_ZERO, attr, xres, yres,
- IPP_RES_PER_CM);
+ ippAddResolution(col, IPP_TAG_ZERO, attr, IPP_RES_PER_CM, xres, yres);
else
- ippAddResolution(col, IPP_TAG_ZERO, attr, xres, yres,
- (ipp_res_t)0);
+ ippAddResolution(col, IPP_TAG_ZERO, attr, (ipp_res_t)0, xres, yres);
}
break;
}
break;
case IPP_TAG_STRING :
- ippAddOctetString(col, IPP_TAG_ZERO, attr, token, strlen(token));
+ ippAddOctetString(col, IPP_TAG_ZERO, attr, token, (int)strlen(token));
break;
default :
else
dstptr = dst; /* Should never happen */
- strlcpy(dstptr, src, dstsize - (dstptr - dst));
+ strlcpy(dstptr, src, dstsize - (size_t)(dstptr - dst));
}
return (dst);
if (flags & _CUPS_WITH_HOSTNAME)
{
- if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme),
- userpass, sizeof(userpass), buffer, bufsize, &port,
- resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
- return ("");
- else
- return (buffer);
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme), userpass, sizeof(userpass), buffer, (int)bufsize, &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
+ buffer[0] = '\0';
+
+ return (buffer);
}
else if (flags & _CUPS_WITH_RESOURCE)
{
- if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme),
- userpass, sizeof(userpass), hostname, sizeof(hostname),
- &port, buffer, bufsize) < HTTP_URI_STATUS_OK)
- return ("");
- else
- return (buffer);
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, buffer, (int)bufsize) < HTTP_URI_STATUS_OK)
+ buffer[0] = '\0';
+
+ return (buffer);
}
else if (flags & _CUPS_WITH_SCHEME)
{
- if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, buffer, bufsize,
- userpass, sizeof(userpass), hostname, sizeof(hostname),
- &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
- return ("");
- else
- return (buffer);
+ if (httpSeparateURI(HTTP_URI_CODING_ALL, ptr, buffer, (int)bufsize, userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
+ buffer[0] = '\0';
+
+ return (buffer);
}
else
return (ptr);
*/
if (bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
if ((ch = getc(fp)) != EOF && bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
else if (ch == quote)
break;
else if (bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
}
*bufptr = '\0';
if (isspace(ch) || ch == '#')
break;
else if (bufptr < bufend)
- *bufptr++ = ch;
+ *bufptr++ = (char)ch;
if (ch == '#')
ungetc(ch, fp);
"\"%s\": Bad URI value \"%s\" - %s "
"(RFC 2911 section 4.1.5).", attr->name,
attr->values[i].string.text,
- URIStatusStrings[uri_status -
- HTTP_URI_OVERFLOW]);
+ httpURIStatusString(uri_status));
}
if (strlen(attr->values[i].string.text) > (IPP_MAX_URI - 1))
if (!*valptr)
break;
- intvalue = strtol(valptr, &nextptr, 0);
+ intvalue = (int)strtol(valptr, &nextptr, 0);
if (nextptr == valptr)
break;
valptr = nextptr;
(op == '>' && attr->values[i].integer > intvalue))
{
if (!matchbuf[0])
- snprintf(matchbuf, matchlen, "%d",
- attr->values[i].integer);
+ snprintf(matchbuf, matchlen, "%d", attr->values[i].integer);
valmatch = 1;
break;
if (!*valptr)
break;
- intvalue = strtol(valptr, &nextptr, 0);
+ intvalue = (int)strtol(valptr, &nextptr, 0);
if (nextptr == valptr)
break;
valptr = nextptr;