xref: /illumos-gate/usr/src/cmd/lp/cmd/lpsched/nodes.h (revision 18c2aff776a775d34a4c9893a4c72e0434d68e36)
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 2003 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"
32 
33 typedef struct alert_node	ALERT;
34 typedef struct cstat_node	CSTATUS;
35 typedef struct exec_node	EXEC;
36 typedef struct form_node	_FORM;
37 typedef struct fstat_node	FSTATUS;
38 typedef struct pfstat_node	PFSTATUS;
39 typedef struct pstat_node	PSTATUS;
40 typedef struct pwstat_node	PWSTATUS;
41 typedef struct rstat_node	RSTATUS;
42 typedef struct waiting_node	WAITING;
43 typedef struct susp_node	SUSPENDED;
44 
45 struct alert_node
46 {
47     short	active;			/* Non-zero if triggered     */
48     EXEC	*exec;			/* Index into EXEC table     */
49     char	*msgfile;
50 };
51 
52 struct cstat_node
53 {
54     short	status;
55     char	*rej_reason;
56     time_t	rej_date;
57     CLASS	*class;
58 };
59 
60 struct exec_node
61 {
62     int		pid;			/* process-id of exec		*/
63     int		status;			/* low order bits from wait	*/
64     long	key;			/* private key for security	*/
65     short	Errno;			/* copy of child's errno	*/
66     short	type;			/* type of exec, EX_...		*/
67     ushort	flags;			/* flags, EXF_...		*/
68     MESG	*md;
69     union ex
70     {
71 	RSTATUS		*request;
72 	FSTATUS		*form;
73 	PWSTATUS	*pwheel;
74 	PSTATUS		*printer;
75     } ex;
76 };
77 
78 struct waiting_node
79 {
80     WAITING	*next;
81     MESG	*md;
82 };
83 
84 struct susp_node
85 {
86     SUSPENDED	*next;
87     char	*message;
88     MESG	*md;
89 };
90 
91 #define	EX_INTERF	1	/* exec interface for ex.printer	*/
92 #define	EX_SLOWF	2	/* exec slow filter for ex.request	*/
93 #define	EX_ALERT	3	/* exec alert for ex.printer		*/
94 #define	EX_FALERT	4	/* exec alert for ex.form		*/
95 #define	EX_PALERT	5	/* exec alert for ex.pwheel		*/
96 #define	EX_NOTIFY	6	/* exec notification for ex.request	*/
97 #define	EX_FAULT_MESSAGE 7	/* exec fault message*/
98 #define	EX_FORM_MESSAGE	8	/* form fault message*/
99 
100 #define REX_INTERF	1	/* send print request to remote		*/
101 #define REX_CANCEL	2	/* send cancellation to remote		*/
102 #define REX_NOTIFY	3	/* send job termination note to remote	*/
103 #define REX_STATUS	4	/* send status request to remote	*/
104 #define REX_FAULT_MESSAGE 5	/* fault message to remote */
105 #define REX_FORM_MESSAGE 6	/* form message to remote */
106 
107 #define	EXF_RESTART	0x0001	/* restart the exec			*/
108 #define	EXF_KILLED	0x0002	/* terminate() has killed the exec	*/
109 #define	EXF_GONE	0x0004	/* child has disappeared		*/
110 #define EXF_WAITCHILD	0x0008	/* waiting for R_NEW_CHILD		*/
111 #define EXF_WAITJOB	0x0010	/* waiting for R_SEND_JOB		*/
112 
113 /*
114 **	Possible values for FLT.type
115 */
116 #define        FLT_FILES       1	/* remove alloc'd files		*/
117 #define        FLT_CHANGE      2	/* clear RS_CHANGING for .r1	*/
118 
119 struct fstat_node
120 {
121     _FORM	*form;
122     ALERT	*alert;
123     short	requests;		/* Number of events thus far */
124     short	requests_last;		/* # when alert last sent */
125     short	trigger;		/* Trigger when this value   */
126     short	mounted;		/* # times currently mounted */
127     char	**users_allowed;
128     char	**users_denied;
129     char	*cpi;
130     char	*lpi;
131     char	*plen;
132     char	*pwid;
133 };
134 
135 struct pfstat_node
136 {
137 	FSTATUS	*form;
138 	short isAvailable;
139 };
140 
141 struct pstat_node
142 {
143     short	status;			/* Current Status of printer */
144     RSTATUS	*request;
145     PRINTER	*printer;
146     ALERT	*alert;
147     EXEC	*exec;
148     PFSTATUS	*forms;
149     char	*pwheel_name;
150     PWSTATUS	*pwheel;
151     char	*dis_reason;
152     char	*rej_reason;
153     char	**users_allowed;
154     char	**users_denied;
155     char	**forms_allowed;
156     char	**forms_denied;
157     char	*cpi;
158     char	*lpi;
159     char	*plen;
160     char	*pwid;
161     time_t	dis_date;
162     time_t	rej_date;
163     short	last_dial_rc;		/* last exit from dial() */
164     short	nretry;			/* number of dial attempts */
165     char	*remote_name;
166     short	nrequests;		/* TEMP ONLY! (used variously) */
167     char	*fault_reason;
168     EXEC	*fault_exec;
169     short	numForms;
170     char	**paper_allowed;
171 };
172 
173 struct pwstat_node
174 {
175     PWHEEL	*pwheel;
176     ALERT	*alert;
177     short	requests;
178     short	requests_last;		/* # when alert last sent */
179     short	trigger;
180     short	mounted;
181 };
182 
183 #if	defined(OLD_MSG_STUFF)
184 
185 #define CLIENT_NEW		1
186 #define CLIENT_PROTOCOL		2
187 #define CLIENT_TALKING		3
188 
189 struct mque_node
190 {
191     char		*msgbuf;
192     unsigned int	size;
193     struct mque_node	*next;
194 };
195 
196 struct client_node
197 {
198     ushort		uid;		/* User id of client		*/
199     ushort		gid;		/* Group id of client		*/
200     char		admin;		/* Non-zero if client is admin	*/
201     char		state;		/* (CLIENT_... value)		*/
202     FLT			*flt;		/* Linked list of fault actions */
203     char		*fifo;		/* Name of client's fifo	*/
204     char		*system;	/* Name of client's system	*/
205     int			fd;		/* File-descriptor of open fifo	*/
206     char		authcode[HEAD_AUTHCODE_LEN];
207 					/* ``Password'' to verify client*/
208     MQUE		*mque;		/* Linked list of pending msgs.	*/
209 };
210 
211 #else
212 
213 #define	NODE		MESG
214 #define send		mputm
215 
216 #endif
217 
218 struct rstat_node
219 {
220     long	status;
221     long	rank;
222     MESG	*md;
223 
224     char	*req_file;
225     char	*slow;
226     char	*fast;
227     short	copies;		/* # copies interface is to make */
228     short	reason;		/* reason for failing _validate() */
229 
230     SECURE	*secure;
231     REQUEST	*request;
232     PSTATUS	*printer;
233     FSTATUS	*form;
234     char	*pwheel_name;
235     PWSTATUS	*pwheel;
236     EXEC	*exec;		/* Pointer to running filter or notify */
237 
238     char	*printer_type;
239     char	*output_type;
240     char	*cpi;
241     char	*lpi;
242     char	*plen;
243     char	*pwid;
244 
245     RSTATUS	*next;
246     RSTATUS	*prev;
247     short	msgType; /* for getting status */
248     short	trayNum; /* for mounting trays remotely */
249     char	*formName; /* for mounting forms remotely */
250 };
251 
252 # define	RSS_MARK	0x00000001
253 # define	RSS_RANK	0x00000002
254 # define	RSS_SENDREMOTE	0x00000004 /* request needs to be sent */
255 # define	RSS_PWMAND	0x00000008 /* pwheel must be mounted */
256 # define	RSS_GETSTATUS	0x00000010 /* get remote status */
257 # define	RSS_RECVSTATUS	0x00000020 /* waiting for remote status */
258 # define	RSS_SEND_FAULT_MESSAGE	0x00000040 /* need to send message*/
259 # define	RSS_SEND_FORM_MESSAGE	0x00000080 /* need to send form message*/
260 
261 struct form_node
262 {
263     SCALED	plen;
264     SCALED	pwid;
265     SCALED	lpi;
266     SCALED	cpi;
267     int	np;
268     char	*chset;
269     short	mandatory;
270     char	*rcolor;
271     char	*comment;
272     char	*conttype;
273     char	*name;
274     FALERT	alert;
275     char	*paper;
276     short	isDefault;
277 };
278 
279 # define	LP_EXEC		0
280 # define	LP_SCHED	1
281 # define	LP_NET		2
282 # define	LP_FILTER	3
283 # define	LP_PRINTER	4
284 # define	LP_ALERT	5
285 # define	LP_NOTIFY	6
286 # define	LP_SYSTEM	7
287 # define	LP_PWHEEL	8
288 # define	LP_FORM		9
289 # define	LP_LATER	10
290 # define	LP_ALARM	11
291 
292 # define	LP_ACTIVE	0x080
293 # define	LP_ALERTING	0x100
294 
295 # define	MINUTES			(60)
296 
297 # define	USER_STATUS_EXPIRED	(3 * MINUTES)
298 
299 # define	SYSTEM_STATUS_EXPIRED	(10 * MINUTES)
300 
301 #define BEGIN_WALK_LOOP(PRS, CONDITION) \
302 	_BEGIN_WALK_LOOP("WALK", PRS, CONDITION)
303 
304 #define _BEGIN_WALK_LOOP(X, PRS, CONDITION) \
305 	{ \
306 		register RSTATUS	*pnext = 0; \
307 		for (PRS = Request_List; PRS; PRS = pnext) { \
308 			pnext = PRS->next; \
309 			if (CONDITION) {
310 
311 #define	END_WALK_LOOP \
312 			} \
313 		} \
314 	}
315 
316 #define BEGIN_WALK_BY_PRINTER_LOOP(PRS, PPS)	\
317 	_BEGIN_WALK_LOOP("WALK_BY_PRINTER", PRS, PRS->printer == PPS)
318 
319 #define BEGIN_WALK_BY_DEST_LOOP(PRS, DEST) \
320 	_BEGIN_WALK_LOOP("WALK_BY_DEST", PRS, STREQU(PRS->request->destination, DEST))
321 
322 #define BEGIN_WALK_BY_FORM_LOOP(PRS, PFS) \
323 	_BEGIN_WALK_LOOP("WALK_BY_FORM", PRS, PRS->form == PFS)
324 
325 #define	BEGIN_WALK_BY_PWHEEL_LOOP(PRS, NAME) \
326 	_BEGIN_WALK_LOOP("WALK_BY_PWHEEL", PRS, PRS->pwheel_name && STREQU(PRS->pwheel_name, NAME))
327