2 * Private definitions for CUPS.
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.
10 #ifndef _CUPS_CUPS_PRIVATE_H_
11 # define _CUPS_CUPS_PRIVATE_H_
14 * Include necessary headers...
17 # include "string-private.h"
18 # include "debug-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>
27 # include <sys/cdefs.h>
28 # include <CoreFoundation/CoreFoundation.h>
29 # endif /* __APPLE__ */
38 # endif /* __cplusplus */
45 typedef struct _cups_buffer_s
/**** Read/write buffer ****/
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 */
53 typedef struct _cups_globals_s
/**** CUPS global state data ****/
55 /* Multiple places... */
56 const char *cups_datadir
, /* CUPS_DATADIR environment var */
57 *cups_serverbin
,/* CUPS_SERVERBIN environment var */
59 /* CUPS_SERVERROOT environment var */
60 *cups_statedir
, /* CUPS_STATEDIR environment var */
61 *localedir
; /* LOCALDIR environment var */
64 time_t cupsd_update
; /* Last time we got or set cupsd.conf */
65 char cupsd_hostname
[HTTP_MAX_HOST
];
66 /* Hostname for connection */
67 int cupsd_num_settings
;
68 /* Number of server settings */
69 cups_option_t
*cupsd_settings
;/* Server settings */
73 char gss_service_name
[32];
74 /* Kerberos service name */
75 # endif /* HAVE_GSSAPI */
78 char resolved_uri
[1024];
79 /* Buffer for cupsBackendDeviceURI */
83 int thread_id
; /* Friendly thread ID */
87 cups_file_t
*stdio_files
[3];/* stdin, stdout, stderr */
90 char http_date
[256]; /* Date+time buffer */
93 unsigned ip_addr
; /* Packed IPv4 address */
94 char *ip_ptrs
[2]; /* Pointer to packed address */
95 struct hostent hostent
; /* Host entry for IP address */
96 # ifdef HAVE_GETADDRINFO
97 char hostname
[1024]; /* Hostname */
98 # endif /* HAVE_GETADDRINFO */
99 int need_res_init
; /* Need to reinitialize resolver? */
102 ipp_uchar_t ipp_date
[11]; /* RFC-2579 date/time data */
103 _cups_buffer_t
*cups_buffers
; /* Buffer list */
106 int ipp_port
; /* IPP port number */
107 char ipp_unknown
[255];
108 /* Unknown error statuses */
111 cups_lang_t
*lang_default
; /* Default language */
113 char language
[32]; /* Cached language */
114 # endif /* __APPLE__ */
117 cups_array_t
*leg_size_lut
, /* Lookup table for legacy names */
118 *ppd_size_lut
, /* Lookup table for PPD names */
119 *pwg_size_lut
; /* Lookup table for PWG names */
120 pwg_media_t pwg_media
; /* PWG media data for custom size */
121 char pwg_name
[65], /* PWG media name for custom size */
122 ppd_name
[41]; /* PPD media name for custom size */
125 http_t
*http
; /* Current server connection */
126 ipp_status_t last_error
; /* Last IPP error */
127 char *last_status_message
;
128 /* Last IPP status-message */
131 char snmp_community
[255];
132 /* Default SNMP community name */
133 int snmp_debug
; /* Log SNMP IO to stderr? */
136 char tempfile
[1024]; /* cupsTempFd/File buffer */
139 http_encryption_t encryption
; /* Encryption setting */
140 char user
[65], /* User name */
141 user_agent
[256],/* User-Agent string */
142 server
[256], /* Server address */
143 servername
[256],/* Server hostname */
144 password
[128]; /* Password for default callback */
145 cups_password_cb2_t password_cb
; /* Password callback */
146 void *password_data
; /* Password user data */
147 http_tls_credentials_t tls_credentials
;
148 /* Default client credentials */
149 cups_client_cert_cb_t client_cert_cb
; /* Client certificate callback */
150 void *client_cert_data
;
151 /* Client certificate user data */
152 cups_server_cert_cb_t server_cert_cb
; /* Server certificate callback */
153 void *server_cert_data
;
154 /* Server certificate user data */
155 int server_version
, /* Server IPP version */
156 trust_first
, /* Trust on first use? */
157 any_root
, /* Allow any (e.g., self-signed) root */
158 expired_certs
, /* Allow expired certs */
159 validate_certs
; /* Validate certificates */
162 char def_printer
[256];
163 /* Default printer */
166 typedef struct _cups_media_db_s
/* Media database */
168 char *color
, /* Media color, if any */
169 *key
, /* Media key, if any */
170 *info
, /* Media human-readable name, if any */
171 *size_name
, /* Media PWG size name, if provided */
172 *source
, /* Media source, if any */
173 *type
; /* Media type, if any */
174 int width
, /* Width in hundredths of millimeters */
175 length
, /* Length in hundredths of
177 bottom
, /* Bottom margin in hundredths of
179 left
, /* Left margin in hundredths of
181 right
, /* Right margin in hundredths of
183 top
; /* Top margin in hundredths of
187 typedef struct _cups_dconstres_s
/* Constraint/resolver */
189 char *name
; /* Name of resolver */
190 ipp_t
*collection
; /* Collection containing attrs */
193 struct _cups_dinfo_s
/* Destination capability and status
196 int version
; /* IPP version */
197 const char *uri
; /* Printer URI */
198 char *resource
; /* Resource path */
199 ipp_t
*attrs
; /* Printer attributes */
200 int num_defaults
; /* Number of default options */
201 cups_option_t
*defaults
; /* Default options */
202 cups_array_t
*constraints
; /* Job constraints */
203 cups_array_t
*resolvers
; /* Job resolvers */
204 cups_array_t
*localizations
; /* Localization information */
205 cups_array_t
*media_db
; /* Media database */
206 _cups_media_db_t min_size
, /* Minimum size */
207 max_size
; /* Maximum size */
208 unsigned cached_flags
; /* Flags used for cached media */
209 cups_array_t
*cached_db
; /* Cache of media from last index/default */
210 time_t ready_time
; /* When xxx-ready attributes were last queried */
211 ipp_t
*ready_attrs
; /* xxx-ready attributes */
212 cups_array_t
*ready_db
; /* media[-col]-ready media database */
221 extern CFStringRef
_cupsAppleCopyDefaultPaperID(void);
222 extern CFStringRef
_cupsAppleCopyDefaultPrinter(void);
223 extern int _cupsAppleGetUseLastPrinter(void);
224 extern void _cupsAppleSetDefaultPaperID(CFStringRef name
);
225 extern void _cupsAppleSetDefaultPrinter(CFStringRef name
);
226 extern void _cupsAppleSetUseLastPrinter(int uselast
);
227 # endif /* __APPLE__ */
229 extern char *_cupsBufferGet(size_t size
);
230 extern void _cupsBufferRelease(char *b
);
232 extern http_t
*_cupsConnect(void);
233 extern char *_cupsCreateDest(const char *name
, const char *info
, const char *device_id
, const char *device_uri
, char *uri
, size_t urisize
);
234 extern int _cupsGet1284Values(const char *device_id
,
235 cups_option_t
**values
);
236 extern const char *_cupsGetDestResource(cups_dest_t
*dest
, char *resource
,
237 size_t resourcesize
);
238 extern int _cupsGetDests(http_t
*http
, ipp_op_t op
,
239 const char *name
, cups_dest_t
**dests
,
240 cups_ptype_t type
, cups_ptype_t mask
);
241 extern const char *_cupsGetPassword(const char *prompt
);
242 extern void _cupsGlobalLock(void);
243 extern _cups_globals_t
*_cupsGlobals(void);
244 extern void _cupsGlobalUnlock(void);
246 extern const char *_cupsGSSServiceName(void);
247 # endif /* HAVE_GSSAPI */
248 extern int _cupsNextDelay(int current
, int *previous
);
249 extern void _cupsSetDefaults(void);
250 extern void _cupsSetError(ipp_status_t status
, const char *message
,
252 extern void _cupsSetHTTPError(http_status_t status
);
254 extern int _cupsSetNegotiateAuthString(http_t
*http
,
256 const char *resource
);
257 # endif /* HAVE_GSSAPI */
258 extern char *_cupsUserDefault(char *name
, size_t namesize
);
267 # endif /* __cplusplus */
268 #endif /* !_CUPS_CUPS_PRIVATE_H_ */