summaryrefslogtreecommitdiff
path: root/usr/src/cmd/lp/include/printers.h
blob: 915f9a6eb3371b648afae641dd748fc44f1a0b97 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
/*	  All Rights Reserved  	*/


/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 * Copyright 2019 Joyent, Inc.
 */

#if	!defined(_LP_PRINTERS_H)
#define	_LP_PRINTERS_H

/*
 * Define the following to support administrator configurable
 * streams modules:
 */
#define	CAN_DO_MODULES	1	/* */

/**
 ** The disk copy of the printer files:
 **/

/*
 * There are 19 fields in the printer configuration file.
 */
#define PR_MAX	19
# define PR_BAN		0
# define PR_CPI		1
# define PR_CS		2
# define PR_ITYPES	3
# define PR_DEV		4
# define PR_DIAL	5
# define PR_RECOV	6
# define PR_INTFC	7
# define PR_LPI		8
# define PR_LEN		9
# define PR_LOGIN	10
# define PR_PTYPE	11
# define PR_REMOTE	12
# define PR_SPEED	13
# define PR_STTY	14
# define PR_WIDTH	15
# define PR_MODULES	16
#define PR_OPTIONS	17
#define PR_PPD		18

/**
 ** The internal flags seen by the Spooler/Scheduler and anyone who asks.
 **/

#define	PS_REJECTED	0x001
#define	PS_DISABLED	0x002
#define	PS_FAULTED	0x004
#define	PS_BUSY		0x008
#define	PS_LATER	0x010	/* Printer is scheduled for service */
#define PS_SHOW_FAULT	0x100 /* set if exMess should be run when fault */
#define PS_USE_AS_KEY	0x200 /* to insure that status used as key is non 0 */
#define PS_FORM_FAULT	0x400 /* set a form fault rather a printer fault*/

/**
 ** The internal copy of a printer as seen by the rest of the world:
 **/

/*
 * A (char **) list is an array of string pointers (char *) with
 * a null pointer after the last item.
 */
typedef struct PRINTER {
	char   *name;		/* name of printer (redundant) */
	unsigned short banner;	/* banner page conditions */
	SCALED cpi;             /* default character pitch */
	char   **char_sets;     /* list of okay char-sets/print-wheels */
	char   **input_types;   /* list of types acceptable to printer */
	char   *device;         /* printer port full path name */
	char   *dial_info;      /* system name or phone # for dial-up */
	char   *fault_rec;      /* printer fault recovery procedure */
	char   *interface;      /* interface program full path name */
	SCALED lpi;             /* default line pitch */
	SCALED plen;            /* default page length */
	unsigned short login;	/* is/isn't a login terminal */
	char   *printer_type;   /* Terminfo look-up value (obsolete) */
	char   *remote;         /* remote machine!printer-name */
	char   *speed;          /* baud rate for connection */
	char   *stty;           /* space separated list of stty options */
	SCALED pwid;            /* default page width */
	char   *description;	/* comment about printer */
	FALERT fault_alert;	/* how to alert on printer fault */
	short  daisy;           /* 1/0 - printwheels/character-sets */
#if     defined(CAN_DO_MODULES)
	char   **modules;	/* streams modules to push */
#endif
	char   **printer_types; /* Terminfo look-up values */
	char	**options;	/* space separated list of undefined -o options */

#ifdef LP_USE_PAPI_ATTR
	char	*ppd;		/* printer's PPD file full path name */
#endif
	/*
	 * Adding new members to this structure? Check out
	 * cmd/lpadmin/do_printer.c, where we initialize
	 * each new printer structure.
	 */
}			PRINTER;

#define BAN_ALWAYS	0x01	/* user can't override banner */
#define BAN_OFF		0x02	/* don't print banner page */
#define BAN_NEVER	BAN_OFF
#define BAN_OPTIONAL	(BAN_ALWAYS | BAN_NEVER) /* user can override banner */

#define LOG_IN		0x01	/* printer is login terminal */

#define PCK_TYPE	0x0001	/* printer type isn't in Terminfo */
#define PCK_CHARSET	0x0002	/* printer type can't handle ".char_sets" */
#define PCK_CPI		0x0004	/* printer type can't handle ".cpi" */
#define PCK_LPI		0x0008	/* printer type can't handle ".lpi" */
#define PCK_WIDTH	0x0010	/* printer type can't handle ".pwid" */
#define PCK_LENGTH	0x0020	/* printer type can't handle ".plen" */
#define PCK_PAPER	0x0040	/* printer type can't handle paper */

/*
 * The following PCK_... bits are only set by the Spooler,
 * when refusing a request.
 */
#define PCK_BANNER	0x1000	/* printer needs banner */

/*
 * Flags set by "putprinter()" for things that go wrong.
 */
#define BAD_REMOTE	0x0001	/* has attributes of remote and local */
#define BAD_INTERFACE	0x0002	/* no interface or can't read it */
#define BAD_DEVDIAL	0x0004	/* no device or dial information */
#define BAD_FAULT	0x0008	/* not recognized fault recovery */
#define BAD_ALERT	0x0010	/* has reserved word for alert command */
#define BAD_ITYPES	0x0020	/* multiple printer AND input types */
#define BAD_PTYPES	0x0040	/* multiple printer types, incl unknown */
#define BAD_DAISY	0x0080	/* printer types don't agree on "daisy" */

/*
 * A comma separated list of STREAMS modules to be pushed on an
 * opened port.
 */
#define	DEFMODULES	"ldterm"

/*
 * For print wheels:
 */

typedef struct PWHEEL {
	char   *name;		/* name of print wheel */
	FALERT alert;		/* how to alert when mount needed */
}			PWHEEL;

extern unsigned long	badprinter,
			ignprinter;

/*
 * Set if ppd file information is from the user rather than
 * the configuration file.
 */
extern int ppdopt;

/**
 ** Various routines.
 **/

PRINTER *	getprinter ( char * );

PWHEEL *	getpwheel ( char * );

char *		getdefault ( void );

int		putprinter ( char *, PRINTER *);
int		delprinter ( char * );
int		putdefault ( char * );
int		deldefault ( void );
int		putpwheel ( char * , PWHEEL * );
int		delpwheel ( char * );
int		okprinter ( char * , PRINTER * , int );

unsigned long	chkprinter (char *, char *, char *, char *, char *, char *);

void		freeprinter ( PRINTER * );
void		freepwheel ( PWHEEL * );

char *	getpentry(char *, int);

/**
 ** Aliases (copies) of some important Terminfo caps.
 **/

extern int		ti_daisy;

#endif