]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/cups-private.h
Sandboxed applications were not able to get the default printer (Issue #5676)
[thirdparty/cups.git] / cups / cups-private.h
1 /*
2 * Private definitions for CUPS.
3 *
4 * Copyright © 2007-2019 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
8 * information.
9 */
10
11 #ifndef _CUPS_CUPS_PRIVATE_H_
12 # define _CUPS_CUPS_PRIVATE_H_
13
14 /*
15 * Include necessary headers...
16 */
17
18 # include "string-private.h"
19 # include "array-private.h"
20 # include "ipp-private.h"
21 # include "http-private.h"
22 # include "language-private.h"
23 # include "pwg-private.h"
24 # include "thread-private.h"
25 # include <cups/cups.h>
26 # ifdef __APPLE__
27 # include <sys/cdefs.h>
28 # include <CoreFoundation/CoreFoundation.h>
29 # endif /* __APPLE__ */
30
31
32 /*
33 * C++ magic...
34 */
35
36 # ifdef __cplusplus
37 extern "C" {
38 # endif /* __cplusplus */
39
40
41 /*
42 * Types...
43 */
44
45 typedef struct _cups_buffer_s /**** Read/write buffer ****/
46 {
47 struct _cups_buffer_s *next; /* Next buffer in list */
48 size_t size; /* Size of buffer */
49 char used, /* Is this buffer used? */
50 d[1]; /* Data buffer */
51 } _cups_buffer_t;
52
53 typedef struct _cups_raster_error_s /**** Error buffer structure ****/
54 {
55 char *start, /* Start of buffer */
56 *current, /* Current position in buffer */
57 *end; /* End of buffer */
58 } _cups_raster_error_t;
59
60 typedef enum _cups_digestoptions_e /**** Digest Options values */
61 {
62 _CUPS_DIGESTOPTIONS_NONE, /* No Digest authentication options */
63 _CUPS_DIGESTOPTIONS_DENYMD5 /* Do not use MD5 hashes for digest */
64 } _cups_digestoptions_t;
65
66 typedef enum _cups_uatokens_e /**** UserAgentTokens values */
67 {
68 _CUPS_UATOKENS_NONE, /* Do not send User-Agent */
69 _CUPS_UATOKENS_PRODUCT_ONLY, /* CUPS IPP */
70 _CUPS_UATOKENS_MAJOR, /* CUPS/major IPP/2 */
71 _CUPS_UATOKENS_MINOR, /* CUPS/major.minor IPP/2.1 */
72 _CUPS_UATOKENS_MINIMAL, /* CUPS/major.minor.patch IPP/2.1 */
73 _CUPS_UATOKENS_OS, /* CUPS/major.minor.patch (osname osversion) IPP/2.1 */
74 _CUPS_UATOKENS_FULL /* CUPS/major.minor.patch (osname osversion; architecture) IPP/2.1 */
75 } _cups_uatokens_t;
76
77 typedef struct _cups_globals_s /**** CUPS global state data ****/
78 {
79 /* Multiple places... */
80 const char *cups_datadir, /* CUPS_DATADIR environment var */
81 *cups_serverbin,/* CUPS_SERVERBIN environment var */
82 *cups_serverroot,
83 /* CUPS_SERVERROOT environment var */
84 *cups_statedir, /* CUPS_STATEDIR environment var */
85 *home, /* HOME environment var */
86 *localedir; /* LOCALDIR environment var */
87
88 /* adminutil.c */
89 time_t cupsd_update; /* Last time we got or set cupsd.conf */
90 char cupsd_hostname[HTTP_MAX_HOST];
91 /* Hostname for connection */
92 int cupsd_num_settings;
93 /* Number of server settings */
94 cups_option_t *cupsd_settings;/* Server settings */
95
96 /* auth.c */
97 # ifdef HAVE_GSSAPI
98 char gss_service_name[32];
99 /* Kerberos service name */
100 # endif /* HAVE_GSSAPI */
101
102 /* backend.c */
103 char resolved_uri[1024];
104 /* Buffer for cupsBackendDeviceURI */
105
106 /* debug.c */
107 # ifdef DEBUG
108 int thread_id; /* Friendly thread ID */
109 # endif /* DEBUG */
110
111 /* file.c */
112 cups_file_t *stdio_files[3];/* stdin, stdout, stderr */
113
114 /* http.c */
115 char http_date[256]; /* Date+time buffer */
116
117 /* http-addr.c */
118 unsigned ip_addr; /* Packed IPv4 address */
119 char *ip_ptrs[2]; /* Pointer to packed address */
120 struct hostent hostent; /* Host entry for IP address */
121 # ifdef HAVE_GETADDRINFO
122 char hostname[1024]; /* Hostname */
123 # endif /* HAVE_GETADDRINFO */
124 int need_res_init; /* Need to reinitialize resolver? */
125
126 /* ipp.c */
127 ipp_uchar_t ipp_date[11]; /* RFC-2579 date/time data */
128 _cups_buffer_t *cups_buffers; /* Buffer list */
129
130 /* ipp-support.c */
131 int ipp_port; /* IPP port number */
132 char ipp_unknown[255];
133 /* Unknown error statuses */
134
135 /* language.c */
136 cups_lang_t *lang_default; /* Default language */
137 # ifdef __APPLE__
138 char language[32]; /* Cached language */
139 # endif /* __APPLE__ */
140
141 /* pwg-media.c */
142 cups_array_t *leg_size_lut, /* Lookup table for legacy names */
143 *ppd_size_lut, /* Lookup table for PPD names */
144 *pwg_size_lut; /* Lookup table for PWG names */
145 pwg_media_t pwg_media; /* PWG media data for custom size */
146 char pwg_name[65], /* PWG media name for custom size */
147 ppd_name[41]; /* PPD media name for custom size */
148
149 /* raster-error.c */
150 _cups_raster_error_t raster_error; /* Raster error information */
151
152 /* request.c */
153 http_t *http; /* Current server connection */
154 ipp_status_t last_error; /* Last IPP error */
155 char *last_status_message;
156 /* Last IPP status-message */
157
158 /* snmp.c */
159 char snmp_community[255];
160 /* Default SNMP community name */
161 int snmp_debug; /* Log SNMP IO to stderr? */
162
163 /* tempfile.c */
164 char tempfile[1024]; /* cupsTempFd/File buffer */
165
166 /* usersys.c */
167 _cups_digestoptions_t digestoptions; /* DigestOptions setting */
168 _cups_uatokens_t uatokens; /* UserAgentTokens setting */
169 http_encryption_t encryption; /* Encryption setting */
170 char user[65], /* User name */
171 user_agent[256],/* User-Agent string */
172 server[256], /* Server address */
173 servername[256],/* Server hostname */
174 password[128]; /* Password for default callback */
175 cups_password_cb2_t password_cb; /* Password callback */
176 void *password_data; /* Password user data */
177 http_tls_credentials_t tls_credentials;
178 /* Default client credentials */
179 cups_client_cert_cb_t client_cert_cb; /* Client certificate callback */
180 void *client_cert_data;
181 /* Client certificate user data */
182 cups_server_cert_cb_t server_cert_cb; /* Server certificate callback */
183 void *server_cert_data;
184 /* Server certificate user data */
185 int server_version, /* Server IPP version */
186 trust_first, /* Trust on first use? */
187 any_root, /* Allow any (e.g., self-signed) root */
188 expired_certs, /* Allow expired certs */
189 validate_certs; /* Validate certificates */
190
191 /* util.c */
192 char def_printer[256];
193 /* Default printer */
194 } _cups_globals_t;
195
196 typedef struct _cups_media_db_s /* Media database */
197 {
198 char *color, /* Media color, if any */
199 *key, /* Media key, if any */
200 *info, /* Media human-readable name, if any */
201 *size_name, /* Media PWG size name, if provided */
202 *source, /* Media source, if any */
203 *type; /* Media type, if any */
204 int width, /* Width in hundredths of millimeters */
205 length, /* Length in hundredths of
206 * millimeters */
207 bottom, /* Bottom margin in hundredths of
208 * millimeters */
209 left, /* Left margin in hundredths of
210 * millimeters */
211 right, /* Right margin in hundredths of
212 * millimeters */
213 top; /* Top margin in hundredths of
214 * millimeters */
215 } _cups_media_db_t;
216
217 typedef struct _cups_dconstres_s /* Constraint/resolver */
218 {
219 char *name; /* Name of resolver */
220 ipp_t *collection; /* Collection containing attrs */
221 } _cups_dconstres_t;
222
223 struct _cups_dinfo_s /* Destination capability and status
224 * information */
225 {
226 int version; /* IPP version */
227 const char *uri; /* Printer URI */
228 char *resource; /* Resource path */
229 ipp_t *attrs; /* Printer attributes */
230 int num_defaults; /* Number of default options */
231 cups_option_t *defaults; /* Default options */
232 cups_array_t *constraints; /* Job constraints */
233 cups_array_t *resolvers; /* Job resolvers */
234 cups_array_t *localizations; /* Localization information */
235 cups_array_t *media_db; /* Media database */
236 _cups_media_db_t min_size, /* Minimum size */
237 max_size; /* Maximum size */
238 unsigned cached_flags; /* Flags used for cached media */
239 cups_array_t *cached_db; /* Cache of media from last index/default */
240 time_t ready_time; /* When xxx-ready attributes were last queried */
241 ipp_t *ready_attrs; /* xxx-ready attributes */
242 cups_array_t *ready_db; /* media[-col]-ready media database */
243 };
244
245
246 /*
247 * Prototypes...
248 */
249
250 # ifdef __APPLE__
251 extern CFStringRef _cupsAppleCopyDefaultPaperID(void) _CUPS_PRIVATE;
252 extern CFStringRef _cupsAppleCopyDefaultPrinter(void) _CUPS_PRIVATE;
253 extern int _cupsAppleGetUseLastPrinter(void) _CUPS_PRIVATE;
254 extern void _cupsAppleSetDefaultPaperID(CFStringRef name) _CUPS_PRIVATE;
255 extern void _cupsAppleSetDefaultPrinter(CFStringRef name) _CUPS_PRIVATE;
256 extern void _cupsAppleSetUseLastPrinter(int uselast) _CUPS_PRIVATE;
257 # endif /* __APPLE__ */
258
259 extern char *_cupsBufferGet(size_t size) _CUPS_PRIVATE;
260 extern void _cupsBufferRelease(char *b) _CUPS_PRIVATE;
261
262 extern http_t *_cupsConnect(void) _CUPS_PRIVATE;
263 extern char *_cupsCreateDest(const char *name, const char *info, const char *device_id, const char *device_uri, char *uri, size_t urisize) _CUPS_PRIVATE;
264 extern ipp_attribute_t *_cupsEncodeOption(ipp_t *ipp, ipp_tag_t group_tag, _ipp_option_t *map, const char *name, const char *value) _CUPS_PRIVATE;
265 extern int _cupsGet1284Values(const char *device_id, cups_option_t **values) _CUPS_PRIVATE;
266 extern const char *_cupsGetDestResource(cups_dest_t *dest, unsigned flags, char *resource, size_t resourcesize) _CUPS_PRIVATE;
267 extern int _cupsGetDests(http_t *http, ipp_op_t op, const char *name, cups_dest_t **dests, cups_ptype_t type, cups_ptype_t mask) _CUPS_PRIVATE;
268 extern const char *_cupsGetPassword(const char *prompt) _CUPS_PRIVATE;
269 extern void _cupsGlobalLock(void) _CUPS_PRIVATE;
270 extern _cups_globals_t *_cupsGlobals(void) _CUPS_PRIVATE;
271 extern void _cupsGlobalUnlock(void) _CUPS_PRIVATE;
272 # ifdef HAVE_GSSAPI
273 extern const char *_cupsGSSServiceName(void) _CUPS_PRIVATE;
274 # endif /* HAVE_GSSAPI */
275 extern int _cupsNextDelay(int current, int *previous) _CUPS_PRIVATE;
276 extern void _cupsSetDefaults(void) _CUPS_INTERNAL;
277 extern void _cupsSetError(ipp_status_t status, const char *message, int localize) _CUPS_PRIVATE;
278 extern void _cupsSetHTTPError(http_status_t status) _CUPS_INTERNAL;
279 # ifdef HAVE_GSSAPI
280 extern int _cupsSetNegotiateAuthString(http_t *http, const char *method, const char *resource) _CUPS_PRIVATE;
281 # endif /* HAVE_GSSAPI */
282 extern char *_cupsUserDefault(char *name, size_t namesize) _CUPS_INTERNAL;
283
284
285 /*
286 * C++ magic...
287 */
288
289 # ifdef __cplusplus
290 }
291 # endif /* __cplusplus */
292 #endif /* !_CUPS_CUPS_PRIVATE_H_ */