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 * 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/".
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>
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 */
39 * DNS-SD types to make the code cleaner/clearer...
43 typedef DNSServiceRef cupsd_srv_t
; /* Service reference */
44 typedef TXTRecordRef cupsd_txt_t
; /* TXT record */
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 */
53 * Printer/class information structure...
56 typedef struct cupsd_job_s cupsd_job_t
;
58 struct cupsd_printer_s
60 _cups_rwlock_t lock
; /* Concurrency lock for background updates */
61 char *uri
, /* Printer URI */
62 *uuid
, /* Printer UUID */
63 *hostname
, /* Host printer resides on */
64 *name
, /* Printer name */
65 *location
, /* Location string */
66 *geo_location
, /* Geographic location URI */
67 *make_model
, /* Make and model */
68 *info
, /* Description */
69 *organization
, /* Organization name */
70 *organizational_unit
, /* Organizational unit (department, etc.) */
71 *op_policy
, /* Operation policy name */
72 *error_policy
; /* Error policy */
73 cupsd_policy_t
*op_policy_ptr
; /* Pointer to operation policy */
74 int shared
; /* Shared? */
75 int temporary
; /* Temporary queue? */
76 int accepting
; /* Accepting jobs? */
77 int holding_new_jobs
; /* Holding new jobs for printing? */
78 int in_implicit_class
; /* In an implicit class? */
79 ipp_pstate_t state
; /* Printer state */
80 char state_message
[1024]; /* Printer state message */
81 int num_reasons
; /* Number of printer-state-reasons */
82 char *reasons
[64]; /* printer-state-reasons strings */
83 time_t config_time
, /* Time at this configuration */
84 state_time
; /* Time at this state */
85 char *job_sheets
[2]; /* Banners/job sheets */
86 cups_ptype_t type
; /* Printer type (color, small, etc.) */
87 char *device_uri
; /* Device URI */
88 char *sanitized_device_uri
; /* Sanitized device URI */
89 char *port_monitor
; /* Port monitor */
90 int raw
; /* Raw queue? */
91 int remote
; /* Remote queue? */
92 mime_type_t
*filetype
, /* Pseudo-filetype for printer */
93 *prefiltertype
; /* Pseudo-filetype for pre-filters */
94 cups_array_t
*filetypes
, /* Supported file types */
95 *dest_types
; /* Destination types for queue */
96 cupsd_job_t
*job
; /* Current job in queue */
97 ipp_t
*attrs
, /* Attributes supported by this printer */
98 *ppd_attrs
; /* Attributes based on the PPD */
99 int num_printers
, /* Number of printers in class */
100 last_printer
; /* Last printer job was sent to */
101 struct cupsd_printer_s
**printers
; /* Printers in class */
102 int quota_period
, /* Period for quotas */
103 page_limit
, /* Maximum number of pages */
104 k_limit
; /* Maximum number of kilobytes */
105 cups_array_t
*quotas
; /* Quota records */
106 int deny_users
; /* 1 = deny, 0 = allow */
107 cups_array_t
*users
; /* Allowed/denied users */
108 int sequence_number
; /* Increasing sequence number */
109 int num_options
; /* Number of default options */
110 cups_option_t
*options
; /* Default options */
111 int num_auth_info_required
; /* Number of required auth fields */
112 const char *auth_info_required
[4]; /* Required authentication fields */
113 char *alert
, /* PSX printer-alert value */
114 *alert_description
; /* PSX printer-alert-description value */
115 time_t marker_time
; /* Last time marker attributes were updated */
116 _ppd_cache_t
*pc
; /* PPD cache and mapping data */
118 #if defined(HAVE_DNSSD) || defined(HAVE_AVAHI)
119 char *reg_name
, /* Name used for service registration */
120 *pdl
; /* pdl value for TXT record */
121 cupsd_srv_t ipp_srv
; /* IPP service(s) */
124 cupsd_srv_t ipps_srv
; /* IPPS service(s) */
125 # endif /* HAVE_SSL */
126 cupsd_srv_t printer_srv
; /* LPD service */
127 # endif /* HAVE_DNSSD */
128 #endif /* HAVE_DNSSD || HAVE_AVAHI */
136 VAR ipp_t
*CommonData
VALUE(NULL
);
137 /* Common printer object attrs */
138 VAR cups_array_t
*CommonDefaults
VALUE(NULL
);
139 /* Common -default option names */
140 VAR cups_array_t
*Printers
VALUE(NULL
);
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
148 /* Pointer to default policy */
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
,
168 extern void cupsdSaveAllPrinters(void);
169 extern int cupsdSetAuthInfoRequired(cupsd_printer_t
*p
,
171 ipp_attribute_t
*attr
);
172 extern void cupsdSetDeviceURI(cupsd_printer_t
*p
, const char *uri
);
173 extern void cupsdSetPrinterAttr(cupsd_printer_t
*p
,
176 extern void cupsdSetPrinterAttrs(cupsd_printer_t
*p
);
177 extern int cupsdSetPrinterReasons(cupsd_printer_t
*p
,
179 extern void cupsdSetPrinterState(cupsd_printer_t
*p
, ipp_pstate_t s
,
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
,
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
,
191 extern const char *cupsdValidateDest(const char *uri
,
193 cupsd_printer_t
**printer
);
194 extern void cupsdWritePrintcap(void);