1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 1993 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28 /* All Rights Reserved */ 29 30 #include "stdio.h" 31 #include "string.h" 32 #include "sys/types.h" 33 34 #include "lp.h" 35 #include "printers.h" 36 #include "msgs.h" 37 #include "requests.h" 38 39 #define WHO_AM_I I_AM_LPADMIN 40 #include "oam.h" 41 42 #include "lpadmin.h" 43 44 45 /** 46 ** output() - (MISNOMER) HANDLE MESSAGES BACK FROM SPOOLER 47 **/ 48 49 int output (type) 50 int type; 51 { 52 char buffer[MSGMAX]; 53 54 int rc; 55 56 short status; 57 char *dummy; 58 59 60 if (!scheduler_active) 61 switch (type) { 62 63 case R_MOUNT_TRAY: 64 case R_UNMOUNT_TRAY: 65 case R_MOUNT: 66 case R_UNMOUNT: 67 case R_MAX_TRAYS: 68 case R_QUIET_ALERT: 69 case R_INQUIRE_PRINTER_STATUS: 70 case R_ALLOC_FILES: 71 case R_PRINT_REQUEST: 72 case R_REJECT_DEST: 73 case R_ACCEPT_DEST: 74 case R_DISABLE_DEST: 75 case R_ENABLE_DEST: 76 case R_CANCEL_REQUEST: 77 default: 78 LP_ERRMSG (ERROR, E_LP_NEEDSCHED); 79 done (1); 80 81 case R_UNLOAD_PRINTER: 82 case R_UNLOAD_CLASS: 83 case R_UNLOAD_PRINTWHEEL: 84 if (anyrequests()) { 85 LP_ERRMSG (ERROR, E_LP_HAVEREQS); 86 done (1); 87 } 88 /* fall through */ 89 90 case R_LOAD_PRINTER: 91 case R_LOAD_CLASS: 92 case R_LOAD_PRINTWHEEL: 93 return (MOK); 94 95 } 96 97 status = MOKMORE; 98 while (status == MOKMORE) { 99 100 if ((rc = mrecv(buffer, MSGMAX)) != type) { 101 LP_ERRMSG (ERROR, E_LP_MRECV); 102 done (1); 103 } 104 105 switch(type) { 106 107 case R_MOUNT_TRAY: 108 case R_UNMOUNT_TRAY: 109 case R_MOUNT: 110 case R_UNMOUNT: 111 case R_MAX_TRAYS: 112 case R_LOAD_PRINTER: 113 case R_UNLOAD_PRINTER: 114 case R_LOAD_CLASS: 115 case R_UNLOAD_CLASS: 116 case R_LOAD_PRINTWHEEL: 117 case R_UNLOAD_PRINTWHEEL: 118 case R_QUIET_ALERT: 119 case R_REJECT_DEST: 120 case R_ACCEPT_DEST: 121 case R_ENABLE_DEST: 122 case R_CANCEL_REQUEST: 123 rc = getmessage(buffer, type, &status); 124 goto CheckRC; 125 126 case R_DISABLE_DEST: 127 rc = getmessage(buffer, type, &status, &dummy); 128 CheckRC: if (rc != type) { 129 LP_ERRMSG1 (ERROR, E_LP_BADREPLY, rc); 130 done (1); 131 } 132 break; 133 134 case R_INQUIRE_PRINTER_STATUS: 135 case R_ALLOC_FILES: 136 case R_PRINT_REQUEST: 137 return (0); /* handled by caller */ 138 } 139 140 } 141 142 return (status); 143 } 144