xref: /titanic_52/usr/src/lib/print/libpapi-lpd/common/papi_impl.h (revision 355b4669e025ff377602b6fc7caaf30dbc218371)
1*355b4669Sjacobs /*
2*355b4669Sjacobs  * CDDL HEADER START
3*355b4669Sjacobs  *
4*355b4669Sjacobs  * The contents of this file are subject to the terms of the
5*355b4669Sjacobs  * Common Development and Distribution License (the "License").
6*355b4669Sjacobs  * You may not use this file except in compliance with the License.
7*355b4669Sjacobs  *
8*355b4669Sjacobs  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*355b4669Sjacobs  * or http://www.opensolaris.org/os/licensing.
10*355b4669Sjacobs  * See the License for the specific language governing permissions
11*355b4669Sjacobs  * and limitations under the License.
12*355b4669Sjacobs  *
13*355b4669Sjacobs  * When distributing Covered Code, include this CDDL HEADER in each
14*355b4669Sjacobs  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*355b4669Sjacobs  * If applicable, add the following below this CDDL HEADER, with the
16*355b4669Sjacobs  * fields enclosed by brackets "[]" replaced with your own identifying
17*355b4669Sjacobs  * information: Portions Copyright [yyyy] [name of copyright owner]
18*355b4669Sjacobs  *
19*355b4669Sjacobs  * CDDL HEADER END
20*355b4669Sjacobs  */
21*355b4669Sjacobs 
22*355b4669Sjacobs /*
23*355b4669Sjacobs  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
24*355b4669Sjacobs  * Use is subject to license terms.
25*355b4669Sjacobs  *
26*355b4669Sjacobs  */
27*355b4669Sjacobs 
28*355b4669Sjacobs #ifndef _PAPI_IMPL_H
29*355b4669Sjacobs #define	_PAPI_IMPL_H
30*355b4669Sjacobs 
31*355b4669Sjacobs /* $Id: papi_impl.h 161 2006-05-03 04:32:59Z njacobs $ */
32*355b4669Sjacobs 
33*355b4669Sjacobs #pragma ident	"%Z%%M%	%I%	%E% SMI"
34*355b4669Sjacobs 
35*355b4669Sjacobs #include <papi.h>
36*355b4669Sjacobs 
37*355b4669Sjacobs #ifdef __cplusplus
38*355b4669Sjacobs extern "C" {
39*355b4669Sjacobs #endif
40*355b4669Sjacobs 
41*355b4669Sjacobs #include <time.h>
42*355b4669Sjacobs #include <sys/types.h>
43*355b4669Sjacobs #include <stdarg.h>
44*355b4669Sjacobs #include <uri.h>
45*355b4669Sjacobs 
46*355b4669Sjacobs typedef struct {
47*355b4669Sjacobs 	papi_attribute_t **attributes;
48*355b4669Sjacobs } printer_t;
49*355b4669Sjacobs 
50*355b4669Sjacobs typedef struct job {
51*355b4669Sjacobs 	papi_attribute_t **attributes;
52*355b4669Sjacobs } job_t;
53*355b4669Sjacobs 
54*355b4669Sjacobs typedef struct stream {
55*355b4669Sjacobs 	job_t  *job;		/* describes current job */
56*355b4669Sjacobs 	int fd;			/* the fd to write to */
57*355b4669Sjacobs 	char *metadata;		/* the converted metadata */
58*355b4669Sjacobs 	char *dfname;		/* the stream data (if we can't stream) */
59*355b4669Sjacobs 
60*355b4669Sjacobs } stream_t;
61*355b4669Sjacobs 
62*355b4669Sjacobs typedef struct {	/* used for query operations only */
63*355b4669Sjacobs 	time_t timestamp;
64*355b4669Sjacobs 	printer_t *printer;
65*355b4669Sjacobs 	job_t **jobs;
66*355b4669Sjacobs } cache_t;
67*355b4669Sjacobs 
68*355b4669Sjacobs typedef struct {
69*355b4669Sjacobs 	papi_attribute_t **attributes;		/* extra info */
70*355b4669Sjacobs 	uri_t *uri;				/* printer uri */
71*355b4669Sjacobs 	cache_t *cache;				/* printer/job cache */
72*355b4669Sjacobs 	int (*authCB)(papi_service_t svc, void *app_data);	/* unused */
73*355b4669Sjacobs 	void *app_data;				/* unused */
74*355b4669Sjacobs } service_t;
75*355b4669Sjacobs 
76*355b4669Sjacobs 
77*355b4669Sjacobs extern papi_status_t service_fill_in(service_t *svc, char *name);
78*355b4669Sjacobs extern void detailed_error(service_t *svc, char *fmt, ...);
79*355b4669Sjacobs extern char *queue_name_from_uri(uri_t *uri);
80*355b4669Sjacobs extern char *fdgets(char *buf, size_t len, int fd);
81*355b4669Sjacobs 
82*355b4669Sjacobs 
83*355b4669Sjacobs /* lpd operations */
84*355b4669Sjacobs 	/* open a connection to remote print service */
85*355b4669Sjacobs extern int lpd_open(service_t *svc, char type, char **args,
86*355b4669Sjacobs 				int timeout);
87*355b4669Sjacobs 	/* job cancelation */
88*355b4669Sjacobs extern papi_status_t lpd_purge_jobs(service_t *svc, job_t ***jobs);
89*355b4669Sjacobs extern papi_status_t lpd_cancel_job(service_t *svc, int job_id);
90*355b4669Sjacobs 	/* job submission */
91*355b4669Sjacobs extern papi_status_t lpd_submit_job(service_t *svc, char *metadata,
92*355b4669Sjacobs 				papi_attribute_t ***attributes, int *fd);
93*355b4669Sjacobs extern papi_status_t lpd_job_add_attributes(service_t *svc,
94*355b4669Sjacobs 				papi_attribute_t **attributes,
95*355b4669Sjacobs 				char **metadata,
96*355b4669Sjacobs 				papi_attribute_t ***used_attributes);
97*355b4669Sjacobs extern papi_status_t lpd_job_add_files(service_t *svc,
98*355b4669Sjacobs 				papi_attribute_t **attributes, char **files,
99*355b4669Sjacobs 				char **metadata,
100*355b4669Sjacobs 				papi_attribute_t ***used_attributes);
101*355b4669Sjacobs 	/* query cache lookup routines */
102*355b4669Sjacobs extern papi_status_t lpd_find_printer_info(service_t *svc, printer_t **result);
103*355b4669Sjacobs extern papi_status_t lpd_find_job_info(service_t *svc, int job_id, job_t **job);
104*355b4669Sjacobs extern papi_status_t lpd_find_jobs_info(service_t *svc, job_t ***jobs);
105*355b4669Sjacobs 
106*355b4669Sjacobs 
107*355b4669Sjacobs #ifdef __cplusplus
108*355b4669Sjacobs }
109*355b4669Sjacobs #endif
110*355b4669Sjacobs 
111*355b4669Sjacobs #endif /* _PAPI_IMPL_H */
112