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
47129df6a4ecc85627c83c26614505a023c155c3Keerthi Kondaka * Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
355b4669e025ff377602b6fc7caaf30dbc218371jacobs/* $Id: lpmove.c 146 2006-03-24 00:26:54Z njacobs $ */
37acf26adb79d43bb16f72774829c6f4655d0cc4"Nagaraj Yedathore - Sun Microsystems - Bangalore India" gettext("Usage: %s [request-id] (destination)\n"
37acf26adb79d43bb16f72774829c6f4655d0cc4"Nagaraj Yedathore - Sun Microsystems - Bangalore India" " %s (source) (destination)\n"), name, name);
355b4669e025ff377602b6fc7caaf30dbc218371jacobsmove_job(papi_service_t svc, char *src, int32_t id, char *dest)
355b4669e025ff377602b6fc7caaf30dbc218371jacobs fprintf(stderr, gettext("%s-%d to %s: %s\n"), src, id, dest, mesg);
355b4669e025ff377602b6fc7caaf30dbc218371jacobs switch (c) {
355b4669e025ff377602b6fc7caaf30dbc218371jacobs status = papiServiceCreate(&svc, printer, NULL, NULL,
37acf26adb79d43bb16f72774829c6f4655d0cc4"Nagaraj Yedathore - Sun Microsystems - Bangalore India" cli_auth_callback, encryption, NULL);
37acf26adb79d43bb16f72774829c6f4655d0cc4"Nagaraj Yedathore - Sun Microsystems - Bangalore India" "Failed to contact service for %s: %s\n"),
37acf26adb79d43bb16f72774829c6f4655d0cc4"Nagaraj Yedathore - Sun Microsystems - Bangalore India" printer, verbose_papi_message(svc, status));
355b4669e025ff377602b6fc7caaf30dbc218371jacobs } else { /* it's a printer */
355b4669e025ff377602b6fc7caaf30dbc218371jacobs snprintf(message, sizeof (message), "moved jobs to %s",
37acf26adb79d43bb16f72774829c6f4655d0cc4"Nagaraj Yedathore - Sun Microsystems - Bangalore India" destination);
027158a41d16aee0de0e0e2d18be458eb39f98b0Keerthi Kondaka status = papiPrinterPause(svc, printer, message);
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India * If the user is denied the permission
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India * to disable then return appropriate msg
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India char *result = NULL;
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India result = papiServiceGetStatusMessage(svc);
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India if (result != NULL) {
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India * Check if user is denied
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India * the permission
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India if (strstr(result, "permission denied")
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India * user is denied
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India * permission
47129df6a4ecc85627c83c26614505a023c155c3Keerthi Kondaka "aren't allowed to do"
47129df6a4ecc85627c83c26614505a023c155c3Keerthi Kondaka "must be logged in as "
47129df6a4ecc85627c83c26614505a023c155c3Keerthi Kondaka "\"lp\" or \"root\"."));
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India exit_code = 1;
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India fprintf(stderr, gettext(
027158a41d16aee0de0e0e2d18be458eb39f98b0Keerthi Kondaka "Reject %s: %s\n"),
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India verbose_papi_message(
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India svc, status));
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India exit_code = 1;
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India fprintf(stderr, gettext(
027158a41d16aee0de0e0e2d18be458eb39f98b0Keerthi Kondaka "Reject %s: %s\n"),
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India verbose_papi_message(svc, status));
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India exit_code = 1;
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India "destination %s is not accepting"\
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India " requests\n"), printer);
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India status = papiPrinterListJobs(svc, printer, NULL,
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India 0, 0, &jobs);
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India if (status != PAPI_OK) {
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India fprintf(stderr, gettext("Jobs %s:"\
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India verbose_papi_message(svc, status));
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India printf(gettext("move in progress ...\n"));
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India while ((jobs != NULL) && (*jobs != NULL)) {
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India id = papiJobGetId(*jobs++);
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India if (move_job(svc, printer,
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India id, destination) < 0)
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India exit_code = 1;
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India printf(gettext(
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India "total of %d requests moved"\
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India " from %s to %s\n"),
3ac6dcfa0bf841831d4cfde190aa15173622957csonam gupta - Sun Microsystems - Bangalore India count, printer, destination);