]> git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/job.h
Merge changes from CUPS 1.6svn-r10267.
[thirdparty/cups.git] / scheduler / job.h
1 /*
2 * "$Id: job.h 7883 2008-08-28 20:38:13Z mike $"
3 *
4 * Print job definitions for the CUPS scheduler.
5 *
6 * Copyright 2007-2011 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 kill_time, /* When to send SIGKILL */
51 hold_until; /* Hold expiration date/time */
52 ipp_attribute_t *state; /* Job state */
53 ipp_attribute_t *reasons; /* Job state reasons */
54 ipp_attribute_t *job_sheets; /* Job sheets (NULL if none) */
55 ipp_attribute_t *printer_message,
56 /* job-printer-state-message */
57 *printer_reasons;
58 /* job-printer-state-reasons */
59 int current_file; /* Current file in job */
60 ipp_t *attrs; /* Job attributes */
61 int print_pipes[2], /* Print data pipes */
62 back_pipes[2], /* Backchannel pipes */
63 side_pipes[2], /* Sidechannel pipes */
64 status_pipes[2];/* Status pipes */
65 cupsd_statbuf_t *status_buffer; /* Status buffer for this job */
66 int status_level; /* Highest log level in a status
67 * message */
68 int cost; /* Filtering cost */
69 int pending_cost; /* Waiting for FilterLimit */
70 int filters[MAX_FILTERS + 1];
71 /* Filter process IDs, 0 terminated */
72 int backend; /* Backend process ID */
73 int status; /* Status code from filters */
74 int tries; /* Number of tries for this job */
75 char *auth_env[3], /* AUTH_xxx environment variables,
76 * if any */
77 *auth_uid; /* AUTH_UID environment variable */
78 void *profile; /* Security profile */
79 cups_array_t *history; /* Debug log history */
80 int progress; /* Printing progress */
81 };
82
83 typedef struct cupsd_joblog_s /**** Job log message ****/
84 {
85 time_t time; /* Time of message */
86 char message[1]; /* Message string */
87 } cupsd_joblog_t;
88
89
90 /*
91 * Globals...
92 */
93
94 VAR int JobHistory VALUE(1);
95 /* Preserve job history? */
96 VAR int JobFiles VALUE(0);
97 /* Preserve job files? */
98 VAR int MaxJobs VALUE(0),
99 /* Max number of jobs */
100 MaxActiveJobs VALUE(0),
101 /* Max number of active jobs */
102 MaxJobsPerUser VALUE(0),
103 /* Max jobs per user */
104 MaxJobsPerPrinter VALUE(0),
105 /* Max jobs per printer */
106 MaxJobTime VALUE(3 * 60 * 60);
107 /* Max time for a job */
108 VAR int JobAutoPurge VALUE(0);
109 /* Automatically purge jobs */
110 VAR cups_array_t *Jobs VALUE(NULL),
111 /* List of current jobs */
112 *ActiveJobs VALUE(NULL),
113 /* List of active jobs */
114 *PrintingJobs VALUE(NULL);
115 /* List of jobs that are printing */
116 VAR int NextJobId VALUE(1);
117 /* Next job ID to use */
118 VAR int JobKillDelay VALUE(DEFAULT_TIMEOUT),
119 /* Delay before killing jobs */
120 JobRetryLimit VALUE(5),
121 /* Max number of tries */
122 JobRetryInterval VALUE(300);
123 /* Seconds between retries */
124
125
126 /*
127 * Prototypes...
128 */
129
130 extern cupsd_job_t *cupsdAddJob(int priority, const char *dest);
131 extern void cupsdCancelJobs(const char *dest, const char *username,
132 int purge);
133 extern void cupsdCheckJobs(void);
134 extern void cupsdCleanJobs(void);
135 extern void cupsdContinueJob(cupsd_job_t *job);
136 extern void cupsdDeleteJob(cupsd_job_t *job,
137 cupsd_jobaction_t action);
138 extern cupsd_job_t *cupsdFindJob(int id);
139 extern void cupsdFreeAllJobs(void);
140 extern int cupsdGetPrinterJobCount(const char *dest);
141 extern int cupsdGetUserJobCount(const char *username);
142 extern void cupsdLoadAllJobs(void);
143 extern int cupsdLoadJob(cupsd_job_t *job);
144 extern void cupsdMoveJob(cupsd_job_t *job, cupsd_printer_t *p);
145 extern void cupsdReleaseJob(cupsd_job_t *job);
146 extern void cupsdRestartJob(cupsd_job_t *job);
147 extern void cupsdSaveAllJobs(void);
148 extern void cupsdSaveJob(cupsd_job_t *job);
149 extern void cupsdSetJobHoldUntil(cupsd_job_t *job,
150 const char *when, int update);
151 extern void cupsdSetJobPriority(cupsd_job_t *job, int priority);
152 extern void cupsdSetJobState(cupsd_job_t *job,
153 ipp_jstate_t newstate,
154 cupsd_jobaction_t action,
155 const char *message, ...)
156 __attribute__((__format__(__printf__,
157 4, 5)));
158 extern void cupsdStopAllJobs(cupsd_jobaction_t action,
159 int kill_delay);
160 extern int cupsdTimeoutJob(cupsd_job_t *job);
161 extern void cupsdUnloadCompletedJobs(void);
162
163
164 /*
165 * End of "$Id: job.h 7883 2008-08-28 20:38:13Z mike $".
166 */