355b4669e025ff377602b6fc7caaf30dbc218371jacobs/*
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * CDDL HEADER START
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * The contents of this file are subject to the terms of the
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Common Development and Distribution License (the "License").
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * You may not use this file except in compliance with the License.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * or http://www.opensolaris.org/os/licensing.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * See the License for the specific language governing permissions
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * and limitations under the License.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * When distributing Covered Code, include this CDDL HEADER in each
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * If applicable, add the following below this CDDL HEADER, with the
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * fields enclosed by brackets "[]" replaced with your own identifying
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * information: Portions Copyright [yyyy] [name of copyright owner]
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * CDDL HEADER END
355b4669e025ff377602b6fc7caaf30dbc218371jacobs */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/*
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Use is subject to license terms.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *
355b4669e025ff377602b6fc7caaf30dbc218371jacobs */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/* $Id: common.c 155 2006-04-26 02:34:54Z ktou $ */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#pragma ident "%Z%%M% %I% %E% SMI"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <stdio.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <stdlib.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <string.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <ctype.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <errno.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <sys/types.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <unistd.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <papi.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#include <ipp-listener.h>
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobschar *
355b4669e025ff377602b6fc7caaf30dbc218371jacobsipp_svc_status_mesg(papi_service_t svc, papi_status_t status)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char *mesg = papiServiceGetStatusMessage(svc);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (mesg == NULL)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs mesg = papiStatusString(status);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs return (mesg);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobschar *
355b4669e025ff377602b6fc7caaf30dbc218371jacobsdestination_from_printer_uri(char *uri)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs static char buf[64];
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char *result = NULL;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (uri != NULL)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs result = strrchr(uri, '/');
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (result == NULL)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs result = uri;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs else
355b4669e025ff377602b6fc7caaf30dbc218371jacobs result++;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#ifdef FORCE_LPSCHED_URI
355b4669e025ff377602b6fc7caaf30dbc218371jacobs snprintf(buf, sizeof (buf), "lpsched://localhost/printers/%s", result);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs result = buf;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#endif /* FORCE_LPSCHED_URI */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs return (result);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid
355b4669e025ff377602b6fc7caaf30dbc218371jacobsget_printer_id(papi_attribute_t **attributes, char **printer, int *id)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papi_status_t result;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char *job = NULL;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char *fodder;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs int junk;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (printer == NULL)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs printer = &fodder;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (id == NULL)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs id = &junk;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *printer = NULL;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *id = -1;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs result = papiAttributeListGetString(attributes, NULL, "job-uri", &job);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (result != PAPI_OK) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobs result = papiAttributeListGetString(attributes, NULL,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "printer-uri", printer);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (result == PAPI_OK)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetInteger(attributes, NULL,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "job-id", id);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs } else {
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *printer = job;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if ((job = strrchr(*printer, '/')) != NULL) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *job = '\0';
355b4669e025ff377602b6fc7caaf30dbc218371jacobs *id = atoi(++job);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs }
355b4669e025ff377602b6fc7caaf30dbc218371jacobs }
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid
355b4669e025ff377602b6fc7caaf30dbc218371jacobsget_string_list(papi_attribute_t **attributes, char *name, char ***values)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papi_status_t result;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs void *iterator = NULL;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char *value = NULL;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs for (result = papiAttributeListGetString(attributes, &iterator,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs name, &value);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs result == PAPI_OK;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs result = papiAttributeListGetString(attributes, &iterator,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs NULL, &value))
355b4669e025ff377602b6fc7caaf30dbc218371jacobs list_append(values, value);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid
355b4669e025ff377602b6fc7caaf30dbc218371jacobsadd_default_attributes(papi_attribute_t ***attributes)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddString(attributes, PAPI_ATTR_APPEND,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "ipp-versions-supported", "1.0");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddString(attributes, PAPI_ATTR_APPEND,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "ipp-versions-supported", "1.1");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddBoolean(attributes, PAPI_ATTR_EXCL,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "multiple-document-jobs-supported", 0);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /*
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Should be able to ask the web server if it supports SSL or TLS, but
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * for now, we pick only "none"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddString(attributes, PAPI_ATTR_EXCL,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "uri-security-supported", "none");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /*
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * For now, we only "none". As we support more authentication methods,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * we will need to add the associated uri for each. Valid values would
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * be:
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * "none", "requesting-user-name", "basic", "digest", "certificate"
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * See RFC2911 page 127 for more information.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddString(attributes, PAPI_ATTR_EXCL,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "uri-authentication-supported", "requesting-user-name");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddString(attributes, PAPI_ATTR_EXCL,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "uri-security-supported", "none");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* printer-uri-supported is added in the service based attributes */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddInteger(attributes, PAPI_ATTR_EXCL,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "multiple-operation-time-out", 60);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* I18N related */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddString(attributes, PAPI_ATTR_EXCL,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "charset-configured", "utf-8");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddString(attributes, PAPI_ATTR_EXCL,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "charset-supported", "utf-8");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "natural-language-configured", "en-us");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobsstatic void
355b4669e025ff377602b6fc7caaf30dbc218371jacobsmassage_printer_attributes_group(papi_attribute_t **group, char *printer_uri)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (papiAttributeListFind(group, "printer-uri-supported") != NULL)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListAddString(&group, PAPI_ATTR_REPLACE,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "printer-uri-supported", printer_uri);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobsstatic void
355b4669e025ff377602b6fc7caaf30dbc218371jacobsmassage_job_attributes_group(papi_attribute_t **group, char *printer_uri)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (papiAttributeListFind(group, "job-printer-uri") != NULL)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListAddString(&group, PAPI_ATTR_REPLACE,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "job-printer-uri", printer_uri);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (papiAttributeListFind(group, "job-printer-uri") != NULL) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char buf[BUFSIZ];
355b4669e025ff377602b6fc7caaf30dbc218371jacobs int32_t id = -1;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetInteger(group, NULL, "job-id", &id);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs snprintf(buf, sizeof (buf), "%s/%d", printer_uri, id);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListAddString(&group, PAPI_ATTR_REPLACE,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "job-uri", buf);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs }
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/*
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * This function will replace the job/printer URIs with the requested
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * uri because the print service may return a URI that isn't IPP based.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs */
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid
355b4669e025ff377602b6fc7caaf30dbc218371jacobsmassage_response(papi_attribute_t **request, papi_attribute_t **response)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papi_status_t status;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papi_attribute_t **group = NULL;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs void *iter = NULL;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char *host = "localhost";
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char *path = "/printers/";
355b4669e025ff377602b6fc7caaf30dbc218371jacobs int port = 631;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char buf[BUFSIZ];
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListGetString(request, NULL, "uri-host", &host);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListGetString(request, NULL, "uri-path", &path);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListGetInteger(request, NULL, "uri-port", &port);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (port == 631)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs snprintf(buf, sizeof (buf), "ipp://%s%s", host, path);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs else
355b4669e025ff377602b6fc7caaf30dbc218371jacobs snprintf(buf, sizeof (buf), "http://%s:%d%s", host, port, path);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs for (status = papiAttributeListGetCollection(response, &iter,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "printer-attributes-group", &group);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs status == PAPI_OK;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs status = papiAttributeListGetCollection(NULL, &iter,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs NULL, &group))
355b4669e025ff377602b6fc7caaf30dbc218371jacobs massage_printer_attributes_group(group, buf);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs iter = NULL;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs for (status = papiAttributeListGetCollection(response, &iter,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "job-attributes-group", &group);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs status == PAPI_OK;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs status = papiAttributeListGetCollection(NULL, &iter,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs NULL, &group))
355b4669e025ff377602b6fc7caaf30dbc218371jacobs massage_job_attributes_group(group, buf);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/*
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * This walks through the locale tab and returns the installed
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * locales. There must be a better way.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs */
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid
355b4669e025ff377602b6fc7caaf30dbc218371jacobsadd_supported_locales(papi_attribute_t ***attributes)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs FILE *fp;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "generated-natural-language-supported", "en-us");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#ifndef __linux__ /* this is Solaris specific */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if ((fp = fopen("/usr/lib/locale/lcttab", "r")) != NULL) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char buf[1024];
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs while (fgets(buf, sizeof (buf), fp) != NULL) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char *name, *file;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs int i, passed = 1;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs name = strtok(buf, " \t\n");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs for (i = 0; ((passed == 1) && (name[i] != NULL)); i++)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (isalpha(name[i]) != 0)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs name[i] = tolower(name[i]);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs else if ((name[i] == '_') || (name[i] == '-'))
355b4669e025ff377602b6fc7caaf30dbc218371jacobs name[i] = '-';
355b4669e025ff377602b6fc7caaf30dbc218371jacobs else
355b4669e025ff377602b6fc7caaf30dbc218371jacobs passed = 0;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if ((passed == 1) &&
355b4669e025ff377602b6fc7caaf30dbc218371jacobs ((file = strtok(NULL, " \t\n")) != NULL)) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char path[1024];
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs snprintf(path, sizeof (path),
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "/usr/lib/locale/%s", file);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (access(path, F_OK) == 0)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListAddString(attributes,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs PAPI_ATTR_APPEND,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "generated-natural-language-supported",
355b4669e025ff377602b6fc7caaf30dbc218371jacobs name);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs }
355b4669e025ff377602b6fc7caaf30dbc218371jacobs }
355b4669e025ff377602b6fc7caaf30dbc218371jacobs }
355b4669e025ff377602b6fc7caaf30dbc218371jacobs#endif
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid
355b4669e025ff377602b6fc7caaf30dbc218371jacobspapi_to_ipp_printer_group(papi_attribute_t ***response,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papi_attribute_t **request, int flags, papi_printer_t p)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papi_attribute_t **ipp_group = NULL;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs copy_attributes(&ipp_group, papiPrinterGetAttributeList(p));
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Windows clients appear to have a problem with very large values */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListDelete(&ipp_group, "lpsched-printer-ppd-contents");
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs add_default_attributes(&ipp_group);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs ipp_operations_supported(&ipp_group, request);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddCollection(response, flags,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "printer-attributes-group", ipp_group);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListFree(ipp_group);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobsvoid
355b4669e025ff377602b6fc7caaf30dbc218371jacobspapi_to_ipp_job_group(papi_attribute_t ***response,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papi_attribute_t **request, int flags, papi_job_t j)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs{
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papi_attribute_t **ipp_group = NULL;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs copy_attributes(&ipp_group, papiJobGetAttributeList(j));
355b4669e025ff377602b6fc7caaf30dbc218371jacobs
355b4669e025ff377602b6fc7caaf30dbc218371jacobs (void) papiAttributeListAddCollection(response, flags,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs "job-attributes-group", ipp_group);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListFree(ipp_group);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs}