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
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/* $Id: cancel.c 147 2006-04-25 16:51:06Z njacobs $ */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs fprintf(stdout, "Usage: %s [-u user] (printer|request-id ...)\n", name);
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore Indiastatic int32_t
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore Indiaget_job_id_requested(papi_job_t job) {
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India int32_t rid = -1;
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India papi_attribute_t **list = papiJobGetAttributeList(job);
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India papiAttributeListGetInteger(list, NULL,
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India "job-id-requested", &rid);
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India return (rid);
d6083ba53b4a1af428be83ca08578cf93a9038c5jccancel_jobs_for_user(char *user, papi_encryption_t encryption, char *pname) {
6b5764c36d253d178caa447fa2a6d7e0c7dfd6e6sonam gupta - Sun Microsystems - Bangalore India status = papiServiceCreate(&svc, NULL, NULL, NULL,
6b5764c36d253d178caa447fa2a6d7e0c7dfd6e6sonam gupta - Sun Microsystems - Bangalore India status = papiServiceCreate(&svc, printer, NULL, NULL,
d6083ba53b4a1af428be83ca08578cf93a9038c5jc "Failed to contact service for %s: %s\n"),
d6083ba53b4a1af428be83ca08578cf93a9038c5jc exit_code = berkeley_cancel_request(svc, stdout, printer, 1,
dcf1b443e6f262cefb7e8babd3bac5fa2736b100sonam gupta - Sun Microsystems - Bangalore India int32_t rid = -1;
355b4669e025ff377602b6fc7caaf30dbc218371jacobs switch (c) {
2cb53ad67f463fb038a7c555bb0611fb6a8acec7Keerthi Kondaka status = papiServiceCreate(&svc, av[c], NULL, NULL,
2cb53ad67f463fb038a7c555bb0611fb6a8acec7Keerthi Kondaka (void) get_printer_id(av[c], &printer, &id);
2cb53ad67f463fb038a7c555bb0611fb6a8acec7Keerthi Kondaka status = papiServiceCreate(&svc, printer, NULL,
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India fprintf(stderr, gettext(
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India "Failed to contact service for %s: %s\n"),
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India char *mesg = gettext("cancelled");
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India * Check if the job-id is job-id-requested
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India * or job-id. If it is job-id-requested then find
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India * corresponding job-id and send it to cancel
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India rid = job_to_be_queried(svc, printer, id);
06f61b77bc179f185bf19957b30740c246a13c0dsonam gupta - Sun Microsystems - Bangalore India if (rid < 0) {
06f61b77bc179f185bf19957b30740c246a13c0dsonam gupta - Sun Microsystems - Bangalore India * Either it is a remote job which cannot be
06f61b77bc179f185bf19957b30740c246a13c0dsonam gupta - Sun Microsystems - Bangalore India * cancelled based on job-id or job-id is
06f61b77bc179f185bf19957b30740c246a13c0dsonam gupta - Sun Microsystems - Bangalore India * not found
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India fprintf(OUT, "%s-%d: %s\n",
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India printer, id, gettext("not-found"));
06f61b77bc179f185bf19957b30740c246a13c0dsonam gupta - Sun Microsystems - Bangalore India status = papiJobCancel(svc, printer, rid);
06f61b77bc179f185bf19957b30740c246a13c0dsonam gupta - Sun Microsystems - Bangalore India if (status == PAPI_NOT_AUTHORIZED) {
06f61b77bc179f185bf19957b30740c246a13c0dsonam gupta - Sun Microsystems - Bangalore India mesg = papiStatusString(status);
06f61b77bc179f185bf19957b30740c246a13c0dsonam gupta - Sun Microsystems - Bangalore India exit_code = 1;
06f61b77bc179f185bf19957b30740c246a13c0dsonam gupta - Sun Microsystems - Bangalore India } else if (status != PAPI_OK) {
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India mesg = gettext(
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India verbose_papi_message(
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India svc, status));
06f61b77bc179f185bf19957b30740c246a13c0dsonam gupta - Sun Microsystems - Bangalore India exit_code = 1;
06f61b77bc179f185bf19957b30740c246a13c0dsonam gupta - Sun Microsystems - Bangalore India fprintf(OUT, "%s-%d: %s\n", printer, id, mesg);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs } else { /* it's a printer */
d6083ba53b4a1af428be83ca08578cf93a9038c5jc /* Remove first job from printer */
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India char *mesg = gettext("cancelled");
d03e4ae852e122903f8876fb2ba7df676722d799Jonathan Cowper-Andrewes if (status == PAPI_NOT_AUTHORIZED) {
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India mesg = gettext(
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India verbose_papi_message(
b6c573b6170aa329dfd387cc19f32a7919c4ff4csonam gupta - Sun Microsystems - Bangalore India svc, status));
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India * If job-id-requested exists for this
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India * job-id then that should be displayed
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India rid = get_job_id_requested(*jobs);
dcf1b443e6f262cefb7e8babd3bac5fa2736b100sonam gupta - Sun Microsystems - Bangalore India if (rid >= 0)
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India fprintf(OUT, "%s-%d: %s\n",
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India printer, rid, mesg);
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India fprintf(OUT, "%s-%d: %s\n",
f0b87b902adb4cdfe4ad24ea596a7311ddbb2953sonam gupta - Sun Microsystems - Bangalore India printer, id, mesg);
d6083ba53b4a1af428be83ca08578cf93a9038c5jc /* Purging user's print jobs */