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 31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7 */ 32 33 #include "stdio.h" 34 #include "string.h" 35 #include "sys/types.h" 36 37 #include "lp.h" 38 #include "printers.h" 39 #include "msgs.h" 40 #include "requests.h" 41 42 #define WHO_AM_I I_AM_LPADMIN 43 #include "oam.h" 44 45 #include "lpadmin.h" 46 47 48 /** 49 ** output() - (MISNOMER) HANDLE MESSAGES BACK FROM SPOOLER 50 **/ 51 52 int output (type) 53 int type; 54 { 55 char buffer[MSGMAX]; 56 57 int rc; 58 59 short status; 60 char *dummy; 61 62 63 if (!scheduler_active) 64 switch (type) { 65 66 case R_MOUNT_TRAY: 67 case R_UNMOUNT_TRAY: 68 case R_MOUNT: 69 case R_UNMOUNT: 70 case R_MAX_TRAYS: 71 case R_QUIET_ALERT: 72 case R_INQUIRE_PRINTER_STATUS: 73 case R_ALLOC_FILES: 74 case R_PRINT_REQUEST: 75 case R_REJECT_DEST: 76 case R_ACCEPT_DEST: 77 case R_DISABLE_DEST: 78 case R_ENABLE_DEST: 79 case R_CANCEL_REQUEST: 80 default: 81 LP_ERRMSG (ERROR, E_LP_NEEDSCHED); 82 done (1); 83 84 case R_UNLOAD_PRINTER: 85 case R_UNLOAD_CLASS: 86 case R_UNLOAD_PRINTWHEEL: 87 if (anyrequests()) { 88 LP_ERRMSG (ERROR, E_LP_HAVEREQS); 89 done (1); 90 } 91 /* fall through */ 92 93 case R_LOAD_PRINTER: 94 case R_LOAD_CLASS: 95 case R_LOAD_PRINTWHEEL: 96 return (MOK); 97 98 } 99 100 status = MOKMORE; 101 while (status == MOKMORE) { 102 103 if ((rc = mrecv(buffer, MSGMAX)) != type) { 104 LP_ERRMSG (ERROR, E_LP_MRECV); 105 done (1); 106 } 107 108 switch(type) { 109 110 case R_MOUNT_TRAY: 111 case R_UNMOUNT_TRAY: 112 case R_MOUNT: 113 case R_UNMOUNT: 114 case R_MAX_TRAYS: 115 case R_LOAD_PRINTER: 116 case R_UNLOAD_PRINTER: 117 case R_LOAD_CLASS: 118 case R_UNLOAD_CLASS: 119 case R_LOAD_PRINTWHEEL: 120 case R_UNLOAD_PRINTWHEEL: 121 case R_QUIET_ALERT: 122 case R_REJECT_DEST: 123 case R_ACCEPT_DEST: 124 case R_ENABLE_DEST: 125 case R_CANCEL_REQUEST: 126 rc = getmessage(buffer, type, &status); 127 goto CheckRC; 128 129 case R_DISABLE_DEST: 130 rc = getmessage(buffer, type, &status, &dummy); 131 CheckRC: if (rc != type) { 132 LP_ERRMSG1 (ERROR, E_LP_BADREPLY, rc); 133 done (1); 134 } 135 break; 136 137 case R_INQUIRE_PRINTER_STATUS: 138 case R_ALLOC_FILES: 139 case R_PRINT_REQUEST: 140 return (0); /* handled by caller */ 141 } 142 143 } 144 145 return (status); 146 } 147