1/* 2 * "$Id: job.h 12078 2014-07-31 11:45:57Z msweet $" 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 20typedef 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 32struct 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 char *name; /* Job name/title */ 43 int koctets; /* job-k-octets */ 44 cups_ptype_t dtype; /* Destination type */ 45 cupsd_printer_t *printer; /* Printer this job is assigned to */ 46 int num_files; /* Number of files in job */ 47 mime_type_t **filetypes; /* File types */ 48 int *compressions; /* Compression status of each file */ 49 ipp_attribute_t *sheets; /* job-media-sheets-completed */ 50 time_t access_time, /* Last access time */ 51 cancel_time, /* When to cancel/send SIGTERM */ 52 creation_time, /* When job was created */ 53 completed_time, /* When job was completed (0 if not) */ 54 file_time, /* Job file retain time */ 55 history_time, /* Job history retain time */ 56 hold_until, /* Hold expiration date/time */ 57 kill_time; /* When to send SIGKILL */ 58 ipp_attribute_t *state; /* Job state */ 59 ipp_attribute_t *reasons; /* Job state reasons */ 60 ipp_attribute_t *job_sheets; /* Job sheets (NULL if none) */ 61 ipp_attribute_t *printer_message, 62 /* job-printer-state-message */ 63 *printer_reasons; 64 /* job-printer-state-reasons */ 65 int current_file; /* Current file in job */ 66 ipp_t *attrs; /* Job attributes */ 67 int print_pipes[2], /* Print data pipes */ 68 back_pipes[2], /* Backchannel pipes */ 69 side_pipes[2], /* Sidechannel pipes */ 70 status_pipes[2];/* Status pipes */ 71 cupsd_statbuf_t *status_buffer; /* Status buffer for this job */ 72 int status_level; /* Highest log level in a status 73 * message */ 74 int cost; /* Filtering cost */ 75 int pending_cost; /* Waiting for FilterLimit */ 76 int filters[MAX_FILTERS + 1]; 77 /* Filter process IDs, 0 terminated */ 78 int backend; /* Backend process ID */ 79 int status; /* Status code from filters */ 80 int tries; /* Number of tries for this job */ 81 int completed; /* cups-waiting-for-job-completed seen */ 82 int retry_as_raster;/* Need to retry the job as raster */ 83 char *auth_env[3], /* AUTH_xxx environment variables, 84 * if any */ 85 *auth_uid; /* AUTH_UID environment variable */ 86 void *profile, /* Security profile for filters */ 87 *bprofile; /* Security profile for backend */ 88 cups_array_t *history; /* Debug log history */ 89 int progress; /* Printing progress */ 90 int num_keywords; /* Number of PPD keywords */ 91 cups_option_t *keywords; /* PPD keywords */ 92}; 93 94typedef struct cupsd_joblog_s /**** Job log message ****/ 95{ 96 time_t time; /* Time of message */ 97 char message[1]; /* Message string */ 98} cupsd_joblog_t; 99 100 101/* 102 * Globals... 103 */ 104 105VAR int JobHistory VALUE(INT_MAX); 106 /* Preserve job history? */ 107VAR int JobFiles VALUE(86400); 108 /* Preserve job files? */ 109VAR time_t JobHistoryUpdate VALUE(0); 110 /* Time for next job history update */ 111VAR int MaxJobs VALUE(0), 112 /* Max number of jobs */ 113 MaxActiveJobs VALUE(0), 114 /* Max number of active jobs */ 115 MaxHoldTime VALUE(0), 116 /* Max time for indefinite hold */ 117 MaxJobsPerUser VALUE(0), 118 /* Max jobs per user */ 119 MaxJobsPerPrinter VALUE(0), 120 /* Max jobs per printer */ 121 MaxJobTime VALUE(3 * 60 * 60); 122 /* Max time for a job */ 123VAR int JobAutoPurge VALUE(0); 124 /* Automatically purge jobs */ 125VAR cups_array_t *Jobs VALUE(NULL), 126 /* List of current jobs */ 127 *ActiveJobs VALUE(NULL), 128 /* List of active jobs */ 129 *PrintingJobs VALUE(NULL); 130 /* List of jobs that are printing */ 131VAR int NextJobId VALUE(1); 132 /* Next job ID to use */ 133VAR int JobKillDelay VALUE(DEFAULT_TIMEOUT), 134 /* Delay before killing jobs */ 135 JobRetryLimit VALUE(5), 136 /* Max number of tries */ 137 JobRetryInterval VALUE(300); 138 /* Seconds between retries */ 139 140 141/* 142 * Prototypes... 143 */ 144 145extern cupsd_job_t *cupsdAddJob(int priority, const char *dest); 146extern void cupsdCancelJobs(const char *dest, const char *username, 147 int purge); 148extern void cupsdCheckJobs(void); 149extern void cupsdCleanJobs(void); 150extern void cupsdContinueJob(cupsd_job_t *job); 151extern void cupsdDeleteJob(cupsd_job_t *job, 152 cupsd_jobaction_t action); 153extern cupsd_job_t *cupsdFindJob(int id); 154extern void cupsdFreeAllJobs(void); 155extern cups_array_t *cupsdGetCompletedJobs(cupsd_printer_t *p); 156extern int cupsdGetPrinterJobCount(const char *dest); 157extern int cupsdGetUserJobCount(const char *username); 158extern void cupsdLoadAllJobs(void); 159extern int cupsdLoadJob(cupsd_job_t *job); 160extern void cupsdMoveJob(cupsd_job_t *job, cupsd_printer_t *p); 161extern void cupsdReleaseJob(cupsd_job_t *job); 162extern void cupsdRestartJob(cupsd_job_t *job); 163extern void cupsdSaveAllJobs(void); 164extern void cupsdSaveJob(cupsd_job_t *job); 165extern void cupsdSetJobHoldUntil(cupsd_job_t *job, 166 const char *when, int update); 167extern void cupsdSetJobPriority(cupsd_job_t *job, int priority); 168extern void cupsdSetJobState(cupsd_job_t *job, 169 ipp_jstate_t newstate, 170 cupsd_jobaction_t action, 171 const char *message, ...) 172 __attribute__((__format__(__printf__, 173 4, 5))); 174extern void cupsdStopAllJobs(cupsd_jobaction_t action, 175 int kill_delay); 176extern int cupsdTimeoutJob(cupsd_job_t *job); 177extern void cupsdUnloadCompletedJobs(void); 178extern void cupsdUpdateJobs(void); 179 180 181/* 182 * End of "$Id: job.h 12078 2014-07-31 11:45:57Z msweet $". 183 */ 184