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