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