]>
Commit | Line | Data |
---|---|---|
ef416fc2 | 1 | /* |
581dae2d | 2 | * Print job definitions for the CUPS scheduler. |
ef416fc2 | 3 | * |
9514a192 | 4 | * Copyright 2007-2015 by Apple Inc. |
581dae2d | 5 | * Copyright 1997-2007 by Easy Software Products, all rights reserved. |
ef416fc2 | 6 | * |
e3101897 | 7 | * Licensed under Apache License v2.0. See the file "LICENSE" for more information. |
ef416fc2 | 8 | */ |
9 | ||
b9faaae1 MS |
10 | /* |
11 | * Constants... | |
12 | */ | |
13 | ||
14 | typedef enum cupsd_jobaction_e /**** Actions for state changes ****/ | |
15 | { | |
16 | CUPSD_JOB_DEFAULT, /* Use default action */ | |
17 | CUPSD_JOB_FORCE, /* Force the change */ | |
18 | CUPSD_JOB_PURGE /* Force the change and purge */ | |
19 | } cupsd_jobaction_t; | |
20 | ||
21 | ||
ef416fc2 | 22 | /* |
23 | * Job request structure... | |
24 | */ | |
25 | ||
178cb736 | 26 | struct cupsd_job_s /**** Job request ****/ |
ef416fc2 | 27 | { |
28 | int id, /* Job ID */ | |
3dfe78b3 MS |
29 | priority, /* Job priority */ |
30 | dirty; /* Do we need to write the "c" file? */ | |
bd7854cb | 31 | ipp_jstate_t state_value; /* Cached job-state */ |
b9faaae1 MS |
32 | int pending_timeout;/* Non-zero if the job was created and |
33 | * waiting on files */ | |
ef416fc2 | 34 | char *username; /* Printing user */ |
35 | char *dest; /* Destination printer or class */ | |
f16ea703 MS |
36 | char *name; /* Job name/title */ |
37 | int koctets; /* job-k-octets */ | |
b9faaae1 | 38 | cups_ptype_t dtype; /* Destination type */ |
10d09e33 | 39 | cupsd_printer_t *printer; /* Printer this job is assigned to */ |
ef416fc2 | 40 | int num_files; /* Number of files in job */ |
ef416fc2 | 41 | mime_type_t **filetypes; /* File types */ |
42 | int *compressions; /* Compression status of each file */ | |
9514a192 MS |
43 | ipp_attribute_t *impressions, /* job-impressions-completed */ |
44 | *sheets; /* job-media-sheets-completed */ | |
238c3832 | 45 | time_t access_time, /* Last access time */ |
dcb445bc | 46 | cancel_time, /* When to cancel/send SIGTERM */ |
f16ea703 | 47 | creation_time, /* When job was created */ |
eec1fbc3 | 48 | completed_time, /* When job was completed (0 if not) */ |
82cc1f9a MS |
49 | file_time, /* Job file retain time */ |
50 | history_time, /* Job history retain time */ | |
51 | hold_until, /* Hold expiration date/time */ | |
52 | kill_time; /* When to send SIGKILL */ | |
bd7854cb | 53 | ipp_attribute_t *state; /* Job state */ |
12f89d24 | 54 | ipp_attribute_t *reasons; /* Job state reasons */ |
bd7854cb | 55 | ipp_attribute_t *job_sheets; /* Job sheets (NULL if none) */ |
bc44d920 | 56 | ipp_attribute_t *printer_message, |
57 | /* job-printer-state-message */ | |
58 | *printer_reasons; | |
59 | /* job-printer-state-reasons */ | |
bd7854cb | 60 | int current_file; /* Current file in job */ |
ef416fc2 | 61 | ipp_t *attrs; /* Job attributes */ |
ef416fc2 | 62 | int print_pipes[2], /* Print data pipes */ |
89d46774 | 63 | back_pipes[2], /* Backchannel pipes */ |
f7deaa1a | 64 | side_pipes[2], /* Sidechannel pipes */ |
89d46774 | 65 | status_pipes[2];/* Status pipes */ |
66 | cupsd_statbuf_t *status_buffer; /* Status buffer for this job */ | |
b9faaae1 MS |
67 | int status_level; /* Highest log level in a status |
68 | * message */ | |
ef416fc2 | 69 | int cost; /* Filtering cost */ |
e07d4801 | 70 | int pending_cost; /* Waiting for FilterLimit */ |
ef416fc2 | 71 | int filters[MAX_FILTERS + 1]; |
72 | /* Filter process IDs, 0 terminated */ | |
73 | int backend; /* Backend process ID */ | |
74 | int status; /* Status code from filters */ | |
ef416fc2 | 75 | int tries; /* Number of tries for this job */ |
1e3e80bb | 76 | int completed; /* cups-waiting-for-job-completed seen */ |
8e67b75b | 77 | int retry_as_raster;/* Need to retry the job as raster */ |
88f9aafc | 78 | char *auth_env[3], /* AUTH_xxx environment variables, |
b9faaae1 | 79 | * if any */ |
88f9aafc | 80 | *auth_uid; /* AUTH_UID environment variable */ |
8fe0183a MS |
81 | void *profile, /* Security profile for filters */ |
82 | *bprofile; /* Security profile for backend */ | |
178cb736 | 83 | cups_array_t *history; /* Debug log history */ |
9a4f8274 | 84 | int progress; /* Printing progress */ |
a29fd7dd MS |
85 | int num_keywords; /* Number of PPD keywords */ |
86 | cups_option_t *keywords; /* PPD keywords */ | |
f11a948a | 87 | }; |
ef416fc2 | 88 | |
178cb736 MS |
89 | typedef struct cupsd_joblog_s /**** Job log message ****/ |
90 | { | |
91 | time_t time; /* Time of message */ | |
92 | char message[1]; /* Message string */ | |
93 | } cupsd_joblog_t; | |
94 | ||
ef416fc2 | 95 | |
96 | /* | |
97 | * Globals... | |
98 | */ | |
99 | ||
82cc1f9a | 100 | VAR int JobHistory VALUE(INT_MAX); |
ef416fc2 | 101 | /* Preserve job history? */ |
82cc1f9a | 102 | VAR int JobFiles VALUE(86400); |
ef416fc2 | 103 | /* Preserve job files? */ |
82cc1f9a MS |
104 | VAR time_t JobHistoryUpdate VALUE(0); |
105 | /* Time for next job history update */ | |
ef416fc2 | 106 | VAR int MaxJobs VALUE(0), |
107 | /* Max number of jobs */ | |
108 | MaxActiveJobs VALUE(0), | |
109 | /* Max number of active jobs */ | |
3e7fe0ca MS |
110 | MaxHoldTime VALUE(0), |
111 | /* Max time for indefinite hold */ | |
ef416fc2 | 112 | MaxJobsPerUser VALUE(0), |
113 | /* Max jobs per user */ | |
dcb445bc | 114 | MaxJobsPerPrinter VALUE(0), |
ef416fc2 | 115 | /* Max jobs per printer */ |
dcb445bc MS |
116 | MaxJobTime VALUE(3 * 60 * 60); |
117 | /* Max time for a job */ | |
ef416fc2 | 118 | VAR int JobAutoPurge VALUE(0); |
119 | /* Automatically purge jobs */ | |
120 | VAR cups_array_t *Jobs VALUE(NULL), | |
121 | /* List of current jobs */ | |
3dfe78b3 | 122 | *ActiveJobs VALUE(NULL), |
ef416fc2 | 123 | /* List of active jobs */ |
3dfe78b3 MS |
124 | *PrintingJobs VALUE(NULL); |
125 | /* List of jobs that are printing */ | |
ef416fc2 | 126 | VAR int NextJobId VALUE(1); |
127 | /* Next job ID to use */ | |
238c3832 MS |
128 | VAR int JobKillDelay VALUE(DEFAULT_TIMEOUT), |
129 | /* Delay before killing jobs */ | |
130 | JobRetryLimit VALUE(5), | |
ef416fc2 | 131 | /* Max number of tries */ |
132 | JobRetryInterval VALUE(300); | |
133 | /* Seconds between retries */ | |
134 | ||
135 | ||
136 | /* | |
137 | * Prototypes... | |
138 | */ | |
139 | ||
140 | extern cupsd_job_t *cupsdAddJob(int priority, const char *dest); | |
ef416fc2 | 141 | extern void cupsdCancelJobs(const char *dest, const char *username, |
142 | int purge); | |
143 | extern void cupsdCheckJobs(void); | |
144 | extern void cupsdCleanJobs(void); | |
b9faaae1 MS |
145 | extern void cupsdContinueJob(cupsd_job_t *job); |
146 | extern void cupsdDeleteJob(cupsd_job_t *job, | |
147 | cupsd_jobaction_t action); | |
ef416fc2 | 148 | extern cupsd_job_t *cupsdFindJob(int id); |
ef416fc2 | 149 | extern void cupsdFreeAllJobs(void); |
eec1fbc3 | 150 | extern cups_array_t *cupsdGetCompletedJobs(cupsd_printer_t *p); |
ef416fc2 | 151 | extern int cupsdGetPrinterJobCount(const char *dest); |
152 | extern int cupsdGetUserJobCount(const char *username); | |
ef416fc2 | 153 | extern void cupsdLoadAllJobs(void); |
dfd5680b | 154 | extern int cupsdLoadJob(cupsd_job_t *job); |
e53920b9 | 155 | extern void cupsdMoveJob(cupsd_job_t *job, cupsd_printer_t *p); |
ef416fc2 | 156 | extern void cupsdReleaseJob(cupsd_job_t *job); |
157 | extern void cupsdRestartJob(cupsd_job_t *job); | |
bd7854cb | 158 | extern void cupsdSaveAllJobs(void); |
ef416fc2 | 159 | extern void cupsdSaveJob(cupsd_job_t *job); |
b9faaae1 MS |
160 | extern void cupsdSetJobHoldUntil(cupsd_job_t *job, |
161 | const char *when, int update); | |
ef416fc2 | 162 | extern void cupsdSetJobPriority(cupsd_job_t *job, int priority); |
b9faaae1 MS |
163 | extern void cupsdSetJobState(cupsd_job_t *job, |
164 | ipp_jstate_t newstate, | |
165 | cupsd_jobaction_t action, | |
166 | const char *message, ...) | |
85dda01c MS |
167 | __attribute__((__format__(__printf__, |
168 | 4, 5))); | |
238c3832 MS |
169 | extern void cupsdStopAllJobs(cupsd_jobaction_t action, |
170 | int kill_delay); | |
91c84a35 | 171 | extern int cupsdTimeoutJob(cupsd_job_t *job); |
bc44d920 | 172 | extern void cupsdUnloadCompletedJobs(void); |
82cc1f9a | 173 | extern void cupsdUpdateJobs(void); |