lpsched-jobs.c revision c389c7f85e1e94d7078f66fbb37362b0387243d0
/*
* 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.
*/
/*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 lower = 0;
int upper = 0;
char buf[256];
"job-class", "job-hold-until", "job-host", "job-name",
"job-originating-user-name", "job-printer",
"job-sheets", "lp-charset", "lp-modes", "number-up",
"orienttation-requested", "page-ranges", "pr-filter",
"pr-indent", "pr-title", "pr-width", "job-priority",
"requesting-user-name", "job-originating-host-name",
NULL };
if (attributes == NULL)
return (PAPI_BAD_ARGUMENT);
/* replace the current destination */
"job-printer", &r->destination);
/* set the copies. We need at least 1 */
i = r->copies;
if (i <= 0)
i = 1;
r->copies = i;
/*
* have to convert it.
*/
== PAPI_OK) {
if ((i < 1) || (i > 100))
i = 50;
i = 40 - (i / 2.5);
r->priority = i;
}
r->priority = 20;
/* set the requested form to print on */
/* set the page range */
}
/*
* set the document format, converting to old format names as
* as needed.
*/
s = NULL;
if (s != NULL)
/*
* If we don't have an owner, set one.
*/
char *user = "intruder";
char buf[256];
"job-originating-host-name", &host);
"job-host", &host);
"job-originating-user-name", &user);
"requesting-user-name", &user);
}
/* set any held state */
s = NULL;
if (s != NULL) {
if (strcmp(s, "resume") == 0)
r->actions |= ACT_RESUME;
else if ((strcmp(s, "immediate") == 0) ||
(strcmp(s, "no-hold") == 0))
r->actions |= ACT_IMMEDIATE;
else if ((strcmp(s, "indefinite") == 0) ||
(strcmp(s, "hold") == 0))
}
/* set lp charset/printwheel */
/* 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 */
s = NULL;
char buf[128];
/* burst page is enabled by default, add the title */
if (buf[0] != '\0') {
}
/* burst page is disabled via lp "option" */
}
/* Convert attribute "number-up" to mode group=n */
}
/*
* Convert attribute "orientation-requested" to modes
* 'landscape', 'portrait', etc.
*/
"orientation-requested", &orientation);
switch (orientation) {
case 4: /* landscape */
case 5: /* reverse-landscape, use landscape instead */
break;
case 3: /* portrait */
case 6: /* reverse-portrait, use portrait instead */
default:
break;
}
}
/* add "lp -y" modes */
int i;
}
}
/* add any unconsumed attributes to the "options" list */
!= PAPI_OK) {
size += 1024;
}
}
}
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;
if (state & RS_NOTIFYING) {
"job-state", 0x0800); /* notifying user */
"job-state-reasons", "job-notifying");
"job-state", 0x0001); /* held */
"job-state-reasons", "job-hold-until-specified");
} else if (state & RS_CANCELLED) {
"job-state", 0x0040); /* job cancelled */
"job-state-reasons", "job-canceled-by-user");
} else if (state & RS_PRINTED) {
"job-state", 0x0010); /* finished printing job */
"job-state-reasons", "job-complete");
} else if (state & RS_PRINTING) {
"job-state", 0x0008); /* printing job */
"job-state-reasons", "job-printing");
} else if (state & RS_ADMINHELD) {
"job-state", 0x2000); /* held by admin */
"job-state-reasons", "job-hold-until-specified");
} else if (state & RS_FILTERED) {
"job-state", 0x0004); /* filtered */
"job-state-reasons", "job-filtered");
} else if (state & RS_CHANGING) {
"job-state", 0x0020); /* job held for changing */
"job-state-reasons", "job-held-for-change");
} else if (state & RS_FILTERING) {
"job-state", 0x0002); /* being filtered */
"job-state-reasons", "job-being-filtered");
} else {
"job-state", 0x4000); /* else */
"job-state-reasons", "job-queued");
}
"job-hold-until",
}
/*
* convert user[@host] to papi attributes
*/
static void
{
"job-originating-user-name", user);
*host = '@';
} else
"job-originating-user-name", user);
}
}
/*
* Convert REQUEST structure to the equivalent PAPI attribute representation.
*/
void
{
char *tmp;
int i;
/* copies */
"copies", r->copies);
/* destination */
"printer-name", r->destination);
/* form */
"form", r->form);
/* options */
r->options);
"job-sheets", tmp);
"sides", tmp);
"orientation-requested", i);
/* priority (map 0-39 to 1-100) */
"job-priority",
/* pages */
"page-ranges", r->pages);
/* charset */
"lp-charset", r->charset);
/* modes */
"lp-modes", r->modes);
/* title */
"job-name", r->title);
/* input_type */
/* user */
/* outcome */
/* 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-octets", size);
"job-id", atoi(++p));
}
destination, atoi(p));
"job-uri", buf);
"job-printer-uri", buf);
"output-device-assigned", destination);
"printer-name", destination);
"form", form);
"time-at-creation", date);
"lpsched-request-id", req_id);
"lp-charset", charset);
"lpsched-job-state", state);
"lpsched-file", file);
"job-name", file);
"tsol-sensitivity-label", slabel);
}
void
{
REQUEST *r;
file);
return;
}
}