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 */
217c478bd9Sstevel@tonic-gate /*
220a44ef6dSjacobs * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
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 "time.h"
317c478bd9Sstevel@tonic-gate #include "dispatch.h"
327c478bd9Sstevel@tonic-gate #include <syslog.h>
337c478bd9Sstevel@tonic-gate
347c478bd9Sstevel@tonic-gate
357c478bd9Sstevel@tonic-gate /**
367c478bd9Sstevel@tonic-gate ** s_accept_dest()
377c478bd9Sstevel@tonic-gate **/
387c478bd9Sstevel@tonic-gate
397c478bd9Sstevel@tonic-gate void
s_accept_dest(char * m,MESG * md)407c478bd9Sstevel@tonic-gate s_accept_dest(char *m, MESG *md)
417c478bd9Sstevel@tonic-gate {
427c478bd9Sstevel@tonic-gate char *destination;
437c478bd9Sstevel@tonic-gate ushort status;
447c478bd9Sstevel@tonic-gate register PSTATUS *pps;
45*19d32b9aSRobert Mustacchi register CLSTATUS *pcs;
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate getmessage (m, S_ACCEPT_DEST, &destination);
487c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_accept_dest(%s)",
497c478bd9Sstevel@tonic-gate (destination ? destination : "NULL"));
507c478bd9Sstevel@tonic-gate
517c478bd9Sstevel@tonic-gate /*
527c478bd9Sstevel@tonic-gate * Have we seen this destination as a printer?
537c478bd9Sstevel@tonic-gate */
540a44ef6dSjacobs if ((pps = search_pstatus(destination)))
557c478bd9Sstevel@tonic-gate if ((pps->status & PS_REJECTED) == 0)
567c478bd9Sstevel@tonic-gate status = MERRDEST;
577c478bd9Sstevel@tonic-gate else {
587c478bd9Sstevel@tonic-gate pps->status &= ~PS_REJECTED;
597c478bd9Sstevel@tonic-gate (void) time (&pps->rej_date);
607c478bd9Sstevel@tonic-gate dump_pstatus ();
617c478bd9Sstevel@tonic-gate status = MOK;
627c478bd9Sstevel@tonic-gate }
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gate /*
657c478bd9Sstevel@tonic-gate * Have we seen this destination as a class?
667c478bd9Sstevel@tonic-gate */
670a44ef6dSjacobs else if ((pcs = search_cstatus(destination)))
687c478bd9Sstevel@tonic-gate if ((pcs->status & CS_REJECTED) == 0)
697c478bd9Sstevel@tonic-gate status = MERRDEST;
707c478bd9Sstevel@tonic-gate else {
717c478bd9Sstevel@tonic-gate pcs->status &= ~CS_REJECTED;
727c478bd9Sstevel@tonic-gate (void) time (&pcs->rej_date);
737c478bd9Sstevel@tonic-gate dump_cstatus ();
747c478bd9Sstevel@tonic-gate status = MOK;
757c478bd9Sstevel@tonic-gate }
767c478bd9Sstevel@tonic-gate
777c478bd9Sstevel@tonic-gate else
787c478bd9Sstevel@tonic-gate status = MNODEST;
797c478bd9Sstevel@tonic-gate
807c478bd9Sstevel@tonic-gate mputm (md, R_ACCEPT_DEST, status);
817c478bd9Sstevel@tonic-gate return;
827c478bd9Sstevel@tonic-gate }
837c478bd9Sstevel@tonic-gate
847c478bd9Sstevel@tonic-gate /**
857c478bd9Sstevel@tonic-gate ** s_reject_dest()
867c478bd9Sstevel@tonic-gate **/
877c478bd9Sstevel@tonic-gate
887c478bd9Sstevel@tonic-gate void
s_reject_dest(char * m,MESG * md)897c478bd9Sstevel@tonic-gate s_reject_dest(char *m, MESG *md)
907c478bd9Sstevel@tonic-gate {
917c478bd9Sstevel@tonic-gate char *destination,
927c478bd9Sstevel@tonic-gate *reason;
937c478bd9Sstevel@tonic-gate ushort status;
947c478bd9Sstevel@tonic-gate register PSTATUS *pps;
95*19d32b9aSRobert Mustacchi register CLSTATUS *pcs;
967c478bd9Sstevel@tonic-gate
977c478bd9Sstevel@tonic-gate
987c478bd9Sstevel@tonic-gate getmessage (m, S_REJECT_DEST, &destination, &reason);
997c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_reject_dest(%s, %s)",
1007c478bd9Sstevel@tonic-gate (destination ? destination : "NULL"),
1017c478bd9Sstevel@tonic-gate (reason ? reason : "NULL"));
1027c478bd9Sstevel@tonic-gate
1037c478bd9Sstevel@tonic-gate /*
1047c478bd9Sstevel@tonic-gate * Have we seen this destination as a printer?
1057c478bd9Sstevel@tonic-gate */
1060a44ef6dSjacobs if ((pps = search_pstatus(destination)))
1077c478bd9Sstevel@tonic-gate if (pps->status & PS_REJECTED)
1087c478bd9Sstevel@tonic-gate status = MERRDEST;
1097c478bd9Sstevel@tonic-gate else {
1107c478bd9Sstevel@tonic-gate pps->status |= PS_REJECTED;
1117c478bd9Sstevel@tonic-gate (void) time (&pps->rej_date);
1127c478bd9Sstevel@tonic-gate load_str (&pps->rej_reason, reason);
1137c478bd9Sstevel@tonic-gate dump_pstatus ();
1147c478bd9Sstevel@tonic-gate status = MOK;
1157c478bd9Sstevel@tonic-gate }
1167c478bd9Sstevel@tonic-gate
1177c478bd9Sstevel@tonic-gate /*
1187c478bd9Sstevel@tonic-gate * Have we seen this destination as a class?
1197c478bd9Sstevel@tonic-gate */
1200a44ef6dSjacobs else if ((pcs = search_cstatus(destination)))
1217c478bd9Sstevel@tonic-gate if (pcs->status & CS_REJECTED)
1227c478bd9Sstevel@tonic-gate status = MERRDEST;
1237c478bd9Sstevel@tonic-gate else {
1247c478bd9Sstevel@tonic-gate pcs->status |= CS_REJECTED;
1257c478bd9Sstevel@tonic-gate (void) time (&pcs->rej_date);
1267c478bd9Sstevel@tonic-gate load_str (&pcs->rej_reason, reason);
1277c478bd9Sstevel@tonic-gate dump_cstatus ();
1287c478bd9Sstevel@tonic-gate status = MOK;
1297c478bd9Sstevel@tonic-gate }
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate else
1327c478bd9Sstevel@tonic-gate status = MNODEST;
1337c478bd9Sstevel@tonic-gate
1347c478bd9Sstevel@tonic-gate mputm (md, R_REJECT_DEST, status);
1357c478bd9Sstevel@tonic-gate return;
1367c478bd9Sstevel@tonic-gate }
1377c478bd9Sstevel@tonic-gate
1387c478bd9Sstevel@tonic-gate /**
1397c478bd9Sstevel@tonic-gate ** s_enable_dest()
1407c478bd9Sstevel@tonic-gate **/
1417c478bd9Sstevel@tonic-gate
1427c478bd9Sstevel@tonic-gate void
s_enable_dest(char * m,MESG * md)1437c478bd9Sstevel@tonic-gate s_enable_dest(char *m, MESG *md)
1447c478bd9Sstevel@tonic-gate {
1457c478bd9Sstevel@tonic-gate char *printer;
1467c478bd9Sstevel@tonic-gate ushort status;
1477c478bd9Sstevel@tonic-gate register PSTATUS *pps;
1487c478bd9Sstevel@tonic-gate
1497c478bd9Sstevel@tonic-gate
1507c478bd9Sstevel@tonic-gate getmessage (m, S_ENABLE_DEST, &printer);
1517c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_enable_dest(%s)", (printer ? printer : "NULL"));
1527c478bd9Sstevel@tonic-gate
1537c478bd9Sstevel@tonic-gate /*
1547c478bd9Sstevel@tonic-gate * Have we seen this printer before?
1557c478bd9Sstevel@tonic-gate */
1560a44ef6dSjacobs if ((pps = search_pstatus(printer)))
1577c478bd9Sstevel@tonic-gate if (enable(pps) == -1)
1587c478bd9Sstevel@tonic-gate status = MERRDEST;
1597c478bd9Sstevel@tonic-gate else
1607c478bd9Sstevel@tonic-gate status = MOK;
1617c478bd9Sstevel@tonic-gate else
1627c478bd9Sstevel@tonic-gate status = MNODEST;
1637c478bd9Sstevel@tonic-gate
1647c478bd9Sstevel@tonic-gate mputm (md, R_ENABLE_DEST, status);
1657c478bd9Sstevel@tonic-gate return;
1667c478bd9Sstevel@tonic-gate }
1677c478bd9Sstevel@tonic-gate
1687c478bd9Sstevel@tonic-gate /**
1697c478bd9Sstevel@tonic-gate ** s_disable_dest()
1707c478bd9Sstevel@tonic-gate **/
1717c478bd9Sstevel@tonic-gate
1727c478bd9Sstevel@tonic-gate void
s_disable_dest(char * m,MESG * md)1737c478bd9Sstevel@tonic-gate s_disable_dest(char *m, MESG *md)
1747c478bd9Sstevel@tonic-gate {
1757c478bd9Sstevel@tonic-gate char *destination,
1767c478bd9Sstevel@tonic-gate *reason,
1777c478bd9Sstevel@tonic-gate *req_id = 0;
1787c478bd9Sstevel@tonic-gate ushort when,
1797c478bd9Sstevel@tonic-gate status;
1807c478bd9Sstevel@tonic-gate register PSTATUS *pps;
1817c478bd9Sstevel@tonic-gate
1827c478bd9Sstevel@tonic-gate getmessage (m, S_DISABLE_DEST, &destination, &reason, &when);
1837c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_disable_dest(%s, %s, %d)",
1847c478bd9Sstevel@tonic-gate (destination ? destination : "NULL"),
1857c478bd9Sstevel@tonic-gate (reason ? reason : "NULL"), when);
1867c478bd9Sstevel@tonic-gate
1877c478bd9Sstevel@tonic-gate
1887c478bd9Sstevel@tonic-gate /*
1897c478bd9Sstevel@tonic-gate * Have we seen this printer before?
1907c478bd9Sstevel@tonic-gate */
1910a44ef6dSjacobs if ((pps = search_pstatus(destination))) {
1927c478bd9Sstevel@tonic-gate
1937c478bd9Sstevel@tonic-gate /*
1947c478bd9Sstevel@tonic-gate * If we are to cancel a currently printing request,
1957c478bd9Sstevel@tonic-gate * we will send back the request's ID.
1967c478bd9Sstevel@tonic-gate * Save a copy of the ID before calling "disable()",
1977c478bd9Sstevel@tonic-gate * in case the disabling loses it (e.g. the request
1987c478bd9Sstevel@tonic-gate * might get attached to another printer). (Actually,
1997c478bd9Sstevel@tonic-gate * the current implementation won't DETACH the request
2007c478bd9Sstevel@tonic-gate * from this printer until the child process responds,
2017c478bd9Sstevel@tonic-gate * but a future implementation might.)
2027c478bd9Sstevel@tonic-gate */
2037c478bd9Sstevel@tonic-gate if (pps->request && when == 2)
2047c478bd9Sstevel@tonic-gate req_id = Strdup(pps->request->secure->req_id);
2057c478bd9Sstevel@tonic-gate
2067c478bd9Sstevel@tonic-gate if (disable(pps, reason, (int)when) == -1) {
2077c478bd9Sstevel@tonic-gate if (req_id) {
2087c478bd9Sstevel@tonic-gate Free (req_id);
2097c478bd9Sstevel@tonic-gate req_id = 0;
2107c478bd9Sstevel@tonic-gate }
2117c478bd9Sstevel@tonic-gate status = MERRDEST;
2127c478bd9Sstevel@tonic-gate } else
2137c478bd9Sstevel@tonic-gate status = MOK;
2147c478bd9Sstevel@tonic-gate
2157c478bd9Sstevel@tonic-gate } else
2167c478bd9Sstevel@tonic-gate status = MNODEST;
2177c478bd9Sstevel@tonic-gate
2187c478bd9Sstevel@tonic-gate mputm (md, R_DISABLE_DEST, status, NB(req_id));
2197c478bd9Sstevel@tonic-gate if (req_id)
2207c478bd9Sstevel@tonic-gate Free (req_id);
2217c478bd9Sstevel@tonic-gate
2227c478bd9Sstevel@tonic-gate return;
2237c478bd9Sstevel@tonic-gate }
2247c478bd9Sstevel@tonic-gate
2257c478bd9Sstevel@tonic-gate /**
2267c478bd9Sstevel@tonic-gate ** s_load_filter_table()
2277c478bd9Sstevel@tonic-gate **/
2287c478bd9Sstevel@tonic-gate
2297c478bd9Sstevel@tonic-gate void
s_load_filter_table(char * m,MESG * md)2307c478bd9Sstevel@tonic-gate s_load_filter_table(char *m, MESG *md)
2317c478bd9Sstevel@tonic-gate {
2327c478bd9Sstevel@tonic-gate ushort status;
2337c478bd9Sstevel@tonic-gate
2347c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_load_filter_table()");
2357c478bd9Sstevel@tonic-gate
2367c478bd9Sstevel@tonic-gate trash_filters ();
2377c478bd9Sstevel@tonic-gate if (Loadfilters((char *)0) == -1)
2387c478bd9Sstevel@tonic-gate status = MNOOPEN;
2397c478bd9Sstevel@tonic-gate else {
2407c478bd9Sstevel@tonic-gate /*
2417c478bd9Sstevel@tonic-gate * This is what makes changing filters expensive!
2427c478bd9Sstevel@tonic-gate */
2437c478bd9Sstevel@tonic-gate queue_check (qchk_filter);
2447c478bd9Sstevel@tonic-gate
2457c478bd9Sstevel@tonic-gate status = MOK;
2467c478bd9Sstevel@tonic-gate }
2477c478bd9Sstevel@tonic-gate
2487c478bd9Sstevel@tonic-gate mputm (md, R_LOAD_FILTER_TABLE, status);
2497c478bd9Sstevel@tonic-gate return;
2507c478bd9Sstevel@tonic-gate }
2517c478bd9Sstevel@tonic-gate
2527c478bd9Sstevel@tonic-gate /**
2537c478bd9Sstevel@tonic-gate ** s_unload_filter_table()
2547c478bd9Sstevel@tonic-gate **/
2557c478bd9Sstevel@tonic-gate
2567c478bd9Sstevel@tonic-gate void
s_unload_filter_table(char * m,MESG * md)2577c478bd9Sstevel@tonic-gate s_unload_filter_table(char *m, MESG *md)
2587c478bd9Sstevel@tonic-gate {
2597c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_unload_filter_table()");
2607c478bd9Sstevel@tonic-gate
2617c478bd9Sstevel@tonic-gate trash_filters ();
2627c478bd9Sstevel@tonic-gate
2637c478bd9Sstevel@tonic-gate /*
2647c478bd9Sstevel@tonic-gate * This is what makes changing filters expensive!
2657c478bd9Sstevel@tonic-gate */
2667c478bd9Sstevel@tonic-gate queue_check (qchk_filter);
2677c478bd9Sstevel@tonic-gate
2687c478bd9Sstevel@tonic-gate mputm (md, R_UNLOAD_FILTER_TABLE, MOK);
2697c478bd9Sstevel@tonic-gate return;
2707c478bd9Sstevel@tonic-gate }
2717c478bd9Sstevel@tonic-gate
2727c478bd9Sstevel@tonic-gate /**
2737c478bd9Sstevel@tonic-gate ** s_load_user_file()
2747c478bd9Sstevel@tonic-gate **/
2757c478bd9Sstevel@tonic-gate
2767c478bd9Sstevel@tonic-gate void
s_load_user_file(char * m,MESG * md)2777c478bd9Sstevel@tonic-gate s_load_user_file(char *m, MESG *md)
2787c478bd9Sstevel@tonic-gate {
2797c478bd9Sstevel@tonic-gate /*
2807c478bd9Sstevel@tonic-gate * The first call to "getuser()" will load the whole file.
2817c478bd9Sstevel@tonic-gate */
2827c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_load_user_file()");
2837c478bd9Sstevel@tonic-gate
2847c478bd9Sstevel@tonic-gate trashusers ();
2857c478bd9Sstevel@tonic-gate
2867c478bd9Sstevel@tonic-gate mputm (md, R_LOAD_USER_FILE, MOK);
2877c478bd9Sstevel@tonic-gate return;
2887c478bd9Sstevel@tonic-gate }
2897c478bd9Sstevel@tonic-gate
2907c478bd9Sstevel@tonic-gate /**
2917c478bd9Sstevel@tonic-gate ** s_unload_user_file()
2927c478bd9Sstevel@tonic-gate **/
2937c478bd9Sstevel@tonic-gate
2947c478bd9Sstevel@tonic-gate void
s_unload_user_file(char * m,MESG * md)2957c478bd9Sstevel@tonic-gate s_unload_user_file(char *m, MESG *md)
2967c478bd9Sstevel@tonic-gate {
2977c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_unload_user_file()");
2987c478bd9Sstevel@tonic-gate
2997c478bd9Sstevel@tonic-gate trashusers (); /* THIS WON'T DO TRUE UNLOAD, SORRY! */
3007c478bd9Sstevel@tonic-gate
3017c478bd9Sstevel@tonic-gate mputm (md, R_UNLOAD_USER_FILE, MOK);
3027c478bd9Sstevel@tonic-gate return;
3037c478bd9Sstevel@tonic-gate }
3047c478bd9Sstevel@tonic-gate /**
3057c478bd9Sstevel@tonic-gate ** s_shutdown()
3067c478bd9Sstevel@tonic-gate **/
3077c478bd9Sstevel@tonic-gate
3087c478bd9Sstevel@tonic-gate void
s_shutdown(char * m,MESG * md)3097c478bd9Sstevel@tonic-gate s_shutdown(char *m, MESG *md)
3107c478bd9Sstevel@tonic-gate {
3117c478bd9Sstevel@tonic-gate ushort immediate;
3127c478bd9Sstevel@tonic-gate
3137c478bd9Sstevel@tonic-gate (void)getmessage (m, S_SHUTDOWN, &immediate);
3147c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_shutdown(%d)", immediate);
3157c478bd9Sstevel@tonic-gate
3167c478bd9Sstevel@tonic-gate switch (md->type) {
3177c478bd9Sstevel@tonic-gate case MD_STREAM:
3187c478bd9Sstevel@tonic-gate case MD_SYS_FIFO:
3197c478bd9Sstevel@tonic-gate case MD_USR_FIFO:
3207c478bd9Sstevel@tonic-gate mputm (md, R_SHUTDOWN, MOK);
3217c478bd9Sstevel@tonic-gate lpshut (immediate);
3227c478bd9Sstevel@tonic-gate /*NOTREACHED*/
3237c478bd9Sstevel@tonic-gate default:
3247c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG,
3257c478bd9Sstevel@tonic-gate "Received S_SHUTDOWN on a type %d connection\n",
3267c478bd9Sstevel@tonic-gate md->type);
3277c478bd9Sstevel@tonic-gate }
3287c478bd9Sstevel@tonic-gate
3297c478bd9Sstevel@tonic-gate return;
3307c478bd9Sstevel@tonic-gate }
3317c478bd9Sstevel@tonic-gate
3327c478bd9Sstevel@tonic-gate /**
3337c478bd9Sstevel@tonic-gate ** s_quiet_alert()
3347c478bd9Sstevel@tonic-gate **/
3357c478bd9Sstevel@tonic-gate
3367c478bd9Sstevel@tonic-gate void
s_quiet_alert(char * m,MESG * md)3377c478bd9Sstevel@tonic-gate s_quiet_alert(char *m, MESG *md)
3387c478bd9Sstevel@tonic-gate {
3397c478bd9Sstevel@tonic-gate char *name;
3407c478bd9Sstevel@tonic-gate ushort type,
3417c478bd9Sstevel@tonic-gate status;
3427c478bd9Sstevel@tonic-gate register FSTATUS *pfs;
3437c478bd9Sstevel@tonic-gate register PSTATUS *pps;
3447c478bd9Sstevel@tonic-gate register PWSTATUS *ppws;
3457c478bd9Sstevel@tonic-gate
3467c478bd9Sstevel@tonic-gate
3477c478bd9Sstevel@tonic-gate /*
3487c478bd9Sstevel@tonic-gate * We quiet an alert by cancelling it with "cancel_alert()"
3497c478bd9Sstevel@tonic-gate * and then resetting the active flag. This effectively just
3507c478bd9Sstevel@tonic-gate * terminates the process running the alert but tricks the
3517c478bd9Sstevel@tonic-gate * rest of the Spooler into thinking it is still active.
3527c478bd9Sstevel@tonic-gate * The alert will be reactivated only AFTER "cancel_alert()"
3537c478bd9Sstevel@tonic-gate * has been called (to clear the active flag) and then "alert()"
3547c478bd9Sstevel@tonic-gate * is called again. Thus:
3557c478bd9Sstevel@tonic-gate *
3567c478bd9Sstevel@tonic-gate * For printer faults the alert will be reactivated when:
3577c478bd9Sstevel@tonic-gate * - a fault is found after the current fault has been
3587c478bd9Sstevel@tonic-gate * cleared (i.e. after successful print or after manually
3597c478bd9Sstevel@tonic-gate * enabled).
3607c478bd9Sstevel@tonic-gate *
3617c478bd9Sstevel@tonic-gate * For forms/print-wheels the alert will be reactivated when:
3627c478bd9Sstevel@tonic-gate * - the form/print-wheel becomes mounted and then unmounted
3637c478bd9Sstevel@tonic-gate * again, with too many requests still pending;
3647c478bd9Sstevel@tonic-gate * - the number of requests falls below the threshold and
3657c478bd9Sstevel@tonic-gate * then rises above it again.
3667c478bd9Sstevel@tonic-gate */
3677c478bd9Sstevel@tonic-gate
3687c478bd9Sstevel@tonic-gate (void)getmessage (m, S_QUIET_ALERT, &name, &type);
3697c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_quiet_alert(%s, %d)", (name ? name : "NULL"),
3707c478bd9Sstevel@tonic-gate type);
3717c478bd9Sstevel@tonic-gate
3727c478bd9Sstevel@tonic-gate if (!*name)
3737c478bd9Sstevel@tonic-gate status = MNODEST;
3747c478bd9Sstevel@tonic-gate
3757c478bd9Sstevel@tonic-gate else switch (type) {
3767c478bd9Sstevel@tonic-gate case QA_FORM:
3770a44ef6dSjacobs if (!(pfs = search_fstatus(name)))
3787c478bd9Sstevel@tonic-gate status = MNODEST;
3797c478bd9Sstevel@tonic-gate
3807c478bd9Sstevel@tonic-gate else if (!pfs->alert->active)
3817c478bd9Sstevel@tonic-gate status = MERRDEST;
3827c478bd9Sstevel@tonic-gate
3837c478bd9Sstevel@tonic-gate else {
3847c478bd9Sstevel@tonic-gate cancel_alert (A_FORM, pfs);
3857c478bd9Sstevel@tonic-gate pfs->alert->active = 1;
3867c478bd9Sstevel@tonic-gate status = MOK;
3877c478bd9Sstevel@tonic-gate }
3887c478bd9Sstevel@tonic-gate break;
3897c478bd9Sstevel@tonic-gate
3907c478bd9Sstevel@tonic-gate case QA_PRINTER:
3910a44ef6dSjacobs if (!(pps = search_pstatus(name)))
3927c478bd9Sstevel@tonic-gate status = MNODEST;
3937c478bd9Sstevel@tonic-gate
3947c478bd9Sstevel@tonic-gate else if (!pps->alert->active)
3957c478bd9Sstevel@tonic-gate status = MERRDEST;
3967c478bd9Sstevel@tonic-gate
3977c478bd9Sstevel@tonic-gate else {
3987c478bd9Sstevel@tonic-gate cancel_alert (A_PRINTER, pps);
3997c478bd9Sstevel@tonic-gate pps->alert->active = 1;
4007c478bd9Sstevel@tonic-gate status = MOK;
4017c478bd9Sstevel@tonic-gate }
4027c478bd9Sstevel@tonic-gate break;
4037c478bd9Sstevel@tonic-gate
4047c478bd9Sstevel@tonic-gate case QA_PRINTWHEEL:
4050a44ef6dSjacobs if (!(ppws = search_pwstatus(name)))
4067c478bd9Sstevel@tonic-gate status = MNODEST;
4077c478bd9Sstevel@tonic-gate
4087c478bd9Sstevel@tonic-gate else if (!ppws->alert->active)
4097c478bd9Sstevel@tonic-gate status = MERRDEST;
4107c478bd9Sstevel@tonic-gate
4117c478bd9Sstevel@tonic-gate else {
4127c478bd9Sstevel@tonic-gate cancel_alert (A_PWHEEL, ppws);
4137c478bd9Sstevel@tonic-gate ppws->alert->active = 1;
4147c478bd9Sstevel@tonic-gate status = MOK;
4157c478bd9Sstevel@tonic-gate }
4167c478bd9Sstevel@tonic-gate break;
4177c478bd9Sstevel@tonic-gate }
4187c478bd9Sstevel@tonic-gate
4197c478bd9Sstevel@tonic-gate mputm (md, R_QUIET_ALERT, status);
4207c478bd9Sstevel@tonic-gate return;
4217c478bd9Sstevel@tonic-gate }
4227c478bd9Sstevel@tonic-gate
4237c478bd9Sstevel@tonic-gate /**
4247c478bd9Sstevel@tonic-gate ** s_send_fault()
4257c478bd9Sstevel@tonic-gate **/
4267c478bd9Sstevel@tonic-gate
4277c478bd9Sstevel@tonic-gate void
s_send_fault(char * m,MESG * md)4287c478bd9Sstevel@tonic-gate s_send_fault(char *m, MESG *md)
4297c478bd9Sstevel@tonic-gate {
4307c478bd9Sstevel@tonic-gate long key;
4317c478bd9Sstevel@tonic-gate char *printerOrForm, *alert_text;
4327c478bd9Sstevel@tonic-gate ushort status;
4337c478bd9Sstevel@tonic-gate register PSTATUS *pps;
4347c478bd9Sstevel@tonic-gate
4357c478bd9Sstevel@tonic-gate getmessage (m, S_SEND_FAULT, &printerOrForm, &key, &alert_text);
4367c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_send_fault(%s, %x, %s)",
4377c478bd9Sstevel@tonic-gate (printerOrForm ? printerOrForm : "NULL"), key,
4387c478bd9Sstevel@tonic-gate (alert_text ? alert_text : "NULL"));
4397c478bd9Sstevel@tonic-gate
4400a44ef6dSjacobs if (!(pps = search_pstatus(printerOrForm)) || (!pps->exec) ||
4417c478bd9Sstevel@tonic-gate pps->exec->key != key || !pps->request) {
4427c478bd9Sstevel@tonic-gate status = MERRDEST;
4437c478bd9Sstevel@tonic-gate } else {
4447c478bd9Sstevel@tonic-gate printer_fault(pps, pps->request, alert_text, 0);
4457c478bd9Sstevel@tonic-gate status = MOK;
4467c478bd9Sstevel@tonic-gate }
4477c478bd9Sstevel@tonic-gate
4487c478bd9Sstevel@tonic-gate mputm (md, R_SEND_FAULT, status);
4497c478bd9Sstevel@tonic-gate }
4507c478bd9Sstevel@tonic-gate
4517c478bd9Sstevel@tonic-gate /*
4527c478bd9Sstevel@tonic-gate * s_clear_fault()
4537c478bd9Sstevel@tonic-gate */
4547c478bd9Sstevel@tonic-gate void
s_clear_fault(char * m,MESG * md)4557c478bd9Sstevel@tonic-gate s_clear_fault(char *m, MESG *md)
4567c478bd9Sstevel@tonic-gate {
4577c478bd9Sstevel@tonic-gate long key;
4587c478bd9Sstevel@tonic-gate char *printerOrForm, *alert_text;
4597c478bd9Sstevel@tonic-gate ushort status;
4607c478bd9Sstevel@tonic-gate register PSTATUS *pps;
4617c478bd9Sstevel@tonic-gate
4627c478bd9Sstevel@tonic-gate getmessage(m, S_CLEAR_FAULT, &printerOrForm, &key, &alert_text);
4637c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_clear_fault(%s, %x, %s)",
4647c478bd9Sstevel@tonic-gate (printerOrForm ? printerOrForm : "NULL"), key,
4657c478bd9Sstevel@tonic-gate (alert_text ? alert_text : "NULL"));
4667c478bd9Sstevel@tonic-gate
4677c478bd9Sstevel@tonic-gate
4680a44ef6dSjacobs if (! (pps = search_pstatus(printerOrForm)) || ((key > 0) &&
4697c478bd9Sstevel@tonic-gate ((!pps->exec) || pps->exec->key != key || !pps->request ))) {
4707c478bd9Sstevel@tonic-gate status = MERRDEST;
4717c478bd9Sstevel@tonic-gate } else {
4727c478bd9Sstevel@tonic-gate clear_printer_fault(pps, alert_text);
4737c478bd9Sstevel@tonic-gate status = MOK;
4747c478bd9Sstevel@tonic-gate }
4757c478bd9Sstevel@tonic-gate
4767c478bd9Sstevel@tonic-gate mputm (md, R_CLEAR_FAULT, status);
4777c478bd9Sstevel@tonic-gate }
4787c478bd9Sstevel@tonic-gate
4797c478bd9Sstevel@tonic-gate
4807c478bd9Sstevel@tonic-gate /*
4817c478bd9Sstevel@tonic-gate * s_paper_changed()
4827c478bd9Sstevel@tonic-gate */
4837c478bd9Sstevel@tonic-gate void
s_paper_changed(char * m,MESG * md)4847c478bd9Sstevel@tonic-gate s_paper_changed(char *m, MESG *md)
4857c478bd9Sstevel@tonic-gate {
4867c478bd9Sstevel@tonic-gate short trayNum, mode, pagesPrinted;
4877c478bd9Sstevel@tonic-gate char *printer, *paper;
4887c478bd9Sstevel@tonic-gate ushort status;
4897c478bd9Sstevel@tonic-gate short chgd = 0;
4907c478bd9Sstevel@tonic-gate register PSTATUS *pps;
4917c478bd9Sstevel@tonic-gate register FSTATUS *pfs,*pfsWas;
4927c478bd9Sstevel@tonic-gate
4937c478bd9Sstevel@tonic-gate getmessage(m, S_PAPER_CHANGED, &printer, &trayNum, &paper, &mode,
4947c478bd9Sstevel@tonic-gate &pagesPrinted);
4957c478bd9Sstevel@tonic-gate syslog(LOG_DEBUG, "s_paper_changed(%s, %d, %s, %d, %d)",
4967c478bd9Sstevel@tonic-gate (printer ? printer : "NULL"), trayNum, (paper ? paper : "NULL"),
4977c478bd9Sstevel@tonic-gate mode, pagesPrinted);
4987c478bd9Sstevel@tonic-gate
4990a44ef6dSjacobs if (!(pps = search_pstatus(printer)))
5007c478bd9Sstevel@tonic-gate status = MNODEST;
5017c478bd9Sstevel@tonic-gate else if ((trayNum <=0) || (trayNum > pps->numForms))
5027c478bd9Sstevel@tonic-gate status = MNOTRAY;
5037c478bd9Sstevel@tonic-gate else {
5047c478bd9Sstevel@tonic-gate status = MOK;
5057c478bd9Sstevel@tonic-gate if (*paper && (pfsWas = pps->forms[trayNum-1].form) &&
5067c478bd9Sstevel@tonic-gate (!STREQU(pfsWas->form->paper,paper))) {
5077c478bd9Sstevel@tonic-gate pfs = search_fptable(paper);
5087c478bd9Sstevel@tonic-gate if (pfs) {
5097c478bd9Sstevel@tonic-gate remount_form(pps, pfs, trayNum);
5107c478bd9Sstevel@tonic-gate chgd = 1;
5117c478bd9Sstevel@tonic-gate } else
5127c478bd9Sstevel@tonic-gate status = MNOMEDIA;
5137c478bd9Sstevel@tonic-gate }
5147c478bd9Sstevel@tonic-gate if ( status == MOK ) {
5157c478bd9Sstevel@tonic-gate pps->forms[trayNum].isAvailable = mode;
5160a44ef6dSjacobs if ((chgd || !mode) && (!pagesPrinted) && pps->exec) {
5177c478bd9Sstevel@tonic-gate if (pps->request)
5187c478bd9Sstevel@tonic-gate pps->request->request->outcome |=
5197c478bd9Sstevel@tonic-gate RS_STOPPED;
5207c478bd9Sstevel@tonic-gate terminate(pps->exec);
5217c478bd9Sstevel@tonic-gate schedule(EV_LATER, 1, EV_INTERF, pps);
5227c478bd9Sstevel@tonic-gate }
5237c478bd9Sstevel@tonic-gate }
5247c478bd9Sstevel@tonic-gate }
5257c478bd9Sstevel@tonic-gate mputm(md, R_PAPER_CHANGED, status);
5267c478bd9Sstevel@tonic-gate }
5277c478bd9Sstevel@tonic-gate
528