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