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