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