xref: /onnv-gate/usr/src/cmd/lp/model/netpr/netpr.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*	Copyright (c) 1996,  by Sun Microsystems, Inc.	*/
23*0Sstevel@tonic-gate /*	All rights reserved.				*/
24*0Sstevel@tonic-gate 
25*0Sstevel@tonic-gate #ifndef	_NETPR_H
26*0Sstevel@tonic-gate #define	_NETPR_H
27*0Sstevel@tonic-gate 
28*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #ifdef	__cplusplus
31*0Sstevel@tonic-gate extern "C" {
32*0Sstevel@tonic-gate #endif
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate #define	BSD	0
35*0Sstevel@tonic-gate #define	TCP	1
36*0Sstevel@tonic-gate #define	NOBANNER	0
37*0Sstevel@tonic-gate #define	BANNER	1
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate #define	CONTROL_FIRST	0
40*0Sstevel@tonic-gate #define	DATA_FIRST	1
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate #define	ERRORMSG	0
43*0Sstevel@tonic-gate #define	OKMSG		1
44*0Sstevel@tonic-gate 
45*0Sstevel@tonic-gate #define	DEST_SEP	":"
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate #define	MAX_REQ_ID	3
48*0Sstevel@tonic-gate 
49*0Sstevel@tonic-gate #define	ASCII_UULONG_MAX 22
50*0Sstevel@tonic-gate 
51*0Sstevel@tonic-gate #define	XFER_REQUEST	2	/* \2printer\n */
52*0Sstevel@tonic-gate #define	XFER_CLEANUP	1 	/* \1 */
53*0Sstevel@tonic-gate #define	XFER_CONTROL	2	/* \2size name\n */
54*0Sstevel@tonic-gate #define	XFER_DATA	3	/* \3size name\n */
55*0Sstevel@tonic-gate #define	PRINT_REQUEST	1   	/* \1printer\n */
56*0Sstevel@tonic-gate #define	REMOVE_REQUEST	5   	/* \5printer person [users|jobs ...]\n */
57*0Sstevel@tonic-gate #define	SHOW_QUEUE_SHORT_REQUEST  3	/* \3printer [users|jobs ...]\n */
58*0Sstevel@tonic-gate #define	SHOW_QUEUE_LONG_REQUEST  4	/* \4printer [users|jobs ...]\n */
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate 
61*0Sstevel@tonic-gate #define	E_SUCCESS			0
62*0Sstevel@tonic-gate #define	E_FAILURE			1
63*0Sstevel@tonic-gate #define	E_SYSTEM_ERROR			2
64*0Sstevel@tonic-gate #define	E_BAD_FILE			3
65*0Sstevel@tonic-gate #define	E_BAD_INPUT			4
66*0Sstevel@tonic-gate #define	E_SYSTEM_ERR			5
67*0Sstevel@tonic-gate #define	E_SEND_OK			6
68*0Sstevel@tonic-gate #define	E_RETRY				129
69*0Sstevel@tonic-gate #define	E_SIGPIPE			130
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate 
72*0Sstevel@tonic-gate #define	NETWORK_ERROR_UNKNOWN		20
73*0Sstevel@tonic-gate #define	NETWORK_ERROR_HOST		21
74*0Sstevel@tonic-gate #define	NETWORK_ERROR_SERVICE		22
75*0Sstevel@tonic-gate #define	NETWORK_ERROR_PORT		23
76*0Sstevel@tonic-gate #define	NETWORK_ERROR_SEND_RESPONSE	24
77*0Sstevel@tonic-gate #define	NETWORK_ERROR_SEND_FAILED	25
78*0Sstevel@tonic-gate #define	NETWORK_ERROR_MSG_FAILED	26
79*0Sstevel@tonic-gate #define	NETWORK_ERROR_WRITE_FAILED	27
80*0Sstevel@tonic-gate #define	NETWORK_PRINTER_REFUSED_CONN	28
81*0Sstevel@tonic-gate #define	NETWORK_READ_RESPONSE_FAILED	29
82*0Sstevel@tonic-gate 
83*0Sstevel@tonic-gate 
84*0Sstevel@tonic-gate #define	MALLOC	(int size, char * msg)	\
85*0Sstevel@tonic-gate 	{ \
86*0Sstevel@tonic-gate 		printf("File %s line %d\n", __FILE__, __LINE__); \
87*0Sstevel@tonic-gate 		printf("malloc: size: <%d>, for <%s>\n"); \
88*0Sstevel@tonic-gate 		malloc(size); \
89*0Sstevel@tonic-gate 	}
90*0Sstevel@tonic-gate 
91*0Sstevel@tonic-gate 
92*0Sstevel@tonic-gate typedef struct np_data np_data_t;
93*0Sstevel@tonic-gate typedef struct np_bsdjob np_bsdjob_t;
94*0Sstevel@tonic-gate typedef struct job	np_job_t;
95*0Sstevel@tonic-gate typedef struct np_tcp_job np_tcpjob_t;
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate /*
98*0Sstevel@tonic-gate  * Contains the input data for this job.
99*0Sstevel@tonic-gate  * Data is independent of protocol
100*0Sstevel@tonic-gate  */
101*0Sstevel@tonic-gate 
102*0Sstevel@tonic-gate struct job {
103*0Sstevel@tonic-gate 	char	*filename;
104*0Sstevel@tonic-gate 	char	*request_id;
105*0Sstevel@tonic-gate 	char	*printer;
106*0Sstevel@tonic-gate 	char	*dest;
107*0Sstevel@tonic-gate 	char	*title;
108*0Sstevel@tonic-gate 	int	protocol;
109*0Sstevel@tonic-gate 	char	*username;
110*0Sstevel@tonic-gate 	int	timeout;
111*0Sstevel@tonic-gate 	int	banner;
112*0Sstevel@tonic-gate 	int	filesize;
113*0Sstevel@tonic-gate };
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate struct np_tcp_job {
116*0Sstevel@tonic-gate 	np_job_t * gen_data;
117*0Sstevel@tonic-gate 	char * np_port;
118*0Sstevel@tonic-gate 	char * np_host;
119*0Sstevel@tonic-gate };
120*0Sstevel@tonic-gate 
121*0Sstevel@tonic-gate struct np_data {
122*0Sstevel@tonic-gate 	char	*np_dfAfilename;
123*0Sstevel@tonic-gate 	char	*np_path_file;	/* /<path>/<filename> we are printing 	*/
124*0Sstevel@tonic-gate 	long	np_data_size;	/* using stat, XXX mmap better??	*/
125*0Sstevel@tonic-gate 	char	*jobfile_data;
126*0Sstevel@tonic-gate };
127*0Sstevel@tonic-gate 
128*0Sstevel@tonic-gate 
129*0Sstevel@tonic-gate struct np_bsdjob {
130*0Sstevel@tonic-gate 	char		*np_filename;
131*0Sstevel@tonic-gate 	char 		*np_request_id;
132*0Sstevel@tonic-gate 	char		*np_printer;
133*0Sstevel@tonic-gate 	char		*np_destination;
134*0Sstevel@tonic-gate 	char		*np_title;
135*0Sstevel@tonic-gate 	char		*np_username;
136*0Sstevel@tonic-gate 	int		np_timeout;
137*0Sstevel@tonic-gate 	int		np_banner;
138*0Sstevel@tonic-gate 	char		*np_host;
139*0Sstevel@tonic-gate 	int		np_print_order;
140*0Sstevel@tonic-gate 	char		*np_cfAfilename;
141*0Sstevel@tonic-gate 	char		*np_cfAfile;
142*0Sstevel@tonic-gate 	uint		np_cfAfilesize;
143*0Sstevel@tonic-gate 	char		np_df_letter;		/* [A-Z][a-z] use this one */
144*0Sstevel@tonic-gate 	np_data_t	*np_data;
145*0Sstevel@tonic-gate };
146*0Sstevel@tonic-gate 
147*0Sstevel@tonic-gate extern append_list(np_data_t *, np_bsdjob_t *);
148*0Sstevel@tonic-gate extern char * long2str(long, char *);
149*0Sstevel@tonic-gate extern void null_sighandler(int);
150*0Sstevel@tonic-gate extern int open_network(char *, int);
151*0Sstevel@tonic-gate extern int xfer_file(int, caddr_t, int, int);
152*0Sstevel@tonic-gate extern int add_bsd_file(char *, np_bsdjob_t *);
153*0Sstevel@tonic-gate extern int start_bsd_job(int, char *);
154*0Sstevel@tonic-gate extern void done_and_close(int);
155*0Sstevel@tonic-gate extern void panic();
156*0Sstevel@tonic-gate extern char * alloc_str(char *);
157*0Sstevel@tonic-gate extern np_bsdjob_t * create_bsd_job(np_job_t *, int, int);
158*0Sstevel@tonic-gate extern np_tcpjob_t * create_tcp_job(np_job_t *, int);
159*0Sstevel@tonic-gate extern int net_send_cmd(int, char *, ...);
160*0Sstevel@tonic-gate extern np_job_t * init_job(void);
161*0Sstevel@tonic-gate extern int bsd_print(int, caddr_t, np_bsdjob_t *);
162*0Sstevel@tonic-gate extern int tcp_print(int, caddr_t, np_tcpjob_t *);
163*0Sstevel@tonic-gate extern int tcp_open(char *, np_tcpjob_t *, int);
164*0Sstevel@tonic-gate extern void tell_lptell(int, char *, ...);
165*0Sstevel@tonic-gate extern int net_open(char *, int);
166*0Sstevel@tonic-gate extern void parse_dest(char *, char **, char **, char *);
167*0Sstevel@tonic-gate extern int check_file(char *);
168*0Sstevel@tonic-gate 
169*0Sstevel@tonic-gate #ifdef	__cplusplus
170*0Sstevel@tonic-gate }
171*0Sstevel@tonic-gate #endif
172*0Sstevel@tonic-gate 
173*0Sstevel@tonic-gate #endif	/* _NETPR_H */
174