xref: /illumos-gate/usr/src/lib/print/libpapi-lpd/common/papi_impl.h (revision e3ae4b35c024af1196582063ecee3ab79367227d)
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 #include <papi.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #include <time.h>
40 #include <sys/types.h>
41 #include <stdarg.h>
42 #include <uri.h>
43 
44 typedef struct {
45 	papi_attribute_t **attributes;
46 } printer_t;
47 
48 typedef struct job {
49 	papi_attribute_t **attributes;
50 } job_t;
51 
52 typedef struct stream {
53 	job_t  *job;		/* describes current job */
54 	int fd;			/* the fd to write to */
55 	char *metadata;		/* the converted metadata */
56 	char *dfname;		/* the stream data (if we can't stream) */
57 
58 } stream_t;
59 
60 typedef struct {	/* used for query operations only */
61 	time_t timestamp;
62 	printer_t *printer;
63 	job_t **jobs;
64 } cache_t;
65 
66 typedef struct {
67 	papi_attribute_t **attributes;		/* extra info */
68 	uri_t *uri;				/* printer uri */
69 	cache_t *cache;				/* printer/job cache */
70 	int (*authCB)(papi_service_t svc, void *app_data);	/* unused */
71 	void *app_data;				/* unused */
72 } service_t;
73 
74 
75 extern papi_status_t service_fill_in(service_t *svc, char *name);
76 extern void detailed_error(service_t *svc, char *fmt, ...);
77 extern char *queue_name_from_uri(uri_t *uri);
78 extern char *fdgets(char *buf, size_t len, int fd);
79 
80 
81 /* lpd operations */
82 	/* open a connection to remote print service */
83 extern int lpd_open(service_t *svc, char type, char **args,
84 				int timeout);
85 	/* job cancelation */
86 extern papi_status_t lpd_purge_jobs(service_t *svc, job_t ***jobs);
87 extern papi_status_t lpd_cancel_job(service_t *svc, int job_id);
88 	/* job submission */
89 extern papi_status_t lpd_submit_job(service_t *svc, char *metadata,
90 				papi_attribute_t ***attributes, int *fd);
91 extern papi_status_t lpd_job_add_attributes(service_t *svc,
92 				papi_attribute_t **attributes,
93 				char **metadata,
94 				papi_attribute_t ***used_attributes);
95 extern papi_status_t lpd_job_add_files(service_t *svc,
96 				papi_attribute_t **attributes, char **files,
97 				char **metadata,
98 				papi_attribute_t ***used_attributes);
99 	/* query cache lookup routines */
100 extern papi_status_t lpd_find_printer_info(service_t *svc, printer_t **result);
101 extern papi_status_t lpd_find_job_info(service_t *svc, int job_id, job_t **job);
102 extern papi_status_t lpd_find_jobs_info(service_t *svc, job_t ***jobs);
103 
104 
105 #ifdef __cplusplus
106 }
107 #endif
108 
109 #endif /* _PAPI_IMPL_H */
110