xref: /illumos-gate/usr/src/cmd/lp/model/netpr/netpr.h (revision 2a8bcb4e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
22*f928ce67Sceastha /*
23*f928ce67Sceastha  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*f928ce67Sceastha  * Use is subject to license terms.
25*f928ce67Sceastha  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate #ifndef	_NETPR_H
287c478bd9Sstevel@tonic-gate #define	_NETPR_H
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
317c478bd9Sstevel@tonic-gate extern "C" {
327c478bd9Sstevel@tonic-gate #endif
337c478bd9Sstevel@tonic-gate 
347c478bd9Sstevel@tonic-gate #define	BSD	0
357c478bd9Sstevel@tonic-gate #define	TCP	1
367c478bd9Sstevel@tonic-gate #define	NOBANNER	0
377c478bd9Sstevel@tonic-gate #define	BANNER	1
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	CONTROL_FIRST	0
407c478bd9Sstevel@tonic-gate #define	DATA_FIRST	1
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #define	ERRORMSG	0
437c478bd9Sstevel@tonic-gate #define	OKMSG		1
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #define	DEST_SEP	":"
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate #define	MAX_REQ_ID	3
487c478bd9Sstevel@tonic-gate 
497c478bd9Sstevel@tonic-gate #define	ASCII_UULONG_MAX 22
507c478bd9Sstevel@tonic-gate 
517c478bd9Sstevel@tonic-gate #define	XFER_REQUEST	2	/* \2printer\n */
527c478bd9Sstevel@tonic-gate #define	XFER_CLEANUP	1 	/* \1 */
537c478bd9Sstevel@tonic-gate #define	XFER_CONTROL	2	/* \2size name\n */
547c478bd9Sstevel@tonic-gate #define	XFER_DATA	3	/* \3size name\n */
557c478bd9Sstevel@tonic-gate #define	PRINT_REQUEST	1   	/* \1printer\n */
567c478bd9Sstevel@tonic-gate #define	REMOVE_REQUEST	5   	/* \5printer person [users|jobs ...]\n */
577c478bd9Sstevel@tonic-gate #define	SHOW_QUEUE_SHORT_REQUEST  3	/* \3printer [users|jobs ...]\n */
587c478bd9Sstevel@tonic-gate #define	SHOW_QUEUE_LONG_REQUEST  4	/* \4printer [users|jobs ...]\n */
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate #define	E_SUCCESS			0
627c478bd9Sstevel@tonic-gate #define	E_FAILURE			1
637c478bd9Sstevel@tonic-gate #define	E_SYSTEM_ERROR			2
647c478bd9Sstevel@tonic-gate #define	E_BAD_FILE			3
657c478bd9Sstevel@tonic-gate #define	E_BAD_INPUT			4
667c478bd9Sstevel@tonic-gate #define	E_SYSTEM_ERR			5
677c478bd9Sstevel@tonic-gate #define	E_SEND_OK			6
687c478bd9Sstevel@tonic-gate #define	E_RETRY				129
697c478bd9Sstevel@tonic-gate #define	E_SIGPIPE			130
707c478bd9Sstevel@tonic-gate 
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate #define	NETWORK_ERROR_UNKNOWN		20
737c478bd9Sstevel@tonic-gate #define	NETWORK_ERROR_HOST		21
747c478bd9Sstevel@tonic-gate #define	NETWORK_ERROR_SERVICE		22
757c478bd9Sstevel@tonic-gate #define	NETWORK_ERROR_PORT		23
767c478bd9Sstevel@tonic-gate #define	NETWORK_ERROR_SEND_RESPONSE	24
777c478bd9Sstevel@tonic-gate #define	NETWORK_ERROR_SEND_FAILED	25
787c478bd9Sstevel@tonic-gate #define	NETWORK_ERROR_MSG_FAILED	26
797c478bd9Sstevel@tonic-gate #define	NETWORK_ERROR_WRITE_FAILED	27
807c478bd9Sstevel@tonic-gate #define	NETWORK_PRINTER_REFUSED_CONN	28
817c478bd9Sstevel@tonic-gate #define	NETWORK_READ_RESPONSE_FAILED	29
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate 
847c478bd9Sstevel@tonic-gate #define	MALLOC	(int size, char * msg)	\
857c478bd9Sstevel@tonic-gate 	{ \
867c478bd9Sstevel@tonic-gate 		printf("File %s line %d\n", __FILE__, __LINE__); \
877c478bd9Sstevel@tonic-gate 		printf("malloc: size: <%d>, for <%s>\n"); \
887c478bd9Sstevel@tonic-gate 		malloc(size); \
897c478bd9Sstevel@tonic-gate 	}
907c478bd9Sstevel@tonic-gate 
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate typedef struct np_data np_data_t;
937c478bd9Sstevel@tonic-gate typedef struct np_bsdjob np_bsdjob_t;
947c478bd9Sstevel@tonic-gate typedef struct job	np_job_t;
957c478bd9Sstevel@tonic-gate typedef struct np_tcp_job np_tcpjob_t;
967c478bd9Sstevel@tonic-gate 
977c478bd9Sstevel@tonic-gate /*
987c478bd9Sstevel@tonic-gate  * Contains the input data for this job.
997c478bd9Sstevel@tonic-gate  * Data is independent of protocol
1007c478bd9Sstevel@tonic-gate  */
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate struct job {
1037c478bd9Sstevel@tonic-gate 	char	*filename;
1047c478bd9Sstevel@tonic-gate 	char	*request_id;
1057c478bd9Sstevel@tonic-gate 	char	*printer;
1067c478bd9Sstevel@tonic-gate 	char	*dest;
1077c478bd9Sstevel@tonic-gate 	char	*title;
1087c478bd9Sstevel@tonic-gate 	int	protocol;
1097c478bd9Sstevel@tonic-gate 	char	*username;
1107c478bd9Sstevel@tonic-gate 	int	timeout;
1117c478bd9Sstevel@tonic-gate 	int	banner;
1127c478bd9Sstevel@tonic-gate 	int	filesize;
1137c478bd9Sstevel@tonic-gate };
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate struct np_tcp_job {
1167c478bd9Sstevel@tonic-gate 	np_job_t * gen_data;
1177c478bd9Sstevel@tonic-gate 	char * np_port;
1187c478bd9Sstevel@tonic-gate 	char * np_host;
1197c478bd9Sstevel@tonic-gate };
1207c478bd9Sstevel@tonic-gate 
1217c478bd9Sstevel@tonic-gate struct np_data {
1227c478bd9Sstevel@tonic-gate 	char	*np_dfAfilename;
1237c478bd9Sstevel@tonic-gate 	char	*np_path_file;	/* /<path>/<filename> we are printing 	*/
1247c478bd9Sstevel@tonic-gate 	long	np_data_size;	/* using stat, XXX mmap better??	*/
1257c478bd9Sstevel@tonic-gate 	char	*jobfile_data;
1267c478bd9Sstevel@tonic-gate };
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate struct np_bsdjob {
1307c478bd9Sstevel@tonic-gate 	char		*np_filename;
1317c478bd9Sstevel@tonic-gate 	char 		*np_request_id;
1327c478bd9Sstevel@tonic-gate 	char		*np_printer;
1337c478bd9Sstevel@tonic-gate 	char		*np_destination;
1347c478bd9Sstevel@tonic-gate 	char		*np_title;
1357c478bd9Sstevel@tonic-gate 	char		*np_username;
1367c478bd9Sstevel@tonic-gate 	int		np_timeout;
1377c478bd9Sstevel@tonic-gate 	int		np_banner;
1387c478bd9Sstevel@tonic-gate 	char		*np_host;
1397c478bd9Sstevel@tonic-gate 	int		np_print_order;
1407c478bd9Sstevel@tonic-gate 	char		*np_cfAfilename;
1417c478bd9Sstevel@tonic-gate 	char		*np_cfAfile;
1427c478bd9Sstevel@tonic-gate 	uint		np_cfAfilesize;
1437c478bd9Sstevel@tonic-gate 	char		np_df_letter;		/* [A-Z][a-z] use this one */
1447c478bd9Sstevel@tonic-gate 	np_data_t	*np_data;
1457c478bd9Sstevel@tonic-gate };
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate extern char * long2str(long, char *);
1487c478bd9Sstevel@tonic-gate extern void null_sighandler(int);
1497c478bd9Sstevel@tonic-gate extern int open_network(char *, int);
1507c478bd9Sstevel@tonic-gate extern int xfer_file(int, caddr_t, int, int);
1517c478bd9Sstevel@tonic-gate extern int add_bsd_file(char *, np_bsdjob_t *);
1527c478bd9Sstevel@tonic-gate extern int start_bsd_job(int, char *);
1537c478bd9Sstevel@tonic-gate extern void done_and_close(int);
1547c478bd9Sstevel@tonic-gate extern void panic();
1557c478bd9Sstevel@tonic-gate extern char * alloc_str(char *);
1567c478bd9Sstevel@tonic-gate extern np_bsdjob_t * create_bsd_job(np_job_t *, int, int);
1577c478bd9Sstevel@tonic-gate extern np_tcpjob_t * create_tcp_job(np_job_t *, int);
1587c478bd9Sstevel@tonic-gate extern int net_send_cmd(int, char *, ...);
1597c478bd9Sstevel@tonic-gate extern np_job_t * init_job(void);
1607c478bd9Sstevel@tonic-gate extern int bsd_print(int, caddr_t, np_bsdjob_t *);
1617c478bd9Sstevel@tonic-gate extern int tcp_print(int, caddr_t, np_tcpjob_t *);
1627c478bd9Sstevel@tonic-gate extern int tcp_open(char *, np_tcpjob_t *, int);
1637c478bd9Sstevel@tonic-gate extern void tell_lptell(int, char *, ...);
1647c478bd9Sstevel@tonic-gate extern int net_open(char *, int);
1657c478bd9Sstevel@tonic-gate extern void parse_dest(char *, char **, char **, char *);
1667c478bd9Sstevel@tonic-gate extern int check_file(char *);
1677c478bd9Sstevel@tonic-gate 
1687c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1697c478bd9Sstevel@tonic-gate }
1707c478bd9Sstevel@tonic-gate #endif
1717c478bd9Sstevel@tonic-gate 
1727c478bd9Sstevel@tonic-gate #endif	/* _NETPR_H */
173