1pappl-job(3) pappl job functions pappl-job(3)
2
3
4
6 pappl-job - pappl job functions
7
9 Printer Application Framework (libpappl, "pkg-config --cflags --libs
10 pappl")
11
13 #include <pappl/pappl.h>
14
15 typedef struct _pappl_job_s pappl_job_t;
16
17 void
18 papplJobCancel(pappl_job_t *job);
19
20
21 bool
22 papplJobFilterImage(pappl_job_t *job, pappl_device_t *device,
23 pappl_joptions_t *options, const unsigned char *pixels, unsigned width,
24 unsigned height, unsigned depth, bool smoothing);
25
26
27 ipp_attribute_t *
28 papplJobGetAttribute(pappl_job_t *job, const char *name);
29
30 void *
31 papplJobGetData(pappl_job_t *job);
32
33 const char *
34 papplJobGetFilename(pappl_job_t *job);
35
36 const char *
37 papplJobGetFormat(pappl_job_t *job);
38
39 int
40 papplJobGetID(pappl_job_t *job);
41
42 int
43 papplJobGetImpressions(pappl_job_t *job);
44
45 int
46 papplJobGetImpressionsCompleted(pappl_job_t *job);
47
48 const char *
49 papplJobGetMessage(pappl_job_t *job);
50
51 const char *
52 papplJobGetName(pappl_job_t *job);
53
54 pappl_joptions_t *
55 papplJobGetOptions(pappl_job_t *job, pappl_joptions_t *options, un‐
56 signed num_pages, bool color);
57
58 pappl_printer_t *
59 papplJobGetPrinter(pappl_job_t *job);
60
61 pappl_jreason_t
62 papplJobGetReasons(pappl_job_t *job);
63
64 ipp_jstate_t
65 papplJobGetState(pappl_job_t *job);
66
67 time_t
68 papplJobGetTimeCompleted(pappl_job_t *job);
69
70 time_t
71 papplJobGetTimeCreated(pappl_job_t *job);
72
73 time_t
74 papplJobGetTimeProcessed(pappl_job_t *job);
75
76 const char *
77 papplJobGetUsername(pappl_job_t *job);
78
79 bool
80 papplJobIsCanceled(pappl_job_t *job);
81
82
83 int
84 papplJobOpenFile(pappl_job_t *job, char *fname, size_t fnamesize, const
85 char *directory, const char *ext, const char *mode);
86
87
88 void
89 papplJobSetData(pappl_job_t *job, void *data);
90
91 void
92 papplJobSetImpressions(pappl_job_t *job, int impressions);
93
94 void
95 papplJobSetImpressionsCompleted(pappl_job_t *job, int add);
96
97 void
98 papplJobSetMessage(pappl_job_t *job, const char *message, ...);
99
100 void
101 papplJobSetReasons(pappl_job_t *job, pappl_jreason_t add, pappl_jrea‐
102 son_t remove);
103
104
106 The PAPPL job functions provide access to the job object. Jobs and the
107 life cycle of the pappl_job_t objects are managed automatically by the
108 system object for the printer application.
109
110 The papplJobGet functions get the current values associated with a job
111 while the papplJobSet functions set the current values associated with
112 a job.
113
114 The papplJobCancel function cancels processing of a job, while the pap‐
115 plJobIsCanceled function returns whether a job is in the canceled state
116 (IPP_JSTATE_CANCELED) or is in the process of being canceled (IPP_JS‐
117 TATE_PROCESSING and PAPPL_JREASON_PROCESSING_TO_STOP_POINT).
118
119 The papplJobOpenFile function opens a file associated with the job.
120 The file descriptor must be closed by the caller using the close(2)
121 system call.
122
123 The papplJobFilterImage function converts raw image data to raster data
124 suitable for the printer.
125
127 pappl_jreason_e
128 IPP "job-state-reasons" bit values
129
130 PAPPL_JREASON_ABORTED_BY_SYSTEM
131 ´aborted-by-system'
132
133 PAPPL_JREASON_COMPRESSION_ERROR
134 ´compression-error'
135
136 PAPPL_JREASON_DOCUMENT_FORMAT_ERROR
137 ´document-format-error'
138
139 PAPPL_JREASON_DOCUMENT_PASSWORD_ERROR
140 ´document-password-error'
141
142 PAPPL_JREASON_DOCUMENT_PERMISSION_ERROR
143 ´document-permission-error'
144
145 PAPPL_JREASON_DOCUMENT_UNPRINTABLE_ERROR
146 ´document-unprintable-error'
147
148 PAPPL_JREASON_ERRORS_DETECTED
149 ´errors-detected'
150
151 PAPPL_JREASON_JOB_CANCELED_AT_DEVICE
152 ´job-canceled-at-device'
153
154 PAPPL_JREASON_JOB_CANCELED_BY_USER
155 ´job-canceled-by-user'
156
157 PAPPL_JREASON_JOB_COMPLETED_SUCCESSFULLY
158 ´job-completed-successfully'
159
160 PAPPL_JREASON_JOB_COMPLETED_WITH_ERRORS
161 ´job-completed-with-errors'
162
163 PAPPL_JREASON_JOB_COMPLETED_WITH_WARNINGS
164 ´job-completed-with-warnings'
165
166 PAPPL_JREASON_JOB_DATA_INSUFFICIENT
167 ´job-data-insufficient'
168
169 PAPPL_JREASON_JOB_INCOMING
170 ´job-incoming'
171
172 PAPPL_JREASON_JOB_PRINTING
173 ´job-printing'
174
175 PAPPL_JREASON_JOB_QUEUED
176 ´job-queued'
177
178 PAPPL_JREASON_JOB_SPOOLING
179 ´job-spooling'
180
181 PAPPL_JREASON_NONE
182 ´none'
183
184 PAPPL_JREASON_PRINTER_STOPPED
185 ´printer-stopped'
186
187 PAPPL_JREASON_PRINTER_STOPPED_PARTLY
188 ´printer-stopped-partly'
189
190 PAPPL_JREASON_PROCESSING_TO_STOP_POINT
191 ´processing-to-stop-point'
192
193 PAPPL_JREASON_QUEUED_IN_DEVICE
194 ´queued-in-device'
195
196 PAPPL_JREASON_WARNINGS_DETECTED
197 ´warnings-detected'
198
200 papplJobCancel
201 Cancel a job.
202
203 void papplJobCancel (
204 pappl_job_t *job
205 );
206
207 This function cancels the specified job. If the job is currently being
208 printed, it will be stopped at a convenient time (usually the end of a
209 page) so that the printer will be left in a known state.
210
211 papplJobCreatePrintOptions
212 Create the printer options for a job.
213
214 pappl_pr_options_t * papplJobCreatePrintOptions (
215 pappl_job_t *job,
216 unsigned num_pages,
217 bool color
218 );
219
220 This function allocates a printer options structure and computes the
221 print options for a job based upon the Job Template attributes submit‐
222 ted in the print request and the default values set in the printer
223 driver data.
224
225 The "num_pages" and "color" arguments specify the number of pages and
226 whether the document contains non-grayscale colors - this information
227 typically comes from parsing the job file.
228
229 papplJobCreateWithFile
230 Create a job with a local file.
231
232 pappl_job_t * papplJobCreateWithFile (
233 pappl_printer_t *printer,
234 const char *username,
235 const char *format,
236 const char *job_name,
237 int num_options,
238 cups_option_t *options,
239 const char *filename
240 );
241
242 This function creates a new print job with a local file. The "num_op‐
243 tions" and "options" parameters specify additional print options, as
244 needed. The file specified by "filename" is removed automatically if
245 it resides in the spool directory.
246
247 papplJobDeletePrintOptions
248 Delete a job options structure.
249
250 void papplJobDeletePrintOptions (
251 pappl_pr_options_t *options
252 );
253
254 This function frees the memory used for a job options structure.
255
256 papplJobFilterImage
257 Filter an image in memory.
258
259 bool papplJobFilterImage (
260 pappl_job_t *job,
261 pappl_device_t *device,
262 pappl_pr_options_t *options,
263 const unsigned char *pixels,
264 int width,
265 int height,
266 int depth,
267 int ppi,
268 bool smoothing
269 );
270
271 This function will print a grayscale or sRGB image using the printer's
272 raster driver interface, scaling and positioning the image as necessary
273 based on the job options, and printing as many copies as requested.
274
275 The image data is an array of grayscale ("depth" = 1) or sRGB ("depth"
276 = 3) pixels starting at the top-left corner of the image.
277
278 The image resolution ("ppi") is expressed in pixels per inch and is
279 used for some "print-scaling" modes. Pass 0 if the image has no ex‐
280 plicit resolution information.
281
282 papplJobGetAttribute
283 Get an attribute from a job.
284
285 ipp_attribute_t * papplJobGetAttribute (
286 pappl_job_t *job,
287 const char *name
288 );
289
290 This function gets the named IPP attribute from a job. The returned
291 attribute can be examined using the ippGetXxx functions.
292
293 papplJobGetData
294 Get per-job driver data.
295
296 void * papplJobGetData (
297 pappl_job_t *job
298 );
299
300 This function returns the driver data associated with the job. It is
301 normally only called from drivers to maintain state for the processing
302 of the job, for example to store bitmap compression information.
303
304 papplJobGetFilename
305 Get the job's filename.
306
307 const char * papplJobGetFilename (
308 pappl_job_t *job
309 );
310
311 This function returns the filename for the job's document data.
312
313 papplJobGetFormat
314 Get the MIME media type for the job's file.
315
316 const char * papplJobGetFormat (
317 pappl_job_t *job
318 );
319
320 This function returns the MIME media type for the job's document data.
321
322 papplJobGetID
323 Get the job ID value.
324
325 int papplJobGetID (
326 pappl_job_t *job
327 );
328
329 This function returns the job's unique integer identifier.
330
331 papplJobGetImpressions
332 Get the number of impressions (sides) in the job.
333
334 int papplJobGetImpressions (
335 pappl_job_t *job
336 );
337
338 This function returns the number of impressions in the job's document
339 data. An impression is one side of an output page.
340
341 papplJobGetImpressionsCompleted
342 Get the number of completed impressions (sides) in the job.
343
344 int papplJobGetImpressionsCompleted (
345 pappl_job_t *job
346 );
347
348 This function returns the number of impressions that have been printed.
349 An impression is one side of an output page.
350
351 papplJobGetMessage
352 Get the current job message string, if any.
353
354 const char * papplJobGetMessage (
355 pappl_job_t *job
356 );
357
358 This function returns the current job message string, if any.
359
360 papplJobGetName
361 Get the job name/title.
362
363 const char * papplJobGetName (
364 pappl_job_t *job
365 );
366
367 This function returns the name or title of the job.
368
369 papplJobGetPrinter
370 Get the printer for the job.
371
372 pappl_printer_t * papplJobGetPrinter (
373 pappl_job_t *job
374 );
375
376 This function returns the printer containing the job.
377
378 papplJobGetReasons
379 Get the current job state reasons.
380
381 pappl_jreason_t papplJobGetReasons (
382 pappl_job_t *job
383 );
384
385 This function returns the current job state reasons bitfield.
386
387 papplJobGetState
388 Get the current job state.
389
390 ipp_jstate_t papplJobGetState (
391 pappl_job_t *job
392 );
393
394 This function returns the current job processing state, which is repre‐
395 sented as an enumeration:
396
397 • IPP_JSTATE_ABORTED: Job has been aborted by the system due to an
398 error.
399
400 • IPP_JSTATE_CANCELED: Job has been canceled by a user.
401
402 • IPP_JSTATE_COMPLETED: Job has finished printing.
403
404 • IPP_JSTATE_HELD: Job is being held for some reason, typically be‐
405 cause the document data is being received.
406
407 • IPP_JSTATE_PENDING: Job is queued and waiting to be printed.
408
409 • IPP_JSTATE_PROCESSING: Job is being printed.
410
411 • IPP_JSTATE_STOPPED: Job is paused, typically when the printer is
412 not ready.</li> </ul>
413
414 papplJobGetTimeCompleted
415 Get the job completion time, if any.
416
417 time_t papplJobGetTimeCompleted (
418 pappl_job_t *job
419 );
420
421 This function returns the date and time when the job reached the com‐
422 pleted, canceled, or aborted states. 0 is returned if the job is not
423 yet in one of those states.
424
425 papplJobGetTimeCreated
426 Get the job creation time.
427
428 time_t papplJobGetTimeCreated (
429 pappl_job_t *job
430 );
431
432 This function returns the date and time when the job was created.
433
434 papplJobGetTimeProcessed
435 Get the job processing time.
436
437 time_t papplJobGetTimeProcessed (
438 pappl_job_t *job
439 );
440
441 This function returns the date and time when the job started processing
442 (printing).
443
444 papplJobGetUsername
445 Get the name of the user that submitted the job.
446
447 const char * papplJobGetUsername (
448 pappl_job_t *job
449 );
450
451 This function returns the name of the user that submitted the job.
452
453 papplJobIsCanceled
454 Return whether the job is canceled.
455
456 bool papplJobIsCanceled (
457 pappl_job_t *job
458 );
459
460 This function returns true if the job has been canceled or aborted.
461
462 papplJobOpenFile
463 Create or open a file for the document in a job.
464
465 int papplJobOpenFile (
466 pappl_job_t *job,
467 char *fname,
468 size_t fnamesize,
469 const char *directory,
470 const char *ext,
471 const char *mode
472 );
473
474 This function creates or opens a file for a job. The "fname" and
475 "fnamesize" arguments specify the location and size of a buffer to
476 store the job filename, which incorporates the "directory", printer ID,
477 job ID, job name (title), and "ext" values. The job name is "sani‐
478 tized" to only contain alphanumeric characters.
479
480 The "mode" argument is "r" to read an existing job file or "w" to write
481 a new job file. New files are created with restricted permissions for
482 security purposes.
483
484 papplJobSetData
485 Set the per-job driver data pointer.
486
487 void papplJobSetData (
488 pappl_job_t *job,
489 void *data
490 );
491
492 This function sets the driver data for the specified job. It is nor‐
493 mally only called from drivers to maintain state for the processing of
494 the job, for example to store bitmap compression information.
495
496 papplJobSetImpressions
497 Set the number of impressions (sides) in a job.
498
499 void papplJobSetImpressions (
500 pappl_job_t *job,
501 int impressions
502 );
503
504 This function sets the number of impressions in a job. An impression
505 is one side of an output page.
506
507 papplJobSetImpressionsCompleted
508 Add completed impressions (sides) to the job.
509
510 void papplJobSetImpressionsCompleted (
511 pappl_job_t *job,
512 int add
513 );
514
515 This function updates the number of completed impressions in a job. An
516 impression is one side of an output page.
517
518 papplJobSetMessage
519 Set the job message string.
520
521 void papplJobSetMessage (
522 pappl_job_t *job,
523 const char *message,
524 ...
525 );
526
527 This function sets the job message string using a printf-style format
528 string.
529
530 5 Note: The maximum length of the job message string is 1023
531 bytes.
532
533 papplJobSetReasons
534 Set the job state reasons bit values.
535
536 void papplJobSetReasons (
537 pappl_job_t *job,
538 pappl_jreason_t add,
539 pappl_jreason_t remove
540 );
541
542 This function updates the job state reasons bitfield. The "remove"
543 bits are cleared first, then the "add" bits are set.
544
545 papplPrinterFindJob
546 Find a job.
547
548 pappl_job_t * papplPrinterFindJob (
549 pappl_printer_t *printer,
550 int job_id
551 );
552
553 This function finds a job submitted to a printer using its integer ID
554 value.
555
556 papplSystemCleanJobs
557 Clean out old (completed) jobs.
558
559 void papplSystemCleanJobs (
560 pappl_system_t *system
561 );
562
563 This function deletes all old (completed) jobs above the limit set by
564 the papplPrinterSetMaxCompletedJobs function. The level may temporar‐
565 ily exceed this limit if the jobs were completed within the last 60
566 seconds.
567
568 5 Note: This function is normally called automatically from the
569
570 5 papplSystemRun function.
571
573 pappl_jreason_t
574 Bitfield for IPP "job-state-reasons" values
575
576 typedef unsigned int pappl_jreason_t;
577
579 pappl(1), pappl-client(3), pappl-device(3), pappl-job(3), pappl-log(3),
580 pappl-mainline(3), pappl-makeresheader(1), pappl-printer(3), pappl-re‐
581 source(3), pappl-system(3), https://www.msweet.org/pappl
582
584 Copyright © 2019-2022 by Michael R Sweet.
585
586 PAPPL is licensed under the Apache License Version 2.0 with an (op‐
587 tional) exception to allow linking against GPL2/LGPL2 software (like
588 older versions of CUPS), so it can be used freely in any project you'd
589 like. See the files "LICENSE" and "NOTICE" in the source distribution
590 for more information.
591
592
593
5942022-05-10 pappl job functions pappl-job(3)