1 0 stevel /* 2 0 stevel * CDDL HEADER START 3 0 stevel * 4 0 stevel * The contents of this file are subject to the terms of the 5 0 stevel * Common Development and Distribution License, Version 1.0 only 6 0 stevel * (the "License"). You may not use this file except in compliance 7 0 stevel * with the License. 8 0 stevel * 9 0 stevel * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 0 stevel * or http://www.opensolaris.org/os/licensing. 11 0 stevel * See the License for the specific language governing permissions 12 0 stevel * and limitations under the License. 13 0 stevel * 14 0 stevel * When distributing Covered Code, include this CDDL HEADER in each 15 0 stevel * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 0 stevel * If applicable, add the following below this CDDL HEADER, with the 17 0 stevel * fields enclosed by brackets "[]" replaced with your own identifying 18 0 stevel * information: Portions Copyright [yyyy] [name of copyright owner] 19 0 stevel * 20 0 stevel * CDDL HEADER END 21 0 stevel */ 22 0 stevel /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23 0 stevel /* All Rights Reserved */ 24 0 stevel 25 0 stevel 26 0 stevel #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9.1.4 */ 27 0 stevel /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */ 28 0 stevel 29 0 stevel #include "lpsched.h" 30 0 stevel #include <time.h> 31 0 stevel 32 0 stevel /** 33 0 stevel ** disable() - DISABLE PRINTER 34 0 stevel **/ 35 0 stevel 36 0 stevel int 37 0 stevel disable(PSTATUS *pps, char *reason, int when) 38 0 stevel { 39 0 stevel if (pps->status & PS_DISABLED) 40 0 stevel return (-1); 41 0 stevel 42 0 stevel else { 43 0 stevel pps->status |= PS_DISABLED; 44 0 stevel time (&pps->dis_date); 45 0 stevel load_str (&pps->dis_reason, reason); 46 0 stevel 47 0 stevel dump_pstatus (); 48 0 stevel 49 0 stevel if (pps->status & PS_BUSY) 50 0 stevel switch (when) { 51 0 stevel 52 0 stevel case DISABLE_STOP: 53 0 stevel /* 54 0 stevel * Stop current job, requeue. 55 0 stevel */ 56 0 stevel if (pps->request) 57 0 stevel pps->request->request->outcome |= RS_STOPPED; 58 0 stevel terminate (pps->exec); 59 0 stevel break; 60 0 stevel 61 0 stevel case DISABLE_FINISH: 62 0 stevel /* 63 0 stevel * Let current job finish. 64 0 stevel */ 65 0 stevel break; 66 0 stevel 67 0 stevel case DISABLE_CANCEL: 68 0 stevel /* 69 0 stevel * Cancel current job outright. 70 0 stevel */ 71 0 stevel if (pps->request) 72 0 stevel cancel (pps->request, 1); 73 0 stevel break; 74 0 stevel 75 0 stevel } 76 0 stevel 77 0 stevel /* 78 0 stevel * Need we check to see if requests assigned to 79 0 stevel * this printer should be assigned elsewhere? 80 0 stevel * No, if the "validate()" routine is properly 81 0 stevel * assigning requests. If another printer is available 82 0 stevel * for printing requests (that would otherwise be) 83 0 stevel * assigned to this printer, at least one of those 84 0 stevel * requests will be assigned to that other printer, 85 0 stevel * and should be currently printing. Once it is done 86 0 stevel * printing, the queue will be examined for the next 87 0 stevel * request, and the one(s) assigned this printer will 88 0 stevel * be picked up. 89 0 stevel */ 90 0 stevel /* (void)queue_repel (pps, 0, (qchk_fnc_type)0); */ 91 0 stevel 92 0 stevel return (0); 93 0 stevel } 94 0 stevel } 95 0 stevel 96 0 stevel /** 97 0 stevel ** enable() - ENABLE PRINTER 98 0 stevel **/ 99 0 stevel 100 0 stevel int 101 0 stevel enable (register PSTATUS *pps) 102 0 stevel { 103 0 stevel /* 104 0 stevel * ``Enabling a printer'' includes clearing a fault and 105 0 stevel * clearing the do-it-later flag to allow the printer 106 0 stevel * to start up again. 107 0 stevel */ 108 0 stevel if (!(pps->status & (PS_FAULTED|PS_DISABLED|PS_LATER))) 109 0 stevel return (-1); 110 0 stevel 111 0 stevel else { 112 0 stevel pps->status &= ~(PS_FAULTED|PS_DISABLED|PS_LATER); 113 0 stevel (void) time (&pps->dis_date); 114 0 stevel 115 0 stevel dump_pstatus (); 116 0 stevel 117 0 stevel if (pps->alert->active) 118 0 stevel cancel_alert (A_PRINTER, pps); 119 0 stevel 120 0 stevel /* 121 0 stevel * Attract the FIRST request that is waiting to 122 0 stevel * print to this printer. In this regard we're acting 123 0 stevel * like the printer just finished printing a request 124 0 stevel * and is looking for another. 125 0 stevel */ 126 0 stevel queue_attract (pps, qchk_waiting, 1); 127 0 stevel return (0); 128 0 stevel } 129 0 stevel } 130