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