lpsched-jobs.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*LINTLIBRARY*/
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libintl.h>
#include <pwd.h>
/* lpsched include files */
#include "lp.h"
#include "requests.h"
#include "printers.h"
#include <papi_impl.h>
{
int i;
char *s;
char pr_filter = 0;
int pr_width = -1;
int pr_indent = -1;
int numberUp = 0;
int orientation = 0;
int lowerPage = 0;
int upperPage = 0;
papi_status_t getResult = 0;
char buf[256];
char banner = 0;
if (attributes == NULL)
return (PAPI_BAD_ARGUMENT);
&r->destination);
i = r->copies;
if (i <= 0)
i = 1;
r->copies = i;
== PAPI_OK) {
if ((i < 1) || (i > 100))
i = 50;
i = (i + 1) / 2.5;
r->priority = i;
}
r->priority = 20;
/*
* 'media' size should be processed both in the lpsched filter and
* the foomatic filter (if present) so that we ensure the result of
* other options like 'page-ranges' are consistent.
*/
/*
* TODO - I thing we should really have this but I can't get it to filter
* so its commented out for now (paulcun)
* papiAttributeListGetString(attributes, NULL, "media", &r->form);
*/
#ifndef LP_USE_PAPI_ATTR
#else
}
else
{
}
/*
* get the next value; note the attribute 'name' is set to
* NULL to do this.
*/
}
#endif
s = NULL;
if (s != NULL)
/*
* If we don't have an owner, set one.
*/
char *user = "intruder";
char buf[256];
"job-host", &host);
"job-originating-user-name", &user);
"requesting-user-name", &user);
}
}
s = NULL;
if (s != NULL) {
if (strcmp(s, "immediate") == 0)
r->actions |= ACT_IMMEDIATE;
else if ((strcmp(s, "resume") == 0) ||
(strcmp(s, "no-hold") == 0))
r->actions |= ACT_RESUME;
else if ((strcmp(s, "hold") == 0) ||
(strcmp(s, "indefinite") == 0))
}
/* legacy pr(1) filter related garbage "lpr -p" */
if (pr_filter != 0) {
char buf[128];
}
if (pr_width > 0) {
}
if (pr_indent > 0) {
}
"pr(1) filter options specified without enabling pr(1) filter"));
/* add burst page information */
{
char buf[128];
/* burst page is enabled by default, add the title */
if (buf[0] != '\0') {
}
}
if (banner == 0) /* burst page is disabled via lp "option" */
/* add "lp -o" options */
int i;
}
}
/* Convert attribute "number-up" to mode group=n */
}
/*
* Convert attribute "orientation-requested" to modes
* 'landscape', 'portrait', etc.
*/
"orientation-requested", &orientation);
switch (orientation) {
case 3:
{
/* 3 = portrait */
break;
}
case 4:
{
/* 4 = landscape */
break;
}
case 5:
{
/*
* 5 = reverse-landscape - not supported in
* lpsched so just use 'landscape' for now
*/
break;
}
case 6:
{
/*
* 6 = reverse-portrait not supported in
* lpsched so just use 'portrait' for now
*/
break;
}
default:
{
break;
}
}
}
/* add "lp -y" modes */
int i;
}
}
return (PAPI_OK);
}
/*
* Convert REQUEST->outcome (or R_REQUEST_* state) to the equivalent
* PAPI attribute representation.
*/
static void
unsigned short state)
{
if (attributes == NULL)
return;
"job-state", 0x04); /* held */
"job-state-reasons", "job-hold-until-specified");
"job-state", 0x05);
if (state & RS_FILTERING)
"job-state-reasons", "job-transforming");
else if (state & RS_PRINTING)
"job-state-reasons", "job-printing");
else
"job-state-reasons", "job-processing");
} else if (state & RS_CANCELLED) {
"job-state", 0x07);
"job-state-reasons", "job-canceled-by-user");
} else if (state & RS_PRINTED) {
"job-state", 0x09);
"job-state-reasons", "job-complete");
} else {
"job-state", 0x03);
"job-state-reasons", "job-queued");
}
"job-hold-until",
}
/*
* Convert REQUEST structure to the equivalent PAPI attribute representation.
*/
void
{
char *tmp;
int i;
/* copies */
"copies", r->copies);
/* destination */
r->destination);
/* file_list */
"lpsched-files", r->file_list);
/* form */
/* actions */
"lpsched-actions", r->actions);
/* alert */
/* options */
"lp-options", r->options);
"job-sheets", tmp);
"sides", tmp);
"orientation-requested", i);
/* priority (map 0-39 to 1-100) */
/* pages */
/* charset */
r->charset);
/* modes */
/* title */
/* input_type */
/* user */
"job-originating-user-name", r->user);
/* outcome */
"lpsched-outcome", r->outcome);
/* version */
"lpsched-version", r->version);
/* constants, (should be derived from options) */
"number-up", 1);
"multiple-document-handling",
"seperate-documents-collated-copies");
}
/*
* Convert R_REQUEST_* results to the equivalent PAPI attribute representation.
*/
void
{
char *p;
"job-originating-user-name", user);
"job-octets", size);
"job-id", atoi(++p));
}
"job-uri", buf);
"job-printer-uri", buf);
"output-device-assigned", destination);
"printer-name", destination);
"time-at-creation", date);
"lpsched-request-id", req_id);
"lp-charset", charset);
"lpsched-job-state", state);
"lpsched-file", file);
"job-name", file);
}
void
{
REQUEST *r;
file);
return;
}
}