diff options
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/lp/lib/papi/lpsched-jobs.c | 58 | ||||
-rw-r--r-- | usr/src/cmd/lp/lib/papi/printer.c | 107 | ||||
-rw-r--r-- | usr/src/cmd/print/bsd-sysv-commands/disable.c | 19 | ||||
-rw-r--r-- | usr/src/cmd/print/bsd-sysv-commands/lpstat.c | 34 |
4 files changed, 122 insertions, 96 deletions
diff --git a/usr/src/cmd/lp/lib/papi/lpsched-jobs.c b/usr/src/cmd/lp/lib/papi/lpsched-jobs.c index fea9caf573..0713de64c2 100644 --- a/usr/src/cmd/lp/lib/papi/lpsched-jobs.c +++ b/usr/src/cmd/lp/lib/papi/lpsched-jobs.c @@ -304,42 +304,60 @@ lpsched_request_outcome_to_attributes(papi_attribute_t ***attributes, if (attributes == NULL) return; - if (state & (RS_HELD|RS_ADMINHELD)) { + if (state & RS_NOTIFYING) { papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, - "job-state", 0x04); /* held */ + "job-state", 0x0800); /* notifying user */ papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, - "job-state-reasons", "job-hold-until-specified"); - } else if (state & RS_ACTIVE) { + "job-state-reasons", "job-notifying"); + } else if (state & RS_HELD) { papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, - "job-state", 0x05); - if (state & RS_FILTERING) - papiAttributeListAddString(attributes, - PAPI_ATTR_REPLACE, - "job-state-reasons", "job-transforming"); - else if (state & RS_PRINTING) - papiAttributeListAddString(attributes, - PAPI_ATTR_REPLACE, - "job-state-reasons", "job-printing"); - else - papiAttributeListAddString(attributes, - PAPI_ATTR_REPLACE, - "job-state-reasons", "job-processing"); + "job-state", 0x0001); /* held */ + papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, + "job-state-reasons", "job-hold-until-specified"); } else if (state & RS_CANCELLED) { papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, - "job-state", 0x07); + "job-state", 0x0040); /* job cancelled */ papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, "job-state-reasons", "job-canceled-by-user"); } else if (state & RS_PRINTED) { papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, - "job-state", 0x09); + "job-state", 0x0010); /* finished printing job */ papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, "job-state-reasons", "job-complete"); + } else if (state & RS_PRINTING) { + papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, + "job-state", 0x0008); /* printing job */ + papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, + "job-state-reasons", "job-printing"); + } else if (state & RS_ADMINHELD) { + papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, + "job-state", 0x2000); /* held by admin */ + papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, + "job-state-reasons", "job-hold-until-specified"); + } else if (state & RS_FILTERED) { + papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, + "job-state", 0x0004); /* filtered */ + papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, + "job-state-reasons", "job-filtered"); + } else if (state & RS_CHANGING) { + papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, + "job-state", 0x0020); /* job held for changing */ + papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, + "job-state-reasons", "job-held-for-change"); + } else if (state & RS_FILTERING) { + papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, + "job-state", 0x0002); /* being filtered */ + papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, + "job-state-reasons", "job-being-filtered"); } else { papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, - "job-state", 0x03); + "job-state", 0x4000); /* else */ papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, "job-state-reasons", "job-queued"); } + + + papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, "job-hold-until", ((state & RS_HELD) ? "indefinite" : "no-hold")); diff --git a/usr/src/cmd/lp/lib/papi/printer.c b/usr/src/cmd/lp/lib/papi/printer.c index 8d1c6f6459..2ba4b90628 100644 --- a/usr/src/cmd/lp/lib/papi/printer.c +++ b/usr/src/cmd/lp/lib/papi/printer.c @@ -19,11 +19,10 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" /*LINTLIBRARY*/ @@ -66,11 +65,11 @@ papiPrintersList(papi_service_t handle, char **requested_attrs, printer_t *p = NULL; short status = MOK; char *printer = NULL, - *form = NULL, - *request_id = NULL, - *character_set = NULL, - *reject_reason = NULL, - *disable_reason = NULL; + *form = NULL, + *request_id = NULL, + *character_set = NULL, + *reject_reason = NULL, + *disable_reason = NULL; short printer_status = 0; long enable_date = 0, reject_date = 0; @@ -86,22 +85,22 @@ papiPrintersList(papi_service_t handle, char **requested_attrs, do { if (rcv_msg(svc, R_INQUIRE_PRINTER_STATUS, &status, - &printer, &form, &character_set, - &disable_reason, &reject_reason, - &printer_status, &request_id, - &enable_date, &reject_date) < 0) + &printer, &form, &character_set, + &disable_reason, &reject_reason, + &printer_status, &request_id, + &enable_date, &reject_date) < 0) return (PAPI_SERVICE_UNAVAILABLE); if ((p = calloc(1, sizeof (*p))) == NULL) return (PAPI_TEMPORARY_ERROR); lpsched_printer_configuration_to_attributes(svc, p, - printer); + printer); printer_status_to_attributes(p, printer, form, - character_set, disable_reason, - reject_reason, printer_status, - request_id, enable_date, reject_date); + character_set, disable_reason, + reject_reason, printer_status, + request_id, enable_date, reject_date); list_append(printers, p); @@ -117,18 +116,18 @@ papiPrintersList(papi_service_t handle, char **requested_attrs, do { if (rcv_msg(svc, R_INQUIRE_CLASS, &status, &printer, - &printer_status, &reject_reason, - &reject_date) < 0) + &printer_status, &reject_reason, + &reject_date) < 0) return (PAPI_SERVICE_UNAVAILABLE); if ((p = calloc(1, sizeof (*p))) == NULL) return (PAPI_TEMPORARY_ERROR); lpsched_class_configuration_to_attributes(svc, p, - printer); + printer); class_status_to_attributes(p, printer, printer_status, - reject_reason, reject_date); + reject_reason, reject_date); list_append(printers, p); @@ -150,11 +149,11 @@ papiPrinterQuery(papi_service_t handle, char *name, char *dest; short status = MOK; char *pname = NULL, - *form = NULL, - *request_id = NULL, - *character_set = NULL, - *reject_reason = NULL, - *disable_reason = NULL; + *form = NULL, + *request_id = NULL, + *character_set = NULL, + *reject_reason = NULL, + *disable_reason = NULL; short printer_status = 0; long enable_date = 0, reject_date = 0; @@ -192,14 +191,14 @@ papiPrinterQuery(papi_service_t handle, char *name, return (PAPI_SERVICE_UNAVAILABLE); if (rcv_msg(svc, R_INQUIRE_PRINTER_STATUS, &status, &pname, - &form, &character_set, &disable_reason, - &reject_reason, &printer_status, &request_id, - &enable_date, &reject_date) < 0) + &form, &character_set, &disable_reason, + &reject_reason, &printer_status, &request_id, + &enable_date, &reject_date) < 0) return (PAPI_SERVICE_UNAVAILABLE); printer_status_to_attributes(p, pname, form, character_set, - disable_reason, reject_reason, printer_status, - request_id, enable_date, reject_date); + disable_reason, reject_reason, printer_status, + request_id, enable_date, reject_date); } else if (isclass(dest) != 0) { pst = lpsched_class_configuration_to_attributes(svc, p, dest); if (pst != PAPI_OK) @@ -210,12 +209,12 @@ papiPrinterQuery(papi_service_t handle, char *name, return (PAPI_SERVICE_UNAVAILABLE); if (rcv_msg(svc, R_INQUIRE_CLASS, &status, &pname, - &printer_status, &reject_reason, - &reject_date) < 0) + &printer_status, &reject_reason, + &reject_date) < 0) return (PAPI_SERVICE_UNAVAILABLE); class_status_to_attributes(p, pname, printer_status, - reject_reason, reject_date); + reject_reason, reject_date); } else if (strcmp(dest, "PrintService") == 0) { /* fill the printer object with service information */ lpsched_service_information(&p->attributes); @@ -242,11 +241,11 @@ papiPrinterAdd(papi_service_t handle, char *name, if (isprinter(dest) != 0) { status = lpsched_add_modify_printer(handle, dest, - attributes, 0); + attributes, 0); if ((*result = p = calloc(1, sizeof (*p))) != NULL) lpsched_printer_configuration_to_attributes(handle, p, - dest); + dest); else status = PAPI_TEMPORARY_ERROR; @@ -255,7 +254,7 @@ papiPrinterAdd(papi_service_t handle, char *name, if ((*result = p = calloc(1, sizeof (*p))) != NULL) lpsched_class_configuration_to_attributes(handle, p, - dest); + dest); else status = PAPI_TEMPORARY_ERROR; @@ -282,11 +281,11 @@ papiPrinterModify(papi_service_t handle, char *name, if (isprinter(dest) != 0) { status = lpsched_add_modify_printer(handle, dest, - attributes, 1); + attributes, 1); if ((*result = p = calloc(1, sizeof (*p))) != NULL) lpsched_printer_configuration_to_attributes(handle, p, - dest); + dest); else status = PAPI_TEMPORARY_ERROR; } else if (isclass(dest) != 0) { @@ -294,7 +293,7 @@ papiPrinterModify(papi_service_t handle, char *name, if ((*result = p = calloc(1, sizeof (*p))) != NULL) lpsched_class_configuration_to_attributes(handle, p, - dest); + dest); else status = PAPI_TEMPORARY_ERROR; } else @@ -406,23 +405,23 @@ papiPrinterPurgeJobs(papi_service_t handle, char *name, papi_job_t **jobs) switch (status) { case MOK: papiAttributeListAddString(&svc->attributes, PAPI_ATTR_APPEND, - "canceled-jobs", req_id); + "canceled-jobs", req_id); break; case M2LATE: case MUNKNOWN: case MNOINFO: papiAttributeListAddString(&svc->attributes, PAPI_ATTR_APPEND, - "cancel-failed", req_id); + "cancel-failed", req_id); result = PAPI_DEVICE_ERROR; break; case MNOPERM: papiAttributeListAddString(&svc->attributes, PAPI_ATTR_APPEND, - "cancel-failed", req_id); + "cancel-failed", req_id); result = PAPI_NOT_AUTHORIZED; break; default: detailed_error(svc, gettext("cancel failed, bad status (%d)\n"), - status); + status); return (PAPI_DEVICE_ERROR); } } while (more == MOKMORE); @@ -453,20 +452,20 @@ papiPrinterListJobs(papi_service_t handle, char *name, do { job_t *job = NULL; char *dest = NULL, - *ptr, - *form = NULL, - *req_id = NULL, - *charset = NULL, - *owner = NULL, - *slabel = NULL, - *file = NULL; + *ptr, + *form = NULL, + *req_id = NULL, + *charset = NULL, + *owner = NULL, + *slabel = NULL, + *file = NULL; time_t date = 0; size_t size = 0; short rank = 0, state = 0; if (rcv_msg(svc, R_INQUIRE_REQUEST_RANK, &rc, &req_id, - &owner, &slabel, &size, &date, &state, &dest, - &form, &charset, &rank, &file) < 0) + &owner, &slabel, &size, &date, &state, &dest, + &form, &charset, &rank, &file) < 0) return (PAPI_SERVICE_UNAVAILABLE); if ((rc != MOK) && (rc != MOKMORE)) @@ -483,9 +482,6 @@ papiPrinterListJobs(papi_service_t handle, char *name, if ((job = calloc(1, sizeof (*job))) == NULL) continue; - job_status_to_attributes(job, req_id, owner, slabel, size, - date, state, dest, form, charset, rank, file); - if ((ptr = strrchr(file, '-')) != NULL) { *++ptr = '0'; *++ptr = NULL; @@ -493,6 +489,9 @@ papiPrinterListJobs(papi_service_t handle, char *name, lpsched_read_job_configuration(svc, job, file); + job_status_to_attributes(job, req_id, owner, slabel, size, + date, state, dest, form, charset, rank, file); + list_append(jobs, job); } while (rc == MOKMORE); diff --git a/usr/src/cmd/print/bsd-sysv-commands/disable.c b/usr/src/cmd/print/bsd-sysv-commands/disable.c index 8b813b6d56..d57abe5728 100644 --- a/usr/src/cmd/print/bsd-sysv-commands/disable.c +++ b/usr/src/cmd/print/bsd-sysv-commands/disable.c @@ -20,14 +20,13 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * */ /* $Id: disable.c 146 2006-03-24 00:26:54Z njacobs $ */ -#pragma ident "%Z%%M% %I% %E% SMI" #include <stdio.h> #include <stdlib.h> @@ -49,8 +48,8 @@ usage(char *program) name++; fprintf(stdout, - gettext("Usage: %s [-c] [-W] [-r reason] destination ...\n"), - name); + gettext("Usage: %s [-c] [-W] [-r reason] destination ...\n"), + name); exit(1); } @@ -73,8 +72,8 @@ cancel_active_job(papi_service_t svc, char *dest) continue; (void) papiAttributeListGetInteger(a, NULL, - "job-state", &state); - if (state == 0x05) { /* processing */ + "job-state", &state); + if (state & 0x082A) { /* If state is RS_ACTIVE */ int32_t id = papiJobGetId(j[i]); (void) papiJobCancel(svc, dest, id); @@ -124,18 +123,18 @@ main(int ac, char *av[]) char *printer = av[optind++]; status = papiServiceCreate(&svc, printer, NULL, NULL, - cli_auth_callback, encryption, NULL); + cli_auth_callback, encryption, NULL); if (status != PAPI_OK) { fprintf(stderr, gettext( - "Failed to contact service for %s: %s\n"), - printer, verbose_papi_message(svc, status)); + "Failed to contact service for %s: %s\n"), + printer, verbose_papi_message(svc, status)); exit_status = 1; } status = papiPrinterDisable(svc, printer, reason); if (status != PAPI_OK) { fprintf(stderr, gettext("disable: %s: %s\n"), printer, - verbose_papi_message(svc, status)); + verbose_papi_message(svc, status)); exit_status = 1; } diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c index 42e56b2fe3..9e446bee19 100644 --- a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c +++ b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c @@ -391,13 +391,10 @@ report_printer(papi_service_t svc, char *name, papi_printer_t printer, NULL, "job-id", &jobid); /* - * If the job-state is not - * "held", "cancelled" or - * "completed" then only print. + * If the job-state is in + * RS_PRINTING then only print. */ - if ((jstate != 0x04) && - (jstate != 0x07) && - (jstate != 0x09)) { + if (jstate == 0x0008) { if (flag == 0) printf(gettext ("now printing"\ @@ -814,12 +811,25 @@ report_job(char *printer, papi_job_t job, int show_rank, int verbose) (void) papiAttributeListGetInteger(attrs, NULL, "job-state", &jstate); - if (jstate == 0x04) - printf(gettext(", being held")); - else if (jstate == 0x07) - printf(gettext(", cancelled")); - else if (jstate == 0x09) - printf(gettext(", complete")); + + if (jstate == 0x0001) + printf(gettext(" being held")); + else if (jstate == 0x0800) + printf(gettext(" notifying user")); + else if (jstate == 0x0040) + printf(gettext(" cancelled")); + else if (jstate == 0x0010) + printf(gettext(" finished printing")); + else if (jstate == 0x0008) + printf(gettext(" on %s"), destination); + else if (jstate == 0x2000) + printf(gettext(" held by admin")); + else if (jstate == 0x0002) + printf(gettext(" being filtered")); + else if (jstate == 0x0004) + printf(gettext(" filtered")); + else if (jstate == 0x0020) + printf(gettext(" held for change")); if (verbose == 1) { char *form = NULL; |