]> git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/printers.h
Fixed a performance regression with large PPDs (rdar://47040759)
[thirdparty/cups.git] / scheduler / printers.h
1 /*
2 * Printer definitions for the CUPS scheduler.
3 *
4 * Copyright 2007-2017 by Apple Inc.
5 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
6 *
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
8 */
9
10 #ifdef HAVE_DNSSD
11 # include <dns_sd.h>
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>
17 #endif /* HAVE_DNSSD */
18 #include <cups/pwg-private.h>
19
20
21 /*
22 * Quota data...
23 */
24
25 typedef 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
34 /*
35 * DNS-SD types to make the code cleaner/clearer...
36 */
37
38 #ifdef HAVE_DNSSD
39 typedef DNSServiceRef cupsd_srv_t; /* Service reference */
40 typedef TXTRecordRef cupsd_txt_t; /* TXT record */
41
42 #elif defined(HAVE_AVAHI)
43 typedef AvahiEntryGroup *cupsd_srv_t; /* Service reference */
44 typedef AvahiStringList *cupsd_txt_t; /* TXT record */
45 #endif /* HAVE_DNSSD */
46
47
48 /*
49 * Printer/class information structure...
50 */
51
52 typedef struct cupsd_job_s cupsd_job_t;
53
54 struct cupsd_printer_s
55 {
56 _cups_rwlock_t lock; /* Concurrency lock for background updates */
57 int printer_id; /* Printer ID */
58 char *uri, /* Printer URI */
59 *uuid, /* Printer UUID */
60 *hostname, /* Host printer resides on */
61 *name, /* Printer name */
62 *location, /* Location string */
63 *geo_location, /* Geographic location URI */
64 *make_model, /* Make and model */
65 *info, /* Description */
66 *organization, /* Organization name */
67 *organizational_unit, /* Organizational unit (department, etc.) */
68 *strings, /* Strings file, if any */
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? */
73 int temporary; /* Temporary queue? */
74 int accepting; /* Accepting jobs? */
75 int holding_new_jobs; /* Holding new jobs for printing? */
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 */
80 char *reasons[64]; /* printer-state-reasons strings */
81 time_t config_time, /* Time at this configuration */
82 state_time; /* Time at this state */
83 char *job_sheets[2]; /* Banners/job sheets */
84 cups_ptype_t type; /* Printer type (color, small, etc.) */
85 char *device_uri; /* Device URI */
86 char *sanitized_device_uri; /* Sanitized device URI */
87 char *port_monitor; /* Port monitor */
88 int raw; /* Raw queue? */
89 int remote; /* Remote queue? */
90 mime_type_t *filetype, /* Pseudo-filetype for printer */
91 *prefiltertype; /* Pseudo-filetype for pre-filters */
92 cups_array_t *filetypes, /* Supported file types */
93 *dest_types; /* Destination types for queue */
94 cupsd_job_t *job; /* Current job in queue */
95 ipp_t *attrs, /* Attributes supported by this printer */
96 *ppd_attrs; /* Attributes based on the PPD */
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 */
102 k_limit; /* Maximum number of kilobytes */
103 cups_array_t *quotas; /* Quota records */
104 int deny_users; /* 1 = deny, 0 = allow */
105 cups_array_t *users; /* Allowed/denied users */
106 int sequence_number; /* Increasing sequence number */
107 int num_options; /* Number of default options */
108 cups_option_t *options; /* Default options */
109 int num_auth_info_required; /* Number of required auth fields */
110 const char *auth_info_required[4]; /* Required authentication fields */
111 char *alert, /* PSX printer-alert value */
112 *alert_description; /* PSX printer-alert-description value */
113 time_t marker_time; /* Last time marker attributes were updated */
114 _ppd_cache_t *pc; /* PPD cache and mapping data */
115
116 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
117 char *reg_name, /* Name used for service registration */
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 */
127 };
128
129
130 /*
131 * Globals...
132 */
133
134 VAR ipp_t *CommonData VALUE(NULL);
135 /* Common printer object attrs */
136 VAR cups_array_t *CommonDefaults VALUE(NULL);
137 /* Common -default option names */
138 VAR int NextPrinterId VALUE(1);
139 /* Next printer-id value */
140 VAR cups_array_t *Printers VALUE(NULL);
141 /* Printer list */
142 VAR cupsd_printer_t *DefaultPrinter VALUE(NULL);
143 /* Default printer */
144 VAR char *DefaultPolicy VALUE(NULL);
145 /* Default policy name */
146 VAR cupsd_policy_t *DefaultPolicyPtr
147 VALUE(NULL);
148 /* Pointer to default policy */
149
150
151 /*
152 * Prototypes...
153 */
154
155 extern cupsd_printer_t *cupsdAddPrinter(const char *name);
156 extern void cupsdCreateCommonData(void);
157 extern void cupsdDeleteAllPrinters(void);
158 extern int cupsdDeletePrinter(cupsd_printer_t *p, int update);
159 extern void cupsdDeleteTemporaryPrinters(int force);
160 extern cupsd_printer_t *cupsdFindDest(const char *name);
161 extern cupsd_printer_t *cupsdFindPrinter(const char *name);
162 extern cupsd_quota_t *cupsdFindQuota(cupsd_printer_t *p,
163 const char *username);
164 extern void cupsdFreeQuotas(cupsd_printer_t *p);
165 extern void cupsdLoadAllPrinters(void);
166 extern void cupsdRenamePrinter(cupsd_printer_t *p,
167 const char *name);
168 extern void cupsdSaveAllPrinters(void);
169 extern int cupsdSetAuthInfoRequired(cupsd_printer_t *p,
170 const char *values,
171 ipp_attribute_t *attr);
172 extern void cupsdSetDeviceURI(cupsd_printer_t *p, const char *uri);
173 extern void cupsdSetPrinterAttr(cupsd_printer_t *p,
174 const char *name,
175 const char *value);
176 extern void cupsdSetPrinterAttrs(cupsd_printer_t *p);
177 extern int cupsdSetPrinterReasons(cupsd_printer_t *p,
178 const char *s);
179 extern void cupsdSetPrinterState(cupsd_printer_t *p, ipp_pstate_t s,
180 int update);
181 #define cupsdStartPrinter(p,u) cupsdSetPrinterState((p), \
182 IPP_PRINTER_IDLE, (u))
183 extern void cupsdStopPrinter(cupsd_printer_t *p, int update);
184 extern int cupsdUpdatePrinterPPD(cupsd_printer_t *p,
185 int num_keywords,
186 cups_option_t *keywords);
187 extern void cupsdUpdatePrinters(void);
188 extern cupsd_quota_t *cupsdUpdateQuota(cupsd_printer_t *p,
189 const char *username, int pages,
190 int k);
191 extern const char *cupsdValidateDest(const char *uri,
192 cups_ptype_t *dtype,
193 cupsd_printer_t **printer);
194 extern void cupsdWritePrintcap(void);