xref: /onnv-gate/usr/src/cmd/lp/model/netpr/netpr.h (revision 320:7e1ecf3ab9be)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
50Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
60Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
70Sstevel@tonic-gate  * with the License.
80Sstevel@tonic-gate  *
90Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
100Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
110Sstevel@tonic-gate  * See the License for the specific language governing permissions
120Sstevel@tonic-gate  * and limitations under the License.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
150Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
160Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
170Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
180Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
190Sstevel@tonic-gate  *
200Sstevel@tonic-gate  * CDDL HEADER END
210Sstevel@tonic-gate  */
22*320Sceastha /*
23*320Sceastha  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24*320Sceastha  * Use is subject to license terms.
25*320Sceastha  */
260Sstevel@tonic-gate 
270Sstevel@tonic-gate #ifndef	_NETPR_H
280Sstevel@tonic-gate #define	_NETPR_H
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #ifdef	__cplusplus
330Sstevel@tonic-gate extern "C" {
340Sstevel@tonic-gate #endif
350Sstevel@tonic-gate 
360Sstevel@tonic-gate #define	BSD	0
370Sstevel@tonic-gate #define	TCP	1
380Sstevel@tonic-gate #define	NOBANNER	0
390Sstevel@tonic-gate #define	BANNER	1
400Sstevel@tonic-gate 
410Sstevel@tonic-gate #define	CONTROL_FIRST	0
420Sstevel@tonic-gate #define	DATA_FIRST	1
430Sstevel@tonic-gate 
440Sstevel@tonic-gate #define	ERRORMSG	0
450Sstevel@tonic-gate #define	OKMSG		1
460Sstevel@tonic-gate 
470Sstevel@tonic-gate #define	DEST_SEP	":"
480Sstevel@tonic-gate 
490Sstevel@tonic-gate #define	MAX_REQ_ID	3
500Sstevel@tonic-gate 
510Sstevel@tonic-gate #define	ASCII_UULONG_MAX 22
520Sstevel@tonic-gate 
530Sstevel@tonic-gate #define	XFER_REQUEST	2	/* \2printer\n */
540Sstevel@tonic-gate #define	XFER_CLEANUP	1 	/* \1 */
550Sstevel@tonic-gate #define	XFER_CONTROL	2	/* \2size name\n */
560Sstevel@tonic-gate #define	XFER_DATA	3	/* \3size name\n */
570Sstevel@tonic-gate #define	PRINT_REQUEST	1   	/* \1printer\n */
580Sstevel@tonic-gate #define	REMOVE_REQUEST	5   	/* \5printer person [users|jobs ...]\n */
590Sstevel@tonic-gate #define	SHOW_QUEUE_SHORT_REQUEST  3	/* \3printer [users|jobs ...]\n */
600Sstevel@tonic-gate #define	SHOW_QUEUE_LONG_REQUEST  4	/* \4printer [users|jobs ...]\n */
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 
630Sstevel@tonic-gate #define	E_SUCCESS			0
640Sstevel@tonic-gate #define	E_FAILURE			1
650Sstevel@tonic-gate #define	E_SYSTEM_ERROR			2
660Sstevel@tonic-gate #define	E_BAD_FILE			3
670Sstevel@tonic-gate #define	E_BAD_INPUT			4
680Sstevel@tonic-gate #define	E_SYSTEM_ERR			5
690Sstevel@tonic-gate #define	E_SEND_OK			6
700Sstevel@tonic-gate #define	E_RETRY				129
710Sstevel@tonic-gate #define	E_SIGPIPE			130
720Sstevel@tonic-gate 
730Sstevel@tonic-gate 
740Sstevel@tonic-gate #define	NETWORK_ERROR_UNKNOWN		20
750Sstevel@tonic-gate #define	NETWORK_ERROR_HOST		21
760Sstevel@tonic-gate #define	NETWORK_ERROR_SERVICE		22
770Sstevel@tonic-gate #define	NETWORK_ERROR_PORT		23
780Sstevel@tonic-gate #define	NETWORK_ERROR_SEND_RESPONSE	24
790Sstevel@tonic-gate #define	NETWORK_ERROR_SEND_FAILED	25
800Sstevel@tonic-gate #define	NETWORK_ERROR_MSG_FAILED	26
810Sstevel@tonic-gate #define	NETWORK_ERROR_WRITE_FAILED	27
820Sstevel@tonic-gate #define	NETWORK_PRINTER_REFUSED_CONN	28
830Sstevel@tonic-gate #define	NETWORK_READ_RESPONSE_FAILED	29
840Sstevel@tonic-gate 
850Sstevel@tonic-gate 
860Sstevel@tonic-gate #define	MALLOC	(int size, char * msg)	\
870Sstevel@tonic-gate 	{ \
880Sstevel@tonic-gate 		printf("File %s line %d\n", __FILE__, __LINE__); \
890Sstevel@tonic-gate 		printf("malloc: size: <%d>, for <%s>\n"); \
900Sstevel@tonic-gate 		malloc(size); \
910Sstevel@tonic-gate 	}
920Sstevel@tonic-gate 
930Sstevel@tonic-gate 
940Sstevel@tonic-gate typedef struct np_data np_data_t;
950Sstevel@tonic-gate typedef struct np_bsdjob np_bsdjob_t;
960Sstevel@tonic-gate typedef struct job	np_job_t;
970Sstevel@tonic-gate typedef struct np_tcp_job np_tcpjob_t;
980Sstevel@tonic-gate 
990Sstevel@tonic-gate /*
1000Sstevel@tonic-gate  * Contains the input data for this job.
1010Sstevel@tonic-gate  * Data is independent of protocol
1020Sstevel@tonic-gate  */
1030Sstevel@tonic-gate 
1040Sstevel@tonic-gate struct job {
1050Sstevel@tonic-gate 	char	*filename;
1060Sstevel@tonic-gate 	char	*request_id;
1070Sstevel@tonic-gate 	char	*printer;
1080Sstevel@tonic-gate 	char	*dest;
1090Sstevel@tonic-gate 	char	*title;
1100Sstevel@tonic-gate 	int	protocol;
1110Sstevel@tonic-gate 	char	*username;
1120Sstevel@tonic-gate 	int	timeout;
1130Sstevel@tonic-gate 	int	banner;
1140Sstevel@tonic-gate 	int	filesize;
1150Sstevel@tonic-gate };
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate struct np_tcp_job {
1180Sstevel@tonic-gate 	np_job_t * gen_data;
1190Sstevel@tonic-gate 	char * np_port;
1200Sstevel@tonic-gate 	char * np_host;
1210Sstevel@tonic-gate };
1220Sstevel@tonic-gate 
1230Sstevel@tonic-gate struct np_data {
1240Sstevel@tonic-gate 	char	*np_dfAfilename;
1250Sstevel@tonic-gate 	char	*np_path_file;	/* /<path>/<filename> we are printing 	*/
1260Sstevel@tonic-gate 	long	np_data_size;	/* using stat, XXX mmap better??	*/
1270Sstevel@tonic-gate 	char	*jobfile_data;
1280Sstevel@tonic-gate };
1290Sstevel@tonic-gate 
1300Sstevel@tonic-gate 
1310Sstevel@tonic-gate struct np_bsdjob {
1320Sstevel@tonic-gate 	char		*np_filename;
1330Sstevel@tonic-gate 	char 		*np_request_id;
1340Sstevel@tonic-gate 	char		*np_printer;
1350Sstevel@tonic-gate 	char		*np_destination;
1360Sstevel@tonic-gate 	char		*np_title;
1370Sstevel@tonic-gate 	char		*np_username;
1380Sstevel@tonic-gate 	int		np_timeout;
1390Sstevel@tonic-gate 	int		np_banner;
1400Sstevel@tonic-gate 	char		*np_host;
1410Sstevel@tonic-gate 	int		np_print_order;
1420Sstevel@tonic-gate 	char		*np_cfAfilename;
1430Sstevel@tonic-gate 	char		*np_cfAfile;
1440Sstevel@tonic-gate 	uint		np_cfAfilesize;
1450Sstevel@tonic-gate 	char		np_df_letter;		/* [A-Z][a-z] use this one */
1460Sstevel@tonic-gate 	np_data_t	*np_data;
1470Sstevel@tonic-gate };
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate extern char * long2str(long, char *);
1500Sstevel@tonic-gate extern void null_sighandler(int);
1510Sstevel@tonic-gate extern int open_network(char *, int);
1520Sstevel@tonic-gate extern int xfer_file(int, caddr_t, int, int);
1530Sstevel@tonic-gate extern int add_bsd_file(char *, np_bsdjob_t *);
1540Sstevel@tonic-gate extern int start_bsd_job(int, char *);
1550Sstevel@tonic-gate extern void done_and_close(int);
1560Sstevel@tonic-gate extern void panic();
1570Sstevel@tonic-gate extern char * alloc_str(char *);
1580Sstevel@tonic-gate extern np_bsdjob_t * create_bsd_job(np_job_t *, int, int);
1590Sstevel@tonic-gate extern np_tcpjob_t * create_tcp_job(np_job_t *, int);
1600Sstevel@tonic-gate extern int net_send_cmd(int, char *, ...);
1610Sstevel@tonic-gate extern np_job_t * init_job(void);
1620Sstevel@tonic-gate extern int bsd_print(int, caddr_t, np_bsdjob_t *);
1630Sstevel@tonic-gate extern int tcp_print(int, caddr_t, np_tcpjob_t *);
1640Sstevel@tonic-gate extern int tcp_open(char *, np_tcpjob_t *, int);
1650Sstevel@tonic-gate extern void tell_lptell(int, char *, ...);
1660Sstevel@tonic-gate extern int net_open(char *, int);
1670Sstevel@tonic-gate extern void parse_dest(char *, char **, char **, char *);
1680Sstevel@tonic-gate extern int check_file(char *);
1690Sstevel@tonic-gate 
1700Sstevel@tonic-gate #ifdef	__cplusplus
1710Sstevel@tonic-gate }
1720Sstevel@tonic-gate #endif
1730Sstevel@tonic-gate 
1740Sstevel@tonic-gate #endif	/* _NETPR_H */
175