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