4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
28 /* $Id: ipp.c 146 2006-03-24 00:26:54Z njacobs $ */
30 #pragma ident "%Z%%M% %I% %E% SMI"
38 * IPP requests/responses are represented as attribute lists. An IPP request
39 * attribute list will contain header information attributes:
44 * It will also contain 1 or more attribute groups (collections)
45 * operational-attribute-group
47 * this routine validates that the request falls within the guidelines of
48 * the protocol specification (or some other level of conformance if the
49 * restrictions have been specified at the top level of the request using
50 * a "conformance" attribute.
53 ipp_validate_request(papi_attribute_t
**request
, papi_attribute_t
***response
)
55 papi_attribute_t
**attributes
= NULL
;
56 papi_status_t result
= PAPI_OK
;
59 if ((request
== NULL
) || (response
== NULL
) || (*response
== NULL
))
60 return (PAPI_BAD_ARGUMENT
);
62 /* validate the operational attributes group */
63 result
= papiAttributeListGetCollection(request
, NULL
,
64 "operational-attributes-group", &attributes
);
65 if (result
!= PAPI_OK
) {
66 ipp_set_status(response
, result
,
67 "operational attribute group: %s",
68 papiStatusString(result
));
72 result
= papiAttributeListGetString(attributes
, NULL
,
73 "attributes-charset", &s
);
74 if (result
!= PAPI_OK
) {
75 ipp_set_status(response
, result
, "attributes-charset: %s",
76 papiStatusString(result
));
80 result
= papiAttributeListGetString(attributes
, NULL
,
81 "attributes-natural-language", &s
);
82 if (result
!= PAPI_OK
) {
83 ipp_set_status(response
, result
,
84 "attributes-natural-language: %s",
85 papiStatusString(result
));
93 * Add/Modify the statuse-code and status-message in an IPP response's
94 * operational attributes group.
97 ipp_set_status(papi_attribute_t
***message
, papi_status_t status
,
103 if (format
!= NULL
) {
104 papi_attribute_t
**operational
= NULL
;
105 papi_attribute_t
**saved
;
106 char mesg
[256]; /* status-message is type text(255) */
109 (void) papiAttributeListGetCollection(*message
, NULL
,
110 "operational-attributes-group",
114 va_start(ap
, format
);
115 (void) vsnprintf(mesg
, sizeof (mesg
), format
, ap
);
118 (void) papiAttributeListAddString(&operational
,
119 PAPI_ATTR_APPEND
, "status-message", mesg
);
122 * We need to check and see if adding the status-message caused
123 * the operational attributes group to be relocated in memory.
124 * If it has been, we will need to re-add the collection to
127 if (saved
!= operational
)
128 (void) papiAttributeListAddCollection(message
,
130 "operational-attributes-group",
134 (void) papiAttributeListAddInteger(message
, PAPI_ATTR_APPEND
,
135 "status-code", status
);