/*
- * "$Id$"
- *
- * Internet Printing Protocol functions for CUPS.
- *
- * Copyright 2007-2013 by Apple Inc.
- * Copyright 1997-2007 by Easy Software Products, all rights reserved.
- *
- * 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/".
- *
- * This file is subject to the Apple OS-Developed Software exception.
- *
- * Contents:
- *
- * _cupsBufferGet() - Get a read/write buffer.
- * _cupsBufferRelease() - Release a read/write buffer.
- * ippAddBoolean() - Add a boolean attribute to an IPP message.
- * ippAddBooleans() - Add an array of boolean values.
- * ippAddCollection() - Add a collection value.
- * ippAddCollections() - Add an array of collection values.
- * ippAddDate() - Add a date attribute to an IPP message.
- * ippAddInteger() - Add a integer attribute to an IPP message.
- * ippAddIntegers() - Add an array of integer values.
- * ippAddOctetString() - Add an octetString value to an IPP message.
- * ippAddOutOfBand() - Add an out-of-band value to an IPP message.
- * ippAddRange() - Add a range of values to an IPP message.
- * ippAddRanges() - Add ranges of values to an IPP message.
- * ippAddResolution() - Add a resolution value to an IPP message.
- * ippAddResolutions() - Add resolution values to an IPP message.
- * ippAddSeparator() - Add a group separator to an IPP message.
- * ippAddString() - Add a language-encoded string to an IPP message.
- * ippAddStringf() - Add a formatted string to an IPP message.
- * ippAddStringfv() - Add a formatted string to an IPP message.
- * ippAddStrings() - Add language-encoded strings to an IPP message.
- * ippContainsInteger() - Determine whether an attribute contains the
- * specified value or is within the list of ranges.
- * ippContainsString() - Determine whether an attribute contains the
- * specified string value.
- * ippCopyAttribute() - Copy an attribute.
- * ippCopyAttributes() - Copy attributes from one IPP message to another.
- * ippDateToTime() - Convert from RFC 1903 Date/Time format to UNIX
- * time in seconds.
- * ippDelete() - Delete an IPP message.
- * ippDeleteAttribute() - Delete a single attribute in an IPP message.
- * ippDeleteValues() - Delete values in an attribute.
- * ippFindAttribute() - Find a named attribute in a request.
- * ippFindNextAttribute() - Find the next named attribute in a request.
- * ippFirstAttribute() - Return the first attribute in the message.
- * ippGetBoolean() - Get a boolean value for an attribute.
- * ippGetCollection() - Get a collection value for an attribute.
- * ippGetCount() - Get the number of values in an attribute.
- * ippGetDate() - Get a date value for an attribute.
- * ippGetGroupTag() - Get the group associated with an attribute.
- * ippGetInteger() - Get the integer/enum value for an attribute.
- * ippGetName() - Get the attribute name.
- * ippGetOctetString() - Get an octetString value from an IPP attribute.
- * ippGetOperation() - Get the operation ID in an IPP message.
- * ippGetRange() - Get a rangeOfInteger value from an attribute.
- * ippGetRequestId() - Get the request ID from an IPP message.
- * ippGetResolution() - Get a resolution value for an attribute.
- * ippGetState() - Get the IPP message state.
- * ippGetStatusCode() - Get the status code from an IPP response or
- * event message.
- * ippGetString() - Get the string and optionally the language code
- * for an attribute.
- * ippGetValueTag() - Get the value tag for an attribute.
- * ippGetVersion() - Get the major and minor version number from an
- * IPP message.
- * ippLength() - Compute the length of an IPP message.
- * ippNextAttribute() - Return the next attribute in the message.
- * ippNew() - Allocate a new IPP message.
- * ippNewRequest() - Allocate a new IPP request message.
- * ippNewResponse() - Allocate a new IPP response message.
- * ippRead() - Read data for an IPP message from a HTTP
- * connection.
- * ippReadFile() - Read data for an IPP message from a file.
- * ippReadIO() - Read data for an IPP message.
- * ippSetBoolean() - Set a boolean value in an attribute.
- * ippSetCollection() - Set a collection value in an attribute.
- * ippSetDate() - Set a date value in an attribute.
- * ippSetGroupTag() - Set the group tag of an attribute.
- * ippSetInteger() - Set an integer or enum value in an attribute.
- * ippSetName() - Set the name of an attribute.
- * ippSetOctetString() - Set an octetString value in an IPP attribute.
- * ippSetOperation() - Set the operation ID in an IPP request message.
- * ippSetRange() - Set a rangeOfInteger value in an attribute.
- * ippSetRequestId() - Set the request ID in an IPP message.
- * ippSetResolution() - Set a resolution value in an attribute.
- * ippSetState() - Set the current state of the IPP message.
- * ippSetStatusCode() - Set the status code in an IPP response or event
- * message.
- * ippSetString() - Set a string value in an attribute.
- * ippSetStringf() - Set a formatted string value of an attribute.
- * ippSetStringf() - Set a formatted string value of an attribute.
- * ippSetValueTag() - Set the value tag of an attribute.
- * ippSetVersion() - Set the version number in an IPP message.
- * ippTimeToDate() - Convert from UNIX time to RFC 1903 format.
- * ippValidateAttribute() - Validate the contents of an attribute.
- * ippValidateAttributes() - Validate all attributes in an IPP message.
- * ippWrite() - Write data for an IPP message to a HTTP
- * connection.
- * ippWriteFile() - Write data for an IPP message to a file.
- * ippWriteIO() - Write data for an IPP message.
- * ipp_add_attr() - Add a new attribute to the message.
- * ipp_free_values() - Free attribute values.
- * ipp_get_code() - Convert a C locale/charset name into an IPP
- * language/charset code.
- * ipp_lang_code() - Convert a C locale name into an IPP language
- * code.
- * ipp_length() - Compute the length of an IPP message or
- * collection value.
- * ipp_read_http() - Semi-blocking read on a HTTP connection...
- * ipp_read_file() - Read IPP data from a file.
- * ipp_set_error() - Set a formatted, localized error string.
- * ipp_set_value() - Get the value element from an attribute,
- * expanding it as needed.
- * ipp_write_file() - Write IPP data to a file.
+ * Internet Printing Protocol functions for CUPS.
+ *
+ * Copyright 2007-2015 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
+ *
+ * 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/".
+ *
+ * This file is subject to the Apple OS-Developed Software exception.
*/
/*
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("ippAddBoolean(ipp=%p, group=%02x(%s), name=\"%s\", value=%d)",
- ipp, group, ippTagString(group), name, value));
+ DEBUG_printf(("ippAddBoolean(ipp=%p, group=%02x(%s), name=\"%s\", value=%d)", (void *)ipp, group, ippTagString(group), name, value));
/*
* Range check input...
_ipp_value_t *value; /* Current value */
- DEBUG_printf(("ippAddBooleans(ipp=%p, group=%02x(%s), name=\"%s\", "
- "num_values=%d, values=%p)", ipp, group, ippTagString(group),
- name, num_values, values));
+ DEBUG_printf(("ippAddBooleans(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)values));
/*
* Range check input...
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("ippAddCollection(ipp=%p, group=%02x(%s), name=\"%s\", "
- "value=%p)", ipp, group, ippTagString(group), name, value));
+ DEBUG_printf(("ippAddCollection(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)", (void *)ipp, group, ippTagString(group), name, (void *)value));
/*
* Range check input...
_ipp_value_t *value; /* Current value */
- DEBUG_printf(("ippAddCollections(ipp=%p, group=%02x(%s), name=\"%s\", "
- "num_values=%d, values=%p)", ipp, group, ippTagString(group),
- name, num_values, values));
+ DEBUG_printf(("ippAddCollections(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)values));
/*
* Range check input...
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("ippAddDate(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)",
- ipp, group, ippTagString(group), name, value));
+ DEBUG_printf(("ippAddDate(ipp=%p, group=%02x(%s), name=\"%s\", value=%p)", (void *)ipp, group, ippTagString(group), name, (void *)value));
/*
* Range check input...
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("ippAddInteger(ipp=%p, group=%02x(%s), type=%02x(%s), "
- "name=\"%s\", value=%d)", ipp, group, ippTagString(group),
- value_tag, ippTagString(value_tag), name, value));
+ DEBUG_printf(("ippAddInteger(ipp=%p, group=%02x(%s), type=%02x(%s), name=\"%s\", value=%d)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, value));
value_tag &= IPP_TAG_CUPS_MASK;
_ipp_value_t *value; /* Current value */
- DEBUG_printf(("ippAddIntegers(ipp=%p, group=%02x(%s), type=%02x(%s), "
- "name=\"%s\", num_values=%d, values=%p)", ipp,
- group, ippTagString(group), value_tag, ippTagString(value_tag), name,
- num_values, values));
+ DEBUG_printf(("ippAddIntegers(ipp=%p, group=%02x(%s), type=%02x(%s), name=\"%s\", num_values=%d, values=%p)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, num_values, (void *)values));
value_tag &= IPP_TAG_CUPS_MASK;
if (data)
{
- if ((attr->values[0].unknown.data = malloc(datalen)) == NULL)
+ if ((attr->values[0].unknown.data = malloc((size_t)datalen)) == NULL)
{
ippDeleteAttribute(ipp, attr);
return (NULL);
}
- memcpy(attr->values[0].unknown.data, data, datalen);
+ memcpy(attr->values[0].unknown.data, data, (size_t)datalen);
}
/*
ipp_tag_t value_tag, /* I - Type of attribute */
const char *name) /* I - Name of attribute */
{
- DEBUG_printf(("ippAddOutOfBand(ipp=%p, group=%02x(%s), value_tag=%02x(%s), "
- "name=\"%s\")", ipp, group, ippTagString(group), value_tag,
- ippTagString(value_tag), name));
+ DEBUG_printf(("ippAddOutOfBand(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\")", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name));
value_tag &= IPP_TAG_CUPS_MASK;
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("ippAddRange(ipp=%p, group=%02x(%s), name=\"%s\", lower=%d, "
- "upper=%d)", ipp, group, ippTagString(group), name, lower,
- upper));
+ DEBUG_printf(("ippAddRange(ipp=%p, group=%02x(%s), name=\"%s\", lower=%d, upper=%d)", (void *)ipp, group, ippTagString(group), name, lower, upper));
/*
* Range check input...
_ipp_value_t *value; /* Current value */
- DEBUG_printf(("ippAddRanges(ipp=%p, group=%02x(%s), name=\"%s\", "
- "num_values=%d, lower=%p, upper=%p)", ipp, group,
- ippTagString(group), name, num_values, lower, upper));
+ DEBUG_printf(("ippAddRanges(ipp=%p, group=%02x(%s), name=\"%s\", num_values=%d, lower=%p, upper=%p)", (void *)ipp, group, ippTagString(group), name, num_values, (void *)lower, (void *)upper));
/*
* Range check input...
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("ippAddResolution(ipp=%p, group=%02x(%s), name=\"%s\", "
- "units=%d, xres=%d, yres=%d)", ipp, group,
+ DEBUG_printf(("ippAddResolution(ipp=%p, group=%02x(%s), name=\"%s\", units=%d, xres=%d, yres=%d)", (void *)ipp, group,
ippTagString(group), name, units, xres, yres));
/*
_ipp_value_t *value; /* Current value */
- DEBUG_printf(("ippAddResolutions(ipp=%p, group=%02x(%s), name=\"%s\", "
- "num_value=%d, units=%d, xres=%p, yres=%p)", ipp, group,
- ippTagString(group), name, num_values, units, xres, yres));
+ DEBUG_printf(("ippAddResolutions(ipp=%p, group=%02x(%s), name=\"%s\", num_value=%d, units=%d, xres=%p, yres=%p)", (void *)ipp, group, ippTagString(group), name, num_values, units, (void *)xres, (void *)yres));
/*
* Range check input...
ipp_attribute_t * /* O - New attribute */
ippAddSeparator(ipp_t *ipp) /* I - IPP message */
{
- DEBUG_printf(("ippAddSeparator(ipp=%p)", ipp));
+ DEBUG_printf(("ippAddSeparator(ipp=%p)", (void *)ipp));
/*
* Range check input...
/* Charset/language code buffer */
- DEBUG_printf(("ippAddString(ipp=%p, group=%02x(%s), value_tag=%02x(%s), "
- "name=\"%s\", language=\"%s\", value=\"%s\")", ipp,
- group, ippTagString(group), value_tag, ippTagString(value_tag), name,
- language, value));
+ DEBUG_printf(("ippAddString(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\", language=\"%s\", value=\"%s\")", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, language, value));
/*
* Range check input...
if (!s)
s = "(null)";
- bytes = strlen(s);
+ bytes = (ssize_t)strlen(s);
strlcpy(buffer, s, sizeof(buffer));
}
else
char code[32]; /* Language/charset value buffer */
- DEBUG_printf(("ippAddStrings(ipp=%p, group=%02x(%s), value_tag=%02x(%s), "
- "name=\"%s\", num_values=%d, language=\"%s\", values=%p)", ipp,
- group, ippTagString(group), value_tag, ippTagString(value_tag), name,
- num_values, language, values));
+ DEBUG_printf(("ippAddStrings(ipp=%p, group=%02x(%s), value_tag=%02x(%s), name=\"%s\", num_values=%d, language=\"%s\", values=%p)", (void *)ipp, group, ippTagString(group), value_tag, ippTagString(value_tag), name, num_values, language, (void *)values));
/*
* Range check input...
_ipp_value_t *avalue; /* Current attribute value */
- DEBUG_printf(("ippContainsString(attr=%p, value=\"%s\")", attr, value));
+ DEBUG_printf(("ippContainsString(attr=%p, value=\"%s\")", (void *)attr, value));
/*
* Range check input...
*dstval; /* Destination value */
- DEBUG_printf(("ippCopyAttribute(dst=%p, srcattr=%p, quickcopy=%d)", dst, srcattr,
- quickcopy));
+ DEBUG_printf(("ippCopyAttribute(dst=%p, srcattr=%p, quickcopy=%d)", (void *)dst, (void *)srcattr, quickcopy));
/*
* Range check input...
if (dstval->unknown.length > 0)
{
- if ((dstval->unknown.data = malloc(dstval->unknown.length)) == NULL)
+ if ((dstval->unknown.data = malloc((size_t)dstval->unknown.length)) == NULL)
dstval->unknown.length = 0;
else
- memcpy(dstval->unknown.data, srcval->unknown.data, dstval->unknown.length);
+ memcpy(dstval->unknown.data, srcval->unknown.data, (size_t)dstval->unknown.length);
}
}
break; /* anti-compiler-warning-code */
/*
* 'ippCopyAttributes()' - Copy attributes from one IPP message to another.
*
- * Zero or more attributes are copied from the source IPP message, @code@ src, to the
+ * Zero or more attributes are copied from the source IPP message, @code src@, to the
* destination IPP message, @code dst@. When @code quickcopy@ is non-zero, a "shallow"
* reference copy of the attribute is created - this should only be done as long as the
* original source IPP message will not be freed for the life of the destination.
ipp_attribute_t *srcattr; /* Source attribute */
- DEBUG_printf(("ippCopyAttributes(dst=%p, src=%p, quickcopy=%d, cb=%p, context=%p)",
- dst, src, quickcopy, cb, context));
+ DEBUG_printf(("ippCopyAttributes(dst=%p, src=%p, quickcopy=%d, cb=%p, context=%p)", (void *)dst, (void *)src, quickcopy, (void *)cb, context));
/*
* Range check input...
*next; /* Next attribute */
- DEBUG_printf(("ippDelete(ipp=%p)", ipp));
+ DEBUG_printf(("ippDelete(ipp=%p)", (void *)ipp));
if (!ipp)
return;
*prev; /* Previous attribute */
- DEBUG_printf(("ippDeleteAttribute(ipp=%p, attr=%p(%s))", ipp, attr,
- attr ? attr->name : "(null)"));
+ DEBUG_printf(("ippDeleteAttribute(ipp=%p, attr=%p(%s))", (void *)ipp, (void *)attr, attr ? attr->name : "(null)"));
/*
* Range check input...
/*
* 'ippFindAttribute()' - Find a named attribute in a request.
+ *
+ * Starting with CUPS 2.0, the attribute name can contain a hierarchical list
+ * of attribute and member names separated by slashes, for example
+ * "media-col/media-size".
*/
ipp_attribute_t * /* O - Matching attribute */
const char *name, /* I - Name of attribute */
ipp_tag_t type) /* I - Type of attribute */
{
- DEBUG_printf(("2ippFindAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", ipp,
- name, type, ippTagString(type)));
+ DEBUG_printf(("2ippFindAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", (void *)ipp, name, type, ippTagString(type)));
if (!ipp || !name)
return (NULL);
*/
ipp->current = NULL;
+ ipp->atend = 0;
/*
* Search for the attribute...
/*
* 'ippFindNextAttribute()' - Find the next named attribute in a request.
+ *
+ * Starting with CUPS 2.0, the attribute name can contain a hierarchical list
+ * of attribute and member names separated by slashes, for example
+ * "media-col/media-size".
*/
ipp_attribute_t * /* O - Matching attribute */
const char *name, /* I - Name of attribute */
ipp_tag_t type) /* I - Type of attribute */
{
- ipp_attribute_t *attr; /* Current atttribute */
+ ipp_attribute_t *attr, /* Current atttribute */
+ *childattr; /* Child attribute */
ipp_tag_t value_tag; /* Value tag */
+ char parent[1024], /* Parent attribute name */
+ *child = NULL; /* Child attribute name */
- DEBUG_printf(("2ippFindNextAttribute(ipp=%p, name=\"%s\", type=%02x(%s))",
- ipp, name, type, ippTagString(type)));
+ DEBUG_printf(("2ippFindNextAttribute(ipp=%p, name=\"%s\", type=%02x(%s))", (void *)ipp, name, type, ippTagString(type)));
if (!ipp || !name)
return (NULL);
- if (ipp->current)
+ DEBUG_printf(("3ippFindNextAttribute: atend=%d", ipp->atend));
+
+ if (ipp->atend)
+ return (NULL);
+
+ if (strchr(name, '/'))
+ {
+ /*
+ * Search for child attribute...
+ */
+
+ strlcpy(parent, name, sizeof(parent));
+ if ((child = strchr(parent, '/')) == NULL)
+ {
+ DEBUG_puts("3ippFindNextAttribute: Attribute name too long.");
+ return (NULL);
+ }
+
+ *child++ = '\0';
+
+ if (ipp->current && ipp->current->name && ipp->current->value_tag == IPP_TAG_BEGIN_COLLECTION && !strcmp(parent, ipp->current->name))
+ {
+ while (ipp->curindex < ipp->current->num_values)
+ {
+ if ((childattr = ippFindNextAttribute(ipp->current->values[ipp->curindex].collection, child, type)) != NULL)
+ return (childattr);
+
+ ipp->curindex ++;
+ if (ipp->curindex < ipp->current->num_values && ipp->current->values[ipp->curindex].collection)
+ ipp->current->values[ipp->curindex].collection->current = NULL;
+ }
+
+ ipp->prev = ipp->current;
+ ipp->current = ipp->current->next;
+ ipp->curindex = 0;
+
+ if (!ipp->current)
+ {
+ ipp->atend = 1;
+ return (NULL);
+ }
+ }
+
+ if (!ipp->current)
+ {
+ ipp->prev = NULL;
+ ipp->current = ipp->attrs;
+ ipp->curindex = 0;
+ }
+
+ name = parent;
+ attr = ipp->current;
+ }
+ else if (ipp->current)
{
ipp->prev = ipp->current;
attr = ipp->current->next;
for (; attr != NULL; ipp->prev = attr, attr = attr->next)
{
- DEBUG_printf(("4ippFindAttribute: attr=%p, name=\"%s\"", attr,
- attr->name));
+ DEBUG_printf(("4ippFindAttribute: attr=%p, name=\"%s\"", (void *)attr, attr->name));
value_tag = (ipp_tag_t)(attr->value_tag & IPP_TAG_CUPS_MASK);
if (attr->name != NULL && _cups_strcasecmp(attr->name, name) == 0 &&
- (value_tag == type || type == IPP_TAG_ZERO ||
+ (value_tag == type || type == IPP_TAG_ZERO || name == parent ||
(value_tag == IPP_TAG_TEXTLANG && type == IPP_TAG_TEXT) ||
(value_tag == IPP_TAG_NAMELANG && type == IPP_TAG_NAME)))
{
ipp->current = attr;
- return (attr);
+ if (name == parent && attr->value_tag == IPP_TAG_BEGIN_COLLECTION)
+ {
+ int i; /* Looping var */
+
+ for (i = 0; i < attr->num_values; i ++)
+ {
+ if ((childattr = ippFindAttribute(attr->values[i].collection, child, type)) != NULL)
+ {
+ attr->values[0].collection->curindex = i;
+ return (childattr);
+ }
+ }
+ }
+ else
+ return (attr);
}
}
ipp->current = NULL;
ipp->prev = NULL;
+ ipp->atend = 1;
return (NULL);
}
* @since CUPS 1.6/OS X 10.8@
*/
-int /* O - Boolean value or -1 on error */
+int /* O - Boolean value or 0 on error */
ippGetBoolean(ipp_attribute_t *attr, /* I - IPP attribute */
int element) /* I - Value number (0-based) */
{
if (!attr || attr->value_tag != IPP_TAG_BOOLEAN ||
element < 0 || element >= attr->num_values)
- return (-1);
+ return (0);
/*
* Return the value...
* @since CUPS 1.6/OS X 10.8@
*/
-int /* O - Number of values or -1 on error */
+int /* O - Number of values or 0 on error */
ippGetCount(ipp_attribute_t *attr) /* I - IPP attribute */
{
/*
*/
if (!attr)
- return (-1);
+ return (0);
/*
* Return the number of values...
* @since CUPS 1.6/OS X 10.8@
*/
-int /* O - Value or -1 on error */
+int /* O - Value or 0 on error */
ippGetInteger(ipp_attribute_t *attr, /* I - IPP attribute */
int element) /* I - Value number (0-based) */
{
if (!attr || (attr->value_tag != IPP_TAG_INTEGER && attr->value_tag != IPP_TAG_ENUM) ||
element < 0 || element >= attr->num_values)
- return (-1);
+ return (0);
/*
* Return the value...
* @since CUPS 1.6/OS X 10.8@
*/
-ipp_op_t /* O - Operation ID or -1 on error */
+ipp_op_t /* O - Operation ID or 0 on error */
ippGetOperation(ipp_t *ipp) /* I - IPP request message */
{
/*
*/
if (!ipp)
- return ((ipp_op_t)-1);
+ return ((ipp_op_t)0);
/*
* Return the value...
* @since CUPS 1.6/OS X 10.8@
*/
-int /* O - Lower value of range or -1 */
+int /* O - Lower value of range or 0 */
ippGetRange(ipp_attribute_t *attr, /* I - IPP attribute */
int element, /* I - Value number (0-based) */
int *uppervalue)/* O - Upper value of range */
element < 0 || element >= attr->num_values)
{
if (uppervalue)
- *uppervalue = -1;
+ *uppervalue = 0;
- return (-1);
+ return (0);
}
/*
* @since CUPS 1.6/OS X 10.8@
*/
-int /* O - Request ID or -1 on error */
+int /* O - Request ID or 0 on error */
ippGetRequestId(ipp_t *ipp) /* I - IPP message */
{
/*
*/
if (!ipp)
- return (-1);
+ return (0);
/*
* Return the request ID...
* @since CUPS 1.6/OS X 10.8@
*/
-int /* O - Horizontal/cross feed resolution or -1 */
+int /* O - Horizontal/cross feed resolution or 0 */
ippGetResolution(
ipp_attribute_t *attr, /* I - IPP attribute */
int element, /* I - Value number (0-based) */
if (!attr || attr->value_tag != IPP_TAG_RESOLUTION ||
element < 0 || element >= attr->num_values)
- return (-1);
+ {
+ if (yres)
+ *yres = 0;
+
+ if (units)
+ *units = (ipp_res_t)0;
+
+ return (0);
+ }
/*
* Return the value...
* @since CUPS 1.6/OS X 10.8@
*/
-int /* O - Major version number or -1 on error */
+int /* O - Major version number or 0 on error */
ippGetVersion(ipp_t *ipp, /* I - IPP message */
int *minor) /* O - Minor version number or @code NULL@ */
{
if (!ipp)
{
if (minor)
- *minor = -1;
+ *minor = 0;
- return (-1);
+ return (0);
}
/*
* Set default version - usually 2.0...
*/
- temp->request.any.version[0] = cg->server_version / 10;
- temp->request.any.version[1] = cg->server_version % 10;
+ if (cg->server_version == 0)
+ _cupsSetDefaults();
+
+ temp->request.any.version[0] = (ipp_uchar_t)(cg->server_version / 10);
+ temp->request.any.version[1] = (ipp_uchar_t)(cg->server_version % 10);
temp->use = 1;
}
- DEBUG_printf(("1ippNew: Returning %p", temp));
+ DEBUG_printf(("1ippNew: Returning %p", (void *)temp));
return (temp);
}
ippRead(http_t *http, /* I - HTTP connection */
ipp_t *ipp) /* I - IPP data */
{
- DEBUG_printf(("ippRead(http=%p, ipp=%p), data_remaining=" CUPS_LLFMT,
- http, ipp, CUPS_LLCAST (http ? http->data_remaining : -1)));
+ DEBUG_printf(("ippRead(http=%p, ipp=%p), data_remaining=" CUPS_LLFMT, (void *)http, (void *)ipp, CUPS_LLCAST (http ? http->data_remaining : -1)));
if (!http)
return (IPP_STATE_ERROR);
- DEBUG_printf(("2ippRead: http->state=%d, http->used=%d", http->state,
- http->used));
+ DEBUG_printf(("2ippRead: http->state=%d, http->used=%d", http->state, http->used));
return (ippReadIO(http, (ipp_iocb_t)ipp_read_http, http->blocking, NULL,
ipp));
ippReadFile(int fd, /* I - HTTP data */
ipp_t *ipp) /* I - IPP data */
{
- DEBUG_printf(("ippReadFile(fd=%d, ipp=%p)", fd, ipp));
+ DEBUG_printf(("ippReadFile(fd=%d, ipp=%p)", fd, (void *)ipp));
return (ippReadIO(&fd, (ipp_iocb_t)ipp_read_file, 1, NULL, ipp));
}
_ipp_value_t *value; /* Current value */
- DEBUG_printf(("ippReadIO(src=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)",
- src, cb, blocking, parent, ipp));
+ DEBUG_printf(("ippReadIO(src=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", (void *)src, (void *)cb, blocking, (void *)parent, (void *)ipp));
DEBUG_printf(("2ippReadIO: ipp->state=%d", ipp ? ipp->state : IPP_STATE_ERROR));
if (!src || !ipp)
return (IPP_STATE_ERROR);
}
- DEBUG_printf(("2ippReadIO: ipp->current=%p, ipp->prev=%p",
- ipp->current, ipp->prev));
+ DEBUG_printf(("2ippReadIO: ipp->current=%p, ipp->prev=%p", (void *)ipp->current, (void *)ipp->prev));
/*
* Read this attribute...
ipp->curtag = tag;
ipp->current = NULL;
- DEBUG_printf(("2ippReadIO: group tag=%x(%s), ipp->prev=%p", tag,
- ippTagString(tag), ipp->prev));
+ DEBUG_printf(("2ippReadIO: group tag=%x(%s), ipp->prev=%p", tag, ippTagString(tag), (void *)ipp->prev));
continue;
}
return (IPP_STATE_ERROR);
}
- DEBUG_printf(("2ippReadIO: membername, ipp->current=%p, ipp->prev=%p",
- ipp->current, ipp->prev));
+ DEBUG_printf(("2ippReadIO: membername, ipp->current=%p, ipp->prev=%p", (void *)ipp->current, (void *)ipp->prev));
value = attr->values;
}
* New attribute; read the name and add it...
*/
- if ((*cb)(src, buffer, n) < n)
+ if ((*cb)(src, buffer, (size_t)n) < n)
{
DEBUG_puts("1ippReadIO: unable to read name.");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
- DEBUG_printf(("2ippReadIO: name=\"%s\", ipp->current=%p, "
- "ipp->prev=%p", buffer, ipp->current, ipp->prev));
+ DEBUG_printf(("2ippReadIO: name=\"%s\", ipp->current=%p, ipp->prev=%p", buffer, (void *)ipp->current, (void *)ipp->prev));
value = attr->values;
}
return (IPP_STATE_ERROR);
}
- value->boolean = buffer[0];
+ value->boolean = (char)buffer[0];
break;
case IPP_TAG_NOVALUE :
case IPP_TAG_MIMETYPE :
if (n > 0)
{
- if ((*cb)(src, buffer, n) < n)
+ if ((*cb)(src, buffer, (size_t)n) < n)
{
DEBUG_puts("1ippReadIO: unable to read string value.");
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
- if ((*cb)(src, buffer, n) < n)
+ if ((*cb)(src, buffer, (size_t)n) < n)
{
DEBUG_puts("1ippReadIO: Unable to read string w/language "
"value.");
n = (bufptr[0] << 8) | bufptr[1];
- if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE) ||
- n >= sizeof(string))
+ if ((bufptr + 2 + n) >= (buffer + IPP_BUF_SIZE) || n >= (int)sizeof(string))
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL,
_("IPP language length overflows value."), 1);
return (IPP_STATE_ERROR);
}
- memcpy(string, bufptr + 2, n);
+ memcpy(string, bufptr + 2, (size_t)n);
string[n] = '\0';
value->string.language = _cupsStrAlloc((char *)string);
_cupsBufferRelease((char *)buffer);
return (IPP_STATE_ERROR);
}
- else if ((*cb)(src, buffer, n) < n)
+ else if ((*cb)(src, buffer, (size_t)n) < n)
{
DEBUG_puts("1ippReadIO: Unable to read member name value.");
_cupsBufferRelease((char *)buffer);
if (n > 0)
{
- if ((value->unknown.data = malloc(n)) == NULL)
+ if ((value->unknown.data = malloc((size_t)n)) == NULL)
{
_cupsSetHTTPError(HTTP_STATUS_ERROR);
DEBUG_puts("1ippReadIO: Unable to allocate value");
return (IPP_STATE_ERROR);
}
- if ((*cb)(src, value->unknown.data, n) < n)
+ if ((*cb)(src, value->unknown.data, (size_t)n) < n)
{
DEBUG_puts("1ippReadIO: Unable to read unsupported value.");
_cupsBufferRelease((char *)buffer);
*/
if ((value = ipp_set_value(ipp, attr, element)) != NULL)
- value->boolean = boolvalue;
+ value->boolean = (char)boolvalue;
return (value != NULL);
}
{
void *temp; /* Temporary data pointer */
- if ((temp = malloc(datalen)) != NULL)
+ if ((temp = malloc((size_t)datalen)) != NULL)
{
- memcpy(temp, data, datalen);
+ memcpy(temp, data, (size_t)datalen);
value->unknown.data = temp;
value->unknown.length = datalen;
if (!s)
s = "(null)";
- bytes = strlen(s);
+ bytes = (ssize_t)strlen(s);
strlcpy(buffer, s, sizeof(buffer));
}
else
* Set the version number...
*/
- ipp->request.any.version[0] = major;
- ipp->request.any.version[1] = minor;
+ ipp->request.any.version[0] = (ipp_uchar_t)major;
+ ipp->request.any.version[1] = (ipp_uchar_t)minor;
return (1);
}
unixdate = gmtime(&t);
unixdate->tm_year += 1900;
- date[0] = unixdate->tm_year >> 8;
- date[1] = unixdate->tm_year;
- date[2] = unixdate->tm_mon + 1;
- date[3] = unixdate->tm_mday;
- date[4] = unixdate->tm_hour;
- date[5] = unixdate->tm_min;
- date[6] = unixdate->tm_sec;
+ date[0] = (ipp_uchar_t)(unixdate->tm_year >> 8);
+ date[1] = (ipp_uchar_t)(unixdate->tm_year);
+ date[2] = (ipp_uchar_t)(unixdate->tm_mon + 1);
+ date[3] = (ipp_uchar_t)unixdate->tm_mday;
+ date[4] = (ipp_uchar_t)unixdate->tm_hour;
+ date[5] = (ipp_uchar_t)unixdate->tm_min;
+ date[6] = (ipp_uchar_t)unixdate->tm_sec;
date[7] = 0;
date[8] = '+';
date[9] = 0;
ippWrite(http_t *http, /* I - HTTP connection */
ipp_t *ipp) /* I - IPP data */
{
- DEBUG_printf(("ippWrite(http=%p, ipp=%p)", http, ipp));
+ DEBUG_printf(("ippWrite(http=%p, ipp=%p)", (void *)http, (void *)ipp));
if (!http)
return (IPP_STATE_ERROR);
ippWriteFile(int fd, /* I - HTTP data */
ipp_t *ipp) /* I - IPP data */
{
- DEBUG_printf(("ippWriteFile(fd=%d, ipp=%p)", fd, ipp));
+ DEBUG_printf(("ippWriteFile(fd=%d, ipp=%p)", fd, (void *)ipp));
ipp->state = IPP_STATE_IDLE;
_ipp_value_t *value; /* Current value */
- DEBUG_printf(("ippWriteIO(dst=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)",
- dst, cb, blocking, parent, ipp));
+ DEBUG_printf(("ippWriteIO(dst=%p, cb=%p, blocking=%d, parent=%p, ipp=%p)", (void *)dst, (void *)cb, blocking, (void *)parent, (void *)ipp));
if (!dst || !ipp)
return (IPP_STATE_ERROR);
*bufptr++ = ipp->request.any.version[0];
*bufptr++ = ipp->request.any.version[1];
- *bufptr++ = ipp->request.any.op_status >> 8;
- *bufptr++ = ipp->request.any.op_status;
- *bufptr++ = ipp->request.any.request_id >> 24;
- *bufptr++ = ipp->request.any.request_id >> 16;
- *bufptr++ = ipp->request.any.request_id >> 8;
- *bufptr++ = ipp->request.any.request_id;
+ *bufptr++ = (ipp_uchar_t)(ipp->request.any.op_status >> 8);
+ *bufptr++ = (ipp_uchar_t)ipp->request.any.op_status;
+ *bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 24);
+ *bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 16);
+ *bufptr++ = (ipp_uchar_t)(ipp->request.any.request_id >> 8);
+ *bufptr++ = (ipp_uchar_t)ipp->request.any.request_id;
DEBUG_printf(("2ippWriteIO: version=%d.%d", buffer[0], buffer[1]));
DEBUG_printf(("2ippWriteIO: op_status=%04x",
DEBUG_printf(("2ippWriteIO: request_id=%d",
ipp->request.any.request_id));
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP header...");
_cupsBufferRelease((char *)buffer);
ipp->current = ipp->attrs;
ipp->curtag = IPP_TAG_ZERO;
- DEBUG_printf(("1ippWriteIO: ipp->current=%p", ipp->current));
+ DEBUG_printf(("1ippWriteIO: ipp->current=%p", (void *)ipp->current));
/*
* If blocking is disabled, stop here...
DEBUG_printf(("2ippWriteIO: wrote group tag=%x(%s)",
attr->group_tag, ippTagString(attr->group_tag)));
- *bufptr++ = attr->group_tag;
+ *bufptr++ = (ipp_uchar_t)attr->group_tag;
}
else if (attr->group_tag == IPP_TAG_ZERO)
continue;
if (attr->value_tag > 0xff)
{
*bufptr++ = IPP_TAG_EXTENSION;
- *bufptr++ = attr->value_tag >> 24;
- *bufptr++ = attr->value_tag >> 16;
- *bufptr++ = attr->value_tag >> 8;
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 24);
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 16);
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 8);
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
}
else
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
- *bufptr++ = n >> 8;
- *bufptr++ = n;
- memcpy(bufptr, attr->name, n);
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
+ memcpy(bufptr, attr->name, (size_t)n);
bufptr += n;
}
else
*bufptr++ = IPP_TAG_MEMBERNAME;
*bufptr++ = 0;
*bufptr++ = 0;
- *bufptr++ = n >> 8;
- *bufptr++ = n;
- memcpy(bufptr, attr->name, n);
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
+ memcpy(bufptr, attr->name, (size_t)n);
bufptr += n;
if (attr->value_tag > 0xff)
{
*bufptr++ = IPP_TAG_EXTENSION;
- *bufptr++ = attr->value_tag >> 24;
- *bufptr++ = attr->value_tag >> 16;
- *bufptr++ = attr->value_tag >> 8;
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 24);
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 16);
+ *bufptr++ = (ipp_uchar_t)(attr->value_tag >> 8);
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
}
else
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 9)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
*bufptr++ = 0;
*bufptr++ = 4;
- *bufptr++ = value->integer >> 24;
- *bufptr++ = value->integer >> 16;
- *bufptr++ = value->integer >> 8;
- *bufptr++ = value->integer;
+ *bufptr++ = (ipp_uchar_t)(value->integer >> 24);
+ *bufptr++ = (ipp_uchar_t)(value->integer >> 16);
+ *bufptr++ = (ipp_uchar_t)(value->integer >> 8);
+ *bufptr++ = (ipp_uchar_t)value->integer;
}
break;
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 6)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
*bufptr++ = 0;
*bufptr++ = 1;
- *bufptr++ = value->boolean;
+ *bufptr++ = (ipp_uchar_t)value->boolean;
}
break;
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
bufptr = buffer;
}
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* Put the 2-byte length and string characters in the buffer.
*/
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
if (n > 0)
{
- memcpy(bufptr, value->string.text, n);
+ memcpy(bufptr, value->string.text, (size_t)n);
bufptr += n;
}
}
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 16)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 14)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
*bufptr++ = 0;
*bufptr++ = 9;
- *bufptr++ = value->resolution.xres >> 24;
- *bufptr++ = value->resolution.xres >> 16;
- *bufptr++ = value->resolution.xres >> 8;
- *bufptr++ = value->resolution.xres;
- *bufptr++ = value->resolution.yres >> 24;
- *bufptr++ = value->resolution.yres >> 16;
- *bufptr++ = value->resolution.yres >> 8;
- *bufptr++ = value->resolution.yres;
- *bufptr++ = value->resolution.units;
+ *bufptr++ = (ipp_uchar_t)(value->resolution.xres >> 24);
+ *bufptr++ = (ipp_uchar_t)(value->resolution.xres >> 16);
+ *bufptr++ = (ipp_uchar_t)(value->resolution.xres >> 8);
+ *bufptr++ = (ipp_uchar_t)value->resolution.xres;
+ *bufptr++ = (ipp_uchar_t)(value->resolution.yres >> 24);
+ *bufptr++ = (ipp_uchar_t)(value->resolution.yres >> 16);
+ *bufptr++ = (ipp_uchar_t)(value->resolution.yres >> 8);
+ *bufptr++ = (ipp_uchar_t)value->resolution.yres;
+ *bufptr++ = (ipp_uchar_t)value->resolution.units;
}
break;
{
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 13)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
*bufptr++ = 0;
*bufptr++ = 8;
- *bufptr++ = value->range.lower >> 24;
- *bufptr++ = value->range.lower >> 16;
- *bufptr++ = value->range.lower >> 8;
- *bufptr++ = value->range.lower;
- *bufptr++ = value->range.upper >> 24;
- *bufptr++ = value->range.upper >> 16;
- *bufptr++ = value->range.upper >> 8;
- *bufptr++ = value->range.upper;
+ *bufptr++ = (ipp_uchar_t)(value->range.lower >> 24);
+ *bufptr++ = (ipp_uchar_t)(value->range.lower >> 16);
+ *bufptr++ = (ipp_uchar_t)(value->range.lower >> 8);
+ *bufptr++ = (ipp_uchar_t)value->range.lower;
+ *bufptr++ = (ipp_uchar_t)(value->range.upper >> 24);
+ *bufptr++ = (ipp_uchar_t)(value->range.upper >> 16);
+ *bufptr++ = (ipp_uchar_t)(value->range.upper >> 8);
+ *bufptr++ = (ipp_uchar_t)value->range.upper;
}
break;
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
bufptr = buffer;
}
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
}
/* Length of entire value */
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
/* Length of language */
if (value->string.language != NULL)
else
n = 0;
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
/* Language */
if (n > 0)
{
- memcpy(bufptr, value->string.language, n);
+ memcpy(bufptr, value->string.language, (size_t)n);
bufptr += n;
}
else
n = 0;
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
/* Text */
if (n > 0)
{
- memcpy(bufptr, value->string.text, n);
+ memcpy(bufptr, value->string.text, (size_t)n);
bufptr += n;
}
}
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 5)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
* values with a zero-length name...
*/
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
*bufptr++ = 0;
*bufptr++ = 0;
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
if ((IPP_BUF_SIZE - (bufptr - buffer)) < 3)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
bufptr = buffer;
}
- *bufptr++ = attr->value_tag;
+ *bufptr++ = (ipp_uchar_t)attr->value_tag;
*bufptr++ = 0;
*bufptr++ = 0;
}
if ((int)(IPP_BUF_SIZE - (bufptr - buffer)) < (n + 2))
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP "
"attribute...");
}
/* Length of unknown value */
- *bufptr++ = n >> 8;
- *bufptr++ = n;
+ *bufptr++ = (ipp_uchar_t)(n >> 8);
+ *bufptr++ = (ipp_uchar_t)n;
/* Value */
if (n > 0)
{
- memcpy(bufptr, value->unknown.data, n);
+ memcpy(bufptr, value->unknown.data, (size_t)n);
bufptr += n;
}
}
if (bufptr > buffer)
{
- if ((*cb)(dst, buffer, (int)(bufptr - buffer)) < 0)
+ if ((*cb)(dst, buffer, (size_t)(bufptr - buffer)) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP attribute...");
_cupsBufferRelease((char *)buffer);
n = 5;
}
- if ((*cb)(dst, buffer, n) < 0)
+ if ((*cb)(dst, buffer, (size_t)n) < 0)
{
DEBUG_puts("1ippWriteIO: Could not write IPP end-tag...");
_cupsBufferRelease((char *)buffer);
ipp_attribute_t *attr; /* New attribute */
- DEBUG_printf(("4ipp_add_attr(ipp=%p, name=\"%s\", group_tag=0x%x, value_tag=0x%x, "
- "num_values=%d)", ipp, name, group_tag, value_tag, num_values));
+ DEBUG_printf(("4ipp_add_attr(ipp=%p, name=\"%s\", group_tag=0x%x, value_tag=0x%x, num_values=%d)", (void *)ipp, name, group_tag, value_tag, num_values));
/*
* Range check input...
alloc_values = (num_values + IPP_MAX_VALUES - 1) & ~(IPP_MAX_VALUES - 1);
attr = calloc(sizeof(ipp_attribute_t) +
- (alloc_values - 1) * sizeof(_ipp_value_t), 1);
+ (size_t)(alloc_values - 1) * sizeof(_ipp_value_t), 1);
if (attr)
{
ipp->last = ipp->current = attr;
}
- DEBUG_printf(("5ipp_add_attr: Returning %p", attr));
+ DEBUG_printf(("5ipp_add_attr: Returning %p", (void *)attr));
return (attr);
}
_ipp_value_t *value; /* Current value */
- DEBUG_printf(("4ipp_free_values(attr=%p, element=%d, count=%d)", attr,
- element, count));
+ DEBUG_printf(("4ipp_free_values(attr=%p, element=%d, count=%d)", (void *)attr, element, count));
if (!(attr->value_tag & IPP_TAG_CUPS_CONST))
{
if ((element + count) < attr->num_values)
memmove(attr->values + element, attr->values + element + count,
- (attr->num_values - count - element) * sizeof(_ipp_value_t));
+ (size_t)(attr->num_values - count - element) * sizeof(_ipp_value_t));
attr->num_values -= count;
}
if (*value == '_')
*bufptr++ = '-';
else
- *bufptr++ = _cups_tolower(*value);
+ *bufptr++ = (char)_cups_tolower(*value);
*bufptr = '\0';
_ipp_value_t *value; /* Current value */
- DEBUG_printf(("3ipp_length(ipp=%p, collection=%d)", ipp, collection));
+ DEBUG_printf(("3ipp_length(ipp=%p, collection=%d)", (void *)ipp, collection));
if (!ipp)
{
DEBUG_printf(("5ipp_length: attr->name=\"%s\", attr->num_values=%d, "
"bytes=" CUPS_LLFMT, attr->name, attr->num_values, CUPS_LLCAST bytes));
- if (attr->value_tag < IPP_TAG_EXTENSION)
- bytes += attr->num_values; /* Value tag for each value */
+ if ((attr->value_tag & ~IPP_TAG_CUPS_CONST) < IPP_TAG_EXTENSION)
+ bytes += (size_t)attr->num_values;/* Value tag for each value */
else
- bytes += 5 * attr->num_values; /* Value tag for each value */
- bytes += 2 * attr->num_values; /* Name lengths */
- bytes += (int)strlen(attr->name); /* Name */
- bytes += 2 * attr->num_values; /* Value lengths */
+ bytes += (size_t)(5 * attr->num_values);
+ /* Value tag for each value */
+ bytes += (size_t)(2 * attr->num_values);
+ /* Name lengths */
+ bytes += strlen(attr->name); /* Name */
+ bytes += (size_t)(2 * attr->num_values);
+ /* Value lengths */
if (collection)
bytes += 5; /* Add membername overhead */
case IPP_TAG_INTEGER :
case IPP_TAG_ENUM :
- bytes += 4 * attr->num_values;
+ bytes += (size_t)(4 * attr->num_values);
break;
case IPP_TAG_BOOLEAN :
- bytes += attr->num_values;
+ bytes += (size_t)attr->num_values;
break;
case IPP_TAG_TEXT :
break;
case IPP_TAG_DATE :
- bytes += 11 * attr->num_values;
+ bytes += (size_t)(11 * attr->num_values);
break;
case IPP_TAG_RESOLUTION :
- bytes += 9 * attr->num_values;
+ bytes += (size_t)(9 * attr->num_values);
break;
case IPP_TAG_RANGE :
- bytes += 8 * attr->num_values;
+ bytes += (size_t)(8 * attr->num_values);
break;
case IPP_TAG_TEXTLANG :
case IPP_TAG_NAMELANG :
- bytes += 4 * attr->num_values;/* Charset + text length */
+ bytes += (size_t)(4 * attr->num_values);
+ /* Charset + text length */
for (i = 0, value = attr->values;
i < attr->num_values;
for (i = 0, value = attr->values;
i < attr->num_values;
i ++, value ++)
- bytes += value->unknown.length;
+ bytes += (size_t)value->unknown.length;
break;
}
}
ipp_uchar_t *buffer, /* O - Buffer for data */
size_t length) /* I - Total length */
{
- int tbytes, /* Total bytes read */
- bytes; /* Bytes read this pass */
+ ssize_t tbytes, /* Total bytes read */
+ bytes; /* Bytes read this pass */
- DEBUG_printf(("7ipp_read_http(http=%p, buffer=%p, length=%d)",
- http, buffer, (int)length));
+ DEBUG_printf(("7ipp_read_http(http=%p, buffer=%p, length=%d)", (void *)http, (void *)buffer, (int)length));
/*
* Loop until all bytes are read...
tbytes < (int)length;
tbytes += bytes, buffer += bytes)
{
- DEBUG_printf(("9ipp_read_http: tbytes=%d, http->state=%d", tbytes,
- http->state));
+ DEBUG_printf(("9ipp_read_http: tbytes=" CUPS_LLFMT ", http->state=%d", CUPS_LLCAST tbytes, http->state));
if (http->state == HTTP_STATE_WAITING)
break;
break;
}
}
+ else if (http->used == 0 && http->timeout_value > 0)
+ {
+ /*
+ * Wait up to timeout seconds for more data on blocking sockets...
+ */
- if ((bytes = httpRead2(http, (char *)buffer, length - tbytes)) < 0)
+ if (!httpWait(http, (int)(1000 * http->timeout_value)))
+ {
+ /*
+ * Signal no data...
+ */
+
+ bytes = -1;
+ break;
+ }
+ }
+
+ if ((bytes = httpRead2(http, (char *)buffer, length - (size_t)tbytes)) < 0)
{
#ifdef WIN32
break;
if (tbytes == 0 && bytes < 0)
tbytes = -1;
- DEBUG_printf(("8ipp_read_http: Returning %d bytes", tbytes));
+ DEBUG_printf(("8ipp_read_http: Returning " CUPS_LLFMT " bytes", CUPS_LLCAST tbytes));
return (tbytes);
}
* Reallocate memory...
*/
- if ((temp = realloc(temp, sizeof(ipp_attribute_t) +
- (alloc_values - 1) * sizeof(_ipp_value_t))) == NULL)
+ if ((temp = realloc(temp, sizeof(ipp_attribute_t) + (size_t)(alloc_values - 1) * sizeof(_ipp_value_t))) == NULL)
{
_cupsSetHTTPError(HTTP_STATUS_ERROR);
DEBUG_puts("4ipp_set_value: Unable to resize attribute.");
* Zero the new memory...
*/
- memset(temp->values + temp->num_values, 0,
- (alloc_values - temp->num_values) * sizeof(_ipp_value_t));
+ memset(temp->values + temp->num_values, 0, (size_t)(alloc_values - temp->num_values) * sizeof(_ipp_value_t));
if (temp != *attr)
{
return (write(*fd, buffer, length));
#endif /* WIN32 */
}
-
-
-/*
- * End of "$Id$".
- */