355b4669e025ff377602b6fc7caaf30dbc218371jacobs * CDDL HEADER START
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 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * See the License for the specific language governing permissions
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * and limitations under the License.
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 * CDDL HEADER END
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Use is subject to license terms.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/* $Id: lpd-job.c 157 2006-04-26 15:07:55Z ktou $ */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs { "application/postscript", 'f' }, /* rfc incorrectly has 'o' */
355b4669e025ff377602b6fc7caaf30dbc218371jacobsadd_lpd_control_line(char **metadata, char code, char *value)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs snprintf(line, sizeof (line), "%c%s\n", code, value);
355b4669e025ff377602b6fc7caaf30dbc218371jacobsadd_svr4_control_line(char **metadata, char code, char *value)
355b4669e025ff377602b6fc7caaf30dbc218371jacobsadd_int_control_line(char **metadata, char code, int value, int flag)
355b4669e025ff377602b6fc7caaf30dbc218371jacobslpd_add_rfc1179_attributes(service_t *svc, papi_attribute_t **attributes,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* There is nothing to do */
286caa64ad16838107c004ca772b1d153e7c7510Keerthi Kondaka if (papiAttributeListGetString(attributes, NULL,
286caa64ad16838107c004ca772b1d153e7c7510Keerthi Kondaka "job-originating-host-name", &h1) == PAPI_OK) {
286caa64ad16838107c004ca772b1d153e7c7510Keerthi Kondaka papiAttributeListAddString(&attributes, PAPI_ATTR_APPEND,
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "job-originating-host-name", host);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(svc->attributes, NULL, "username",
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "job-originating-user-name", user);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Class for Banner Page */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "rfc-1179-class", &s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (s != NULL) {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "rfc-1179-class", s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Print Banner Page */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "job-sheets", &s);
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "job-sheets", s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Jobname */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "job-name", &s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (s != NULL) {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "job-name", s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* User to mail when job is done - lpr -m */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetBoolean(attributes, NULL, "rfc-1179-mail", &bool);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (bool == PAPI_TRUE) {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "rfc-1179-mail", bool);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Title for pr */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "pr-title", &s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (s != NULL) {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "pr-title", s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Indent - used with pr filter */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetInteger(attributes, NULL, "pr-indent", &integer);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs add_int_control_line(metadata, 'I', integer, LPD_RFC);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Width - used with pr filter */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetInteger(attributes, NULL, "pr-width", &integer);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs add_int_control_line(metadata, 'W', integer, LPD_RFC);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* file with Times Roman font lpr -1 */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "rfc-1179-font-r", &s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (s != NULL) {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "rfc-1179-font-r", s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* file with Times Roman font lpr -2 */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "rfc-1179-font-i", &s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (s != NULL) {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "rfc-1179-font-i", s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* file with Times Roman font lpr -3 */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "rfc-1179-font-b", &s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (s != NULL) {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "rfc-1179-font-b", s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* file with Times Roman font lpr -4 */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "rfc-1179-font-s", &s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (s != NULL) {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "rfc-1179-font-s", s);
b657fff74acfeed123d06540dcbf2ebf0f4ebee9"Nagaraj Yedathore - Sun Microsystems - Bangalore India" * The document format needs to be added, but the control line
b657fff74acfeed123d06540dcbf2ebf0f4ebee9"Nagaraj Yedathore - Sun Microsystems - Bangalore India" * should be added when the filenames are figured out.
b657fff74acfeed123d06540dcbf2ebf0f4ebee9"Nagaraj Yedathore - Sun Microsystems - Bangalore India" s = NULL;
b657fff74acfeed123d06540dcbf2ebf0f4ebee9"Nagaraj Yedathore - Sun Microsystems - Bangalore India" papiAttributeListGetString(attributes, NULL, "document-format", &s);
b657fff74acfeed123d06540dcbf2ebf0f4ebee9"Nagaraj Yedathore - Sun Microsystems - Bangalore India" if (s != NULL) {
b657fff74acfeed123d06540dcbf2ebf0f4ebee9"Nagaraj Yedathore - Sun Microsystems - Bangalore India" papiAttributeListAddString(used, PAPI_ATTR_EXCL,
b657fff74acfeed123d06540dcbf2ebf0f4ebee9"Nagaraj Yedathore - Sun Microsystems - Bangalore India" "document-format", s);
fd06a699040f011e80ab8ac5213bb0a47858e69bjacobsstatic char *
fd06a699040f011e80ab8ac5213bb0a47858e69bjacobsunused_attributes(papi_attribute_t **list, papi_attribute_t **used)
fd06a699040f011e80ab8ac5213bb0a47858e69bjacobs /* add these to the list of things to ignore */
fd06a699040f011e80ab8ac5213bb0a47858e69bjacobs split_and_copy_attributes(names, list, NULL, &unused);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * lpd_add_svr4_attributes
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * Solaris 2.x LP - BSD protocol extensions
355b4669e025ff377602b6fc7caaf30dbc218371jacobslpd_add_svr4_attributes(service_t *svc, papi_attribute_t **attributes,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* media */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "media", &s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (s != NULL) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Handling */
43b9c05035ac59f7f7a8e7827598db5a15f30ed3jacobs papiAttributeListGetString(attributes, NULL, "job-hold-until", &s);
fe37c54d747b42e6ba91c90c9a1bdd69d2c8b909"Nagaraj Yedathore - Sun Microsystems - Bangalore India" if ((s != NULL) && (strcmp(s, "indefinite") == 0)) {
fe37c54d747b42e6ba91c90c9a1bdd69d2c8b909"Nagaraj Yedathore - Sun Microsystems - Bangalore India" } else if ((s != NULL) && (strcmp(s, "no-hold") == 0)) {
43b9c05035ac59f7f7a8e7827598db5a15f30ed3jacobs } else if (s != NULL) {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "job-hold-until", s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Pages */
43b9c05035ac59f7f7a8e7827598db5a15f30ed3jacobs tmp[0] = papiAttributeListFind(attributes, "page-ranges");
43b9c05035ac59f7f7a8e7827598db5a15f30ed3jacobs papiAttributeListToString(tmp, " ", buf, sizeof (buf));
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "page-ranges", s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Priority : lp -q */
43b9c05035ac59f7f7a8e7827598db5a15f30ed3jacobs papiAttributeListGetInteger(attributes, NULL, "job-priority", &integer);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs add_int_control_line(metadata, 'q', integer, LPD_SVR4);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Charset : lp -S */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "lp-charset", &s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (s != NULL) {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "lp-charset", s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Type : done when adding file */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Mode : lp -y */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "lp-modes", &s);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (s != NULL) {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes "lp-modes", s);
fd06a699040f011e80ab8ac5213bb0a47858e69bjacobs /* Options lp -o are handled elsewhere */
fd06a699040f011e80ab8ac5213bb0a47858e69bjacobs if ((s = unused_attributes(attributes, *used)) != NULL) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobslpd_add_hpux_attributes(service_t *svc, papi_attribute_t **attributes,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* Options lp -o */
fd06a699040f011e80ab8ac5213bb0a47858e69bjacobs if ((s = unused_attributes(attributes, *used)) != NULL) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobslpd_job_add_attributes(service_t *svc, papi_attribute_t **attributes,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs lpd_add_rfc1179_attributes(svc, attributes, metadata, used);
fd06a699040f011e80ab8ac5213bb0a47858e69bjacobs /* add protocol extensions if applicable */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if ((strcasecmp(svc->uri->fragment, "solaris") == 0) ||
355b4669e025ff377602b6fc7caaf30dbc218371jacobs else if (strcasecmp(svc->uri->fragment, "hpux") == 0)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * others could be added here:
355b4669e025ff377602b6fc7caaf30dbc218371jacobs * lprng, sco, aix, digital unix, xerox, ...
355b4669e025ff377602b6fc7caaf30dbc218371jacobslpd_job_add_files(service_t *svc, papi_attribute_t **attributes,
355b4669e025ff377602b6fc7caaf30dbc218371jacobs char **files, char **metadata, papi_attribute_t ***used)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if ((svc == NULL) || (attributes == NULL) || (files == NULL) ||
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetString(attributes, NULL, "document-format",
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if ((rfc_fmt = mime_type_to_rfc1179_type(format)) == '\0') {
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes (strcasecmp(svc->uri->fragment, "svr4") == 0)))
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListGetInteger(attributes, NULL, "copies", &copies);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs papiAttributeListAddInteger(used, PAPI_ATTR_EXCL, "copies", copies);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs detailed_error(svc, gettext("aborting request, %s: %s"),
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes if (strcmp("standard input", files[i]) != 0) {
a5669307eaef64af8519feb70d42f0aa0e7ec21aJonathan Cowper-Andrewes if (stat(files[i], &statbuf) < 0) {
a5669307eaef64af8519feb70d42f0aa0e7ec21aJonathan Cowper-Andrewes gettext("Cannot access file: %s: %s"),
a5669307eaef64af8519feb70d42f0aa0e7ec21aJonathan Cowper-Andrewes return (PAPI_DOCUMENT_ACCESS_ERROR);
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes gettext("Zero byte (empty) file: %s"),
355b4669e025ff377602b6fc7caaf30dbc218371jacobs if (i < 26)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs else if (i < 52)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs else if (i < 62)
95c2d3023b88b9097d9822eb47ace5466e6d1cf4Jonathan Cowper-Andrewes gettext("too many files, truncated at 62"));
355b4669e025ff377602b6fc7caaf30dbc218371jacobs snprintf(name, sizeof (name), "df%cXXX%s", key, host);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs for (j = 0; j < copies; j++)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs add_lpd_control_line(metadata, 'N', (char *)files[i]);
355b4669e025ff377602b6fc7caaf30dbc218371jacobslpd_submit_job(service_t *svc, char *metadata, papi_attribute_t ***attributes,
4bd2082ff2d009263265d7de938de336894b6009ceastha if (((fd = lpd_open(svc, 's', list, 15)) < 0) && (errno != EBADMSG)) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobs /* read the ID and add it to to the job */