diff options
author | sonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM> | 2009-04-09 23:37:50 -0700 |
---|---|---|
committer | sonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM> | 2009-04-09 23:37:50 -0700 |
commit | f0b87b902adb4cdfe4ad24ea596a7311ddbb2953 (patch) | |
tree | df5d3435e267baa0cf0483c2ca43b499f51514b8 /usr/src/cmd/print/bsd-sysv-commands/common.c | |
parent | 40e7ce05bde825a43b0db32ded62db8cc5b6ec9c (diff) | |
download | illumos-joyent-f0b87b902adb4cdfe4ad24ea596a7311ddbb2953.tar.gz |
6815222 lpstat -o reports incorrect job# for general user
Diffstat (limited to 'usr/src/cmd/print/bsd-sysv-commands/common.c')
-rw-r--r-- | usr/src/cmd/print/bsd-sysv-commands/common.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/usr/src/cmd/print/bsd-sysv-commands/common.c b/usr/src/cmd/print/bsd-sysv-commands/common.c index 8b4f50bdc8..ceb9177677 100644 --- a/usr/src/cmd/print/bsd-sysv-commands/common.c +++ b/usr/src/cmd/print/bsd-sysv-commands/common.c @@ -580,3 +580,43 @@ cli_auth_callback(papi_service_t svc, void *app_data) return (0); } + +int32_t +job_to_be_queried(papi_service_t svc, char *printer, int32_t id) +{ + papi_job_t *jobs = NULL; + papi_status_t status; + char *jattrs[] = { "job-id", + "job-id-requested", NULL }; + + status = papiPrinterListJobs(svc, printer, jattrs, PAPI_LIST_JOBS_ALL, + 0, &jobs); + + if (status != PAPI_OK) { + fprintf(stderr, gettext("Failed to query service for %s: %s\n"), + printer, verbose_papi_message(svc, status)); + return (-1); + } + + if (jobs != NULL) { + int i = 0; + + for (i = 0; jobs[i] != NULL; i++) { + int32_t rid = -1; + papi_attribute_t **list = + papiJobGetAttributeList(jobs[i]); + + papiAttributeListGetInteger(list, NULL, + "job-id-requested", &rid); + + /* check if this matches with id */ + if (rid == id) { + /* get the actual id and return it */ + papiAttributeListGetInteger(list, NULL, + "job-id", &id); + return (id); + } + } + } + return (id); +} |