2 * Private definitions for CUPS.
4 * Copyright 2007-2015 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 * file is missing or damaged, see the license at "http://www.cups.org/".
13 * This file is subject to the Apple OS-Developed Software exception.
16 #ifndef _CUPS_CUPS_PRIVATE_H_
17 # define _CUPS_CUPS_PRIVATE_H_
20 * Include necessary headers...
23 # include "string-private.h"
24 # include "debug-private.h"
25 # include "array-private.h"
26 # include "ipp-private.h"
27 # include "http-private.h"
28 # include "language-private.h"
29 # include "pwg-private.h"
30 # include "thread-private.h"
31 # include <cups/cups.h>
33 # include <sys/cdefs.h>
34 # include <CoreFoundation/CoreFoundation.h>
35 # endif /* __APPLE__ */
44 # endif /* __cplusplus */
51 typedef struct _cups_buffer_s
/**** Read/write buffer ****/
53 struct _cups_buffer_s
*next
; /* Next buffer in list */
54 size_t size
; /* Size of buffer */
55 char used
, /* Is this buffer used? */
56 d
[1]; /* Data buffer */
59 typedef struct _cups_globals_s
/**** CUPS global state data ****/
61 /* Multiple places... */
62 const char *cups_datadir
, /* CUPS_DATADIR environment var */
63 *cups_serverbin
,/* CUPS_SERVERBIN environment var */
65 /* CUPS_SERVERROOT environment var */
66 *cups_statedir
, /* CUPS_STATEDIR environment var */
67 *localedir
; /* LOCALDIR environment var */
70 time_t cupsd_update
; /* Last time we got or set cupsd.conf */
71 char cupsd_hostname
[HTTP_MAX_HOST
];
72 /* Hostname for connection */
73 int cupsd_num_settings
;
74 /* Number of server settings */
75 cups_option_t
*cupsd_settings
;/* Server settings */
79 char gss_service_name
[32];
80 /* Kerberos service name */
81 # endif /* HAVE_GSSAPI */
84 char resolved_uri
[1024];
85 /* Buffer for cupsBackendDeviceURI */
89 int thread_id
; /* Friendly thread ID */
93 cups_file_t
*stdio_files
[3];/* stdin, stdout, stderr */
96 char http_date
[256]; /* Date+time buffer */
99 unsigned ip_addr
; /* Packed IPv4 address */
100 char *ip_ptrs
[2]; /* Pointer to packed address */
101 struct hostent hostent
; /* Host entry for IP address */
102 # ifdef HAVE_GETADDRINFO
103 char hostname
[1024]; /* Hostname */
104 # endif /* HAVE_GETADDRINFO */
105 int need_res_init
; /* Need to reinitialize resolver? */
108 ipp_uchar_t ipp_date
[11]; /* RFC-1903 date/time data */
109 _cups_buffer_t
*cups_buffers
; /* Buffer list */
112 int ipp_port
; /* IPP port number */
113 char ipp_unknown
[255];
114 /* Unknown error statuses */
117 cups_lang_t
*lang_default
; /* Default language */
119 char language
[32]; /* Cached language */
120 # endif /* __APPLE__ */
123 cups_array_t
*leg_size_lut
, /* Lookup table for legacy names */
124 *ppd_size_lut
, /* Lookup table for PPD names */
125 *pwg_size_lut
; /* Lookup table for PWG names */
126 pwg_media_t pwg_media
; /* PWG media data for custom size */
127 char pwg_name
[65]; /* PWG media name for custom size */
130 http_t
*http
; /* Current server connection */
131 ipp_status_t last_error
; /* Last IPP error */
132 char *last_status_message
;
133 /* Last IPP status-message */
136 char snmp_community
[255];
137 /* Default SNMP community name */
138 int snmp_debug
; /* Log SNMP IO to stderr? */
141 char tempfile
[1024]; /* cupsTempFd/File buffer */
144 http_encryption_t encryption
; /* Encryption setting */
145 char user
[65], /* User name */
146 user_agent
[256],/* User-Agent string */
147 server
[256], /* Server address */
148 servername
[256],/* Server hostname */
149 password
[128]; /* Password for default callback */
150 cups_password_cb2_t password_cb
; /* Password callback */
151 void *password_data
; /* Password user data */
152 http_tls_credentials_t tls_credentials
;
153 /* Default client credentials */
154 cups_client_cert_cb_t client_cert_cb
; /* Client certificate callback */
155 void *client_cert_data
;
156 /* Client certificate user data */
157 cups_server_cert_cb_t server_cert_cb
; /* Server certificate callback */
158 void *server_cert_data
;
159 /* Server certificate user data */
160 int server_version
, /* Server IPP version */
161 trust_first
, /* Trust on first use? */
162 any_root
, /* Allow any (e.g., self-signed) root */
163 expired_certs
, /* Allow expired certs */
164 validate_certs
; /* Validate certificates */
167 char def_printer
[256];
168 /* Default printer */
171 typedef struct _cups_media_db_s
/* Media database */
173 char *color
, /* Media color, if any */
174 *key
, /* Media key, if any */
175 *info
, /* Media human-readable name, if any */
176 *size_name
, /* Media PWG size name, if provided */
177 *source
, /* Media source, if any */
178 *type
; /* Media type, if any */
179 int width
, /* Width in hundredths of millimeters */
180 length
, /* Length in hundredths of
182 bottom
, /* Bottom margin in hundredths of
184 left
, /* Left margin in hundredths of
186 right
, /* Right margin in hundredths of
188 top
; /* Top margin in hundredths of
192 typedef struct _cups_dconstres_s
/* Constraint/resolver */
194 char *name
; /* Name of resolver */
195 ipp_t
*collection
; /* Collection containing attrs */
198 struct _cups_dinfo_s
/* Destination capability and status
201 int version
; /* IPP version */
202 const char *uri
; /* Printer URI */
203 char *resource
; /* Resource path */
204 ipp_t
*attrs
; /* Printer attributes */
205 int num_defaults
; /* Number of default options */
206 cups_option_t
*defaults
; /* Default options */
207 cups_array_t
*constraints
; /* Job constraints */
208 cups_array_t
*resolvers
; /* Job resolvers */
209 cups_array_t
*localizations
; /* Localization information */
210 cups_array_t
*media_db
; /* Media database */
211 _cups_media_db_t min_size
, /* Minimum size */
212 max_size
; /* Maximum size */
213 unsigned cached_flags
; /* Flags used for cached media */
214 cups_array_t
*cached_db
; /* Cache of media from last index/default */
215 time_t ready_time
; /* When xxx-ready attributes were last queried */
216 ipp_t
*ready_attrs
; /* xxx-ready attributes */
217 cups_array_t
*ready_db
; /* media[-col]-ready media database */
226 extern CFStringRef
_cupsAppleCopyDefaultPaperID(void);
227 extern CFStringRef
_cupsAppleCopyDefaultPrinter(void);
228 extern int _cupsAppleGetUseLastPrinter(void);
229 extern void _cupsAppleSetDefaultPaperID(CFStringRef name
);
230 extern void _cupsAppleSetDefaultPrinter(CFStringRef name
);
231 extern void _cupsAppleSetUseLastPrinter(int uselast
);
232 # endif /* __APPLE__ */
234 extern char *_cupsBufferGet(size_t size
);
235 extern void _cupsBufferRelease(char *b
);
237 extern http_t
*_cupsConnect(void);
238 extern char *_cupsCreateDest(const char *name
, const char *info
, const char *device_id
, const char *device_uri
, char *uri
, size_t urisize
);
239 extern int _cupsGet1284Values(const char *device_id
,
240 cups_option_t
**values
);
241 extern const char *_cupsGetDestResource(cups_dest_t
*dest
, char *resource
,
242 size_t resourcesize
);
243 extern int _cupsGetDests(http_t
*http
, ipp_op_t op
,
244 const char *name
, cups_dest_t
**dests
,
245 cups_ptype_t type
, cups_ptype_t mask
);
246 extern const char *_cupsGetPassword(const char *prompt
);
247 extern void _cupsGlobalLock(void);
248 extern _cups_globals_t
*_cupsGlobals(void);
249 extern void _cupsGlobalUnlock(void);
251 extern const char *_cupsGSSServiceName(void);
252 # endif /* HAVE_GSSAPI */
253 extern int _cupsNextDelay(int current
, int *previous
);
254 extern void _cupsSetDefaults(void);
255 extern void _cupsSetError(ipp_status_t status
, const char *message
,
257 extern void _cupsSetHTTPError(http_status_t status
);
259 extern int _cupsSetNegotiateAuthString(http_t
*http
,
261 const char *resource
);
262 # endif /* HAVE_GSSAPI */
263 extern char *_cupsUserDefault(char *name
, size_t namesize
);
272 # endif /* __cplusplus */
273 #endif /* !_CUPS_CUPS_PRIVATE_H_ */