]> git.ipfire.org Git - thirdparty/cups.git/blame - scheduler/printers.h
Fix stuck multi-file jobs (Issue #5359, Issue #5413)
[thirdparty/cups.git] / scheduler / printers.h
CommitLineData
ef416fc2 1/*
7d644288 2 * Printer definitions for the CUPS scheduler.
ef416fc2 3 *
b4974142 4 * Copyright 2007-2017 by Apple Inc.
7d644288 5 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
ef416fc2 6 *
e3101897 7 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
ef416fc2 8 */
9
f7deaa1a 10#ifdef HAVE_DNSSD
11# include <dns_sd.h>
f3c17241
MS
12#elif defined(HAVE_AVAHI)
13# include <avahi-client/client.h>
14# include <avahi-client/publish.h>
15# include <avahi-common/error.h>
16# include <avahi-common/thread-watch.h>
f7deaa1a 17#endif /* HAVE_DNSSD */
54afec33
MS
18#include <cups/pwg-private.h>
19
f7deaa1a 20
ef416fc2 21/*
22 * Quota data...
23 */
24
25typedef struct
26{
27 char username[33]; /* User data */
28 time_t next_update; /* Next update time */
29 int page_count, /* Count of pages */
30 k_count; /* Count of kilobytes */
31} cupsd_quota_t;
32
33
f3c17241
MS
34/*
35 * DNS-SD types to make the code cleaner/clearer...
36 */
37
38#ifdef HAVE_DNSSD
39typedef DNSServiceRef cupsd_srv_t; /* Service reference */
40typedef TXTRecordRef cupsd_txt_t; /* TXT record */
41
42#elif defined(HAVE_AVAHI)
43typedef AvahiEntryGroup *cupsd_srv_t; /* Service reference */
44typedef AvahiStringList *cupsd_txt_t; /* TXT record */
45#endif /* HAVE_DNSSD */
46
47
ef416fc2 48/*
49 * Printer/class information structure...
50 */
51
f11a948a
MS
52typedef struct cupsd_job_s cupsd_job_t;
53
10d09e33 54struct cupsd_printer_s
ef416fc2 55{
95ece0cb 56 _cups_rwlock_t lock; /* Concurrency lock for background updates */
409f5497 57 int printer_id; /* Printer ID */
ef416fc2 58 char *uri, /* Printer URI */
82f97232 59 *uuid, /* Printer UUID */
ef416fc2 60 *hostname, /* Host printer resides on */
61 *name, /* Printer name */
9b4bd602
MS
62 *location, /* Location string */
63 *geo_location, /* Geographic location URI */
ef416fc2 64 *make_model, /* Make and model */
65 *info, /* Description */
9b4bd602
MS
66 *organization, /* Organization name */
67 *organizational_unit, /* Organizational unit (department, etc.) */
2fa1ba3c 68 *strings, /* Strings file, if any */
ef416fc2 69 *op_policy, /* Operation policy name */
70 *error_policy; /* Error policy */
71 cupsd_policy_t *op_policy_ptr; /* Pointer to operation policy */
72 int shared; /* Shared? */
7ae00c35 73 int temporary; /* Temporary queue? */
ef416fc2 74 int accepting; /* Accepting jobs? */
61cf44e2 75 int holding_new_jobs; /* Holding new jobs for printing? */
ef416fc2 76 int in_implicit_class; /* In an implicit class? */
77 ipp_pstate_t state; /* Printer state */
78 char state_message[1024]; /* Printer state message */
79 int num_reasons; /* Number of printer-state-reasons */
d1c13e16 80 char *reasons[64]; /* printer-state-reasons strings */
9b4bd602
MS
81 time_t config_time, /* Time at this configuration */
82 state_time; /* Time at this state */
ef416fc2 83 char *job_sheets[2]; /* Banners/job sheets */
09a101d6 84 cups_ptype_t type; /* Printer type (color, small, etc.) */
ef416fc2 85 char *device_uri; /* Device URI */
0af14961 86 char *sanitized_device_uri; /* Sanitized device URI */
ef416fc2 87 char *port_monitor; /* Port monitor */
88 int raw; /* Raw queue? */
d09495fa 89 int remote; /* Remote queue? */
f7deaa1a 90 mime_type_t *filetype, /* Pseudo-filetype for printer */
91 *prefiltertype; /* Pseudo-filetype for pre-filters */
f14324a7
MS
92 cups_array_t *filetypes, /* Supported file types */
93 *dest_types; /* Destination types for queue */
f11a948a 94 cupsd_job_t *job; /* Current job in queue */
61cf44e2
MS
95 ipp_t *attrs, /* Attributes supported by this printer */
96 *ppd_attrs; /* Attributes based on the PPD */
ef416fc2 97 int num_printers, /* Number of printers in class */
98 last_printer; /* Last printer job was sent to */
99 struct cupsd_printer_s **printers; /* Printers in class */
100 int quota_period, /* Period for quotas */
101 page_limit, /* Maximum number of pages */
fa73b229 102 k_limit; /* Maximum number of kilobytes */
103 cups_array_t *quotas; /* Quota records */
10d09e33
MS
104 int deny_users; /* 1 = deny, 0 = allow */
105 cups_array_t *users; /* Allowed/denied users */
ef416fc2 106 int sequence_number; /* Increasing sequence number */
b423cd4c 107 int num_options; /* Number of default options */
108 cups_option_t *options; /* Default options */
f7deaa1a 109 int num_auth_info_required; /* Number of required auth fields */
110 const char *auth_info_required[4]; /* Required authentication fields */
323c5de1 111 char *alert, /* PSX printer-alert value */
112 *alert_description; /* PSX printer-alert-description value */
5a738aea 113 time_t marker_time; /* Last time marker attributes were updated */
f14324a7 114 _ppd_cache_t *pc; /* PPD cache and mapping data */
f7deaa1a 115
f3c17241 116#if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
f7deaa1a 117 char *reg_name, /* Name used for service registration */
f3c17241
MS
118 *pdl; /* pdl value for TXT record */
119 cupsd_srv_t ipp_srv; /* IPP service(s) */
120# ifdef HAVE_DNSSD
121# ifdef HAVE_SSL
122 cupsd_srv_t ipps_srv; /* IPPS service(s) */
123# endif /* HAVE_SSL */
124 cupsd_srv_t printer_srv; /* LPD service */
125# endif /* HAVE_DNSSD */
126#endif /* HAVE_DNSSD || HAVE_AVAHI */
10d09e33 127};
ef416fc2 128
129
130/*
131 * Globals...
132 */
133
134VAR ipp_t *CommonData VALUE(NULL);
135 /* Common printer object attrs */
f7deaa1a 136VAR cups_array_t *CommonDefaults VALUE(NULL);
137 /* Common -default option names */
409f5497
MS
138VAR int NextPrinterId VALUE(1);
139 /* Next printer-id value */
a2326b5b 140VAR cups_array_t *Printers VALUE(NULL);
ef416fc2 141 /* Printer list */
ef416fc2 142VAR cupsd_printer_t *DefaultPrinter VALUE(NULL);
143 /* Default printer */
144VAR char *DefaultPolicy VALUE(NULL);
145 /* Default policy name */
146VAR cupsd_policy_t *DefaultPolicyPtr
147 VALUE(NULL);
148 /* Pointer to default policy */
149
150
151/*
152 * Prototypes...
153 */
154
155extern cupsd_printer_t *cupsdAddPrinter(const char *name);
ef416fc2 156extern void cupsdCreateCommonData(void);
157extern void cupsdDeleteAllPrinters(void);
f8b3a85b 158extern int cupsdDeletePrinter(cupsd_printer_t *p, int update);
b4974142 159extern void cupsdDeleteTemporaryPrinters(int force);
ef416fc2 160extern cupsd_printer_t *cupsdFindDest(const char *name);
161extern cupsd_printer_t *cupsdFindPrinter(const char *name);
3d8365b8 162extern cupsd_quota_t *cupsdFindQuota(cupsd_printer_t *p,
163 const char *username);
ef416fc2 164extern void cupsdFreeQuotas(cupsd_printer_t *p);
165extern void cupsdLoadAllPrinters(void);
f7deaa1a 166extern void cupsdRenamePrinter(cupsd_printer_t *p,
167 const char *name);
ef416fc2 168extern void cupsdSaveAllPrinters(void);
f7deaa1a 169extern int cupsdSetAuthInfoRequired(cupsd_printer_t *p,
170 const char *values,
171 ipp_attribute_t *attr);
0af14961 172extern void cupsdSetDeviceURI(cupsd_printer_t *p, const char *uri);
5a738aea 173extern void cupsdSetPrinterAttr(cupsd_printer_t *p,
7d644288
MS
174 const char *name,
175 const char *value);
ef416fc2 176extern void cupsdSetPrinterAttrs(cupsd_printer_t *p);
e07d4801 177extern int cupsdSetPrinterReasons(cupsd_printer_t *p,
f7deaa1a 178 const char *s);
179extern void cupsdSetPrinterState(cupsd_printer_t *p, ipp_pstate_t s,
180 int update);
a29fd7dd
MS
181#define cupsdStartPrinter(p,u) cupsdSetPrinterState((p), \
182 IPP_PRINTER_IDLE, (u))
ef416fc2 183extern void cupsdStopPrinter(cupsd_printer_t *p, int update);
c9fc04c6
MS
184extern int cupsdUpdatePrinterPPD(cupsd_printer_t *p,
185 int num_keywords,
186 cups_option_t *keywords);
ef416fc2 187extern void cupsdUpdatePrinters(void);
f7deaa1a 188extern cupsd_quota_t *cupsdUpdateQuota(cupsd_printer_t *p,
189 const char *username, int pages,
190 int k);
191extern const char *cupsdValidateDest(const char *uri,
ef416fc2 192 cups_ptype_t *dtype,
193 cupsd_printer_t **printer);
194extern void cupsdWritePrintcap(void);