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.
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.
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]
23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
31 /* $Id: papi.h 161 2006-05-03 04:32:59Z njacobs $ */
33 #pragma ident "%Z%%M% %I% %E% SMI"
35 #include <sys/types.h>
47 /* service related types */
48 typedef void *papi_service_t
;
49 typedef void *papi_printer_t
;
50 typedef void *papi_job_t
;
51 typedef void *papi_stream_t
;
54 PAPI_ENCRYPT_IF_REQUESTED
, /* Encrypt if requested (TLS upgrade) */
55 PAPI_ENCRYPT_NEVER
, /* Never encrypt */
56 PAPI_ENCRYPT_REQUIRED
, /* Encryption required (TLS upgrade) */
57 PAPI_ENCRYPT_ALWAYS
/* Always encrypt (SSL) */
60 /* attribute related types */
70 } papi_attribute_value_type_t
;
73 PAPI_RES_PER_INCH
= 3,
75 } papi_resolution_unit_t
;
77 enum { /* for boolean values */
83 PAPI_UNSUPPORTED
= 0x10,
87 PAPI_NOT_SETTABLE
= 0x15,
91 #define PAPI_LIST_JOBS_OTHERS 0x0001
92 #define PAPI_LIST_JOBS_COMPLETED 0x0002
93 #define PAPI_LIST_JOBS_NOT_COMPLETED 0x0004
94 #define PAPI_LIST_JOBS_ALL 0xFFFF
96 typedef struct papi_attribute_s papi_attribute_t
;
99 char *string
; /* PAPI_STRING value */
100 int integer
; /* PAPI_INTEGER value */
101 char boolean
; /* PAPI_BOOLEAN value */
102 struct { /* PAPI_RANGE value */
106 struct { /* PAPI_RESOLUTION value */
109 papi_resolution_unit_t units
;
111 time_t datetime
; /* PAPI_DATETIME value */
112 papi_attribute_t
**collection
; /* PAPI_COLLECTION value */
113 papi_metadata_t metadata
; /* PAPI_METADATA value */
114 } papi_attribute_value_t
;
116 struct papi_attribute_s
{
117 char *name
; /* attribute name */
118 papi_attribute_value_type_t type
; /* type of values */
119 papi_attribute_value_t
**values
; /* list of values */
122 #define PAPI_ATTR_APPEND 0x0001 /* Add values to attr */
123 #define PAPI_ATTR_REPLACE 0x0002 /* Delete existing values, then add */
124 #define PAPI_ATTR_EXCL 0x0004 /* Fail if attr exists */
126 /* job related types */
128 PAPI_JT_FORMAT_JDF
= 0,
129 PAPI_JT_FORMAT_PWG
= 1
133 papi_jt_format_t format
;
138 /* status related types */
143 PAPI_OK_IGNORED_SUBSCRIPTIONS
,
144 PAPI_OK_IGNORED_NOTIFICATIONS
,
145 PAPI_OK_TOO_MANY_EVENTS
,
146 PAPI_OK_BUT_CANCEL_SUBSCRIPTION
,
147 PAPI_REDIRECTION_OTHER_SITE
= 0x0300,
148 PAPI_BAD_REQUEST
= 0x0400,
150 PAPI_NOT_AUTHENTICATED
,
158 PAPI_DOCUMENT_FORMAT
,
163 PAPI_COMPRESSION_NOT_SUPPORTED
,
164 PAPI_COMPRESSION_ERROR
,
165 PAPI_DOCUMENT_FORMAT_ERROR
,
166 PAPI_DOCUMENT_ACCESS_ERROR
,
167 PAPI_ATTRIBUTES_NOT_SETTABLE
,
168 PAPI_IGNORED_ALL_SUBSCRIPTIONS
,
169 PAPI_TOO_MANY_SUBSCRIPTIONS
,
170 PAPI_IGNORED_ALL_NOTIFICATIONS
,
171 PAPI_PRINT_SUPPORT_FILE_NOT_FOUND
,
172 PAPI_INTERNAL_ERROR
= 0x0500,
173 PAPI_OPERATION_NOT_SUPPORTED
,
174 PAPI_SERVICE_UNAVAILABLE
,
175 PAPI_VERSION_NOT_SUPPORTED
,
177 PAPI_TEMPORARY_ERROR
,
180 PAPI_ERROR_JOB_CANCELLED
,
181 PAPI_MULTIPLE_JOBS_NOT_SUPPORTED
,
182 PAPI_PRINTER_IS_DEACTIVATED
,
184 PAPI_JOB_TICKET_NOT_SUPPORTED
187 /* list filter related */
189 PAPI_FILTER_BITMASK
= 0
190 } papi_filter_type_t
;
193 papi_filter_type_t type
;
195 struct { /* PAPI_FILTER_BITMASK */
203 PAPI_PRINTER_LOCAL
= 0x0000, /* Local destination */
204 PAPI_PRINTER_CLASS
= 0x0001, /* Printer class */
205 PAPI_PRINTER_REMOTE
= 0x0002, /* Remote destination */
206 PAPI_PRINTER_BW
= 0x0004, /* Can do B&W printing */
207 PAPI_PRINTER_COLOR
= 0x0008, /* Can do color printing */
208 PAPI_PRINTER_DUPLEX
= 0x0010, /* Can do duplex printing */
209 PAPI_PRINTER_STAPLE
= 0x0020, /* Can do stapling */
210 PAPI_PRINTER_COPIES
= 0x0040, /* Can do copies */
211 PAPI_PRINTER_COLLATE
= 0x0080, /* Can collate copies */
212 PAPI_PRINTER_PUNCH
= 0x0100, /* Can punch output */
213 PAPI_PRINTER_COVER
= 0x0200, /* Can cover output */
214 PAPI_PRINTER_BIND
= 0x0400, /* Can bind output */
215 PAPI_PRINTER_SORT
= 0x0800, /* Can sort output */
216 PAPI_PRINTER_SMALL
= 0x1000, /* Can do letter/legal/a4 */
217 PAPI_PRINTER_MEDIUM
= 0x2000, /* Can do tabloid/B/C/A3/A2 */
218 PAPI_PRINTER_LARGE
= 0x4000, /* Can do D/E/A1/A0 */
219 PAPI_PRINTER_VARIABLE
= 0x8000, /* Can do variable sizes */
220 PAPI_PRINTER_IMPLICIT
= 0x10000, /* implicit class */
221 PAPI_PRINTER_DEFAULT
= 0x20000, /* Default printer on network */
222 PAPI_PRINTER_OPTIONS
= 0xfffc /* ~ (CLASS | REMOTE | IMPLICIT) */
229 /* Service related */
230 extern papi_status_t
papiServiceCreate(papi_service_t
*handle
,
231 char *service_name
, char *user_name
,
233 int (*authCB
)(papi_service_t svc
,
235 papi_encryption_t encryption
,
237 extern void papiServiceDestroy(papi_service_t handle
);
238 extern papi_status_t
papiServiceSetUserName(papi_service_t handle
,
240 extern papi_status_t
papiServiceSetPassword(papi_service_t handle
,
242 extern papi_status_t
papiServiceSetEncryption(papi_service_t handle
,
243 papi_encryption_t encryption
);
244 extern papi_status_t
papiServiceSetAuthCB(papi_service_t handle
,
245 int (*authCB
)(papi_service_t s
,
247 extern papi_status_t
papiServiceSetAppData(papi_service_t handle
,
249 extern char *papiServiceGetServiceName(papi_service_t handle
);
250 extern char *papiServiceGetUserName(papi_service_t handle
);
251 extern char *papiServiceGetPassword(papi_service_t handle
);
252 extern papi_encryption_t
papiServiceGetEncryption(papi_service_t handle
);
253 extern void *papiServiceGetAppData(papi_service_t handle
);
254 extern papi_attribute_t
**papiServiceGetAttributeList(papi_service_t handle
);
255 extern char *papiServiceGetStatusMessage(papi_service_t handle
);
257 /* Attribute related */
258 extern papi_status_t
papiAttributeListAddValue(papi_attribute_t
***attrs
,
259 int flags
, char *name
,
260 papi_attribute_value_type_t type
,
261 papi_attribute_value_t
*value
);
262 extern papi_status_t
papiAttributeListAddString(papi_attribute_t
***attrs
,
263 int flags
, char *name
, char *string
);
264 extern papi_status_t
papiAttributeListAddInteger(papi_attribute_t
***attrs
,
265 int flags
, char *name
, int integer
);
266 extern papi_status_t
papiAttributeListAddBoolean(papi_attribute_t
***attrs
,
267 int flags
, char *name
, char boolean
);
268 extern papi_status_t
papiAttributeListAddRange(papi_attribute_t
***attrs
,
269 int flags
, char *name
,
270 int lower
, int upper
);
271 extern papi_status_t
papiAttributeListAddResolution(papi_attribute_t
***attrs
,
272 int flags
, char *name
,
274 papi_resolution_unit_t units
);
275 extern papi_status_t
papiAttributeListAddDatetime(papi_attribute_t
***attrs
,
276 int flags
, char *name
, time_t datetime
);
277 extern papi_status_t
papiAttributeListAddCollection(papi_attribute_t
***attrs
,
278 int flags
, char *name
,
279 papi_attribute_t
**collection
);
280 extern papi_status_t
papiAttributeListAddMetadata(papi_attribute_t
***attrs
,
281 int flags
, char *name
,
282 papi_metadata_t metadata
);
283 extern papi_status_t
papiAttributeListDelete(papi_attribute_t
***attributes
,
285 extern papi_status_t
papiAttributeListGetValue(papi_attribute_t
**list
,
286 void **iterator
, char *name
,
287 papi_attribute_value_type_t type
,
288 papi_attribute_value_t
**value
);
289 extern papi_status_t
papiAttributeListGetString(papi_attribute_t
**list
,
290 void **iterator
, char *name
,
292 extern papi_status_t
papiAttributeListGetInteger(papi_attribute_t
**list
,
293 void **iterator
, char *name
, int *vptr
);
294 extern papi_status_t
papiAttributeListGetBoolean(papi_attribute_t
**list
,
295 void **iterator
, char *name
,
297 extern papi_status_t
papiAttributeListGetRange(papi_attribute_t
**list
,
298 void **iterator
, char *name
,
300 extern papi_status_t
papiAttributeListGetResolution(papi_attribute_t
**list
,
301 void **iterator
, char *name
,
303 papi_resolution_unit_t
*units
);
304 extern papi_status_t
papiAttributeListGetDatetime(papi_attribute_t
**list
,
305 void **iterator
, char *name
,
307 extern papi_status_t
papiAttributeListGetCollection(papi_attribute_t
**list
,
308 void **iterator
, char *name
,
309 papi_attribute_t
***collection
);
310 extern papi_status_t
papiAttributeListGetMetadata(papi_attribute_t
**list
,
311 void **iterator
, char *name
,
312 papi_metadata_t
*vptr
);
313 extern papi_attribute_t
*papiAttributeListFind(papi_attribute_t
**list
,
315 extern papi_attribute_t
*papiAttributeListGetNext(papi_attribute_t
**list
,
317 extern void papiAttributeListFree(papi_attribute_t
**attributes
);
319 extern papi_status_t
papiAttributeListFromString(papi_attribute_t
***attrs
,
320 int flags
, char *string
);
321 extern papi_status_t
papiAttributeListToString(papi_attribute_t
**attrs
,
323 char *buffer
, size_t buflen
);
324 extern void papiAttributeListPrint(FILE *fp
, papi_attribute_t
**list
,
325 char *prefix_fmt
, ...);
327 /* Printer related */
328 extern papi_status_t
papiPrintersList(papi_service_t handle
,
329 char **requested_attrs
,
330 papi_filter_t
*filter
,
331 papi_printer_t
**printers
);
332 extern papi_status_t
papiPrinterQuery(papi_service_t handle
, char *name
,
333 char **requested_attrs
,
334 papi_attribute_t
**job_attributes
,
335 papi_printer_t
*printer
);
336 extern papi_status_t
papiPrinterAdd(papi_service_t handle
, char *name
,
337 papi_attribute_t
**attributes
,
338 papi_printer_t
*printer
);
339 extern papi_status_t
papiPrinterModify(papi_service_t handle
, char *name
,
340 papi_attribute_t
**attributes
,
341 papi_printer_t
*printer
);
342 extern papi_status_t
papiPrinterRemove(papi_service_t handle
, char *name
);
343 extern papi_status_t
papiPrinterDisable(papi_service_t handle
, char *name
,
345 extern papi_status_t
papiPrinterEnable(papi_service_t handle
, char *name
);
346 extern papi_status_t
papiPrinterPause(papi_service_t handle
, char *name
,
348 extern papi_status_t
papiPrinterResume(papi_service_t handle
, char *name
);
349 extern papi_status_t
papiPrinterPurgeJobs(papi_service_t handle
,
350 char *name
, papi_job_t
**jobs
);
351 extern papi_status_t
papiPrinterListJobs(papi_service_t handle
,
352 char *name
, char **requested_attrs
,
353 int type_mask
, int max_num_jobs
,
355 extern papi_attribute_t
**papiPrinterGetAttributeList(papi_printer_t printer
);
356 extern void papiPrinterFree(papi_printer_t printer
);
357 extern void papiPrinterListFree(papi_printer_t
*printers
);
360 extern papi_status_t
papiJobSubmit(papi_service_t handle
, char *printer
,
361 papi_attribute_t
**job_attributes
,
362 papi_job_ticket_t
*job_ticket
,
363 char **files
, papi_job_t
*job
);
364 extern papi_status_t
papiJobSubmitByReference(papi_service_t handle
,
366 papi_attribute_t
**job_attributes
,
367 papi_job_ticket_t
*job_ticket
,
368 char **files
, papi_job_t
*job
);
369 extern papi_status_t
papiJobValidate(papi_service_t handle
, char *printer
,
370 papi_attribute_t
**job_attributes
,
371 papi_job_ticket_t
*job_ticket
,
372 char **files
, papi_job_t
*job
);
373 extern papi_status_t
papiJobStreamOpen(papi_service_t handle
,
375 papi_attribute_t
**job_attributes
,
376 papi_job_ticket_t
*job_ticket
,
377 papi_stream_t
*stream
);
378 extern papi_status_t
papiJobStreamWrite(papi_service_t handle
,
379 papi_stream_t stream
,
380 void *buffer
, size_t buflen
);
381 extern papi_status_t
papiJobStreamClose(papi_service_t handle
,
382 papi_stream_t stream
,
384 extern papi_status_t
papiJobQuery(papi_service_t handle
, char *printer
,
385 int32_t job_id
, char **requested_attrs
,
387 extern papi_status_t
papiJobModify(papi_service_t handle
, char *printer
,
389 papi_attribute_t
**attributes
,
391 extern papi_status_t
papiJobMove(papi_service_t handle
, char *printer
,
392 int32_t job_id
, char *destination
);
393 extern papi_status_t
papiJobCancel(papi_service_t handle
, char *printer
,
395 extern papi_status_t
papiJobHold(papi_service_t handle
, char *printer
,
397 extern papi_status_t
papiJobRelease(papi_service_t handle
, char *printer
,
399 extern papi_status_t
papiJobRestart(papi_service_t handle
, char *printer
,
401 extern papi_status_t
papiJobPromote(papi_service_t handle
, char *printer
,
403 extern papi_attribute_t
**papiJobGetAttributeList(papi_job_t printer
);
404 extern char *papiJobGetPrinterName(papi_job_t printer
);
405 extern int32_t papiJobGetId(papi_job_t printer
);
406 extern papi_job_ticket_t
*papiJobGetJobTicket(papi_job_t printer
);
407 extern void papiJobFree(papi_job_t job
);
408 extern void papiJobListFree(papi_job_t
*jobs
);
410 #ifdef SOLARIS_PRIVATE_POST_0_9
412 * These have been added to support IPP create-job/send-document with PAPI v0.9
413 * in an IPP listener using PAPI as it's spooler interface. A future version
414 * of the API is expected to support this type of functionality
416 extern papi_status_t
papiJobCreate(papi_service_t handle
, char *printer
,
417 papi_attribute_t
**job_attributes
,
418 papi_job_ticket_t
*job_ticket
,
420 extern papi_status_t
papiJobStreamAdd(papi_service_t handle
, char *printer
,
421 int32_t id
, papi_stream_t
*stream
);
422 extern papi_status_t
papiJobCommit(papi_service_t handle
, char *printer
,
424 extern papi_status_t
papiServiceSetPeer(papi_service_t handle
, int peerfd
);
425 #endif /* SOLARIS_PRIVATE_POST_0_9 */
427 extern char *papiStatusString(papi_status_t status
);
430 * Internal functions that aren't in the API, but are shared across
431 * protocol support implementations(psms) and the tightly bound
432 * listener library. Do not use these in your applications.
434 extern void list_append();
435 extern void list_concatenate();
436 extern void list_remove();
437 extern void copy_attributes(papi_attribute_t
***result
,
438 papi_attribute_t
**list
);
439 extern void split_and_copy_attributes(char **list
,
440 papi_attribute_t
**attributes
,
441 papi_attribute_t
***in
,
442 papi_attribute_t
***out
);
444 extern papi_attribute_t
**getprinterbyname(char *name
, char *ns
);
446 extern int is_localhost(char *hostname
);