2 * Printer definitions for the CUPS scheduler.
4 * Copyright 2007-2017 by Apple Inc.
5 * Copyright 1997-2007 by Easy Software Products, all rights reserved.
7 * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
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>
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 */
35 * DNS-SD types to make the code cleaner/clearer...
39 typedef DNSServiceRef cupsd_srv_t
; /* Service reference */
40 typedef TXTRecordRef cupsd_txt_t
; /* TXT record */
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 */
49 * Printer/class information structure...
52 typedef struct cupsd_job_s cupsd_job_t
;
54 struct cupsd_printer_s
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 */
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) */
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 */
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
);
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
147 /* Pointer to default policy */
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
,
167 extern void cupsdSaveAllPrinters(void);
168 extern int cupsdSetAuthInfoRequired(cupsd_printer_t
*p
,
170 ipp_attribute_t
*attr
);
171 extern void cupsdSetDeviceURI(cupsd_printer_t
*p
, const char *uri
);
172 extern void cupsdSetPrinterAttr(cupsd_printer_t
*p
,
175 extern void cupsdSetPrinterAttrs(cupsd_printer_t
*p
);
176 extern int cupsdSetPrinterReasons(cupsd_printer_t
*p
,
178 extern void cupsdSetPrinterState(cupsd_printer_t
*p
, ipp_pstate_t s
,
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
,
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
,
190 extern const char *cupsdValidateDest(const char *uri
,
192 cupsd_printer_t
**printer
);
193 extern void cupsdWritePrintcap(void);