1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _NETPR_H
#define _NETPR_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#define BSD 0
#define TCP 1
#define NOBANNER 0
#define BANNER 1
#define CONTROL_FIRST 0
#define DATA_FIRST 1
#define ERRORMSG 0
#define OKMSG 1
#define DEST_SEP ":"
#define MAX_REQ_ID 3
#define ASCII_UULONG_MAX 22
#define XFER_REQUEST 2 /* \2printer\n */
#define XFER_CLEANUP 1 /* \1 */
#define XFER_CONTROL 2 /* \2size name\n */
#define XFER_DATA 3 /* \3size name\n */
#define PRINT_REQUEST 1 /* \1printer\n */
#define REMOVE_REQUEST 5 /* \5printer person [users|jobs ...]\n */
#define SHOW_QUEUE_SHORT_REQUEST 3 /* \3printer [users|jobs ...]\n */
#define SHOW_QUEUE_LONG_REQUEST 4 /* \4printer [users|jobs ...]\n */
#define E_SUCCESS 0
#define E_FAILURE 1
#define E_SYSTEM_ERROR 2
#define E_BAD_FILE 3
#define E_BAD_INPUT 4
#define E_SYSTEM_ERR 5
#define E_SEND_OK 6
#define E_RETRY 129
#define E_SIGPIPE 130
#define NETWORK_ERROR_UNKNOWN 20
#define NETWORK_ERROR_HOST 21
#define NETWORK_ERROR_SERVICE 22
#define NETWORK_ERROR_PORT 23
#define NETWORK_ERROR_SEND_RESPONSE 24
#define NETWORK_ERROR_SEND_FAILED 25
#define NETWORK_ERROR_MSG_FAILED 26
#define NETWORK_ERROR_WRITE_FAILED 27
#define NETWORK_PRINTER_REFUSED_CONN 28
#define NETWORK_READ_RESPONSE_FAILED 29
#define MALLOC (int size, char * msg) \
{ \
printf("File %s line %d\n", __FILE__, __LINE__); \
printf("malloc: size: <%d>, for <%s>\n"); \
malloc(size); \
}
typedef struct np_data np_data_t;
typedef struct np_bsdjob np_bsdjob_t;
typedef struct job np_job_t;
typedef struct np_tcp_job np_tcpjob_t;
/*
* Contains the input data for this job.
* Data is independent of protocol
*/
struct job {
char *filename;
char *request_id;
char *printer;
char *dest;
char *title;
int protocol;
char *username;
int timeout;
int banner;
int filesize;
};
struct np_tcp_job {
np_job_t * gen_data;
char * np_port;
char * np_host;
};
struct np_data {
char *np_dfAfilename;
char *np_path_file; /* /<path>/<filename> we are printing */
long np_data_size; /* using stat, XXX mmap better?? */
char *jobfile_data;
};
struct np_bsdjob {
char *np_filename;
char *np_request_id;
char *np_printer;
char *np_destination;
char *np_title;
char *np_username;
int np_timeout;
int np_banner;
char *np_host;
int np_print_order;
char *np_cfAfilename;
char *np_cfAfile;
uint np_cfAfilesize;
char np_df_letter; /* [A-Z][a-z] use this one */
np_data_t *np_data;
};
extern char * long2str(long, char *);
extern void null_sighandler(int);
extern int open_network(char *, int);
extern int xfer_file(int, caddr_t, int, int);
extern int add_bsd_file(char *, np_bsdjob_t *);
extern int start_bsd_job(int, char *);
extern void done_and_close(int);
extern void panic();
extern char * alloc_str(char *);
extern np_bsdjob_t * create_bsd_job(np_job_t *, int, int);
extern np_tcpjob_t * create_tcp_job(np_job_t *, int);
extern int net_send_cmd(int, char *, ...);
extern np_job_t * init_job(void);
extern int bsd_print(int, caddr_t, np_bsdjob_t *);
extern int tcp_print(int, caddr_t, np_tcpjob_t *);
extern int tcp_open(char *, np_tcpjob_t *, int);
extern void tell_lptell(int, char *, ...);
extern int net_open(char *, int);
extern void parse_dest(char *, char **, char **, char *);
extern int check_file(char *);
#ifdef __cplusplus
}
#endif
#endif /* _NETPR_H */
|