1 '\" te
   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"
   7 .SH NAME
   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
  13 .SH SYNOPSIS
  14 .LP
  15 .nf
  16 cc [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lpapi\fR [ \fIlibrary\fR\&.\|.\|. ]
  17 #include <papi.h>
  18 
  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);
  23 .fi
  24 
  25 .LP
  26 .nf
  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);
  31 .fi
  32 
  33 .LP
  34 .nf
  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);
  39 .fi
  40 
  41 .LP
  42 .nf
  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);
  46 .fi
  47 
  48 .LP
  49 .nf
  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);
  52 .fi
  53 
  54 .LP
  55 .nf
  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);
  58 .fi
  59 
  60 .LP
  61 .nf
  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);
  65 .fi
  66 
  67 .LP
  68 .nf
  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);
  72 .fi
  73 
  74 .LP
  75 .nf
  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);
  78 .fi
  79 
  80 .LP
  81 .nf
  82 \fBpapi_status_t\fR \fBpapiJobCancel\fR(\fBpapi_service_t\fR \fIhandle\fR,
  83      \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR);
  84 .fi
  85 
  86 .LP
  87 .nf
  88 \fBpapi_status_t\fR \fBpapiJobHold\fR(\fBpapi_service_t\fR \fIhandle\fR,
  89      \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR);
  90 .fi
  91 
  92 .LP
  93 .nf
  94 \fBpapi_status_t\fR \fBpapiJobRelease\fR(\fBpapi_service_t\fR \fIhandle\fR,
  95      \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR);
  96 .fi
  97 
  98 .LP
  99 .nf
 100 \fBpapi_status_t\fR \fBpapiJobRestart\fR(\fBpapi_service_t\fR \fIhandle\fR,
 101      \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR);
 102 .fi
 103 
 104 .LP
 105 .nf
 106 \fBpapi_status_t\fR \fBpapiJobPromote\fR(\fBpapi_service_t\fR \fIhandle\fR,
 107      \fBchar *\fR\fIprinter\fR, \fBint32_t\fR \fIjob_id\fR);
 108 .fi
 109 
 110 .LP
 111 .nf
 112 \fBpapi_attribute_t **\fR\fBpapiJobGetAttributeList\fR(\fBpapi_job_t\fR \fIjob\fR);
 113 .fi
 114 
 115 .LP
 116 .nf
 117 \fBchar *\fR\fBpapiJobGetPrinterName\fR(\fBpapi_job_t\fR \fIjob\fR);
 118 .fi
 119 
 120 .LP
 121 .nf
 122 \fBint32_t\fR \fBpapiJobGetId\fR(\fBpapi_job_t\fR \fIjob\fR);
 123 .fi
 124 
 125 .LP
 126 .nf
 127 \fBpapi_job_ticket_t *\fR\fBpapiJobGetJobTicket\fR(\fBpapi_job_t\fR \fIjob\fR);
 128 .fi
 129 
 130 .LP
 131 .nf
 132 \fBvoid\fR \fBpapiJobFree\fR(\fBpapi_job_t\fR \fIjob\fR);
 133 .fi
 134 
 135 .LP
 136 .nf
 137 \fBvoid\fR \fBpapiJobListFree\fR(\fBpapi_job_t *\fR\fIjobs\fR);
 138 .fi
 139 
 140 .SH PARAMETERS
 141 .sp
 142 .ne 2
 143 .na
 144 \fB\fIattributes\fR\fR
 145 .ad
 146 .RS 19n
 147 a set of attributes to be applied to a printer object
 148 .RE
 149 
 150 .sp
 151 .ne 2
 152 .na
 153 \fB\fIbuffer\fR\fR
 154 .ad
 155 .RS 19n
 156 a buffer of data to be written to the job stream
 157 .RE
 158 
 159 .sp
 160 .ne 2
 161 .na
 162 \fB\fIbufflen\fR\fR
 163 .ad
 164 .RS 19n
 165 the size of the supplied buffer
 166 .RE
 167 
 168 .sp
 169 .ne 2
 170 .na
 171 \fB\fIdestination\fR\fR
 172 .ad
 173 .RS 19n
 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
 176 .RE
 177 
 178 .sp
 179 .ne 2
 180 .na
 181 \fB\fIfiles\fR\fR
 182 .ad
 183 .RS 19n
 184 files to use during job submission
 185 .RE
 186 
 187 .sp
 188 .ne 2
 189 .na
 190 \fB\fIhandle\fR\fR
 191 .ad
 192 .RS 19n
 193 a pointer to a handle to be used for all PAPI operations that is created by
 194 calling \fBpapiServiceCreate()\fR
 195 .RE
 196 
 197 .sp
 198 .ne 2
 199 .na
 200 \fB\fIjob\fR\fR
 201 .ad
 202 .RS 19n
 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
 206 .RE
 207 
 208 .sp
 209 .ne 2
 210 .na
 211 \fB\fIjob_attributes\fR\fR
 212 .ad
 213 .RS 19n
 214 attributes to apply during job creation or modification
 215 .RE
 216 
 217 .sp
 218 .ne 2
 219 .na
 220 \fB\fIjob_id\fR\fR
 221 .ad
 222 .RS 19n
 223 ID number of the job reported on or manipulated
 224 .RE
 225 
 226 .sp
 227 .ne 2
 228 .na
 229 \fB\fIjob_ticket\fR\fR
 230 .ad
 231 .RS 19n
 232 unused
 233 .RE
 234 
 235 .sp
 236 .ne 2
 237 .na
 238 \fB\fIjobs\fR\fR
 239 .ad
 240 .RS 19n
 241 a list of job objects returned by \fBpapiPrinterListJobs()\fR or
 242 \fBpapiPrinterPurgeJobs()\fR
 243 .RE
 244 
 245 .sp
 246 .ne 2
 247 .na
 248 \fB\fIprinter\fR\fR
 249 .ad
 250 .RS 19n
 251 name of the printer where the job is or should reside
 252 .RE
 253 
 254 .sp
 255 .ne 2
 256 .na
 257 \fB\fIrequested_attrs\fR\fR
 258 .ad
 259 .RS 19n
 260 a null-terminated array of pointers to attribute names requested during job
 261 enumeration (\fBpapiPrinterListJobs()\fR) or job query (\fBpapiJobQuery()\fR)
 262 .RE
 263 
 264 .sp
 265 .ne 2
 266 .na
 267 \fB\fIstream\fR\fR
 268 .ad
 269 .RS 19n
 270 a communication endpoint for sending print job data
 271 .RE
 272 
 273 .SH DESCRIPTION
 274 .sp
 275 .LP
 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.
 280 .sp
 281 .LP
 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.
 286 .sp
 287 .LP
 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.
 291 .sp
 292 .LP
 293 The \fBpapiJobValidate()\fR function validates that the supplied attributes and
 294 files will result in a valid print job.
 295 .sp
 296 .LP
 297 The \fBpapiJobQuery()\fR function retrieves job information from the print
 298 service.
 299 .sp
 300 .LP
 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.
 304 .sp
 305 .LP
 306 The \fBpapiJobMove()\fR function moves a job from its current queue to the
 307 named destination within the same print service.
 308 .sp
 309 .LP
 310 The \fBpapiJobCancel()\fR function removes a job from the queue.
 311 .sp
 312 .LP
 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.
 315 .sp
 316 .LP
 317 The \fBpapiJobRestart()\fR function restarts processing of a currently queued
 318 print job.
 319 .sp
 320 .LP
 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).
 324 .sp
 325 .LP
 326 The \fBpapiJobGetPrinterName()\fR function returns the name of the queue where
 327 the job is currently queued.
 328 .sp
 329 .LP
 330 The \fBpapiJobGetId()\fR function returns a job identifier number from the job
 331 object passed in.
 332 .sp
 333 .LP
 334 The \fBpapiJobPromote()\fR function moves a job to the head of the print queue.
 335 .sp
 336 .LP
 337 The \fBpapiJobGetJobTicket()\fR function retrieves a pointer to a job ticket
 338 associated with the job object.
 339 .sp
 340 .LP
 341 The \fBpapiJobFree()\fR and \fBpapiJobListFree()\fR functions deallocate memory
 342 allocated for the return of printer object(s) from functions that return
 343 printer objects.
 344 .SH RETURN VALUES
 345 .sp
 346 .LP
 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.
 350 .sp
 351 .LP
 352 Upon successful completion, \fBpapiJobGetAttributeList()\fR returns a pointer
 353 to the requested data. Otherwise, it returns \fINULL\fR.
 354 .SH EXAMPLES
 355 .LP
 356 \fBExample 1 \fREnumerate all jobs in a queue
 357 .sp
 358 .in +2
 359 .nf
 360 /*
 361  * program to enumerate queued jobs using PAPI interfaces.
 362  */
 363 #include <stdio.h>
 364 #include <stdlib.h>
 365 #include <unistd.h>
 366 #include <libintl.h>
 367 #include <pwd.h>
 368 #include <papi.h>
 369 
 370 static int
 371 authCB(papi_service_t svc, void *app_data)
 372 {
 373     char prompt[BUFSIZ];
 374     char *user, *svc_name, *passphrase;
 375 
 376     /* get the name of the service we are contacting */
 377     if ((svc_name = papiServiceGetServiceName(svc)) == NULL)
 378             return (-1);
 379 
 380     /* find out who we are supposed to be */
 381     if ((user = papiServiceGetUserName(svc)) == NULL) {
 382             struct passwd *pw;
 383 
 384             if ((pw = getpwuid(getuid())) != NULL)
 385                     user = pw->pw_name;
 386             else
 387                     user = "nobody";
 388     }
 389 
 390     /* build the prompt string */
 391     snprintf(prompt, sizeof (prompt),
 392             gettext("passphrase for %s to access %s: "), user,
 393                   svc_name);
 394 
 395     /* ask for the passphrase */
 396     if ((passphrase = getpassphrase(prompt)) != NULL)
 397             papiServiceSetPassword(svc, passphrase);
 398 
 399     return (0);
 400 }
 401 
 402 /*ARGSUSED*/
 403 int
 404 main(int ac, char *av[])
 405 {
 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";
 411     int c;
 412 
 413     while ((c = getopt(ac, av, "s:p:")) != EOF)
 414         switch (c) {
 415         case 's':
 416             svc_name = optarg;
 417             break;
 418         case 'p':
 419             pname = optarg;
 420             break;
 421         }
 422 
 423     status = papiServiceCreate(&svc, svc_name, NULL, NULL, authCB,
 424                             PAPI_ENCRYPT_NEVER, NULL);
 425 
 426     if (status != PAPI_OK) {
 427         printf("papiServiceCreate(%s): %s\en", svc_name ? svc_name :
 428                      "NULL", papiStatusString(status));
 429         papiServiceDestroy(svc);
 430         exit(1);
 431     }
 432 
 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);
 438         exit(1);
 439     }
 440 
 441     if (jobs != NULL) {
 442         int i;
 443 
 444         for (i = 0; jobs[i] != NULL; i++) {
 445             papi_attribute_t **list = papiJobGetAttributeList(jobs[i]);
 446 
 447             if (list != NULL) {
 448                 char *name = "unknown";
 449                             int32_t id = 0;
 450                 char *buffer = NULL;
 451                 size_t size = 0;
 452 
 453                (void) papiAttributeListGetString(list, NULL,
 454                                     "printer-name", &name);
 455                (void) papiAttributeListGetInteger(list, NULL,
 456                                     "job-id", &id);
 457                 while (papiAttributeListToString(list, "\n\t", buffer,
 458                             size) != PAPI_OK)
 459                     buffer = realloc(buffer, size += BUFSIZ);
 460 
 461                 printf("%s-%d:\en\t%s\en", name, id, buffer);
 462                 free(buffer);
 463             }
 464         }
 465         papiJobListFree(jobs);
 466     }
 467 
 468     papiServiceDestroy(svc);
 469 
 470     exit(0);
 471 }
 472 .fi
 473 .in -2
 474 
 475 .LP
 476 \fBExample 2 \fRDump all job attributes.
 477 .sp
 478 .in +2
 479 .nf
 480 /*
 481  * program to dump a queued job's attributes using PAPI interfaces.
 482  */
 483 #include <stdio.h>
 484 #include <stdlib.h>
 485 #include <unistd.h>
 486 #include <libintl.h>
 487 #include <pwd.h>
 488 #include <papi.h>
 489 
 490 static int
 491 authCB(papi_service_t svc, void *app_data)
 492 {
 493     char prompt[BUFSIZ];
 494     char *user, *svc_name, *passphrase;
 495 
 496     /* get the name of the service we are contacting */
 497     if ((svc_name = papiServiceGetServiceName(svc)) == NULL)
 498             return (-1);
 499 
 500     /* find out who we are supposed to be */
 501     if ((user = papiServiceGetUserName(svc)) == NULL) {
 502             struct passwd *pw;
 503 
 504             if ((pw = getpwuid(getuid())) != NULL)
 505                     user = pw->pw_name;
 506             else
 507                     user = "nobody";
 508     }
 509 
 510     /* build the prompt string */
 511     snprintf(prompt, sizeof (prompt),
 512             gettext("passphrase for %s to access %s: "), user,
 513                      svc_name);
 514 
 515     /* ask for the passphrase */
 516     if ((passphrase = getpassphrase(prompt)) != NULL)
 517             papiServiceSetPassword(svc, passphrase);
 518 
 519     return (0);
 520 }
 521 
 522 /*ARGSUSED*/
 523 int
 524 main(int ac, char *av[])
 525 {
 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";
 531     int id = 0;
 532     int c;
 533 
 534     while ((c = getopt(ac, av, "s:p:j:")) != EOF)
 535         switch (c) {
 536         case 's':
 537             svc_name = optarg;
 538             break;
 539         case 'p':
 540             pname = optarg;
 541             break;
 542         case 'j':
 543             id = atoi(optarg);
 544             break;
 545         }
 546 
 547     status = papiServiceCreate(&svc, svc_name, NULL, NULL, authCB,
 548                             PAPI_ENCRYPT_NEVER, NULL);
 549 
 550     if (status != PAPI_OK) {
 551         printf("papiServiceCreate(%s): %s\en", svc_name ? svc_name :
 552                      "NULL", papiStatusString(status));
 553         papiServiceDestroy(svc);
 554         exit(1);
 555     }
 556 
 557     status = papiJobQuery(svc, pname, id, NULL, &job);
 558     if ((status == PAPI_OK) && (job != NULL)) {
 559         papi_attribute_t **list = papiJobGetAttributeList(job);
 560 
 561         if (list != NULL) {
 562             char *name = "unknown";
 563             int32_t id = 0;
 564             char *buffer = NULL;
 565             size_t size = 0;
 566 
 567             (void) papiAttributeListGetString(list, NULL,
 568                                     "printer-name", &name);
 569             (void) papiAttributeListGetInteger(list, NULL,
 570                                     "job-id", &id);
 571             while (papiAttributeListToString(list, "\en\et", buffer, size)
 572                             != PAPI_OK)
 573                 buffer = realloc(buffer, size += BUFSIZ);
 574 
 575             printf("%s-%d:\en\et%s\n", name, id, buffer);
 576             free(buffer);
 577         }
 578     } else
 579         printf("papiJobQuery(%s-%d): %s\en", pname, id,
 580                     papiStatusString(status));
 581 
 582     papiJobFree(job);
 583     papiServiceDestroy(svc);
 584 
 585     exit(0);
 586 }
 587 .fi
 588 .in -2
 589 
 590 .LP
 591 \fBExample 3 \fRSubmit a job (stream).
 592 .sp
 593 .in +2
 594 .nf
 595 /*
 596  * program to submit a job from standard input.
 597  */
 598 #include <stdio.h>
 599 #include <stdlib.h>
 600 #include <unistd.h>
 601 #include <libintl.h>
 602 #include <pwd.h>
 603 #include <papi.h>
 604 
 605 static int
 606 authCB(papi_service_t svc, void *app_data)
 607 {
 608     char prompt[BUFSIZ];
 609     char *user, *svc_name, *passphrase;
 610 
 611     /* get the name of the service we are contacting */
 612     if ((svc_name = papiServiceGetServiceName(svc)) == NULL)
 613             return (-1);
 614 
 615     /* find out who we are supposed to be */
 616     if ((user = papiServiceGetUserName(svc)) == NULL) {
 617             struct passwd *pw;
 618 
 619             if ((pw = getpwuid(getuid())) != NULL)
 620                     user = pw->pw_name;
 621             else
 622                     user = "nobody";
 623     }
 624 
 625     /* build the prompt string */
 626     snprintf(prompt, sizeof (prompt),
 627             gettext("passphrase for %s to access %s: "), user,
 628                     svc_name);
 629 
 630     /* ask for the passphrase */
 631     if ((passphrase = getpassphrase(prompt)) != NULL)
 632             papiServiceSetPassword(svc, passphrase);
 633 
 634     return (0);
 635 }
 636 
 637 /*ARGSUSED*/
 638 int
 639 main(int ac, char *av[])
 640 {
 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";
 648     int id = 0;
 649     int c;
 650     int rc;
 651     char buf[BUFSIZ];
 652 
 653     while ((c = getopt(ac, av, "s:p:")) != EOF)
 654         switch (c) {
 655         case 's':
 656             svc_name = optarg;
 657             break;
 658         case 'p':
 659             pname = optarg;
 660             break;
 661         }
 662 
 663     status = papiServiceCreate(&svc, svc_name, NULL, NULL, authCB,
 664                             PAPI_ENCRYPT_NEVER, NULL);
 665 
 666     if (status != PAPI_OK) {
 667         printf("papiServiceCreate(%s): %s\en", svc_name ? svc_name :
 668                     "NULL", papiStatusString(status));
 669         papiServiceDestroy(svc);
 670         exit(1);
 671     }
 672 
 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");
 678 
 679     status = papiJobStreamOpen(svc, pname, attrs, NULL, &stream);
 680     while ((status == PAPI_OK) && ((rc = read(0, buf,
 681                      sizeof (buf))) > 0))
 682             status = papiJobStreamWrite(svc, stream, buf, rc);
 683 
 684     if (status == PAPI_OK)
 685             status = papiJobStreamClose(svc, stream, &job);
 686 
 687 
 688     if ((status == PAPI_OK) && (job != NULL)) {
 689         papi_attribute_t **list = papiJobGetAttributeList(job);
 690 
 691         if (list != NULL) {
 692             char *name = "unknown";
 693             int32_t id = 0;
 694             char *buffer = NULL;
 695             size_t size = 0;
 696 
 697             (void) papiAttributeListGetString(list, NULL,
 698                                     "printer-name", &name);
 699             (void) papiAttributeListGetInteger(list, NULL,
 700                                     "job-id", &id);
 701             while (papiAttributeListToString(list, "\n\t", buffer, size)
 702                             != PAPI_OK)
 703                 buffer = realloc(buffer, size += BUFSIZ);
 704 
 705             printf("%s-%d:\en\t%s\en", name, id, buffer);
 706             free(buffer);
 707         }
 708     } else
 709         printf("papiJobStream*(%s-%d): %s\en", pname, id,
 710                     papiStatusString(status));
 711 
 712     papiJobFree(job);
 713     papiServiceDestroy(svc);
 714 
 715     exit(0);
 716 }
 717 .fi
 718 .in -2
 719 
 720 .SH ATTRIBUTES
 721 .sp
 722 .LP
 723 See \fBattributes\fR(5) for descriptions of the following attributes:
 724 .sp
 725 
 726 .sp
 727 .TS
 728 box;
 729 c | c
 730 l | l .
 731 ATTRIBUTE TYPE  ATTRIBUTE VALUE
 732 _
 733 Interface Stability     Volatile
 734 _
 735 MT-Level        Safe
 736 .TE
 737 
 738 .SH SEE ALSO
 739 .sp
 740 .LP
 741 \fBlibpapi\fR(3LIB), \fBpapiAttributeListAddValue\fR(3PAPI),
 742 \fBattributes\fR(5)