]> git.ipfire.org Git - thirdparty/cups.git/blob - scheduler/printers.h
License change: Apache License, Version 2.0.
[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 *op_policy, /* Operation policy name */
69 *error_policy; /* Error policy */
70 cupsd_policy_t *op_policy_ptr; /* Pointer to operation policy */
71 int shared; /* Shared? */
72 int temporary; /* Temporary queue? */
73 int accepting; /* Accepting jobs? */
74 int holding_new_jobs; /* Holding new jobs for printing? */
75 int in_implicit_class; /* In an implicit class? */
76 ipp_pstate_t state; /* Printer state */
77 char state_message[1024]; /* Printer state message */
78 int num_reasons; /* Number of printer-state-reasons */
79 char *reasons[64]; /* printer-state-reasons strings */
80 time_t config_time, /* Time at this configuration */
81 state_time; /* Time at this state */
82 char *job_sheets[2]; /* Banners/job sheets */
83 cups_ptype_t type; /* Printer type (color, small, etc.) */
84 char *device_uri; /* Device URI */
85 char *sanitized_device_uri; /* Sanitized device URI */
86 char *port_monitor; /* Port monitor */
87 int raw; /* Raw queue? */
88 int remote; /* Remote queue? */
89 mime_type_t *filetype, /* Pseudo-filetype for printer */
90 *prefiltertype; /* Pseudo-filetype for pre-filters */
91 cups_array_t *filetypes, /* Supported file types */
92 *dest_types; /* Destination types for queue */
93 cupsd_job_t *job; /* Current job in queue */
94 ipp_t *attrs, /* Attributes supported by this printer */
95 *ppd_attrs; /* Attributes based on the PPD */
96 int num_printers, /* Number of printers in class */
97 last_printer; /* Last printer job was sent to */
98 struct cupsd_printer_s **printers; /* Printers in class */
99 int quota_period, /* Period for quotas */
100 page_limit, /* Maximum number of pages */
101 k_limit; /* Maximum number of kilobytes */
102 cups_array_t *quotas; /* Quota records */
103 int deny_users; /* 1 = deny, 0 = allow */
104 cups_array_t *users; /* Allowed/denied users */
105 int sequence_number; /* Increasing sequence number */
106 int num_options; /* Number of default options */
107 cups_option_t *options; /* Default options */
108 int num_auth_info_required; /* Number of required auth fields */
109 const char *auth_info_required[4]; /* Required authentication fields */
110 char *alert, /* PSX printer-alert value */
111 *alert_description; /* PSX printer-alert-description value */
112 time_t marker_time; /* Last time marker attributes were updated */
113 _ppd_cache_t *pc; /* PPD cache and mapping data */
114
115 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
116 char *reg_name, /* Name used for service registration */
117 *pdl; /* pdl value for TXT record */
118 cupsd_srv_t ipp_srv; /* IPP service(s) */
119 # ifdef HAVE_DNSSD
120 # ifdef HAVE_SSL
121 cupsd_srv_t ipps_srv; /* IPPS service(s) */
122 # endif /* HAVE_SSL */
123 cupsd_srv_t printer_srv; /* LPD service */
124 # endif /* HAVE_DNSSD */
125 #endif /* HAVE_DNSSD || HAVE_AVAHI */
126 };
127
128
129 /*
130 * Globals...
131 */
132
133 VAR ipp_t *CommonData VALUE(NULL);
134 /* Common printer object attrs */
135 VAR cups_array_t *CommonDefaults VALUE(NULL);
136 /* Common -default option names */
137 VAR int NextPrinterId VALUE(1);
138 /* Next printer-id value */
139 VAR cups_array_t *Printers VALUE(NULL);
140 /* Printer list */
141 VAR cupsd_printer_t *DefaultPrinter VALUE(NULL);
142 /* Default printer */
143 VAR char *DefaultPolicy VALUE(NULL);
144 /* Default policy name */
145 VAR cupsd_policy_t *DefaultPolicyPtr
146 VALUE(NULL);
147 /* Pointer to default policy */
148
149
150 /*
151 * Prototypes...
152 */
153
154 extern cupsd_printer_t *cupsdAddPrinter(const char *name);
155 extern void cupsdCreateCommonData(void);
156 extern void cupsdDeleteAllPrinters(void);
157 extern int cupsdDeletePrinter(cupsd_printer_t *p, int update);
158 extern void cupsdDeleteTemporaryPrinters(int force);
159 extern cupsd_printer_t *cupsdFindDest(const char *name);
160 extern cupsd_printer_t *cupsdFindPrinter(const char *name);
161 extern cupsd_quota_t *cupsdFindQuota(cupsd_printer_t *p,
162 const char *username);
163 extern void cupsdFreeQuotas(cupsd_printer_t *p);
164 extern void cupsdLoadAllPrinters(void);
165 extern void cupsdRenamePrinter(cupsd_printer_t *p,
166 const char *name);
167 extern void cupsdSaveAllPrinters(void);
168 extern int cupsdSetAuthInfoRequired(cupsd_printer_t *p,
169 const char *values,
170 ipp_attribute_t *attr);
171 extern void cupsdSetDeviceURI(cupsd_printer_t *p, const char *uri);
172 extern void cupsdSetPrinterAttr(cupsd_printer_t *p,
173 const char *name,
174 const char *value);
175 extern void cupsdSetPrinterAttrs(cupsd_printer_t *p);
176 extern int cupsdSetPrinterReasons(cupsd_printer_t *p,
177 const char *s);
178 extern void cupsdSetPrinterState(cupsd_printer_t *p, ipp_pstate_t s,
179 int update);
180 #define cupsdStartPrinter(p,u) cupsdSetPrinterState((p), \
181 IPP_PRINTER_IDLE, (u))
182 extern void cupsdStopPrinter(cupsd_printer_t *p, int update);
183 extern int cupsdUpdatePrinterPPD(cupsd_printer_t *p,
184 int num_keywords,
185 cups_option_t *keywords);
186 extern void cupsdUpdatePrinters(void);
187 extern cupsd_quota_t *cupsdUpdateQuota(cupsd_printer_t *p,
188 const char *username, int pages,
189 int k);
190 extern const char *cupsdValidateDest(const char *uri,
191 cups_ptype_t *dtype,
192 cupsd_printer_t **printer);
193 extern void cupsdWritePrintcap(void);