xref: /illumos-gate/usr/src/cmd/lp/include/printers.h (revision ed093b41a93e8563e6e1e5dae0768dda2a7bcc27)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
22 /*	  All Rights Reserved  	*/
23 
24 
25 /*
26  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
27  * Use is subject to license terms.
28  * Copyright 2019 Joyent, Inc.
29  */
30 
31 #if	!defined(_LP_PRINTERS_H)
32 #define	_LP_PRINTERS_H
33 
34 /*
35  * Define the following to support administrator configurable
36  * streams modules:
37  */
38 #define	CAN_DO_MODULES	1	/* */
39 
40 /**
41  ** The disk copy of the printer files:
42  **/
43 
44 /*
45  * There are 19 fields in the printer configuration file.
46  */
47 #define PR_MAX	19
48 # define PR_BAN		0
49 # define PR_CPI		1
50 # define PR_CS		2
51 # define PR_ITYPES	3
52 # define PR_DEV		4
53 # define PR_DIAL	5
54 # define PR_RECOV	6
55 # define PR_INTFC	7
56 # define PR_LPI		8
57 # define PR_LEN		9
58 # define PR_LOGIN	10
59 # define PR_PTYPE	11
60 # define PR_REMOTE	12
61 # define PR_SPEED	13
62 # define PR_STTY	14
63 # define PR_WIDTH	15
64 # define PR_MODULES	16
65 #define PR_OPTIONS	17
66 #define PR_PPD		18
67 
68 /**
69  ** The internal flags seen by the Spooler/Scheduler and anyone who asks.
70  **/
71 
72 #define	PS_REJECTED	0x001
73 #define	PS_DISABLED	0x002
74 #define	PS_FAULTED	0x004
75 #define	PS_BUSY		0x008
76 #define	PS_LATER	0x010	/* Printer is scheduled for service */
77 #define PS_SHOW_FAULT	0x100 /* set if exMess should be run when fault */
78 #define PS_USE_AS_KEY	0x200 /* to insure that status used as key is non 0 */
79 #define PS_FORM_FAULT	0x400 /* set a form fault rather a printer fault*/
80 
81 /**
82  ** The internal copy of a printer as seen by the rest of the world:
83  **/
84 
85 /*
86  * A (char **) list is an array of string pointers (char *) with
87  * a null pointer after the last item.
88  */
89 typedef struct PRINTER {
90 	char   *name;		/* name of printer (redundant) */
91 	unsigned short banner;	/* banner page conditions */
92 	SCALED cpi;             /* default character pitch */
93 	char   **char_sets;     /* list of okay char-sets/print-wheels */
94 	char   **input_types;   /* list of types acceptable to printer */
95 	char   *device;         /* printer port full path name */
96 	char   *dial_info;      /* system name or phone # for dial-up */
97 	char   *fault_rec;      /* printer fault recovery procedure */
98 	char   *interface;      /* interface program full path name */
99 	SCALED lpi;             /* default line pitch */
100 	SCALED plen;            /* default page length */
101 	unsigned short login;	/* is/isn't a login terminal */
102 	char   *printer_type;   /* Terminfo look-up value (obsolete) */
103 	char   *remote;         /* remote machine!printer-name */
104 	char   *speed;          /* baud rate for connection */
105 	char   *stty;           /* space separated list of stty options */
106 	SCALED pwid;            /* default page width */
107 	char   *description;	/* comment about printer */
108 	FALERT fault_alert;	/* how to alert on printer fault */
109 	short  daisy;           /* 1/0 - printwheels/character-sets */
110 #if     defined(CAN_DO_MODULES)
111 	char   **modules;	/* streams modules to push */
112 #endif
113 	char   **printer_types; /* Terminfo look-up values */
114 	char	**options;	/* space separated list of undefined -o options */
115 
116 #ifdef LP_USE_PAPI_ATTR
117 	char	*ppd;		/* printer's PPD file full path name */
118 #endif
119 	/*
120 	 * Adding new members to this structure? Check out
121 	 * cmd/lpadmin/do_printer.c, where we initialize
122 	 * each new printer structure.
123 	 */
124 }			PRINTER;
125 
126 #define BAN_ALWAYS	0x01	/* user can't override banner */
127 #define BAN_OFF		0x02	/* don't print banner page */
128 #define BAN_NEVER	BAN_OFF
129 #define BAN_OPTIONAL	(BAN_ALWAYS | BAN_NEVER) /* user can override banner */
130 
131 #define LOG_IN		0x01	/* printer is login terminal */
132 
133 #define PCK_TYPE	0x0001	/* printer type isn't in Terminfo */
134 #define PCK_CHARSET	0x0002	/* printer type can't handle ".char_sets" */
135 #define PCK_CPI		0x0004	/* printer type can't handle ".cpi" */
136 #define PCK_LPI		0x0008	/* printer type can't handle ".lpi" */
137 #define PCK_WIDTH	0x0010	/* printer type can't handle ".pwid" */
138 #define PCK_LENGTH	0x0020	/* printer type can't handle ".plen" */
139 #define PCK_PAPER	0x0040	/* printer type can't handle paper */
140 
141 /*
142  * The following PCK_... bits are only set by the Spooler,
143  * when refusing a request.
144  */
145 #define PCK_BANNER	0x1000	/* printer needs banner */
146 
147 /*
148  * Flags set by "putprinter()" for things that go wrong.
149  */
150 #define BAD_REMOTE	0x0001	/* has attributes of remote and local */
151 #define BAD_INTERFACE	0x0002	/* no interface or can't read it */
152 #define BAD_DEVDIAL	0x0004	/* no device or dial information */
153 #define BAD_FAULT	0x0008	/* not recognized fault recovery */
154 #define BAD_ALERT	0x0010	/* has reserved word for alert command */
155 #define BAD_ITYPES	0x0020	/* multiple printer AND input types */
156 #define BAD_PTYPES	0x0040	/* multiple printer types, incl unknown */
157 #define BAD_DAISY	0x0080	/* printer types don't agree on "daisy" */
158 
159 /*
160  * A comma separated list of STREAMS modules to be pushed on an
161  * opened port.
162  */
163 #define	DEFMODULES	"ldterm"
164 
165 /*
166  * For print wheels:
167  */
168 
169 typedef struct PWHEEL {
170 	char   *name;		/* name of print wheel */
171 	FALERT alert;		/* how to alert when mount needed */
172 }			PWHEEL;
173 
174 extern unsigned long	badprinter,
175 			ignprinter;
176 
177 /*
178  * Set if ppd file information is from the user rather than
179  * the configuration file.
180  */
181 extern int ppdopt;
182 
183 /**
184  ** Various routines.
185  **/
186 
187 PRINTER *	getprinter ( char * );
188 
189 PWHEEL *	getpwheel ( char * );
190 
191 char *		getdefault ( void );
192 
193 int		putprinter ( char *, PRINTER *);
194 int		delprinter ( char * );
195 int		putdefault ( char * );
196 int		deldefault ( void );
197 int		putpwheel ( char * , PWHEEL * );
198 int		delpwheel ( char * );
199 int		okprinter ( char * , PRINTER * , int );
200 
201 unsigned long	chkprinter (char *, char *, char *, char *, char *, char *);
202 
203 void		freeprinter ( PRINTER * );
204 void		freepwheel ( PWHEEL * );
205 
206 char *	getpentry(char *, int);
207 
208 /**
209  ** Aliases (copies) of some important Terminfo caps.
210  **/
211 
212 extern int		ti_daisy;
213 
214 #endif
215