/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*
*/
/* $Id: ipp-support.c 148 2006-04-25 16:54:17Z njacobs $ */
#include <papi_impl.h>
#include <stdlib.h>
#include <pwd.h>
#include <locale.h>
#include <errno.h>
#include <fcntl.h>
#include <md5.h>
#include <config-site.h>
#include <ipp.h>
papi_attribute_t ***op);
{
switch (status) {
case HTTP_OK:
return (PAPI_OK);
case HTTP_BAD_REQUEST:
return (PAPI_BAD_REQUEST);
case HTTP_UNAUTHORIZED:
case HTTP_FORBIDDEN:
return (PAPI_NOT_AUTHORIZED);
case HTTP_NOT_FOUND:
return (PAPI_NOT_FOUND);
case HTTP_GONE:
return (PAPI_GONE);
case HTTP_SERVICE_UNAVAILABLE:
return (PAPI_SERVICE_UNAVAILABLE);
default:
return ((papi_status_t)status);
}
}
{
switch (status) {
case IPP_OK:
return (PAPI_OK);
return (PAPI_OK);
return (PAPI_OK);
return (PAPI_OK_IGNORED_SUBSCRIPTIONS);
return (PAPI_OK_IGNORED_NOTIFICATIONS);
case IPP_CERR_BAD_REQUEST:
return (PAPI_BAD_REQUEST);
case IPP_CERR_FORBIDDEN:
return (PAPI_FORBIDDEN);
return (PAPI_NOT_AUTHENTICATED);
case IPP_CERR_NOT_AUTHORIZED:
return (PAPI_NOT_AUTHORIZED);
case IPP_CERR_NOT_POSSIBLE:
return (PAPI_NOT_POSSIBLE);
case IPP_CERR_TIMEOUT:
return (PAPI_TIMEOUT);
case IPP_CERR_NOT_FOUND:
return (PAPI_NOT_FOUND);
case IPP_CERR_GONE:
return (PAPI_GONE);
case IPP_CERR_REQUEST_ENTITY:
return (PAPI_REQUEST_ENTITY);
case IPP_CERR_REQUEST_VALUE:
return (PAPI_REQUEST_VALUE);
case IPP_CERR_DOCUMENT_FORMAT:
return (PAPI_DOCUMENT_FORMAT);
case IPP_CERR_ATTRIBUTES:
return (PAPI_ATTRIBUTES);
case IPP_CERR_URI_SCHEME:
return (PAPI_URI_SCHEME);
case IPP_CERR_CHARSET:
return (PAPI_CHARSET);
case IPP_CERR_CONFLICT:
return (PAPI_CONFLICT);
return (PAPI_COMPRESSION_NOT_SUPPORTED);
return (PAPI_COMPRESSION_ERROR);
return (PAPI_DOCUMENT_FORMAT_ERROR);
return (PAPI_DOCUMENT_ACCESS_ERROR);
return (PAPI_ATTRIBUTES_NOT_SETTABLE);
return (PAPI_IGNORED_ALL_SUBSCRIPTIONS);
return (PAPI_TOO_MANY_SUBSCRIPTIONS);
return (PAPI_IGNORED_ALL_NOTIFICATIONS);
return (PAPI_PRINT_SUPPORT_FILE_NOT_FOUND);
case IPP_SERR_INTERNAL:
return (PAPI_INTERNAL_ERROR);
return (PAPI_OPERATION_NOT_SUPPORTED);
return (PAPI_SERVICE_UNAVAILABLE);
return (PAPI_VERSION_NOT_SUPPORTED);
case IPP_SERR_DEVICE_ERROR:
return (PAPI_DEVICE_ERROR);
case IPP_SERR_TEMPORARY_ERROR:
return (PAPI_TEMPORARY_ERROR);
case IPP_SERR_NOT_ACCEPTING:
return (PAPI_NOT_ACCEPTING);
case IPP_SERR_BUSY:
case IPP_SERR_CANCELLED:
default:
return (PAPI_TEMPORARY_ERROR);
}
}
void
{
"version-major", 1);
"version-minor", 1);
"request-id", (short)lrand48());
"operation-id", operation);
}
void
{
/*
* All IPP requests must contain the following:
* attributes-charset (UTF-8)
* attributes-natural-language (our current locale)
* (object identifier) printer-uri/job-id or job-uri
* requesting-user-name (process user or none)
*/
"attributes-charset", charset);
"attributes-natural-language", language);
"job-id", job_id);
/*
* if our euid is 0 "super user", we will allow the system supplied
* user name to be overridden, if the requestor wants to.
*/
if (geteuid() == 0) {
}
"requesting-user-name", user);
}
#ifndef OPID_CUPS_GET_DEFAULT /* for servers that will enumerate */
#endif /* OPID_CUPS_GET_DEFAULT */
static papi_status_t
{
return (PAPI_BAD_ARGUMENT);
/* we must be connected to find the default destination */
return (PAPI_NOT_POSSIBLE);
return (PAPI_TEMPORARY_ERROR);
"requested-attributes", "printer-uri-supported");
"operational-attributes-group", op);
"printer-attributes-group", &op);
"printer-uri-supported", &tmp);
}
return (result);
}
static void
{
/* not the "default" */
} else
}
/* save the printer-uri's path to be used by http POST request */
}
}
/*
* don't actually write anything, just add to the total size and return the
* size of what would be written, so we can figure out how big the request
* is going to be.
*/
static ssize_t
{
return (length);
}
static ssize_t
{
return (length);
}
{
#ifdef DEBUG
#endif
}
{
char *p = buffer;
if (rc == 0)
return (rc);
if (rc < 0)
return (rc);
i -= rc;
p += rc;
}
#ifdef DEBUG
printf("ipp_request_read(0x%8.8x, 0x%8.8x, %d) = %d\n",
#endif
return (length);
}
{
/* calculate the request size */
/* Fill in the HTTP Header information */
"chunked");
else {
length);
}
"application/ipp");
/* flush any state information about this connection */
/* if we have don't have a POST path, use the service uri path */
/* send the HTTP POST message for the IPP request */
/* if the POST fails, return the error */
if (status != 0)
return (http_to_papi_status(status));
return (http_to_papi_status(status));
}
/* build the request chunk */
#ifdef DEBUG
#endif
/* send the actual IPP request */
return (http_to_papi_status(status));
}
return (result);
}
static int
{
return (-1);
struct passwd *p;
user = "nobody";
} else
/* if the passphrase is not set, use the Authentication Callback */
/* if there is still no passphrase, we have to fail */
return (-1);
"Basic", 5) == 0) {
"Basic %s", encoded);
"Digest", 6) == 0) {
"realm", realm);
"nonce", nonce);
"Digest username=\"%s\", realm=\"%s\", nonce=\"%s\", "
encoded);
}
return (0);
}
{
"operational-attributes-group", &operational);
if (operational != NULL) {
"status-message", &message);
"detailed-status-message", message);
}
return (ipp_to_papi_status(status));
}
{
int fd;
#ifdef DEBUG
#endif
/*
* if we are sending a file, open it and include it's size in the
* message size.
*/
return (PAPI_DOCUMENT_ACCESS_ERROR);
gettext("Cannot access file: %s: %s"),
return (PAPI_DOCUMENT_ACCESS_ERROR);
}
"Zero byte (empty) file: %s", file);
return (PAPI_BAD_ARGUMENT);
}
} else if (svc->transfer_encoding !=
}
}
/* send the file contents if we have it */
int rc;
< rc) {
break;
}
}
}
}
/* update our connection info */
while (status == HTTP_CONTINUE)
if (status == HTTP_UNAUTHORIZED) {
(setAuthString(svc) == 0)) {
continue;
}
} else if (status == HTTP_UPGRADE_REQUIRED) {
/*
* If the transport was built with TLS support, we can
* try to use it.
*/
continue;
}
return (http_to_papi_status(status));
/* read the IPP response */
#ifdef DEBUG
#endif
}
return (result);
}
{
}