2 .\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH PAPIJOBSUBMIT 3PAPI "Sep 10, 2013"
8 papiJobSubmit, papiJobSubmitByReference, papiJobValidate, papiJobStreamOpen,
9 papiJobStreamWrite, papiJobStreamClose, papiJobQuery, papiJobModify,
10 papiJobMove, papiJobCancel, papiJobHold, papiJobRelease, papiJobRestart,
11 papiJobPromote, papiJobGetAttributeList, papiJobGetPrinterName, papiJobGetId,
12 papiJobGetJobTicket, papiJobFree, papiJobListFree \- job object manipulation
16 cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lpapi\fR [ \fIlibrary\fR\&.\|.\|. ]
19 \fBpapi_status_t\fR \fBpapiJobSubmit\fR(\fBpapi_service_t\fR \fIhandle\fR,
20 \fBchar *\fR\fIprinter\fR, \fBpapi_attribute_t **\fR\fIjob_attributes\fR,
21 \fBpapi_job_ticket_t *\fR\fIjob_ticket\fR, \fBchar **\fR\fIfiles\fR,
22 \fBpapi_job_t *\fR\fIjob\fR);
27 \fBpapi_status_t\fR \fBpapiJobSubmitByReference\fR(\fBpapi_service_t\fR \fIhandle\fR,
28 \fBchar *\fR\fIprinter\fR, \fBpapi_attribute_t **\fR\fIjob_attributes\fR,
29 \fBpapi_job_ticket_t *\fR\fIjob_ticket\fR, \fBchar **\fR\fIfiles\fR,
30 \fBpapi_job_t *\fR\fIjob\fR);
35 \fBpapi_status_t\fR \fBpapiJobValidate\fR(\fBpapi_service_t\fR \fIhandle\fR,
36 \fBchar *\fR\fIprinter\fR, \fBpapi_attribute_t **\fR\fIjob_attributes\fR,
37 \fBpapi_job_ticket_t *\fR\fIjob_ticket\fR, \fBchar **\fR\fIfiles\fR,
38 \fBpapi_job_t *\fR\fIjob\fR);
43 \fBpapi_status_t\fR \fBpapiJobStreamOpen\fR(\fBpapi_service_t\fR \fIhandle\fR,
44 \fBchar *\fR\fIprinter\fR, \fBpapi_attribute_t **\fR\fIjob_attributes\fR,
45 \fBpapi_job_ticket_t *\fR\fIjob_ticket\fR, \fBpapi_stream_t *\fR\fIstream\fR);
50 \fBpapi_status_t\fR \fBpapiJobStreamWrite\fR(\fBpapi_service_t\fR \fIhandle\fR,
51 \fBpapi_stream_t\fR \fIstream\fR, \fBvoid *\fR\fIbuffer\fR, \fBsize_t\fR \fIbuflen\fR);
56 \fBpapi_status_t\fR \fBpapiJobStreamClose\fR(\fBpapi_service_t\fR \fIhandle\fR,
57 \fBpapi_stream_t\fR \fIstream\fR, \fBpapi_job_t *\fR\fIjob\fR);
62 \fBpapi_status_t\fR \fBpapiJobQuery\fR(\fBpapi_service_t\fR \fIhandle\fR,
63 \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR, \fBchar **\fR\fIrequested_attrs\fR,
64 \fBpapi_job_t *\fR\fIjob\fR);
69 \fBpapi_status_t\fR \fBpapiJobModify\fR(\fBpapi_service_t\fR \fIhandle\fR,
70 \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR,
71 \fBpapi_attribute_t **\fR\fIattributes\fR, \fBpapi_job_t *\fR\fIjob\fR);
76 \fBpapi_status_t\fR \fBpapiJobMove\fR(\fBpapi_service_t\fR \fIhandle\fR,
77 \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR, \fBchar *\fR\fIdestination\fR);
82 \fBpapi_status_t\fR \fBpapiJobCancel\fR(\fBpapi_service_t\fR \fIhandle\fR,
83 \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR);
88 \fBpapi_status_t\fR \fBpapiJobHold\fR(\fBpapi_service_t\fR \fIhandle\fR,
89 \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR);
94 \fBpapi_status_t\fR \fBpapiJobRelease\fR(\fBpapi_service_t\fR \fIhandle\fR,
95 \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR);
100 \fBpapi_status_t\fR \fBpapiJobRestart\fR(\fBpapi_service_t\fR \fIhandle\fR,
101 \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR);
106 \fBpapi_status_t\fR \fBpapiJobPromote\fR(\fBpapi_service_t\fR \fIhandle\fR,
107 \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR);
112 \fBpapi_attribute_t **\fR\fBpapiJobGetAttributeList\fR(\fBpapi_job_t\fR \fIjob\fR);
117 \fBchar *\fR\fBpapiJobGetPrinterName\fR(\fBpapi_job_t\fR \fIjob\fR);
122 \fBint32_t\fR \fBpapiJobGetId\fR(\fBpapi_job_t\fR \fIjob\fR);
127 \fBpapi_job_ticket_t *\fR\fBpapiJobGetJobTicket\fR(\fBpapi_job_t\fR \fIjob\fR);
132 \fBvoid\fR \fBpapiJobFree\fR(\fBpapi_job_t\fR \fIjob\fR);
137 \fBvoid\fR \fBpapiJobListFree\fR(\fBpapi_job_t *\fR\fIjobs\fR);
144 \fB\fIattributes\fR\fR
147 a set of attributes to be applied to a printer object
156 a buffer of data to be written to the job stream
165 the size of the supplied buffer
171 \fB\fIdestination\fR\fR
174 the name of the printer where a print job should be relocated, which must
175 reside within the same print services as the job is currently queued
184 files to use during job submission
193 a pointer to a handle to be used for all PAPI operations that is created by
194 calling \fBpapiServiceCreate()\fR
203 a pointer to a printer object (initialized to NULL) to be filled in by
204 \fBpapiJobQuery()\fR, \fBpapiJobSubmit()\fR, \fBpapiJobSubmitByReference()\fR,
205 \fBpapiJobValidate()\fR, \fBpapiJobStreamClose()\fR, and \fBpapiJobModify()\fR
211 \fB\fIjob_attributes\fR\fR
214 attributes to apply during job creation or modification
223 ID number of the job reported on or manipulated
229 \fB\fIjob_ticket\fR\fR
241 a list of job objects returned by \fBpapiPrinterListJobs()\fR or
242 \fBpapiPrinterPurgeJobs()\fR
251 name of the printer where the job is or should reside
257 \fB\fIrequested_attrs\fR\fR
260 a null-terminated array of pointers to attribute names requested during job
261 enumeration (\fBpapiPrinterListJobs()\fR) or job query (\fBpapiJobQuery()\fR)
270 a communication endpoint for sending print job data
276 The \fBpapiJobSubmit()\fR function creates a print job containing the passed in
277 files with the supplied attributes. When the function returns, the data in the
278 passed files will have been copied by the print service. A job object is
279 returned that reflects the state of the job.
282 The \fBpapiJobSubmitByReference()\fR function creates a print job containing
283 the passed in files with the supplied attributes. When the function returns,
284 the data in the passed files might have been copied by the print service. A job
285 object is returned that reflects the state of the job.
288 The \fBpapiJobStreamOpen()\fR, \fBpapiJobStreamWrite()\fR,
289 \fBpapiJobStreamClose()\fR functions create a print job by opening a stream,
290 writing to the stream, and closing it.
293 The \fBpapiJobValidate()\fR function validates that the supplied attributes and
294 files will result in a valid print job.
297 The \fBpapiJobQuery()\fR function retrieves job information from the print
301 The \fBpapiJobModify()\fR function modifies a queued job according to the
302 attribute list passed into the call. A job object is returned that reflects
303 the state of the job after the modification has been applied.
306 The \fBpapiJobMove()\fR function moves a job from its current queue to the
307 named destination within the same print service.
310 The \fBpapiJobCancel()\fR function removes a job from the queue.
313 The \fBpapiJobHold()\fR and \fBpapiJobRelease()\fR functions set the job state
314 to "held" or "idle" to indicate whether the job is eligible for processing.
317 The \fBpapiJobRestart()\fR function restarts processing of a currently queued
321 The \fBpapiJobGetAttributeList()\fR function returns a list of attributes
322 describing the job. This list can be searched and/or enumerated using
323 \fBpapiAttributeList*()\fR calls. See \fBpapiAttributeListAddValue\fR(3PAPI).
326 The \fBpapiJobGetPrinterName()\fR function returns the name of the queue where
327 the job is currently queued.
330 The \fBpapiJobGetId()\fR function returns a job identifier number from the job
334 The \fBpapiJobPromote()\fR function moves a job to the head of the print queue.
337 The \fBpapiJobGetJobTicket()\fR function retrieves a pointer to a job ticket
338 associated with the job object.
341 The \fBpapiJobFree()\fR and \fBpapiJobListFree()\fR functions deallocate memory
342 allocated for the return of printer object(s) from functions that return
347 Upon successful completion, all \fBpapiJob*()\fR functions that return a value
348 return \fBPAPI_OK\fR. Otherwise, they return an appropriate \fBpapi_status_t\fR
349 indicating the type of failure.
352 Upon successful completion, \fBpapiJobGetAttributeList()\fR returns a pointer
353 to the requested data. Otherwise, it returns \fINULL\fR.
356 \fBExample 1 \fREnumerate all jobs in a queue
361 * program to enumerate queued jobs using PAPI interfaces.
371 authCB(papi_service_t svc, void *app_data)
374 char *user, *svc_name, *passphrase;
376 /* get the name of the service we are contacting */
377 if ((svc_name = papiServiceGetServiceName(svc)) == NULL)
380 /* find out who we are supposed to be */
381 if ((user = papiServiceGetUserName(svc)) == NULL) {
384 if ((pw = getpwuid(getuid())) != NULL)
390 /* build the prompt string */
391 snprintf(prompt, sizeof (prompt),
392 gettext("passphrase for %s to access %s: "), user,
395 /* ask for the passphrase */
396 if ((passphrase = getpassphrase(prompt)) != NULL)
397 papiServiceSetPassword(svc, passphrase);
404 main(int ac, char *av[])
406 papi_status_t status;
407 papi_service_t svc = NULL;
408 papi_job_t *jobs = NULL;
409 char *svc_name = NULL;
410 char *pname = "unknown";
413 while ((c = getopt(ac, av, "s:p:")) != EOF)
423 status = papiServiceCreate(&svc, svc_name, NULL, NULL, authCB,
424 PAPI_ENCRYPT_NEVER, NULL);
426 if (status != PAPI_OK) {
427 printf("papiServiceCreate(%s): %s\en", svc_name ? svc_name :
428 "NULL", papiStatusString(status));
429 papiServiceDestroy(svc);
433 status = papiPrinterListJobs(svc, pname, NULL, 0, 0, &jobs);
434 if (status != PAPI_OK) {
435 printf("papiPrinterListJobs(%s): %s\en", pname,
436 papiStatusString(status));
437 papiServiceDestroy(svc);
444 for (i = 0; jobs[i] != NULL; i++) {
445 papi_attribute_t **list = papiJobGetAttributeList(jobs[i]);
448 char *name = "unknown";
453 (void) papiAttributeListGetString(list, NULL,
454 "printer-name", &name);
455 (void) papiAttributeListGetInteger(list, NULL,
457 while (papiAttributeListToString(list, "\n\t", buffer,
459 buffer = realloc(buffer, size += BUFSIZ);
461 printf("%s-%d:\en\t%s\en", name, id, buffer);
465 papiJobListFree(jobs);
468 papiServiceDestroy(svc);
476 \fBExample 2 \fRDump all job attributes.
481 * program to dump a queued job's attributes using PAPI interfaces.
491 authCB(papi_service_t svc, void *app_data)
494 char *user, *svc_name, *passphrase;
496 /* get the name of the service we are contacting */
497 if ((svc_name = papiServiceGetServiceName(svc)) == NULL)
500 /* find out who we are supposed to be */
501 if ((user = papiServiceGetUserName(svc)) == NULL) {
504 if ((pw = getpwuid(getuid())) != NULL)
510 /* build the prompt string */
511 snprintf(prompt, sizeof (prompt),
512 gettext("passphrase for %s to access %s: "), user,
515 /* ask for the passphrase */
516 if ((passphrase = getpassphrase(prompt)) != NULL)
517 papiServiceSetPassword(svc, passphrase);
524 main(int ac, char *av[])
526 papi_status_t status;
527 papi_service_t svc = NULL;
528 papi_job_t job = NULL;
529 char *svc_name = NULL;
530 char *pname = "unknown";
534 while ((c = getopt(ac, av, "s:p:j:")) != EOF)
547 status = papiServiceCreate(&svc, svc_name, NULL, NULL, authCB,
548 PAPI_ENCRYPT_NEVER, NULL);
550 if (status != PAPI_OK) {
551 printf("papiServiceCreate(%s): %s\en", svc_name ? svc_name :
552 "NULL", papiStatusString(status));
553 papiServiceDestroy(svc);
557 status = papiJobQuery(svc, pname, id, NULL, &job);
558 if ((status == PAPI_OK) && (job != NULL)) {
559 papi_attribute_t **list = papiJobGetAttributeList(job);
562 char *name = "unknown";
567 (void) papiAttributeListGetString(list, NULL,
568 "printer-name", &name);
569 (void) papiAttributeListGetInteger(list, NULL,
571 while (papiAttributeListToString(list, "\en\et", buffer, size)
573 buffer = realloc(buffer, size += BUFSIZ);
575 printf("%s-%d:\en\et%s\n", name, id, buffer);
579 printf("papiJobQuery(%s-%d): %s\en", pname, id,
580 papiStatusString(status));
583 papiServiceDestroy(svc);
591 \fBExample 3 \fRSubmit a job (stream).
596 * program to submit a job from standard input.
606 authCB(papi_service_t svc, void *app_data)
609 char *user, *svc_name, *passphrase;
611 /* get the name of the service we are contacting */
612 if ((svc_name = papiServiceGetServiceName(svc)) == NULL)
615 /* find out who we are supposed to be */
616 if ((user = papiServiceGetUserName(svc)) == NULL) {
619 if ((pw = getpwuid(getuid())) != NULL)
625 /* build the prompt string */
626 snprintf(prompt, sizeof (prompt),
627 gettext("passphrase for %s to access %s: "), user,
630 /* ask for the passphrase */
631 if ((passphrase = getpassphrase(prompt)) != NULL)
632 papiServiceSetPassword(svc, passphrase);
639 main(int ac, char *av[])
641 papi_status_t status;
642 papi_service_t svc = NULL;
643 papi_stream_t stream = NULL;
644 papi_job_t job = NULL;
645 papi_attribute_t **attrs = NULL;
646 char *svc_name = NULL;
647 char *pname = "unknown";
653 while ((c = getopt(ac, av, "s:p:")) != EOF)
663 status = papiServiceCreate(&svc, svc_name, NULL, NULL, authCB,
664 PAPI_ENCRYPT_NEVER, NULL);
666 if (status != PAPI_OK) {
667 printf("papiServiceCreate(%s): %s\en", svc_name ? svc_name :
668 "NULL", papiStatusString(status));
669 papiServiceDestroy(svc);
673 papiAttributeListAddInteger(&attrs, PAPI_ATTR_EXCL, "copies", 1);
674 papiAttributeListAddString(&attrs, PAPI_ATTR_EXCL,
675 "document-format", "application/octet-stream");
676 papiAttributeListAddString(&attrs, PAPI_ATTR_EXCL,
677 "job-title", "Standard Input");
679 status = papiJobStreamOpen(svc, pname, attrs, NULL, &stream);
680 while ((status == PAPI_OK) && ((rc = read(0, buf,
682 status = papiJobStreamWrite(svc, stream, buf, rc);
684 if (status == PAPI_OK)
685 status = papiJobStreamClose(svc, stream, &job);
688 if ((status == PAPI_OK) && (job != NULL)) {
689 papi_attribute_t **list = papiJobGetAttributeList(job);
692 char *name = "unknown";
697 (void) papiAttributeListGetString(list, NULL,
698 "printer-name", &name);
699 (void) papiAttributeListGetInteger(list, NULL,
701 while (papiAttributeListToString(list, "\n\t", buffer, size)
703 buffer = realloc(buffer, size += BUFSIZ);
705 printf("%s-%d:\en\t%s\en", name, id, buffer);
709 printf("papiJobStream*(%s-%d): %s\en", pname, id,
710 papiStatusString(status));
713 papiServiceDestroy(svc);
723 See \fBattributes\fR(5) for descriptions of the following attributes:
731 ATTRIBUTE TYPE ATTRIBUTE VALUE
733 Interface Stability Volatile
741 \fBlibpapi\fR(3LIB), \fBpapiAttributeListAddValue\fR(3PAPI),