/*
- * "$Id: ipp.c 10102 2011-11-02 23:52:39Z mike $"
+ * "$Id$"
*
* Internet Printing Protocol functions for CUPS.
*
* 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.
* 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.
* needed. The formatted string is truncated as needed to the maximum length of
* the corresponding value type.
*
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
*/
ipp_attribute_t * /* O - New attribute */
* stdarg pointer @code ap@. The formatted string is truncated as needed to the
* maximum length of the corresponding value type.
*
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
*/
ipp_attribute_t * /* O - New attribute */
group == IPP_TAG_END || group >= IPP_TAG_UNSUPPORTED_VALUE ||
(value_tag < IPP_TAG_TEXT && value_tag != IPP_TAG_TEXTLANG &&
value_tag != IPP_TAG_NAMELANG) || value_tag > IPP_TAG_MIMETYPE ||
- !format || !ap)
+ !format)
return (NULL);
if ((value_tag == IPP_TAG_TEXTLANG || value_tag == IPP_TAG_NAMELANG)
* enum value, or the value falls within one of the rangeOfInteger values for
* the attribute.
*
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
*/
int /* O - 1 on a match, 0 on no match */
* Returns non-zero when the attribute contains a matching charset, keyword,
* language, mimeMediaType, name, text, URI, or URI scheme value.
*
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
*/
int /* O - 1 on a match, 0 on no match */
}
+/*
+ * 'ippGetOctetString()' - Get an octetString value from an IPP attribute.
+ *
+ * The @code element@ parameter specifies which value to get from 0 to
+ * @link ippGetCount(attr)@ - 1.
+ *
+ * @since CUPS 1.7/OS X 10.9@
+ */
+
+void * /* O - Pointer to octetString data */
+ippGetOctetString(
+ ipp_attribute_t *attr, /* I - IPP attribute */
+ int element, /* I - Value number (0-based) */
+ int *datalen) /* O - Length of octetString data */
+{
+ /*
+ * Range check input...
+ */
+
+ if (!attr || attr->value_tag != IPP_TAG_STRING ||
+ element < 0 || element >= attr->num_values)
+ {
+ if (datalen)
+ *datalen = 0;
+
+ return (NULL);
+ }
+
+ /*
+ * Return the values...
+ */
+
+ if (datalen)
+ *datalen = attr->values[element].unknown.length;
+
+ return (attr->values[element].unknown.data);
+}
+
+
/*
* 'ippGetOperation()' - Get the operation ID in an IPP message.
*
* Set default version - usually 2.0...
*/
+ if (cg->server_version == 0)
+ _cupsSetDefaults();
+
temp->request.any.version[0] = cg->server_version / 10;
temp->request.any.version[1] = cg->server_version % 10;
temp->use = 1;
* "utf-8" and a value derived from the current locale are substituted,
* respectively.
*
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
*/
ipp_t * /* O - IPP response message */
*/
int /* O - 1 on success, 0 on failure */
-ippSetBoolean(ipp_t *ipp, /* IO - IPP message */
+ippSetBoolean(ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - IPP attribute */
int element, /* I - Value number (0-based) */
int boolvalue)/* I - Boolean value */
int /* O - 1 on success, 0 on failure */
ippSetCollection(
- ipp_t *ipp, /* IO - IPP message */
+ ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - IPP attribute */
int element, /* I - Value number (0-based) */
ipp_t *colvalue) /* I - Collection value */
*/
int /* O - 1 on success, 0 on failure */
-ippSetDate(ipp_t *ipp, /* IO - IPP message */
+ippSetDate(ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - IPP attribute */
int element, /* I - Value number (0-based) */
const ipp_uchar_t *datevalue)/* I - Date value */
int /* O - 1 on success, 0 on failure */
ippSetGroupTag(
- ipp_t *ipp, /* IO - IPP message */
+ ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - Attribute */
ipp_tag_t group_tag) /* I - Group tag */
{
*/
int /* O - 1 on success, 0 on failure */
-ippSetInteger(ipp_t *ipp, /* IO - IPP message */
+ippSetInteger(ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - IPP attribute */
int element, /* I - Value number (0-based) */
int intvalue) /* I - Integer/enum value */
*/
int /* O - 1 on success, 0 on failure */
-ippSetName(ipp_t *ipp, /* IO - IPP message */
+ippSetName(ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - IPP attribute */
const char *name) /* I - Attribute name */
{
}
+/*
+ * 'ippSetOctetString()' - Set an octetString value in an IPP attribute.
+ *
+ * The @code ipp@ parameter refers to an IPP message previously created using
+ * the @link ippNew@, @link ippNewRequest@, or @link ippNewResponse@ functions.
+ *
+ * The @code attr@ parameter may be modified as a result of setting the value.
+ *
+ * The @code element@ parameter specifies which value to set from 0 to
+ * @link ippGetCount(attr)@.
+ *
+ * @since CUPS 1.7/OS X 10.9@
+ */
+
+int /* O - 1 on success, 0 on failure */
+ippSetOctetString(
+ ipp_t *ipp, /* I - IPP message */
+ ipp_attribute_t **attr, /* IO - IPP attribute */
+ int element, /* I - Value number (0-based) */
+ const void *data, /* I - Pointer to octetString data */
+ int datalen) /* I - Length of octetString data */
+{
+ _ipp_value_t *value; /* Current value */
+
+
+ /*
+ * Range check input...
+ */
+
+ if (!ipp || !attr || !*attr || (*attr)->value_tag != IPP_TAG_STRING ||
+ element < 0 || element > (*attr)->num_values ||
+ datalen < 0 || datalen > IPP_MAX_LENGTH)
+ return (0);
+
+ /*
+ * Set the value and return...
+ */
+
+ if ((value = ipp_set_value(ipp, attr, element)) != NULL)
+ {
+ if ((int)((*attr)->value_tag) & IPP_TAG_CUPS_CONST)
+ {
+ /*
+ * Just copy the pointer...
+ */
+
+ value->unknown.data = (void *)data;
+ value->unknown.length = datalen;
+ }
+ else
+ {
+ /*
+ * Copy the data...
+ */
+
+ if (value->unknown.data)
+ {
+ /*
+ * Free previous data...
+ */
+
+ free(value->unknown.data);
+
+ value->unknown.data = NULL;
+ value->unknown.length = 0;
+ }
+
+ if (datalen > 0)
+ {
+ void *temp; /* Temporary data pointer */
+
+ if ((temp = malloc(datalen)) != NULL)
+ {
+ memcpy(temp, data, datalen);
+
+ value->unknown.data = temp;
+ value->unknown.length = datalen;
+ }
+ else
+ return (0);
+ }
+ }
+ }
+
+ return (value != NULL);
+}
+
+
/*
* 'ippSetOperation()' - Set the operation ID in an IPP request message.
*
*/
int /* O - 1 on success, 0 on failure */
-ippSetRange(ipp_t *ipp, /* IO - IPP message */
+ippSetRange(ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - IPP attribute */
int element, /* I - Value number (0-based) */
int lowervalue, /* I - Lower bound for range */
int /* O - 1 on success, 0 on failure */
ippSetResolution(
- ipp_t *ipp, /* IO - IPP message */
+ ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - IPP attribute */
int element, /* I - Value number (0-based) */
ipp_res_t unitsvalue, /* I - Resolution units */
*/
int /* O - 1 on success, 0 on failure */
-ippSetString(ipp_t *ipp, /* IO - IPP message */
+ippSetString(ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - IPP attribute */
int element, /* I - Value number (0-based) */
const char *strvalue) /* I - String value */
* needed. The formatted string is truncated as needed to the maximum length of
* the corresponding value type.
*
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
*/
int /* O - 1 on success, 0 on failure */
-ippSetStringf(ipp_t *ipp, /* IO - IPP message */
+ippSetStringf(ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - IPP attribute */
int element, /* I - Value number (0-based) */
const char *format, /* I - Printf-style format string */
* needed. The formatted string is truncated as needed to the maximum length of
* the corresponding value type.
*
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
*/
int /* O - 1 on success, 0 on failure */
-ippSetStringfv(ipp_t *ipp, /* IO - IPP message */
+ippSetStringfv(ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - IPP attribute */
int element, /* I - Value number (0-based) */
const char *format, /* I - Printf-style format string */
if (!ipp || !attr || !*attr ||
(value_tag < IPP_TAG_TEXT && value_tag != IPP_TAG_TEXTLANG &&
value_tag != IPP_TAG_NAMELANG) || value_tag > IPP_TAG_MIMETYPE ||
- !format || !ap)
+ !format)
return (0);
/*
int /* O - 1 on success, 0 on failure */
ippSetValueTag(
- ipp_t *ipp, /* IO - IPP message */
+ ipp_t *ipp, /* I - IPP message */
ipp_attribute_t **attr, /* IO - IPP attribute */
ipp_tag_t value_tag) /* I - Value tag */
{
* value tag. 1 is returned if the attribute is valid, 0 otherwise. On
* failure, cupsLastErrorString() is set to a human-readable message.
*
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
*/
int /* O - 1 if valid, 0 otherwise */
* attribute. Like @link ippValidateAttribute@, cupsLastErrorString() is set
* to a human-readable message on failure.
*
- * @since CUPS 1.7@
+ * @since CUPS 1.7/OS X 10.9@
*/
int /* O - 1 if valid, 0 otherwise */
}
/*
- * If blocking is disabled, stop here...
+ * If blocking is disabled and we aren't at the end of the attribute
+ * list, stop here...
*/
- if (!blocking)
+ if (!blocking && ipp->current)
break;
}
/*
- * End of "$Id: ipp.c 10102 2011-11-02 23:52:39Z mike $".
+ * End of "$Id$".
*/