xref: /illumos-gate/usr/src/cmd/lp/lib/papi/papi_impl.h (revision 0dd92943508086ca1800de461a7c66109737bcd5)
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  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _PAPI_IMPL_H
27 #define	_PAPI_IMPL_H
28 
29 #include <papi.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 #include <time.h>
36 #include <sys/types.h>
37 #include <stdarg.h>
38 
39 /* lpsched include files */
40 #include <lp.h>
41 #include <msgs.h>
42 #include <printers.h>
43 #include <requests.h>
44 
45 
46 /*
47  * Implementation specific types/prototypes/definitions follow
48  *
49  *
50  * Ex:
51  */
52 
53 typedef struct {
54 	papi_attribute_t **attributes;
55 	int (*authCB)(papi_service_t svc, void *app_data);
56 	void *app_data;
57 	MESG *md;
58 	char *msgbuf;
59 	size_t msgbuf_size;
60 } service_t;
61 
62 typedef struct job {
63 	papi_attribute_t **attributes;	/* job attributes */
64 } job_t;
65 
66 typedef struct {
67 	papi_attribute_t **attributes;	/* queue attributes */
68 } printer_t;
69 
70 typedef struct {
71 	int fd;
72 	REQUEST *request;
73 	char *meta_data_file;
74 	char added;
75 } job_stream_t;
76 
77 extern void lpsched_read_job_configuration(service_t *svc, job_t *j,
78 				char *file);
79 extern void lpsched_request_to_job(REQUEST *r, job_t *j);
80 
81 extern void job_status_to_attributes(job_t *job, char *req_id, char *user,
82 				char *slabel, size_t size, time_t date,
83 				short state, char *destination, char *form,
84 				char *charset, short rank, char *file);
85 extern papi_status_t addLPString(papi_attribute_t ***list,
86 					int flags, char *name, char *value);
87 extern papi_status_t papiAttributeListAddLPStrings(papi_attribute_t ***list,
88 					int flags, char *name, char **values);
89 extern void papiAttributeListGetLPString(papi_attribute_t **attributes,
90 			char *key, char **string);
91 extern void papiAttributeListGetLPStrings(papi_attribute_t **attributes,
92 			char *key, char ***string);
93 
94 extern papi_status_t lpsched_printer_configuration_to_attributes(
95 				service_t *svc, printer_t *p, char *dest);
96 extern papi_status_t lpsched_class_configuration_to_attributes(service_t *svc,
97 	printer_t *p, char *dest);
98 extern papi_status_t class_status_to_attributes(printer_t *p, char *printer,
99 	short status, char *reject_reason, long reject_date);
100 extern papi_status_t lpsched_reject_printer(papi_service_t svc,
101 	char *printer, char *message);
102 extern papi_status_t lpsched_accept_printer(papi_service_t svc,
103 	char *printer);
104 extern papi_status_t lpsched_disable_printer(papi_service_t svc,
105 	char *printer, char *message);
106 extern papi_status_t lpsched_enable_printer(papi_service_t svc,
107 	char *printer);
108 extern papi_status_t lpsched_status_to_papi_status(int status);
109 extern papi_status_t job_attributes_to_lpsched_request(papi_service_t svc,
110 	REQUEST *r, papi_attribute_t **attributes);
111 extern papi_status_t lpsched_alloc_files(papi_service_t svc, int number,
112 	char **prefix);
113 extern papi_status_t lpsched_commit_job(papi_service_t svc, char *job,
114 	char **tmp);
115 extern papi_status_t lpsched_start_change(papi_service_t svc,
116 	char *printer, int32_t job_id, char **tmp);
117 extern papi_status_t lpsched_end_change(papi_service_t svc,
118 	char *printer, int32_t job_id);
119 extern papi_status_t printer_status_to_attributes(printer_t *p, char *printer,
120 	char *form, char *character_set, char *reject_reason,
121 	char *disable_reason, short status, char *request_id, long enable_date,
122 	long reject_date);
123 extern papi_status_t lpsched_remove_printer(papi_service_t svc, char *dest);
124 extern papi_status_t lpsched_remove_class(papi_service_t svc, char *dest);
125 extern papi_status_t lpsched_add_modify_printer(papi_service_t svc, char *dest,
126 	papi_attribute_t **attributes, int type);
127 extern papi_status_t lpsched_add_modify_class(papi_service_t svc, char *dest,
128 	papi_attribute_t **attributes);
129 
130 extern void lpsched_service_information(papi_attribute_t ***attrs);
131 extern void lpsched_request_to_job_attributes(REQUEST *r, job_t *j);
132 extern void detailed_error(service_t *svc, char *fmt, ...);
133 extern char *banner_type(unsigned short banner);
134 extern char *mime_type_to_lp_type(char *mime_type);
135 extern char *lp_type_to_mime_type(char *lp_type);
136 extern char *fifo_name_from_uri(char *uri);
137 extern char *printer_name_from_uri_id(char *uri, int32_t id);
138 
139 extern int snd_msg(service_t *svc, int type, ...);
140 extern int rcv_msg(service_t *svc, int type, ...);
141 
142 #ifdef __cplusplus
143 }
144 #endif
145 
146 #endif /* _PAPI_IMPL_H */
147