17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
50a44ef6dSjacobs * Common Development and Distribution License (the "License").
60a44ef6dSjacobs * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
210a44ef6dSjacobs
227c478bd9Sstevel@tonic-gate /*
23bfe4ed66Ssonam gupta - Sun Microsystems - Bangalore India * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
277c478bd9Sstevel@tonic-gate /* All Rights Reserved */
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate
307c478bd9Sstevel@tonic-gate #include "dispatch.h"
317c478bd9Sstevel@tonic-gate #include <syslog.h>
327c478bd9Sstevel@tonic-gate
337c478bd9Sstevel@tonic-gate /**
347c478bd9Sstevel@tonic-gate ** remount_form() - MOUNT A FORM WHERE ANOTHER WAS MOUNTED
357c478bd9Sstevel@tonic-gate **/
367c478bd9Sstevel@tonic-gate
377c478bd9Sstevel@tonic-gate void
remount_form(register PSTATUS * pps,FSTATUS * pfs,short trayNum)387c478bd9Sstevel@tonic-gate remount_form(register PSTATUS *pps, FSTATUS *pfs, short trayNum)
397c478bd9Sstevel@tonic-gate {
407c478bd9Sstevel@tonic-gate trayNum--; /* make zero based */
417c478bd9Sstevel@tonic-gate if (pps->forms && (pps->forms[trayNum].form == pfs)) {
420a44ef6dSjacobs pps->forms[trayNum].isAvailable = (pfs ? 1 : 0);
437c478bd9Sstevel@tonic-gate /* force it */
447c478bd9Sstevel@tonic-gate return; /* nothing to do */
457c478bd9Sstevel@tonic-gate } else if ((!pps->forms) && (!pfs)) {
467c478bd9Sstevel@tonic-gate return; /* nothing to do */
477c478bd9Sstevel@tonic-gate }
487c478bd9Sstevel@tonic-gate
497c478bd9Sstevel@tonic-gate /*
507c478bd9Sstevel@tonic-gate * Unmount the old form.
517c478bd9Sstevel@tonic-gate */
527c478bd9Sstevel@tonic-gate if (pps->forms && pps->forms[trayNum].form) {
537c478bd9Sstevel@tonic-gate register FSTATUS *Opfs = pps->forms[trayNum].form;
547c478bd9Sstevel@tonic-gate
557c478bd9Sstevel@tonic-gate pps->forms[trayNum].form = 0;
56bfe4ed66Ssonam gupta - Sun Microsystems - Bangalore India pps->forms[trayNum].isAvailable = 1;
577c478bd9Sstevel@tonic-gate Opfs->mounted--;
587c478bd9Sstevel@tonic-gate
597c478bd9Sstevel@tonic-gate /*
607c478bd9Sstevel@tonic-gate * Unmounting the form may make some print requests
617c478bd9Sstevel@tonic-gate * no longer printable, because they were accepted
627c478bd9Sstevel@tonic-gate * only because the form was already mounted.
637c478bd9Sstevel@tonic-gate * Unmounting the form will also force some requests
647c478bd9Sstevel@tonic-gate * to another printer (where the form is mounted)
657c478bd9Sstevel@tonic-gate * so they can print.
667c478bd9Sstevel@tonic-gate */
677c478bd9Sstevel@tonic-gate form_in_question = Opfs;
687c478bd9Sstevel@tonic-gate (void)queue_repel (pps, 0, qchk_form);
697c478bd9Sstevel@tonic-gate
707c478bd9Sstevel@tonic-gate /*
717c478bd9Sstevel@tonic-gate * Maybe an alert is due.
727c478bd9Sstevel@tonic-gate */
737c478bd9Sstevel@tonic-gate check_form_alert (Opfs, (_FORM *)0);
747c478bd9Sstevel@tonic-gate }
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gate /*
777c478bd9Sstevel@tonic-gate * Mount the new form?
787c478bd9Sstevel@tonic-gate */
797c478bd9Sstevel@tonic-gate if (pfs) {
807c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "remount_form add %x(%s) to tray %d\n",
817c478bd9Sstevel@tonic-gate pfs, (pfs ? pfs->form->name : "NULL"), trayNum);
82*55fea89dSDan Cross
837c478bd9Sstevel@tonic-gate if (pps && !pps->forms) {
847c478bd9Sstevel@tonic-gate pps->forms = (PFSTATUS *)calloc((trayNum +1),
857c478bd9Sstevel@tonic-gate sizeof(PFSTATUS));
867c478bd9Sstevel@tonic-gate pps->numForms = trayNum + 1;
877c478bd9Sstevel@tonic-gate }
887c478bd9Sstevel@tonic-gate
897c478bd9Sstevel@tonic-gate if (pps && pps->forms && (pps->numForms > trayNum)) {
907c478bd9Sstevel@tonic-gate pps->forms[trayNum].form = pfs;
917c478bd9Sstevel@tonic-gate pps->forms[trayNum].isAvailable = 1;
927c478bd9Sstevel@tonic-gate pfs->mounted++;
937c478bd9Sstevel@tonic-gate } else {
947c478bd9Sstevel@tonic-gate return; /* nothing to do, can't mount form,
957c478bd9Sstevel@tonic-gate so no need to pretend we did */
967c478bd9Sstevel@tonic-gate }
977c478bd9Sstevel@tonic-gate
987c478bd9Sstevel@tonic-gate
997c478bd9Sstevel@tonic-gate /*
1007c478bd9Sstevel@tonic-gate * Attract all the requests needing this newly mounted
1017c478bd9Sstevel@tonic-gate * form. This may cause some unnecessary shuffling, but
1027c478bd9Sstevel@tonic-gate * we have to ensure requests aren't assigned to a printer
1037c478bd9Sstevel@tonic-gate * without the form mounted, so that the alert check is
1047c478bd9Sstevel@tonic-gate * correct.
1057c478bd9Sstevel@tonic-gate */
1067c478bd9Sstevel@tonic-gate if (pfs->requests) {
1077c478bd9Sstevel@tonic-gate form_in_question = pfs;
1087c478bd9Sstevel@tonic-gate queue_attract (pps, qchk_form, 0);
1097c478bd9Sstevel@tonic-gate
1107c478bd9Sstevel@tonic-gate /*
1117c478bd9Sstevel@tonic-gate * Maybe an alert can be shut off.
1127c478bd9Sstevel@tonic-gate */
1137c478bd9Sstevel@tonic-gate check_form_alert (pfs, (_FORM *)0);
1147c478bd9Sstevel@tonic-gate }
1157c478bd9Sstevel@tonic-gate
1167c478bd9Sstevel@tonic-gate } else {
1177c478bd9Sstevel@tonic-gate /*
1187c478bd9Sstevel@tonic-gate * Attract first request that doesn't need a form mounted.
1197c478bd9Sstevel@tonic-gate * We only need to get one request printing, because it
1207c478bd9Sstevel@tonic-gate * completing will cause the next request to be attracted.
1217c478bd9Sstevel@tonic-gate */
1227c478bd9Sstevel@tonic-gate form_in_question = 0;
1237c478bd9Sstevel@tonic-gate queue_attract (pps, qchk_form, 1);
1247c478bd9Sstevel@tonic-gate }
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate dump_pstatus ();
1277c478bd9Sstevel@tonic-gate
1287c478bd9Sstevel@tonic-gate return;
1297c478bd9Sstevel@tonic-gate }
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate /**
1327c478bd9Sstevel@tonic-gate ** remount_pwheel() - MOUNT A PRINT-WHEEL WHERE ANOTHER WAS MOUNTED
1337c478bd9Sstevel@tonic-gate **/
1347c478bd9Sstevel@tonic-gate
1357c478bd9Sstevel@tonic-gate static void
remount_pwheel(register PSTATUS * pps,char * pwheel_name)1367c478bd9Sstevel@tonic-gate remount_pwheel(register PSTATUS *pps, char *pwheel_name)
1377c478bd9Sstevel@tonic-gate {
1387c478bd9Sstevel@tonic-gate PWSTATUS *ppws;
1397c478bd9Sstevel@tonic-gate
1407c478bd9Sstevel@tonic-gate if (SAME(pps->pwheel_name, pwheel_name))
1417c478bd9Sstevel@tonic-gate return; /* nothing to do */
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate /*
1447c478bd9Sstevel@tonic-gate * Unmount the old print wheel
1457c478bd9Sstevel@tonic-gate */
1467c478bd9Sstevel@tonic-gate if (pps->pwheel_name) {
1477c478bd9Sstevel@tonic-gate register PWSTATUS *Oppws = pps->pwheel;
1487c478bd9Sstevel@tonic-gate
1497c478bd9Sstevel@tonic-gate pps->pwheel = 0;
1507c478bd9Sstevel@tonic-gate if (Oppws)
1517c478bd9Sstevel@tonic-gate Oppws->mounted--;
1527c478bd9Sstevel@tonic-gate
1537c478bd9Sstevel@tonic-gate /*
1547c478bd9Sstevel@tonic-gate * Unmounting the print wheel may make some print
1557c478bd9Sstevel@tonic-gate * requests no longer printable, because they were
1567c478bd9Sstevel@tonic-gate * accepted only because the print wheel was already
1577c478bd9Sstevel@tonic-gate * mounted. Unmounting the print wheel will also force
1587c478bd9Sstevel@tonic-gate * some requests to another printer (where the print wheel
1597c478bd9Sstevel@tonic-gate * is mounted) so they can print.
1607c478bd9Sstevel@tonic-gate */
1617c478bd9Sstevel@tonic-gate pwheel_in_question = pps->pwheel_name;
1627c478bd9Sstevel@tonic-gate (void)queue_repel (pps, 0, qchk_pwheel);
1637c478bd9Sstevel@tonic-gate
1647c478bd9Sstevel@tonic-gate unload_str (&pps->pwheel_name);
1657c478bd9Sstevel@tonic-gate
1667c478bd9Sstevel@tonic-gate /*
1677c478bd9Sstevel@tonic-gate * Maybe an alert is due.
1687c478bd9Sstevel@tonic-gate */
1697c478bd9Sstevel@tonic-gate if (Oppws)
1707c478bd9Sstevel@tonic-gate check_pwheel_alert (Oppws, (PWHEEL *)0);
1717c478bd9Sstevel@tonic-gate }
1727c478bd9Sstevel@tonic-gate
1737c478bd9Sstevel@tonic-gate /*
1747c478bd9Sstevel@tonic-gate * Mount the new print wheel?
1757c478bd9Sstevel@tonic-gate */
1767c478bd9Sstevel@tonic-gate if (pwheel_name) {
1777c478bd9Sstevel@tonic-gate load_str (&pps->pwheel_name, pwheel_name);
1780a44ef6dSjacobs if (ppws = search_pwstatus(pwheel_name)) {
1797c478bd9Sstevel@tonic-gate pps->pwheel = ppws;
1807c478bd9Sstevel@tonic-gate ppws->mounted++;
1817c478bd9Sstevel@tonic-gate
1827c478bd9Sstevel@tonic-gate /*
1837c478bd9Sstevel@tonic-gate * Attract all requests needing this newly
1847c478bd9Sstevel@tonic-gate * mounted print wheel. This may cause some
1857c478bd9Sstevel@tonic-gate * unnecessary shuffling, but we have to ensure
1867c478bd9Sstevel@tonic-gate * requests aren't assigned to a printer without
1877c478bd9Sstevel@tonic-gate * the print-wheel mounted, so that the alert
1887c478bd9Sstevel@tonic-gate * check is correct.
1897c478bd9Sstevel@tonic-gate */
1907c478bd9Sstevel@tonic-gate if (ppws->requests) {
1917c478bd9Sstevel@tonic-gate pwheel_in_question = pwheel_name;
1927c478bd9Sstevel@tonic-gate queue_attract (pps, qchk_pwheel, 0);
1937c478bd9Sstevel@tonic-gate
1947c478bd9Sstevel@tonic-gate /*
1957c478bd9Sstevel@tonic-gate * Maybe an alert can be shut off.
1967c478bd9Sstevel@tonic-gate */
1977c478bd9Sstevel@tonic-gate check_pwheel_alert (ppws, (PWHEEL *)0);
1987c478bd9Sstevel@tonic-gate }
1997c478bd9Sstevel@tonic-gate
2007c478bd9Sstevel@tonic-gate } else {
2017c478bd9Sstevel@tonic-gate /*
2027c478bd9Sstevel@tonic-gate * Attract the first request that needs this newly
2037c478bd9Sstevel@tonic-gate * mounted print wheel. If no alert has been
2047c478bd9Sstevel@tonic-gate * defined for the print wheel, we don't know how
2057c478bd9Sstevel@tonic-gate * many requests are queued waiting for it, so we
2067c478bd9Sstevel@tonic-gate * have to do this unconditionally.
2077c478bd9Sstevel@tonic-gate */
2087c478bd9Sstevel@tonic-gate pwheel_in_question = pwheel_name;
2097c478bd9Sstevel@tonic-gate queue_attract (pps, qchk_pwheel, 1);
2107c478bd9Sstevel@tonic-gate }
2117c478bd9Sstevel@tonic-gate
2127c478bd9Sstevel@tonic-gate } else {
2137c478bd9Sstevel@tonic-gate /*
2147c478bd9Sstevel@tonic-gate * Attract the first request that doesn't need a
2157c478bd9Sstevel@tonic-gate * print wheel mounted.
2167c478bd9Sstevel@tonic-gate * We only need to get one request printing, because it
2177c478bd9Sstevel@tonic-gate * completing will cause the next request to be attracted.
2187c478bd9Sstevel@tonic-gate */
2197c478bd9Sstevel@tonic-gate pwheel_in_question = 0;
2207c478bd9Sstevel@tonic-gate queue_attract (pps, qchk_pwheel, 1);
2217c478bd9Sstevel@tonic-gate }
2227c478bd9Sstevel@tonic-gate
2237c478bd9Sstevel@tonic-gate dump_pstatus ();
2247c478bd9Sstevel@tonic-gate
2257c478bd9Sstevel@tonic-gate return;
2267c478bd9Sstevel@tonic-gate }
2277c478bd9Sstevel@tonic-gate
2287c478bd9Sstevel@tonic-gate #define MAX_TRAYS 100
2297c478bd9Sstevel@tonic-gate
2307c478bd9Sstevel@tonic-gate /**
2317c478bd9Sstevel@tonic-gate ** s_max_trays()
2327c478bd9Sstevel@tonic-gate **/
2337c478bd9Sstevel@tonic-gate
2347c478bd9Sstevel@tonic-gate void
s_max_trays(char * m,MESG * md)2357c478bd9Sstevel@tonic-gate s_max_trays(char *m, MESG *md)
2367c478bd9Sstevel@tonic-gate {
2377c478bd9Sstevel@tonic-gate char *printer;
2387c478bd9Sstevel@tonic-gate ushort status;
2397c478bd9Sstevel@tonic-gate short numTrays;
2407c478bd9Sstevel@tonic-gate register PSTATUS *pps;
2417c478bd9Sstevel@tonic-gate register PFSTATUS *ppfs;
2427c478bd9Sstevel@tonic-gate
2437c478bd9Sstevel@tonic-gate (void) getmessage(m, S_MAX_TRAYS, &printer, &numTrays);
2447c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_max_trays(%s, %d)", (printer ? printer : "NULL"),
2457c478bd9Sstevel@tonic-gate numTrays);
2467c478bd9Sstevel@tonic-gate
2477c478bd9Sstevel@tonic-gate /* Have we seen this printer before? */
2480a44ef6dSjacobs if (!*printer || !(pps = search_pstatus(printer)))
2497c478bd9Sstevel@tonic-gate status = MNODEST;
2507c478bd9Sstevel@tonic-gate
2517c478bd9Sstevel@tonic-gate /* How about the tray? */
2527c478bd9Sstevel@tonic-gate else if ((numTrays <=0) || (numTrays > MAX_TRAYS))
2537c478bd9Sstevel@tonic-gate status = MNOTRAY;
2547c478bd9Sstevel@tonic-gate
2557c478bd9Sstevel@tonic-gate /* If the printer is currently printing, we can't disturb it. */
2567c478bd9Sstevel@tonic-gate else if (pps->request)
2577c478bd9Sstevel@tonic-gate status = MBUSY;
2587c478bd9Sstevel@tonic-gate
2597c478bd9Sstevel@tonic-gate else if (pps->forms) {
2607c478bd9Sstevel@tonic-gate if (!(ppfs = Realloc(pps->forms,numTrays * sizeof(PFSTATUS))))
2617c478bd9Sstevel@tonic-gate status = MNOMEM;
2627c478bd9Sstevel@tonic-gate else {
2637c478bd9Sstevel@tonic-gate int i;
2647c478bd9Sstevel@tonic-gate
2657c478bd9Sstevel@tonic-gate for (i = pps->numForms; i < numTrays; i++) {
2667c478bd9Sstevel@tonic-gate ppfs[i].form = NULL;
267bfe4ed66Ssonam gupta - Sun Microsystems - Bangalore India ppfs[i].isAvailable = 1;
2687c478bd9Sstevel@tonic-gate }
2697c478bd9Sstevel@tonic-gate pps->forms = ppfs;
2707c478bd9Sstevel@tonic-gate pps->numForms = numTrays;
2717c478bd9Sstevel@tonic-gate status = MOK;
2727c478bd9Sstevel@tonic-gate }
2737c478bd9Sstevel@tonic-gate } else if (!(ppfs = Calloc(numTrays,sizeof(PFSTATUS)))) {
2747c478bd9Sstevel@tonic-gate status = MNOMEM;
2757c478bd9Sstevel@tonic-gate } else {
2767c478bd9Sstevel@tonic-gate pps->forms = ppfs;
2777c478bd9Sstevel@tonic-gate pps->numForms = numTrays;
2787c478bd9Sstevel@tonic-gate status = MOK;
2797c478bd9Sstevel@tonic-gate }
2807c478bd9Sstevel@tonic-gate dump_pstatus();
2817c478bd9Sstevel@tonic-gate mputm(md, R_MAX_TRAYS, status);
2827c478bd9Sstevel@tonic-gate }
2837c478bd9Sstevel@tonic-gate
2847c478bd9Sstevel@tonic-gate /**
2857c478bd9Sstevel@tonic-gate ** s_mount()
2867c478bd9Sstevel@tonic-gate **/
2877c478bd9Sstevel@tonic-gate
2887c478bd9Sstevel@tonic-gate void
s_mount(char * m,MESG * md)2897c478bd9Sstevel@tonic-gate s_mount(char *m, MESG *md)
2907c478bd9Sstevel@tonic-gate {
2917c478bd9Sstevel@tonic-gate char *printer, *form, *pwheel_name;
2927c478bd9Sstevel@tonic-gate ushort status;
2937c478bd9Sstevel@tonic-gate register PSTATUS *pps;
2947c478bd9Sstevel@tonic-gate register FSTATUS *pfs;
2957c478bd9Sstevel@tonic-gate
2967c478bd9Sstevel@tonic-gate (void) getmessage(m, S_MOUNT, &printer, &form, &pwheel_name);
2977c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_mount(%s, %s, %s)", (printer ? printer : "NULL"),
2987c478bd9Sstevel@tonic-gate (form ? form : "NULL"), (pwheel_name ? pwheel_name : "NULL"));
2997c478bd9Sstevel@tonic-gate
3007c478bd9Sstevel@tonic-gate if (!*form && !*pwheel_name)
3017c478bd9Sstevel@tonic-gate status = MNOMEDIA;
3027c478bd9Sstevel@tonic-gate
3037c478bd9Sstevel@tonic-gate /* Have we seen this printer before? */
3040a44ef6dSjacobs else if (!*printer || !(pps = search_pstatus(printer)))
3057c478bd9Sstevel@tonic-gate status = MNODEST;
3067c478bd9Sstevel@tonic-gate
3077c478bd9Sstevel@tonic-gate /* How about the form? */
3080a44ef6dSjacobs else if (*form && !(pfs = search_fstatus(form)))
3097c478bd9Sstevel@tonic-gate status = MNOMEDIA;
3107c478bd9Sstevel@tonic-gate
3117c478bd9Sstevel@tonic-gate /* If the printer is currently printing, we can't disturb it. */
3127c478bd9Sstevel@tonic-gate else if (pps->request)
3137c478bd9Sstevel@tonic-gate status = MBUSY;
3147c478bd9Sstevel@tonic-gate
3157c478bd9Sstevel@tonic-gate else {
3167c478bd9Sstevel@tonic-gate /*
3177c478bd9Sstevel@tonic-gate * Mount them.
3187c478bd9Sstevel@tonic-gate */
3197c478bd9Sstevel@tonic-gate if (*form)
3207c478bd9Sstevel@tonic-gate remount_form (pps, pfs,1);
3217c478bd9Sstevel@tonic-gate if (*pwheel_name)
3227c478bd9Sstevel@tonic-gate remount_pwheel(pps, pwheel_name);
3237c478bd9Sstevel@tonic-gate
3247c478bd9Sstevel@tonic-gate status = MOK;
3257c478bd9Sstevel@tonic-gate }
3267c478bd9Sstevel@tonic-gate
3277c478bd9Sstevel@tonic-gate mputm(md, R_MOUNT, status);
3287c478bd9Sstevel@tonic-gate }
3297c478bd9Sstevel@tonic-gate
3307c478bd9Sstevel@tonic-gate /*
3317c478bd9Sstevel@tonic-gate * s_mount_tray()
3327c478bd9Sstevel@tonic-gate */
3337c478bd9Sstevel@tonic-gate
3347c478bd9Sstevel@tonic-gate void
s_mount_tray(char * m,MESG * md)3357c478bd9Sstevel@tonic-gate s_mount_tray(char *m, MESG *md)
3367c478bd9Sstevel@tonic-gate {
3377c478bd9Sstevel@tonic-gate char *printer, *form, *pwheel_name;
3387c478bd9Sstevel@tonic-gate ushort status;
3397c478bd9Sstevel@tonic-gate short trayNum;
3407c478bd9Sstevel@tonic-gate register PSTATUS *pps;
3417c478bd9Sstevel@tonic-gate register FSTATUS *pfs;
3427c478bd9Sstevel@tonic-gate
3437c478bd9Sstevel@tonic-gate (void) getmessage(m, S_MOUNT_TRAY, &printer, &form, &pwheel_name,
3447c478bd9Sstevel@tonic-gate &trayNum);
3457c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_mount_tray(%s, %s, %s, %d)",
3467c478bd9Sstevel@tonic-gate (printer ? printer : "NULL"), (form ? form : "NULL"),
3477c478bd9Sstevel@tonic-gate (pwheel_name ? pwheel_name : "NULL"), trayNum);
3487c478bd9Sstevel@tonic-gate
3497c478bd9Sstevel@tonic-gate if (!*form && !*pwheel_name)
3507c478bd9Sstevel@tonic-gate status = MNOMEDIA;
3517c478bd9Sstevel@tonic-gate
3527c478bd9Sstevel@tonic-gate /* Have we seen this printer before? */
3530a44ef6dSjacobs else if (!*printer || !(pps = search_pstatus(printer)))
3547c478bd9Sstevel@tonic-gate status = MNODEST;
3557c478bd9Sstevel@tonic-gate
3567c478bd9Sstevel@tonic-gate /* How about the form? */
3570a44ef6dSjacobs else if (*form && !(pfs = search_fstatus(form)))
3587c478bd9Sstevel@tonic-gate status = MNOMEDIA;
3597c478bd9Sstevel@tonic-gate
3607c478bd9Sstevel@tonic-gate /* How about the tray? */
3617c478bd9Sstevel@tonic-gate else if ((trayNum <=0) || (trayNum > pps->numForms))
3627c478bd9Sstevel@tonic-gate status = MNOTRAY;
3637c478bd9Sstevel@tonic-gate
3647c478bd9Sstevel@tonic-gate /* If the printer is currently printing, we can't disturb it. */
3657c478bd9Sstevel@tonic-gate else if (pps->request)
3667c478bd9Sstevel@tonic-gate status = MBUSY;
3677c478bd9Sstevel@tonic-gate
3687c478bd9Sstevel@tonic-gate else {
3697c478bd9Sstevel@tonic-gate /*
3707c478bd9Sstevel@tonic-gate * Mount them.
3717c478bd9Sstevel@tonic-gate */
3727c478bd9Sstevel@tonic-gate if (*form)
3737c478bd9Sstevel@tonic-gate remount_form(pps, pfs,trayNum);
3747c478bd9Sstevel@tonic-gate if (*pwheel_name)
3757c478bd9Sstevel@tonic-gate remount_pwheel(pps, pwheel_name);
3767c478bd9Sstevel@tonic-gate
3777c478bd9Sstevel@tonic-gate status = MOK;
3787c478bd9Sstevel@tonic-gate }
3797c478bd9Sstevel@tonic-gate
3807c478bd9Sstevel@tonic-gate mputm (md, R_MOUNT_TRAY, status);
3817c478bd9Sstevel@tonic-gate }
3827c478bd9Sstevel@tonic-gate
3837c478bd9Sstevel@tonic-gate /**
3847c478bd9Sstevel@tonic-gate ** s_unmount()
3857c478bd9Sstevel@tonic-gate **/
3867c478bd9Sstevel@tonic-gate
3877c478bd9Sstevel@tonic-gate void
s_unmount(char * m,MESG * md)3887c478bd9Sstevel@tonic-gate s_unmount(char *m, MESG *md)
3897c478bd9Sstevel@tonic-gate {
3907c478bd9Sstevel@tonic-gate char *printer,
3917c478bd9Sstevel@tonic-gate *form,
3927c478bd9Sstevel@tonic-gate *pwheel_name;
3937c478bd9Sstevel@tonic-gate ushort status;
3947c478bd9Sstevel@tonic-gate register PSTATUS *pps;
3957c478bd9Sstevel@tonic-gate
3967c478bd9Sstevel@tonic-gate (void)getmessage (m, S_UNMOUNT, &printer, &form, &pwheel_name);
3977c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_unmount(%s, %s, %s)",
3987c478bd9Sstevel@tonic-gate (printer ? printer : "NULL"), (form ? form : "NULL"),
3997c478bd9Sstevel@tonic-gate (pwheel_name ? pwheel_name : "NULL"));
4007c478bd9Sstevel@tonic-gate
4017c478bd9Sstevel@tonic-gate if (!*form && !*pwheel_name)
4027c478bd9Sstevel@tonic-gate status = MNOMEDIA;
4037c478bd9Sstevel@tonic-gate
4047c478bd9Sstevel@tonic-gate /*
4057c478bd9Sstevel@tonic-gate * Have we seen this printer before?
4067c478bd9Sstevel@tonic-gate */
4070a44ef6dSjacobs else if (!*printer || !(pps = search_pstatus(printer)))
4087c478bd9Sstevel@tonic-gate status = MNODEST;
4097c478bd9Sstevel@tonic-gate
4107c478bd9Sstevel@tonic-gate
4117c478bd9Sstevel@tonic-gate /*
4127c478bd9Sstevel@tonic-gate * If the printer is currently printing a request,
4137c478bd9Sstevel@tonic-gate * we can't unmount the current form/pwheel.
4147c478bd9Sstevel@tonic-gate */
4157c478bd9Sstevel@tonic-gate else if (pps->request)
4167c478bd9Sstevel@tonic-gate status = MBUSY;
4177c478bd9Sstevel@tonic-gate
4187c478bd9Sstevel@tonic-gate else {
4197c478bd9Sstevel@tonic-gate /*
4207c478bd9Sstevel@tonic-gate * Unmount them.
4217c478bd9Sstevel@tonic-gate */
4227c478bd9Sstevel@tonic-gate if (*form)
4237c478bd9Sstevel@tonic-gate remount_form (pps, (FSTATUS *)0,1);
4247c478bd9Sstevel@tonic-gate if (*pwheel_name)
4257c478bd9Sstevel@tonic-gate remount_pwheel (pps, (char *)0);
4267c478bd9Sstevel@tonic-gate
4277c478bd9Sstevel@tonic-gate status = MOK;
4287c478bd9Sstevel@tonic-gate }
4297c478bd9Sstevel@tonic-gate
4307c478bd9Sstevel@tonic-gate mputm (md, R_UNMOUNT, status);
4317c478bd9Sstevel@tonic-gate return;
4327c478bd9Sstevel@tonic-gate }
4337c478bd9Sstevel@tonic-gate /**
4347c478bd9Sstevel@tonic-gate ** s_unmount_tray()
4357c478bd9Sstevel@tonic-gate **/
4367c478bd9Sstevel@tonic-gate
4377c478bd9Sstevel@tonic-gate void
s_unmount_tray(char * m,MESG * md)4387c478bd9Sstevel@tonic-gate s_unmount_tray(char *m, MESG *md)
4397c478bd9Sstevel@tonic-gate {
4407c478bd9Sstevel@tonic-gate char *printer,
4417c478bd9Sstevel@tonic-gate *form,
4427c478bd9Sstevel@tonic-gate *pwheel_name;
4437c478bd9Sstevel@tonic-gate
4447c478bd9Sstevel@tonic-gate ushort status;
4457c478bd9Sstevel@tonic-gate short trayNum;
4467c478bd9Sstevel@tonic-gate
4477c478bd9Sstevel@tonic-gate register PSTATUS *pps;
4487c478bd9Sstevel@tonic-gate
4497c478bd9Sstevel@tonic-gate (void)getmessage (m, S_UNMOUNT_TRAY, &printer, &form, &pwheel_name,
4507c478bd9Sstevel@tonic-gate &trayNum);
4517c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_unmount_tray(%s, %s, %s, %d)",
4527c478bd9Sstevel@tonic-gate (printer ? printer : "NULL"), (form ? form : "NULL"),
4537c478bd9Sstevel@tonic-gate (pwheel_name ? pwheel_name : "NULL"), trayNum);
4547c478bd9Sstevel@tonic-gate
4557c478bd9Sstevel@tonic-gate
4567c478bd9Sstevel@tonic-gate if (!*form && !*pwheel_name)
4577c478bd9Sstevel@tonic-gate status = MNOMEDIA;
4587c478bd9Sstevel@tonic-gate
4590a44ef6dSjacobs else if (!*printer || !(pps = search_pstatus(printer)))
4607c478bd9Sstevel@tonic-gate /* haven't seen this printer before */
4617c478bd9Sstevel@tonic-gate status = MNODEST;
4627c478bd9Sstevel@tonic-gate else if ((trayNum <=0) || (trayNum > pps->numForms))
4637c478bd9Sstevel@tonic-gate /* haven't seen the tray before */
4647c478bd9Sstevel@tonic-gate status = MNOTRAY;
4657c478bd9Sstevel@tonic-gate else if (pps->request)
4667c478bd9Sstevel@tonic-gate /* is the printer busy */
4677c478bd9Sstevel@tonic-gate status = MBUSY;
4687c478bd9Sstevel@tonic-gate else {
4697c478bd9Sstevel@tonic-gate /* Unmount them. */
4707c478bd9Sstevel@tonic-gate if (*form)
4717c478bd9Sstevel@tonic-gate remount_form (pps, (FSTATUS *)0,trayNum);
4727c478bd9Sstevel@tonic-gate if (*pwheel_name)
4737c478bd9Sstevel@tonic-gate remount_pwheel (pps, (char *)0);
4747c478bd9Sstevel@tonic-gate
4757c478bd9Sstevel@tonic-gate status = MOK;
4767c478bd9Sstevel@tonic-gate }
4777c478bd9Sstevel@tonic-gate
4787c478bd9Sstevel@tonic-gate mputm (md, R_UNMOUNT_TRAY, status);
4797c478bd9Sstevel@tonic-gate return;
4807c478bd9Sstevel@tonic-gate }
4817c478bd9Sstevel@tonic-gate
4827c478bd9Sstevel@tonic-gate /**
4837c478bd9Sstevel@tonic-gate ** s_load_form()
4847c478bd9Sstevel@tonic-gate **/
4857c478bd9Sstevel@tonic-gate
4867c478bd9Sstevel@tonic-gate void
s_load_form(char * m,MESG * md)4877c478bd9Sstevel@tonic-gate s_load_form(char *m, MESG *md)
4887c478bd9Sstevel@tonic-gate {
4897c478bd9Sstevel@tonic-gate char *form;
4907c478bd9Sstevel@tonic-gate ushort status;
4917c478bd9Sstevel@tonic-gate register _FORM *pf;
4927c478bd9Sstevel@tonic-gate register FSTATUS *pfs;
4937c478bd9Sstevel@tonic-gate
4947c478bd9Sstevel@tonic-gate (void)getmessage (m, S_LOAD_FORM, &form);
4957c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_load_form(%s)", (form ? form : "NULL"));
4967c478bd9Sstevel@tonic-gate
4977c478bd9Sstevel@tonic-gate if (!*form)
4987c478bd9Sstevel@tonic-gate /* no form specified */
4997c478bd9Sstevel@tonic-gate status = MNODEST;
5007c478bd9Sstevel@tonic-gate else if (!(pf = Getform(form))) {
5017c478bd9Sstevel@tonic-gate /* strange or missing form */
5027c478bd9Sstevel@tonic-gate switch (errno) {
5037c478bd9Sstevel@tonic-gate case EBADF:
5047c478bd9Sstevel@tonic-gate status = MERRDEST;
5057c478bd9Sstevel@tonic-gate break;
5067c478bd9Sstevel@tonic-gate case ENOENT:
5077c478bd9Sstevel@tonic-gate default:
5087c478bd9Sstevel@tonic-gate status = MNODEST;
5097c478bd9Sstevel@tonic-gate break;
5107c478bd9Sstevel@tonic-gate }
5117c478bd9Sstevel@tonic-gate
5120a44ef6dSjacobs } else if ((pfs = search_fstatus(form))) {
5137c478bd9Sstevel@tonic-gate /* Have we seen this form before? */
5147c478bd9Sstevel@tonic-gate unload_list (&pfs->users_allowed);
5157c478bd9Sstevel@tonic-gate unload_list (&pfs->users_denied);
5167c478bd9Sstevel@tonic-gate load_userform_access (
5177c478bd9Sstevel@tonic-gate pf->name,
5187c478bd9Sstevel@tonic-gate &pfs->users_allowed,
5197c478bd9Sstevel@tonic-gate &pfs->users_denied
5207c478bd9Sstevel@tonic-gate );
5217c478bd9Sstevel@tonic-gate
5227c478bd9Sstevel@tonic-gate load_sdn (&pfs->cpi, pf->cpi);
5237c478bd9Sstevel@tonic-gate load_sdn (&pfs->lpi, pf->lpi);
5247c478bd9Sstevel@tonic-gate load_sdn (&pfs->plen, pf->plen);
5257c478bd9Sstevel@tonic-gate load_sdn (&pfs->pwid, pf->pwid);
5267c478bd9Sstevel@tonic-gate
5277c478bd9Sstevel@tonic-gate
5287c478bd9Sstevel@tonic-gate /*
5297c478bd9Sstevel@tonic-gate * These have to be done in the order shown,
5307c478bd9Sstevel@tonic-gate * and after the assignments above, so that all
5317c478bd9Sstevel@tonic-gate * the new information is in place for the
5327c478bd9Sstevel@tonic-gate * checks. An unfortunate side effect is that
5337c478bd9Sstevel@tonic-gate * it is possible for the alert to shut off
5347c478bd9Sstevel@tonic-gate * and then come on again, if (1) enough requests
5357c478bd9Sstevel@tonic-gate * are canceled to drop the level below the old
5367c478bd9Sstevel@tonic-gate * alert threshold, but (2) the new alert threshold
5377c478bd9Sstevel@tonic-gate * is even lower. The final alert will be correct,
5387c478bd9Sstevel@tonic-gate * though.
5397c478bd9Sstevel@tonic-gate */
5407c478bd9Sstevel@tonic-gate
5417c478bd9Sstevel@tonic-gate form_in_question = pfs;
5427c478bd9Sstevel@tonic-gate queue_check (qchk_form);
5437c478bd9Sstevel@tonic-gate
5447c478bd9Sstevel@tonic-gate check_form_alert (pfs, pf);
5457c478bd9Sstevel@tonic-gate
5467c478bd9Sstevel@tonic-gate
5477c478bd9Sstevel@tonic-gate status = MOK;
5487c478bd9Sstevel@tonic-gate
5497c478bd9Sstevel@tonic-gate /*
5507c478bd9Sstevel@tonic-gate * Room for a new form?
5517c478bd9Sstevel@tonic-gate */
5520a44ef6dSjacobs } else if ((pfs = new_fstatus(pf))) {
5537c478bd9Sstevel@tonic-gate /*
5547c478bd9Sstevel@tonic-gate * No alert is possible for a new form, of course,
5557c478bd9Sstevel@tonic-gate * but this routine does a bit more than just check
5567c478bd9Sstevel@tonic-gate * the alert.
5577c478bd9Sstevel@tonic-gate */
5587c478bd9Sstevel@tonic-gate check_form_alert (pfs, pf);
5597c478bd9Sstevel@tonic-gate status = MOK;
5607c478bd9Sstevel@tonic-gate } else {
5617c478bd9Sstevel@tonic-gate free_form (pf);
5627c478bd9Sstevel@tonic-gate status = MNOSPACE;
5637c478bd9Sstevel@tonic-gate }
5647c478bd9Sstevel@tonic-gate
5657c478bd9Sstevel@tonic-gate mputm (md, R_LOAD_FORM, status);
5667c478bd9Sstevel@tonic-gate return;
5677c478bd9Sstevel@tonic-gate }
5687c478bd9Sstevel@tonic-gate
5697c478bd9Sstevel@tonic-gate /**
5707c478bd9Sstevel@tonic-gate ** s_unload_form()
5717c478bd9Sstevel@tonic-gate **/
5727c478bd9Sstevel@tonic-gate
5737c478bd9Sstevel@tonic-gate static void
_unload_form(register FSTATUS * pfs)5747c478bd9Sstevel@tonic-gate _unload_form(register FSTATUS *pfs)
5757c478bd9Sstevel@tonic-gate {
5767c478bd9Sstevel@tonic-gate int i;
5777c478bd9Sstevel@tonic-gate short numForms;
5787c478bd9Sstevel@tonic-gate PFSTATUS *ppfs;
5797c478bd9Sstevel@tonic-gate
5807c478bd9Sstevel@tonic-gate /*
5817c478bd9Sstevel@tonic-gate * Unmount this form everywhere and get rid of it.
5827c478bd9Sstevel@tonic-gate */
5830a44ef6dSjacobs for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++)
5840a44ef6dSjacobs if (((ppfs = PStatus[i]->forms) != NULL) &&
5850a44ef6dSjacobs ((numForms = PStatus[i]->numForms) > 0)) {
5860a44ef6dSjacobs int j;
5870a44ef6dSjacobs for ( j = 0 ; j < numForms ; j++ )
5880a44ef6dSjacobs if (ppfs[j].form == pfs) ppfs[j].form= NULL;
5890a44ef6dSjacobs }
5907c478bd9Sstevel@tonic-gate
5917c478bd9Sstevel@tonic-gate return;
5927c478bd9Sstevel@tonic-gate }
5937c478bd9Sstevel@tonic-gate
5947c478bd9Sstevel@tonic-gate void
s_unload_form(char * m,MESG * md)5957c478bd9Sstevel@tonic-gate s_unload_form(char *m, MESG *md)
5967c478bd9Sstevel@tonic-gate {
5977c478bd9Sstevel@tonic-gate char *form;
5987c478bd9Sstevel@tonic-gate ushort status;
5997c478bd9Sstevel@tonic-gate RSTATUS *prs;
6007c478bd9Sstevel@tonic-gate register FSTATUS *pfs;
6017c478bd9Sstevel@tonic-gate
6027c478bd9Sstevel@tonic-gate (void)getmessage (m, S_UNLOAD_FORM, &form);
6037c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_unload_form(%s)", (form ? form : "NULL"));
6047c478bd9Sstevel@tonic-gate
6057c478bd9Sstevel@tonic-gate if (!*form || STREQU(form, NAME_ALL)) {
6060a44ef6dSjacobs int i;
6077c478bd9Sstevel@tonic-gate /* If we have a request queued for ANY form, we can't do it. */
6087c478bd9Sstevel@tonic-gate status = MOK;
6090a44ef6dSjacobs for (i = 0; FStatus != NULL && FStatus[i] != NULL &&
6100a44ef6dSjacobs status == MOK; i++) {
6110a44ef6dSjacobs for (prs = Request_List; prs != NULL; prs = prs->next)
6120a44ef6dSjacobs if (prs->form == FStatus[i]) {
6130a44ef6dSjacobs status = MBUSY;
6140a44ef6dSjacobs break;
6150a44ef6dSjacobs }
6160a44ef6dSjacobs }
6177c478bd9Sstevel@tonic-gate
6180a44ef6dSjacobs if (status == MOK) {
6190a44ef6dSjacobs for (i = 0; FStatus != NULL && FStatus[i] != NULL; i++)
6200a44ef6dSjacobs _unload_form (FStatus[i]);
6210a44ef6dSjacobs free(FStatus);
6220a44ef6dSjacobs FStatus = NULL;
6230a44ef6dSjacobs }
624*55fea89dSDan Cross
6250a44ef6dSjacobs } else if (!*form || !(pfs = search_fstatus(form)))
6267c478bd9Sstevel@tonic-gate /* Have we seen this form before? */
6277c478bd9Sstevel@tonic-gate status = MNODEST;
6287c478bd9Sstevel@tonic-gate else {
6297c478bd9Sstevel@tonic-gate /* Is there even one request waiting for this form? */
6307c478bd9Sstevel@tonic-gate status = MOK;
6310a44ef6dSjacobs for (prs = Request_List; prs != NULL; prs = prs->next)
6320a44ef6dSjacobs if (prs->form == pfs) {
6330a44ef6dSjacobs status = MBUSY;
6340a44ef6dSjacobs break;
6350a44ef6dSjacobs }
6360a44ef6dSjacobs
6370a44ef6dSjacobs if (status == MOK) {
6387c478bd9Sstevel@tonic-gate _unload_form (pfs);
6390a44ef6dSjacobs list_remove((void ***)&FStatus, (void *)pfs);
6400a44ef6dSjacobs }
6417c478bd9Sstevel@tonic-gate }
6427c478bd9Sstevel@tonic-gate
6437c478bd9Sstevel@tonic-gate mputm (md, R_UNLOAD_FORM, status);
6447c478bd9Sstevel@tonic-gate return;
6457c478bd9Sstevel@tonic-gate }
6467c478bd9Sstevel@tonic-gate
6477c478bd9Sstevel@tonic-gate /**
6487c478bd9Sstevel@tonic-gate ** s_load_printwheel()
6497c478bd9Sstevel@tonic-gate **/
6507c478bd9Sstevel@tonic-gate
6517c478bd9Sstevel@tonic-gate void
s_load_printwheel(char * m,MESG * md)6527c478bd9Sstevel@tonic-gate s_load_printwheel(char *m, MESG *md)
6537c478bd9Sstevel@tonic-gate {
6547c478bd9Sstevel@tonic-gate char *pwheel_name;
6557c478bd9Sstevel@tonic-gate ushort status;
6567c478bd9Sstevel@tonic-gate register PWHEEL *ppw;
6577c478bd9Sstevel@tonic-gate register PWSTATUS *ppws;
6587c478bd9Sstevel@tonic-gate
6597c478bd9Sstevel@tonic-gate (void)getmessage (m, S_LOAD_PRINTWHEEL, &pwheel_name);
6607c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_load_printwheel(%s)",
6617c478bd9Sstevel@tonic-gate (pwheel_name ? pwheel_name : "NULL"));
6627c478bd9Sstevel@tonic-gate
6637c478bd9Sstevel@tonic-gate if (!*pwheel_name)
6647c478bd9Sstevel@tonic-gate /* no printwheel specified */
6657c478bd9Sstevel@tonic-gate status = MNODEST;
6667c478bd9Sstevel@tonic-gate else if (!(ppw = Getpwheel(pwheel_name))) {
6677c478bd9Sstevel@tonic-gate /* Strange or missing print wheel? */
6687c478bd9Sstevel@tonic-gate switch (errno) {
6697c478bd9Sstevel@tonic-gate case EBADF:
6707c478bd9Sstevel@tonic-gate status = MERRDEST;
6717c478bd9Sstevel@tonic-gate break;
6727c478bd9Sstevel@tonic-gate case ENOENT:
6737c478bd9Sstevel@tonic-gate default:
6747c478bd9Sstevel@tonic-gate status = MNODEST;
6757c478bd9Sstevel@tonic-gate break;
6767c478bd9Sstevel@tonic-gate }
6770a44ef6dSjacobs } else if ((ppws = search_pwstatus(pwheel_name))) {
6787c478bd9Sstevel@tonic-gate /* Print wheel we already know about? */
6797c478bd9Sstevel@tonic-gate check_pwheel_alert (ppws, ppw);
6807c478bd9Sstevel@tonic-gate status = MOK;
6810a44ef6dSjacobs } else if ((ppws = new_pwstatus(ppw))) {
6827c478bd9Sstevel@tonic-gate /* Room for a new print wheel? */
6830a44ef6dSjacobs register RSTATUS *prs;
6847c478bd9Sstevel@tonic-gate
6857c478bd9Sstevel@tonic-gate /*
6867c478bd9Sstevel@tonic-gate * Because of the quirky nature of the print wheel
6877c478bd9Sstevel@tonic-gate * structures, i.e. no structure unless an alert has
6887c478bd9Sstevel@tonic-gate * been defined, we have to run through the requests
6897c478bd9Sstevel@tonic-gate * and see which ones are waiting for this print wheel,
6907c478bd9Sstevel@tonic-gate * so we can assign alerts and count pending requests.
6917c478bd9Sstevel@tonic-gate */
6920a44ef6dSjacobs for (prs = Request_List; prs != NULL; prs = prs->next)
6930a44ef6dSjacobs if ((prs->pwheel_name == pwheel_name) &&
6940a44ef6dSjacobs (!one_printer_with_charsets(prs))) {
6957c478bd9Sstevel@tonic-gate prs->pwheel = ppws;
6967c478bd9Sstevel@tonic-gate ppws->requests++;
6977c478bd9Sstevel@tonic-gate }
6987c478bd9Sstevel@tonic-gate check_pwheel_alert (ppws, ppw);
6997c478bd9Sstevel@tonic-gate
7007c478bd9Sstevel@tonic-gate status = MOK;
7017c478bd9Sstevel@tonic-gate } else {
7027c478bd9Sstevel@tonic-gate freepwheel (ppw);
7037c478bd9Sstevel@tonic-gate status = MNOSPACE;
7047c478bd9Sstevel@tonic-gate }
7057c478bd9Sstevel@tonic-gate
7067c478bd9Sstevel@tonic-gate mputm (md, R_LOAD_PRINTWHEEL, status);
7077c478bd9Sstevel@tonic-gate return;
7087c478bd9Sstevel@tonic-gate }
7097c478bd9Sstevel@tonic-gate
7107c478bd9Sstevel@tonic-gate /**
7117c478bd9Sstevel@tonic-gate ** s_unload_printwheel()
7127c478bd9Sstevel@tonic-gate **/
7137c478bd9Sstevel@tonic-gate
7147c478bd9Sstevel@tonic-gate static void
_unload_pwheel(register PWSTATUS * ppws)7157c478bd9Sstevel@tonic-gate _unload_pwheel(register PWSTATUS *ppws)
7167c478bd9Sstevel@tonic-gate {
7170a44ef6dSjacobs register PSTATUS *pps;
7180a44ef6dSjacobs register RSTATUS *prs;
7190a44ef6dSjacobs int i;
7207c478bd9Sstevel@tonic-gate
7217c478bd9Sstevel@tonic-gate
7227c478bd9Sstevel@tonic-gate /*
7237c478bd9Sstevel@tonic-gate * ``Unmount'' the alert part of this print wheel everywhere.
7247c478bd9Sstevel@tonic-gate * THIS IS NOT A COMPLETE UNMOUNT, JUST THE ALERT STRUCTURE
7257c478bd9Sstevel@tonic-gate * IS REMOVED.
7267c478bd9Sstevel@tonic-gate */
7270a44ef6dSjacobs for (i = 0; PStatus != NULL && PStatus[i] != NULL; i++)
7280a44ef6dSjacobs if (PStatus[i]->pwheel == ppws)
7290a44ef6dSjacobs PStatus[i]->pwheel = 0;
7307c478bd9Sstevel@tonic-gate
7317c478bd9Sstevel@tonic-gate /*
7327c478bd9Sstevel@tonic-gate * Remove the alert part from all requests.
7337c478bd9Sstevel@tonic-gate */
7347c478bd9Sstevel@tonic-gate for (prs = Request_List; prs; prs = prs->next)
7357c478bd9Sstevel@tonic-gate if (prs->pwheel == ppws)
7367c478bd9Sstevel@tonic-gate prs->pwheel = 0;
7377c478bd9Sstevel@tonic-gate
7387c478bd9Sstevel@tonic-gate /*
7397c478bd9Sstevel@tonic-gate * Cancel any alert pending. Here we're different from the
740*55fea89dSDan Cross * similar code for unloading a form, because, to be able to
7417c478bd9Sstevel@tonic-gate * unload a form we first require NO requests pending. If no
7427c478bd9Sstevel@tonic-gate * requests are pending there should be no alert to cancel.
7437c478bd9Sstevel@tonic-gate * Print wheels, on the other hand, only exist as names and
7447c478bd9Sstevel@tonic-gate * alerts. We can always unload a ``print wheel'' because
7457c478bd9Sstevel@tonic-gate * all we're really unloading is an alert. Thus, there can
7467c478bd9Sstevel@tonic-gate * be requests queued for the print wheel (the name), and
7477c478bd9Sstevel@tonic-gate * thus there can be an alert running.
7487c478bd9Sstevel@tonic-gate */
7497c478bd9Sstevel@tonic-gate if (ppws->alert->active)
7507c478bd9Sstevel@tonic-gate cancel_alert (A_PWHEEL, ppws);
7517c478bd9Sstevel@tonic-gate
7520a44ef6dSjacobs free_pwstatus(ppws);
7537c478bd9Sstevel@tonic-gate
7547c478bd9Sstevel@tonic-gate return;
7557c478bd9Sstevel@tonic-gate }
7567c478bd9Sstevel@tonic-gate
7577c478bd9Sstevel@tonic-gate void
s_unload_printwheel(char * m,MESG * md)7587c478bd9Sstevel@tonic-gate s_unload_printwheel(char *m, MESG *md)
7597c478bd9Sstevel@tonic-gate {
7607c478bd9Sstevel@tonic-gate char *pwheel_name;
7617c478bd9Sstevel@tonic-gate
7627c478bd9Sstevel@tonic-gate ushort status;
7637c478bd9Sstevel@tonic-gate
7647c478bd9Sstevel@tonic-gate register PWSTATUS *ppws;
7657c478bd9Sstevel@tonic-gate
7667c478bd9Sstevel@tonic-gate
7677c478bd9Sstevel@tonic-gate /*
7687c478bd9Sstevel@tonic-gate * We don't care if any requests are waiting for the print
7697c478bd9Sstevel@tonic-gate * wheel(s)--what we're removing here is (are) just the alert(s)!
7707c478bd9Sstevel@tonic-gate */
7717c478bd9Sstevel@tonic-gate
7727c478bd9Sstevel@tonic-gate (void)getmessage (m, S_UNLOAD_PRINTWHEEL, &pwheel_name);
7737c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_unload_printwheel(%s)",
7747c478bd9Sstevel@tonic-gate (pwheel_name ? pwheel_name : "NULL"));
7757c478bd9Sstevel@tonic-gate
7767c478bd9Sstevel@tonic-gate
7777c478bd9Sstevel@tonic-gate /*
7787c478bd9Sstevel@tonic-gate * Remove all print wheel alerts?
7797c478bd9Sstevel@tonic-gate */
7807c478bd9Sstevel@tonic-gate if (!*pwheel_name || STREQU(pwheel_name, NAME_ALL)) {
7810a44ef6dSjacobs int i;
7820a44ef6dSjacobs
7830a44ef6dSjacobs for (i = 0; PWStatus != NULL && PWStatus[i] != NULL; i++)
7840a44ef6dSjacobs _unload_pwheel (PWStatus[i]);
7850a44ef6dSjacobs free(PWStatus);
7860a44ef6dSjacobs PWStatus = NULL;
7877c478bd9Sstevel@tonic-gate status = MOK;
7887c478bd9Sstevel@tonic-gate
7897c478bd9Sstevel@tonic-gate /*
7907c478bd9Sstevel@tonic-gate * Have we seen this print wheel before?
7917c478bd9Sstevel@tonic-gate */
7920a44ef6dSjacobs } else if (!(ppws = search_pwstatus(pwheel_name)))
7937c478bd9Sstevel@tonic-gate status = MNODEST;
7947c478bd9Sstevel@tonic-gate
7957c478bd9Sstevel@tonic-gate else {
7967c478bd9Sstevel@tonic-gate _unload_pwheel (ppws);
7970a44ef6dSjacobs list_remove((void ***)&PWStatus, (void *)ppws);
7987c478bd9Sstevel@tonic-gate status = MOK;
7997c478bd9Sstevel@tonic-gate
8007c478bd9Sstevel@tonic-gate }
8017c478bd9Sstevel@tonic-gate
8027c478bd9Sstevel@tonic-gate mputm (md, R_UNLOAD_PRINTWHEEL, status);
8037c478bd9Sstevel@tonic-gate return;
8047c478bd9Sstevel@tonic-gate }
805