xref: /illumos-gate/usr/src/cmd/lp/include/msgs.h (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
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
545916cd2Sjpk  * Common Development and Distribution License (the "License").
645916cd2Sjpk  * 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 /*
2245916cd2Sjpk  * 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 # include	<sys/types.h>
307c478bd9Sstevel@tonic-gate # include	<poll.h>
317c478bd9Sstevel@tonic-gate # include	<stdarg.h>
327c478bd9Sstevel@tonic-gate # include	<stropts.h>
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #if	!defined(_LP_MSGS_H)
357c478bd9Sstevel@tonic-gate # define	_LP_MSGS_H
367c478bd9Sstevel@tonic-gate 
377c478bd9Sstevel@tonic-gate /*
387c478bd9Sstevel@tonic-gate  * THE DISPATCH TABLE DEPENDS ON EACH R_... MESSAGE FOLLOWING
397c478bd9Sstevel@tonic-gate  * IMMEDIATELY AFTER ITS CORRESPONDING S_... COUNTERPART.
407c478bd9Sstevel@tonic-gate  * I.E R_... MESSAGE FOR A S_... MESSAGE IS (S_... + 1)
417c478bd9Sstevel@tonic-gate  */
427c478bd9Sstevel@tonic-gate # define	R_BAD_MESSAGE			0
43*0a44ef6dSjacobs /* # define	S_NEW_QUEUE			1	DEFUNCT */
44*0a44ef6dSjacobs /* # define	R_NEW_QUEUE			2	DEFUNCT */
457c478bd9Sstevel@tonic-gate # define	S_ALLOC_FILES			3
467c478bd9Sstevel@tonic-gate # define	R_ALLOC_FILES			4
477c478bd9Sstevel@tonic-gate # define	S_PRINT_REQUEST			5
487c478bd9Sstevel@tonic-gate # define	R_PRINT_REQUEST			6
497c478bd9Sstevel@tonic-gate # define	S_START_CHANGE_REQUEST		7
507c478bd9Sstevel@tonic-gate # define	R_START_CHANGE_REQUEST		8
517c478bd9Sstevel@tonic-gate # define	S_END_CHANGE_REQUEST		9
527c478bd9Sstevel@tonic-gate # define	R_END_CHANGE_REQUEST		10
537c478bd9Sstevel@tonic-gate # define	S_CANCEL_REQUEST		11
547c478bd9Sstevel@tonic-gate # define	R_CANCEL_REQUEST		12
55*0a44ef6dSjacobs /* # define	S_INQUIRE_REQUEST		13	DEFUNCT */
56*0a44ef6dSjacobs /* # define	R_INQUIRE_REQUEST		14	DEFUNCT */
577c478bd9Sstevel@tonic-gate # define	S_LOAD_PRINTER			15
587c478bd9Sstevel@tonic-gate # define	R_LOAD_PRINTER			16
597c478bd9Sstevel@tonic-gate # define	S_UNLOAD_PRINTER		17
607c478bd9Sstevel@tonic-gate # define	R_UNLOAD_PRINTER		18
617c478bd9Sstevel@tonic-gate # define	S_INQUIRE_PRINTER_STATUS	19
627c478bd9Sstevel@tonic-gate # define	R_INQUIRE_PRINTER_STATUS	20
637c478bd9Sstevel@tonic-gate # define	S_LOAD_CLASS			21
647c478bd9Sstevel@tonic-gate # define	R_LOAD_CLASS			22
657c478bd9Sstevel@tonic-gate # define	S_UNLOAD_CLASS			23
667c478bd9Sstevel@tonic-gate # define	R_UNLOAD_CLASS			24
677c478bd9Sstevel@tonic-gate # define	S_INQUIRE_CLASS			25
687c478bd9Sstevel@tonic-gate # define	R_INQUIRE_CLASS			26
697c478bd9Sstevel@tonic-gate # define	S_MOUNT				27
707c478bd9Sstevel@tonic-gate # define	R_MOUNT				28
717c478bd9Sstevel@tonic-gate # define	S_UNMOUNT			29
727c478bd9Sstevel@tonic-gate # define	R_UNMOUNT			30
737c478bd9Sstevel@tonic-gate # define	S_MOVE_REQUEST			31
747c478bd9Sstevel@tonic-gate # define	R_MOVE_REQUEST			32
757c478bd9Sstevel@tonic-gate # define	S_MOVE_DEST			33
767c478bd9Sstevel@tonic-gate # define	R_MOVE_DEST			34
777c478bd9Sstevel@tonic-gate # define	S_ACCEPT_DEST			35
787c478bd9Sstevel@tonic-gate # define	R_ACCEPT_DEST			36
797c478bd9Sstevel@tonic-gate # define	S_REJECT_DEST			37
807c478bd9Sstevel@tonic-gate # define	R_REJECT_DEST			38
817c478bd9Sstevel@tonic-gate # define	S_ENABLE_DEST			39
827c478bd9Sstevel@tonic-gate # define	R_ENABLE_DEST			40
837c478bd9Sstevel@tonic-gate # define	S_DISABLE_DEST			41
847c478bd9Sstevel@tonic-gate # define	R_DISABLE_DEST			42
857c478bd9Sstevel@tonic-gate # define	S_LOAD_FILTER_TABLE		43
867c478bd9Sstevel@tonic-gate # define	R_LOAD_FILTER_TABLE		44
877c478bd9Sstevel@tonic-gate # define	S_UNLOAD_FILTER_TABLE		45
887c478bd9Sstevel@tonic-gate # define	R_UNLOAD_FILTER_TABLE		46
897c478bd9Sstevel@tonic-gate # define	S_LOAD_PRINTWHEEL		47
907c478bd9Sstevel@tonic-gate # define	R_LOAD_PRINTWHEEL		48
917c478bd9Sstevel@tonic-gate # define	S_UNLOAD_PRINTWHEEL		49
927c478bd9Sstevel@tonic-gate # define	R_UNLOAD_PRINTWHEEL		50
937c478bd9Sstevel@tonic-gate # define	S_LOAD_USER_FILE		51
947c478bd9Sstevel@tonic-gate # define	R_LOAD_USER_FILE		52
957c478bd9Sstevel@tonic-gate # define	S_UNLOAD_USER_FILE		53
967c478bd9Sstevel@tonic-gate # define	R_UNLOAD_USER_FILE		54
977c478bd9Sstevel@tonic-gate # define	S_LOAD_FORM			55
987c478bd9Sstevel@tonic-gate # define	R_LOAD_FORM			56
997c478bd9Sstevel@tonic-gate # define	S_UNLOAD_FORM			57
1007c478bd9Sstevel@tonic-gate # define	R_UNLOAD_FORM			58
101*0a44ef6dSjacobs /* # define	S_GETSTATUS			59	DEFUNCT */
102*0a44ef6dSjacobs /* # define	R_GETSTATUS			60	DEFUNCT */
1037c478bd9Sstevel@tonic-gate # define	S_QUIET_ALERT			61
1047c478bd9Sstevel@tonic-gate # define	R_QUIET_ALERT			62
1057c478bd9Sstevel@tonic-gate # define	S_SEND_FAULT			63
1067c478bd9Sstevel@tonic-gate # define	R_SEND_FAULT			64
1077c478bd9Sstevel@tonic-gate # define	S_SHUTDOWN			65
1087c478bd9Sstevel@tonic-gate # define	R_SHUTDOWN			66
1097c478bd9Sstevel@tonic-gate # define	S_GOODBYE			67
1107c478bd9Sstevel@tonic-gate # define	S_CHILD_DONE			68
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate /*
1137c478bd9Sstevel@tonic-gate **	These are for use by the scheduler only
1147c478bd9Sstevel@tonic-gate */
1157c478bd9Sstevel@tonic-gate # define	I_GET_TYPE			69
1167c478bd9Sstevel@tonic-gate # define	I_QUEUE_CHK			70
117*0a44ef6dSjacobs /* # define	R_CONNECT			71	DEFUNCT */
1187c478bd9Sstevel@tonic-gate 
119*0a44ef6dSjacobs /* # define	S_GET_STATUS			72	DEFUNCT */
120*0a44ef6dSjacobs /* # define	R_GET_STATUS			73	DEFUNCT */
1217c478bd9Sstevel@tonic-gate # define	S_INQUIRE_REQUEST_RANK		74
1227c478bd9Sstevel@tonic-gate # define	R_INQUIRE_REQUEST_RANK		75
1237c478bd9Sstevel@tonic-gate # define	S_CANCEL			76
1247c478bd9Sstevel@tonic-gate # define	R_CANCEL			77
125*0a44ef6dSjacobs /* # define	S_NEW_CHILD			78	DEFUNCT */
126*0a44ef6dSjacobs /* # define	R_NEW_CHILD			79	DEFUNCT */
127*0a44ef6dSjacobs /* # define	S_SEND_JOB			80	DEFUNCT */
128*0a44ef6dSjacobs /* # define	R_SEND_JOB			81	DEFUNCT */
129*0a44ef6dSjacobs /* # define	S_JOB_COMPLETED			82	DEFUNCT */
130*0a44ef6dSjacobs /* # define	R_JOB_COMPLETED			83	DEFUNCT */
131*0a44ef6dSjacobs /* # define	S_INQUIRE_REMOTE_PRINTER	84	DEFUNCT */
132*0a44ef6dSjacobs /* # define	R_INQUIRE_REMOTE_PRINTER	20	DEFUNCT */
133*0a44ef6dSjacobs /* # define	S_CHILD_SYNC			85	DEFUNCT */
134*0a44ef6dSjacobs /* # define	S_LOAD_SYSTEM			86	DEFUNCT */
135*0a44ef6dSjacobs /* # define	R_LOAD_SYSTEM			87	DEFUNCT */
136*0a44ef6dSjacobs /* # define	S_UNLOAD_SYSTEM			88	DEFUNCT */
137*0a44ef6dSjacobs /* # define	R_UNLOAD_SYSTEM			89	DEFUNCT */
1387c478bd9Sstevel@tonic-gate /* new messages */
1397c478bd9Sstevel@tonic-gate # define	S_CLEAR_FAULT			90
1407c478bd9Sstevel@tonic-gate # define	R_CLEAR_FAULT			91
1417c478bd9Sstevel@tonic-gate # define	S_MOUNT_TRAY			92
1427c478bd9Sstevel@tonic-gate # define	R_MOUNT_TRAY			93
1437c478bd9Sstevel@tonic-gate # define	S_UNMOUNT_TRAY			94
1447c478bd9Sstevel@tonic-gate # define	R_UNMOUNT_TRAY			95
1457c478bd9Sstevel@tonic-gate # define	S_MAX_TRAYS			96
1467c478bd9Sstevel@tonic-gate # define	R_MAX_TRAYS			97
1477c478bd9Sstevel@tonic-gate # define	S_PAPER_CHANGED			98
1487c478bd9Sstevel@tonic-gate # define	R_PAPER_CHANGED			99
1497c478bd9Sstevel@tonic-gate # define	S_PAPER_ALLOWED			100
1507c478bd9Sstevel@tonic-gate # define	R_PAPER_ALLOWED			101
15145916cd2Sjpk # define	S_PASS_PEER_CONNECTION		102
15245916cd2Sjpk # define	R_PASS_PEER_CONNECTION		103
1537c478bd9Sstevel@tonic-gate /*
1547c478bd9Sstevel@tonic-gate **	Last available message
1557c478bd9Sstevel@tonic-gate */
15645916cd2Sjpk # define	LAST_MESSAGE			104
1577c478bd9Sstevel@tonic-gate 
1587c478bd9Sstevel@tonic-gate /*
1597c478bd9Sstevel@tonic-gate **      These are the possible status codes returned by the scheduler
1607c478bd9Sstevel@tonic-gate */
1617c478bd9Sstevel@tonic-gate # define	MOK		 0
1627c478bd9Sstevel@tonic-gate # define	MOKMORE		 1
1637c478bd9Sstevel@tonic-gate # define	MOKREMOTE	 2
1647c478bd9Sstevel@tonic-gate # define	MMORERR		 3
1657c478bd9Sstevel@tonic-gate # define	MNODEST		 4
1667c478bd9Sstevel@tonic-gate # define	MERRDEST	 5
1677c478bd9Sstevel@tonic-gate # define	MDENYDEST	 6
1687c478bd9Sstevel@tonic-gate # define	MNOMEDIA	 7
1697c478bd9Sstevel@tonic-gate # define	MDENYMEDIA	 8
1707c478bd9Sstevel@tonic-gate # define	MNOFILTER	 9
1717c478bd9Sstevel@tonic-gate # define	MNOINFO		10
1727c478bd9Sstevel@tonic-gate # define	MNOMEM		11
1737c478bd9Sstevel@tonic-gate # define	MNOMOUNT	12
1747c478bd9Sstevel@tonic-gate # define	MNOOPEN		13
1757c478bd9Sstevel@tonic-gate # define	MNOPERM		14
1767c478bd9Sstevel@tonic-gate # define	MNOSTART	15
1777c478bd9Sstevel@tonic-gate # define	MUNKNOWN	16
1787c478bd9Sstevel@tonic-gate # define	M2LATE		17
1797c478bd9Sstevel@tonic-gate # define	MNOSPACE	18
1807c478bd9Sstevel@tonic-gate # define	MBUSY		19
1817c478bd9Sstevel@tonic-gate # define	MTRANSMITERR	20
1827c478bd9Sstevel@tonic-gate # define	MNOMORE		21
1837c478bd9Sstevel@tonic-gate # define	MGONEREMOTE	22
1847c478bd9Sstevel@tonic-gate # define	MNOTRAY		23
1857c478bd9Sstevel@tonic-gate 
1867c478bd9Sstevel@tonic-gate /*
1877c478bd9Sstevel@tonic-gate ** Offsets and lengths of the various elements of the message header.
1887c478bd9Sstevel@tonic-gate **
1897c478bd9Sstevel@tonic-gate **	Macro		Data Type	Size	Comment
1907c478bd9Sstevel@tonic-gate **
1917c478bd9Sstevel@tonic-gate **	HEAD_RESYNC	2 bytes		(2)	*
1927c478bd9Sstevel@tonic-gate **	HEAD_AUTHCODE	short + long	(6)	*
1937c478bd9Sstevel@tonic-gate **
1947c478bd9Sstevel@tonic-gate **	HEAD_SIZE	4 bytes		(4)	\
1957c478bd9Sstevel@tonic-gate **	HEAD_TYPE	4 bytes		(4)	 > message propper
1967c478bd9Sstevel@tonic-gate **	HEAD_DATA	n bytes		(n)	/
1977c478bd9Sstevel@tonic-gate **
1987c478bd9Sstevel@tonic-gate **	TAIL_CHKSUM	4 bytes		(4)	*
1997c478bd9Sstevel@tonic-gate **	TAIL_ENDSYNC	2 bytes		(2)	*
2007c478bd9Sstevel@tonic-gate **
2017c478bd9Sstevel@tonic-gate **	Items marked with an asterisk are only used with the 3.2
2027c478bd9Sstevel@tonic-gate **	Spooler protocol.
2037c478bd9Sstevel@tonic-gate */
2047c478bd9Sstevel@tonic-gate 
2057c478bd9Sstevel@tonic-gate /*
2067c478bd9Sstevel@tonic-gate **	3.2 Protocol Header Information:
2077c478bd9Sstevel@tonic-gate **		2-byte message introduction
2087c478bd9Sstevel@tonic-gate **		6-byte client authorization data
2097c478bd9Sstevel@tonic-gate */
2107c478bd9Sstevel@tonic-gate #define	HEAD_RESYNC		(0)
2117c478bd9Sstevel@tonic-gate #define HEAD_RESYNC_LEN		2
2127c478bd9Sstevel@tonic-gate #define HEAD_AUTHCODE		(HEAD_RESYNC + HEAD_RESYNC_LEN)
2137c478bd9Sstevel@tonic-gate #define HEAD_AUTHCODE_LEN		(sizeof(short) + sizeof(long))
2147c478bd9Sstevel@tonic-gate 
2157c478bd9Sstevel@tonic-gate /*
2167c478bd9Sstevel@tonic-gate **	3.2 Protocol Message Information:
2177c478bd9Sstevel@tonic-gate **		4-byte message size
2187c478bd9Sstevel@tonic-gate **		4-byte message type
2197c478bd9Sstevel@tonic-gate **		n-byte message data
2207c478bd9Sstevel@tonic-gate */
2217c478bd9Sstevel@tonic-gate #define HEAD_SIZE		(HEAD_AUTHCODE + HEAD_AUTHCODE_LEN)
2227c478bd9Sstevel@tonic-gate #define HEAD_SIZE_LEN			4
2237c478bd9Sstevel@tonic-gate #define HEAD_TYPE		(HEAD_SIZE + HEAD_SIZE_LEN)
2247c478bd9Sstevel@tonic-gate #define HEAD_TYPE_LEN			4
2257c478bd9Sstevel@tonic-gate #define HEAD_DATA		(HEAD_TYPE + HEAD_TYPE_LEN)
2267c478bd9Sstevel@tonic-gate 
2277c478bd9Sstevel@tonic-gate /*
2287c478bd9Sstevel@tonic-gate **	3.2 Protocol Size of non-data header information
2297c478bd9Sstevel@tonic-gate */
2307c478bd9Sstevel@tonic-gate #define HEAD_LEN		HEAD_DATA
2317c478bd9Sstevel@tonic-gate 
2327c478bd9Sstevel@tonic-gate /*
2337c478bd9Sstevel@tonic-gate **	Equivalents for 4.0 protocol
2347c478bd9Sstevel@tonic-gate */
2357c478bd9Sstevel@tonic-gate #define MESG_SIZE		(0)
2367c478bd9Sstevel@tonic-gate #define MESG_SIZE_LEN			4
2377c478bd9Sstevel@tonic-gate #define MESG_TYPE		(MESG_SIZE + MESG_SIZE_LEN)
2387c478bd9Sstevel@tonic-gate #define MESG_TYPE_LEN			4
2397c478bd9Sstevel@tonic-gate #define MESG_DATA		(MESG_TYPE + MESG_TYPE_LEN)
2407c478bd9Sstevel@tonic-gate 
2417c478bd9Sstevel@tonic-gate #define MESG_LEN		MESG_DATA
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate /*
2447c478bd9Sstevel@tonic-gate **	3.2 Protocol Trailer Information:
2457c478bd9Sstevel@tonic-gate **		4-byte message check sum
2467c478bd9Sstevel@tonic-gate **		2-byte message closing identifier
2477c478bd9Sstevel@tonic-gate **
2487c478bd9Sstevel@tonic-gate **	"N" is the decoded value of buffer[HEAD_SIZE].  This must
2497c478bd9Sstevel@tonic-gate **	be provided because messages are variable length.
2507c478bd9Sstevel@tonic-gate */
2517c478bd9Sstevel@tonic-gate #define	TAIL_ENDSYNC_LEN		2
2527c478bd9Sstevel@tonic-gate #define	TAIL_ENDSYNC(N)		(N - TAIL_ENDSYNC_LEN)
2537c478bd9Sstevel@tonic-gate #define TAIL_CHKSUM_LEN			4
2547c478bd9Sstevel@tonic-gate #define TAIL_CHKSUM(N)		(TAIL_ENDSYNC(N) - TAIL_CHKSUM_LEN)
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate /*
2577c478bd9Sstevel@tonic-gate **	3.2 Protocol Size of non-data trailer information
2587c478bd9Sstevel@tonic-gate */
2597c478bd9Sstevel@tonic-gate #define	TAIL_LEN		(TAIL_CHKSUM_LEN + TAIL_ENDSYNC_LEN)
2607c478bd9Sstevel@tonic-gate 
2617c478bd9Sstevel@tonic-gate /*
2627c478bd9Sstevel@tonic-gate **	3.2 Protocol Size of all non-data information
2637c478bd9Sstevel@tonic-gate **	(This is also the minimum size for 3.2 protocol messages)
2647c478bd9Sstevel@tonic-gate */
2657c478bd9Sstevel@tonic-gate #define	CONTROL_LEN		(HEAD_LEN + TAIL_LEN)
2667c478bd9Sstevel@tonic-gate 
2677c478bd9Sstevel@tonic-gate /*
2687c478bd9Sstevel@tonic-gate **	Size of excess data induced by 3.2 Protocol.
2697c478bd9Sstevel@tonic-gate **	(This is also the size differance between 3.2 & 4.0 protocols)
2707c478bd9Sstevel@tonic-gate */
2717c478bd9Sstevel@tonic-gate #define	EXCESS_3_2_LEN		(HEAD_SIZE + TAIL_LEN)
2727c478bd9Sstevel@tonic-gate /**
2737c478bd9Sstevel@tonic-gate  ** Checksum:
2747c478bd9Sstevel@tonic-gate  **/
2757c478bd9Sstevel@tonic-gate #define CALC_CHKSUM(B,SZ,RC) \
2767c478bd9Sstevel@tonic-gate if (SZ >= CONTROL_LEN) \
2777c478bd9Sstevel@tonic-gate { \
2787c478bd9Sstevel@tonic-gate     register unsigned char	*p = (unsigned char *)B, \
2797c478bd9Sstevel@tonic-gate 			    *pend = p + SZ - TAIL_LEN; \
2807c478bd9Sstevel@tonic-gate     RC = 0; \
2817c478bd9Sstevel@tonic-gate     while (p < pend) \
2827c478bd9Sstevel@tonic-gate 	RC += *p++;  /* let it overflow */ \
2837c478bd9Sstevel@tonic-gate } \
2847c478bd9Sstevel@tonic-gate else \
2857c478bd9Sstevel@tonic-gate     return ((errno = EINVAL, -1))
2867c478bd9Sstevel@tonic-gate 
2877c478bd9Sstevel@tonic-gate /*
2887c478bd9Sstevel@tonic-gate **      Largest size permitted for any given message
2897c478bd9Sstevel@tonic-gate */
2907c478bd9Sstevel@tonic-gate # define	MSGMAX		2048
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate /*
2937c478bd9Sstevel@tonic-gate **      Possible values of the type field of S_QUIET_ALERT
2947c478bd9Sstevel@tonic-gate */
2957c478bd9Sstevel@tonic-gate # define	QA_FORM		1
2967c478bd9Sstevel@tonic-gate # define	QA_PRINTER	2
2977c478bd9Sstevel@tonic-gate # define	QA_PRINTWHEEL	3
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate typedef	struct	strbuf	strbuf_t;	/*  STREAMS buffer */
3007c478bd9Sstevel@tonic-gate 
3017c478bd9Sstevel@tonic-gate typedef	struct mque
3027c478bd9Sstevel@tonic-gate {
3037c478bd9Sstevel@tonic-gate     struct mque	  *next;
3047c478bd9Sstevel@tonic-gate     struct strbuf *dat;
3057c478bd9Sstevel@tonic-gate } MQUE;
3067c478bd9Sstevel@tonic-gate 
3077c478bd9Sstevel@tonic-gate /*
3087c478bd9Sstevel@tonic-gate **	Definition of a message descriptor
3097c478bd9Sstevel@tonic-gate */
3107c478bd9Sstevel@tonic-gate typedef struct
3117c478bd9Sstevel@tonic-gate {
3127c478bd9Sstevel@tonic-gate     short	type;			/* type of connection */
3137c478bd9Sstevel@tonic-gate     int		readfd;			/* STREAM fd to read from */
3147c478bd9Sstevel@tonic-gate     int		writefd;		/* STREAM fd to write to */
3157c478bd9Sstevel@tonic-gate     int		wait;			/* number of systems waiting for */
3167c478bd9Sstevel@tonic-gate     char	*file;			/* pipe name if type==MD_FIFO */
3177c478bd9Sstevel@tonic-gate     short	state;			/* Current state of client */
3187c478bd9Sstevel@tonic-gate     short	admin;			/* Non zero if admin  */
3197c478bd9Sstevel@tonic-gate     short	event;			/* Event returned from poll */
3207c478bd9Sstevel@tonic-gate     MQUE *	mque;			/* backlogged message ptr */
3217c478bd9Sstevel@tonic-gate     uid_t	uid;			/* Clients UID */
3227c478bd9Sstevel@tonic-gate     gid_t	gid;			/* Clients GID */
32345916cd2Sjpk     char *	slabel;			/* Clients SLABEL */
3247c478bd9Sstevel@tonic-gate     void	(**on_discon)();	/* Clean up functions */
3257c478bd9Sstevel@tonic-gate } MESG;
3267c478bd9Sstevel@tonic-gate 
3277c478bd9Sstevel@tonic-gate # define	MDSIZE	(sizeof(MESG))
3287c478bd9Sstevel@tonic-gate 
3297c478bd9Sstevel@tonic-gate /*
3307c478bd9Sstevel@tonic-gate **	Possible values of MESG.state
3317c478bd9Sstevel@tonic-gate */
3327c478bd9Sstevel@tonic-gate # define	MDS_IDLE	0
3337c478bd9Sstevel@tonic-gate 
3347c478bd9Sstevel@tonic-gate # define	MDS_32PROTO	320
3357c478bd9Sstevel@tonic-gate # define	MDS_32CONNECT	321
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate /*
3387c478bd9Sstevel@tonic-gate **	Possible values of MESG.type
3397c478bd9Sstevel@tonic-gate */
3407c478bd9Sstevel@tonic-gate # define	MD_UNKNOWN	0	/* We don't know just yet */
3417c478bd9Sstevel@tonic-gate # define	MD_STREAM	1	/* 4.0 STREAMS pipe protocol */
3427c478bd9Sstevel@tonic-gate # define	MD_BOUND	2	/* 4.0 STREAMS fd protocol */
3437c478bd9Sstevel@tonic-gate # define	MD_SYS_FIFO	3	/* 3.2 named-pipe protocol */
3447c478bd9Sstevel@tonic-gate # define	MD_USR_FIFO	4	/* 3.2 named-pipe protocol */
3457c478bd9Sstevel@tonic-gate # define	MD_MASTER	5	/* MD_STREAM used by lpsched */
3467c478bd9Sstevel@tonic-gate # define	MD_CHILD	6	/* MD_STREAM to a child process */
3477c478bd9Sstevel@tonic-gate 
3487c478bd9Sstevel@tonic-gate /*
3497c478bd9Sstevel@tonic-gate **	Definition for a FIFO buffer (used
3507c478bd9Sstevel@tonic-gate **	in read_fifo.
3517c478bd9Sstevel@tonic-gate */
3527c478bd9Sstevel@tonic-gate typedef struct
3537c478bd9Sstevel@tonic-gate {
3547c478bd9Sstevel@tonic-gate 	int	full;
3557c478bd9Sstevel@tonic-gate 	char	save [MSGMAX],
3567c478bd9Sstevel@tonic-gate 		*psave,
3577c478bd9Sstevel@tonic-gate 		*psave_end;
3587c478bd9Sstevel@tonic-gate } fifobuffer_t;
3597c478bd9Sstevel@tonic-gate 
3607c478bd9Sstevel@tonic-gate /*
3617c478bd9Sstevel@tonic-gate **      Definitions for the rest of the world and lint
3627c478bd9Sstevel@tonic-gate */
3637c478bd9Sstevel@tonic-gate /*
3647c478bd9Sstevel@tonic-gate **	Server functions in order of usage
3657c478bd9Sstevel@tonic-gate */
3667c478bd9Sstevel@tonic-gate MESG		* mcreate ( char * );
3677c478bd9Sstevel@tonic-gate int		mlisteninit ( MESG * );
3687c478bd9Sstevel@tonic-gate MESG		* mlisten ( void );
3697c478bd9Sstevel@tonic-gate int		mlistenadd ( MESG *, short );
3707c478bd9Sstevel@tonic-gate int		mon_discon ( MESG *, void (*)());
3717c478bd9Sstevel@tonic-gate MESG		* mlistenreset ( void );
3727c478bd9Sstevel@tonic-gate int		mdestroy ( MESG * );
3737c478bd9Sstevel@tonic-gate 
3747c478bd9Sstevel@tonic-gate /*
3757c478bd9Sstevel@tonic-gate **	Client functions in order of typical usage
3767c478bd9Sstevel@tonic-gate */
3777c478bd9Sstevel@tonic-gate MESG		* mconnect ( char *, int, int );
3787c478bd9Sstevel@tonic-gate int		mgetm ( MESG *, int, ... );
3797c478bd9Sstevel@tonic-gate int		mwrite ( MESG *, char * );
3807c478bd9Sstevel@tonic-gate int		mputm ( MESG *, int, ... );
3817c478bd9Sstevel@tonic-gate int		mread ( MESG *, char *, int );
3827c478bd9Sstevel@tonic-gate short		msize ( char * );
3837c478bd9Sstevel@tonic-gate short		mpeek ( MESG * );
3847c478bd9Sstevel@tonic-gate int		mdisconnect ( MESG * );
3857c478bd9Sstevel@tonic-gate 
3867c478bd9Sstevel@tonic-gate /*
3877c478bd9Sstevel@tonic-gate **	This may be called to deallocate internal buffers allocated
3887c478bd9Sstevel@tonic-gate **	by mgetm and mputm.  Probably not useful except right before
3897c478bd9Sstevel@tonic-gate **	a fork().
3907c478bd9Sstevel@tonic-gate */
3917c478bd9Sstevel@tonic-gate void		__mbfree ( void );
3927c478bd9Sstevel@tonic-gate 
3937c478bd9Sstevel@tonic-gate /*
3947c478bd9Sstevel@tonic-gate **	Client functions for pre-4.0 compatability
3957c478bd9Sstevel@tonic-gate */
3967c478bd9Sstevel@tonic-gate int		mclose ( void );
3977c478bd9Sstevel@tonic-gate int		mneeds ( void );
3987c478bd9Sstevel@tonic-gate int		mopen ( void );
3997c478bd9Sstevel@tonic-gate int		mrecv ( char *, int );
4007c478bd9Sstevel@tonic-gate int		msend ( char * );
4017c478bd9Sstevel@tonic-gate 
4027c478bd9Sstevel@tonic-gate int		Putmsg (MESG *, strbuf_t *, strbuf_t *, int);
4037c478bd9Sstevel@tonic-gate int		Getmsg (MESG *, strbuf_t *, strbuf_t *, int *);
4047c478bd9Sstevel@tonic-gate int		read3_2 (MESG * md, char *msgbuf, int size);
4057c478bd9Sstevel@tonic-gate int		write3_2 (MESG *, char *, int);
4067c478bd9Sstevel@tonic-gate int		read_fifo (int, char *, unsigned int);
4077c478bd9Sstevel@tonic-gate int		write_fifo (int, char *, unsigned int);
4087c478bd9Sstevel@tonic-gate int		ResetFifoBuffer (int);
4097c478bd9Sstevel@tonic-gate fifobuffer_t	*GetFifoBuffer (int);
4107c478bd9Sstevel@tonic-gate 
4117c478bd9Sstevel@tonic-gate /*
4127c478bd9Sstevel@tonic-gate **	General purpose message manipulating functions
4137c478bd9Sstevel@tonic-gate */
4147c478bd9Sstevel@tonic-gate char		* htos ( char *, unsigned short );
4157c478bd9Sstevel@tonic-gate char		* ltos ( char *, unsigned long );
4167c478bd9Sstevel@tonic-gate unsigned long	stol ( char * );
4177c478bd9Sstevel@tonic-gate unsigned short	stoh ( char * );
4187c478bd9Sstevel@tonic-gate int		_getmessage ( char *, short, va_list );
4197c478bd9Sstevel@tonic-gate int		_putmessage ( char *, short, va_list );
4207c478bd9Sstevel@tonic-gate int		getmessage ( char *, short, ... );
4217c478bd9Sstevel@tonic-gate int		putmessage ( char *, short, ... );
4227c478bd9Sstevel@tonic-gate 
4237c478bd9Sstevel@tonic-gate /*
4247c478bd9Sstevel@tonic-gate **	This will yield the type of a message
4257c478bd9Sstevel@tonic-gate */
4267c478bd9Sstevel@tonic-gate # define	mtype(buffer)	(getmessage(buffer, I_GET_TYPE))
4277c478bd9Sstevel@tonic-gate 
4287c478bd9Sstevel@tonic-gate /*
4297c478bd9Sstevel@tonic-gate **	This will yeild the size of a message
4307c478bd9Sstevel@tonic-gate */
4317c478bd9Sstevel@tonic-gate # define	msize(buffer)	(stoh(buffer))
4327c478bd9Sstevel@tonic-gate 
4337c478bd9Sstevel@tonic-gate /*
4347c478bd9Sstevel@tonic-gate **	Pass this for the request-id argument of S_CANCEL
4357c478bd9Sstevel@tonic-gate **	to obtain the effect of the 3.2 S_CANCEL_REQUEST.
4367c478bd9Sstevel@tonic-gate */
4377c478bd9Sstevel@tonic-gate # define	CURRENT_REQ	"current"
4387c478bd9Sstevel@tonic-gate 
4397c478bd9Sstevel@tonic-gate #endif	/* !defined (_LP_MSGS_H) */
440