xref: /titanic_50/usr/src/cmd/lp/model/netpr/netpr.h (revision f928ce67ef743c33ea27c573c9c7e2d4a4833cbd)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_NETPR_H
28 #define	_NETPR_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #define	BSD	0
37 #define	TCP	1
38 #define	NOBANNER	0
39 #define	BANNER	1
40 
41 #define	CONTROL_FIRST	0
42 #define	DATA_FIRST	1
43 
44 #define	ERRORMSG	0
45 #define	OKMSG		1
46 
47 #define	DEST_SEP	":"
48 
49 #define	MAX_REQ_ID	3
50 
51 #define	ASCII_UULONG_MAX 22
52 
53 #define	XFER_REQUEST	2	/* \2printer\n */
54 #define	XFER_CLEANUP	1 	/* \1 */
55 #define	XFER_CONTROL	2	/* \2size name\n */
56 #define	XFER_DATA	3	/* \3size name\n */
57 #define	PRINT_REQUEST	1   	/* \1printer\n */
58 #define	REMOVE_REQUEST	5   	/* \5printer person [users|jobs ...]\n */
59 #define	SHOW_QUEUE_SHORT_REQUEST  3	/* \3printer [users|jobs ...]\n */
60 #define	SHOW_QUEUE_LONG_REQUEST  4	/* \4printer [users|jobs ...]\n */
61 
62 
63 #define	E_SUCCESS			0
64 #define	E_FAILURE			1
65 #define	E_SYSTEM_ERROR			2
66 #define	E_BAD_FILE			3
67 #define	E_BAD_INPUT			4
68 #define	E_SYSTEM_ERR			5
69 #define	E_SEND_OK			6
70 #define	E_RETRY				129
71 #define	E_SIGPIPE			130
72 
73 
74 #define	NETWORK_ERROR_UNKNOWN		20
75 #define	NETWORK_ERROR_HOST		21
76 #define	NETWORK_ERROR_SERVICE		22
77 #define	NETWORK_ERROR_PORT		23
78 #define	NETWORK_ERROR_SEND_RESPONSE	24
79 #define	NETWORK_ERROR_SEND_FAILED	25
80 #define	NETWORK_ERROR_MSG_FAILED	26
81 #define	NETWORK_ERROR_WRITE_FAILED	27
82 #define	NETWORK_PRINTER_REFUSED_CONN	28
83 #define	NETWORK_READ_RESPONSE_FAILED	29
84 
85 
86 #define	MALLOC	(int size, char * msg)	\
87 	{ \
88 		printf("File %s line %d\n", __FILE__, __LINE__); \
89 		printf("malloc: size: <%d>, for <%s>\n"); \
90 		malloc(size); \
91 	}
92 
93 
94 typedef struct np_data np_data_t;
95 typedef struct np_bsdjob np_bsdjob_t;
96 typedef struct job	np_job_t;
97 typedef struct np_tcp_job np_tcpjob_t;
98 
99 /*
100  * Contains the input data for this job.
101  * Data is independent of protocol
102  */
103 
104 struct job {
105 	char	*filename;
106 	char	*request_id;
107 	char	*printer;
108 	char	*dest;
109 	char	*title;
110 	int	protocol;
111 	char	*username;
112 	int	timeout;
113 	int	banner;
114 	int	filesize;
115 };
116 
117 struct np_tcp_job {
118 	np_job_t * gen_data;
119 	char * np_port;
120 	char * np_host;
121 };
122 
123 struct np_data {
124 	char	*np_dfAfilename;
125 	char	*np_path_file;	/* /<path>/<filename> we are printing 	*/
126 	long	np_data_size;	/* using stat, XXX mmap better??	*/
127 	char	*jobfile_data;
128 };
129 
130 
131 struct np_bsdjob {
132 	char		*np_filename;
133 	char 		*np_request_id;
134 	char		*np_printer;
135 	char		*np_destination;
136 	char		*np_title;
137 	char		*np_username;
138 	int		np_timeout;
139 	int		np_banner;
140 	char		*np_host;
141 	int		np_print_order;
142 	char		*np_cfAfilename;
143 	char		*np_cfAfile;
144 	uint		np_cfAfilesize;
145 	char		np_df_letter;		/* [A-Z][a-z] use this one */
146 	np_data_t	*np_data;
147 };
148 
149 extern char * long2str(long, char *);
150 extern void null_sighandler(int);
151 extern int open_network(char *, int);
152 extern int xfer_file(int, caddr_t, int, int);
153 extern int add_bsd_file(char *, np_bsdjob_t *);
154 extern int start_bsd_job(int, char *);
155 extern void done_and_close(int);
156 extern void panic();
157 extern char * alloc_str(char *);
158 extern np_bsdjob_t * create_bsd_job(np_job_t *, int, int);
159 extern np_tcpjob_t * create_tcp_job(np_job_t *, int);
160 extern int net_send_cmd(int, char *, ...);
161 extern np_job_t * init_job(void);
162 extern int bsd_print(int, caddr_t, np_bsdjob_t *);
163 extern int tcp_print(int, caddr_t, np_tcpjob_t *);
164 extern int tcp_open(char *, np_tcpjob_t *, int);
165 extern void tell_lptell(int, char *, ...);
166 extern int net_open(char *, int);
167 extern void parse_dest(char *, char **, char **, char *);
168 extern int check_file(char *);
169 
170 #ifdef	__cplusplus
171 }
172 #endif
173 
174 #endif	/* _NETPR_H */
175