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