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 #pragma ident "%Z%%M% %I% %E% SMI" 317c478bd9Sstevel@tonic-gate 327c478bd9Sstevel@tonic-gate #ifdef __cplusplus 337c478bd9Sstevel@tonic-gate extern "C" { 347c478bd9Sstevel@tonic-gate #endif 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #define BSD 0 377c478bd9Sstevel@tonic-gate #define TCP 1 387c478bd9Sstevel@tonic-gate #define NOBANNER 0 397c478bd9Sstevel@tonic-gate #define BANNER 1 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #define CONTROL_FIRST 0 427c478bd9Sstevel@tonic-gate #define DATA_FIRST 1 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate #define ERRORMSG 0 457c478bd9Sstevel@tonic-gate #define OKMSG 1 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate #define DEST_SEP ":" 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define MAX_REQ_ID 3 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate #define ASCII_UULONG_MAX 22 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #define XFER_REQUEST 2 /* \2printer\n */ 547c478bd9Sstevel@tonic-gate #define XFER_CLEANUP 1 /* \1 */ 557c478bd9Sstevel@tonic-gate #define XFER_CONTROL 2 /* \2size name\n */ 567c478bd9Sstevel@tonic-gate #define XFER_DATA 3 /* \3size name\n */ 577c478bd9Sstevel@tonic-gate #define PRINT_REQUEST 1 /* \1printer\n */ 587c478bd9Sstevel@tonic-gate #define REMOVE_REQUEST 5 /* \5printer person [users|jobs ...]\n */ 597c478bd9Sstevel@tonic-gate #define SHOW_QUEUE_SHORT_REQUEST 3 /* \3printer [users|jobs ...]\n */ 607c478bd9Sstevel@tonic-gate #define SHOW_QUEUE_LONG_REQUEST 4 /* \4printer [users|jobs ...]\n */ 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate #define E_SUCCESS 0 647c478bd9Sstevel@tonic-gate #define E_FAILURE 1 657c478bd9Sstevel@tonic-gate #define E_SYSTEM_ERROR 2 667c478bd9Sstevel@tonic-gate #define E_BAD_FILE 3 677c478bd9Sstevel@tonic-gate #define E_BAD_INPUT 4 687c478bd9Sstevel@tonic-gate #define E_SYSTEM_ERR 5 697c478bd9Sstevel@tonic-gate #define E_SEND_OK 6 707c478bd9Sstevel@tonic-gate #define E_RETRY 129 717c478bd9Sstevel@tonic-gate #define E_SIGPIPE 130 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate 747c478bd9Sstevel@tonic-gate #define NETWORK_ERROR_UNKNOWN 20 757c478bd9Sstevel@tonic-gate #define NETWORK_ERROR_HOST 21 767c478bd9Sstevel@tonic-gate #define NETWORK_ERROR_SERVICE 22 777c478bd9Sstevel@tonic-gate #define NETWORK_ERROR_PORT 23 787c478bd9Sstevel@tonic-gate #define NETWORK_ERROR_SEND_RESPONSE 24 797c478bd9Sstevel@tonic-gate #define NETWORK_ERROR_SEND_FAILED 25 807c478bd9Sstevel@tonic-gate #define NETWORK_ERROR_MSG_FAILED 26 817c478bd9Sstevel@tonic-gate #define NETWORK_ERROR_WRITE_FAILED 27 827c478bd9Sstevel@tonic-gate #define NETWORK_PRINTER_REFUSED_CONN 28 837c478bd9Sstevel@tonic-gate #define NETWORK_READ_RESPONSE_FAILED 29 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate #define MALLOC (int size, char * msg) \ 877c478bd9Sstevel@tonic-gate { \ 887c478bd9Sstevel@tonic-gate printf("File %s line %d\n", __FILE__, __LINE__); \ 897c478bd9Sstevel@tonic-gate printf("malloc: size: <%d>, for <%s>\n"); \ 907c478bd9Sstevel@tonic-gate malloc(size); \ 917c478bd9Sstevel@tonic-gate } 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate 947c478bd9Sstevel@tonic-gate typedef struct np_data np_data_t; 957c478bd9Sstevel@tonic-gate typedef struct np_bsdjob np_bsdjob_t; 967c478bd9Sstevel@tonic-gate typedef struct job np_job_t; 977c478bd9Sstevel@tonic-gate typedef struct np_tcp_job np_tcpjob_t; 987c478bd9Sstevel@tonic-gate 997c478bd9Sstevel@tonic-gate /* 1007c478bd9Sstevel@tonic-gate * Contains the input data for this job. 1017c478bd9Sstevel@tonic-gate * Data is independent of protocol 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate struct job { 1057c478bd9Sstevel@tonic-gate char *filename; 1067c478bd9Sstevel@tonic-gate char *request_id; 1077c478bd9Sstevel@tonic-gate char *printer; 1087c478bd9Sstevel@tonic-gate char *dest; 1097c478bd9Sstevel@tonic-gate char *title; 1107c478bd9Sstevel@tonic-gate int protocol; 1117c478bd9Sstevel@tonic-gate char *username; 1127c478bd9Sstevel@tonic-gate int timeout; 1137c478bd9Sstevel@tonic-gate int banner; 1147c478bd9Sstevel@tonic-gate int filesize; 1157c478bd9Sstevel@tonic-gate }; 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate struct np_tcp_job { 1187c478bd9Sstevel@tonic-gate np_job_t * gen_data; 1197c478bd9Sstevel@tonic-gate char * np_port; 1207c478bd9Sstevel@tonic-gate char * np_host; 1217c478bd9Sstevel@tonic-gate }; 1227c478bd9Sstevel@tonic-gate 1237c478bd9Sstevel@tonic-gate struct np_data { 1247c478bd9Sstevel@tonic-gate char *np_dfAfilename; 1257c478bd9Sstevel@tonic-gate char *np_path_file; /* /<path>/<filename> we are printing */ 1267c478bd9Sstevel@tonic-gate long np_data_size; /* using stat, XXX mmap better?? */ 1277c478bd9Sstevel@tonic-gate char *jobfile_data; 1287c478bd9Sstevel@tonic-gate }; 1297c478bd9Sstevel@tonic-gate 1307c478bd9Sstevel@tonic-gate 1317c478bd9Sstevel@tonic-gate struct np_bsdjob { 1327c478bd9Sstevel@tonic-gate char *np_filename; 1337c478bd9Sstevel@tonic-gate char *np_request_id; 1347c478bd9Sstevel@tonic-gate char *np_printer; 1357c478bd9Sstevel@tonic-gate char *np_destination; 1367c478bd9Sstevel@tonic-gate char *np_title; 1377c478bd9Sstevel@tonic-gate char *np_username; 1387c478bd9Sstevel@tonic-gate int np_timeout; 1397c478bd9Sstevel@tonic-gate int np_banner; 1407c478bd9Sstevel@tonic-gate char *np_host; 1417c478bd9Sstevel@tonic-gate int np_print_order; 1427c478bd9Sstevel@tonic-gate char *np_cfAfilename; 1437c478bd9Sstevel@tonic-gate char *np_cfAfile; 1447c478bd9Sstevel@tonic-gate uint np_cfAfilesize; 1457c478bd9Sstevel@tonic-gate char np_df_letter; /* [A-Z][a-z] use this one */ 1467c478bd9Sstevel@tonic-gate np_data_t *np_data; 1477c478bd9Sstevel@tonic-gate }; 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate extern char * long2str(long, char *); 1507c478bd9Sstevel@tonic-gate extern void null_sighandler(int); 1517c478bd9Sstevel@tonic-gate extern int open_network(char *, int); 1527c478bd9Sstevel@tonic-gate extern int xfer_file(int, caddr_t, int, int); 1537c478bd9Sstevel@tonic-gate extern int add_bsd_file(char *, np_bsdjob_t *); 1547c478bd9Sstevel@tonic-gate extern int start_bsd_job(int, char *); 1557c478bd9Sstevel@tonic-gate extern void done_and_close(int); 1567c478bd9Sstevel@tonic-gate extern void panic(); 1577c478bd9Sstevel@tonic-gate extern char * alloc_str(char *); 1587c478bd9Sstevel@tonic-gate extern np_bsdjob_t * create_bsd_job(np_job_t *, int, int); 1597c478bd9Sstevel@tonic-gate extern np_tcpjob_t * create_tcp_job(np_job_t *, int); 1607c478bd9Sstevel@tonic-gate extern int net_send_cmd(int, char *, ...); 1617c478bd9Sstevel@tonic-gate extern np_job_t * init_job(void); 1627c478bd9Sstevel@tonic-gate extern int bsd_print(int, caddr_t, np_bsdjob_t *); 1637c478bd9Sstevel@tonic-gate extern int tcp_print(int, caddr_t, np_tcpjob_t *); 1647c478bd9Sstevel@tonic-gate extern int tcp_open(char *, np_tcpjob_t *, int); 1657c478bd9Sstevel@tonic-gate extern void tell_lptell(int, char *, ...); 1667c478bd9Sstevel@tonic-gate extern int net_open(char *, int); 1677c478bd9Sstevel@tonic-gate extern void parse_dest(char *, char **, char **, char *); 1687c478bd9Sstevel@tonic-gate extern int check_file(char *); 1697c478bd9Sstevel@tonic-gate 1707c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1717c478bd9Sstevel@tonic-gate } 1727c478bd9Sstevel@tonic-gate #endif 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate #endif /* _NETPR_H */ 175