]> git.ipfire.org Git - thirdparty/cups.git/blob - cups/cups.h
Merge changes from CUPS 1.4svn-r8628.
[thirdparty/cups.git] / cups / cups.h
1 /*
2 * "$Id: cups.h 7847 2008-08-19 04:22:14Z mike $"
3 *
4 * API definitions for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 2007-2009 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products.
8 *
9 * These coded instructions, statements, and computer programs are the
10 * property of Apple Inc. and are protected by Federal copyright
11 * law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 * which should have been included with this file. If this file is
13 * file is missing or damaged, see the license at "http://www.cups.org/".
14 *
15 * This file is subject to the Apple OS-Developed Software exception.
16 */
17
18 #ifndef _CUPS_CUPS_H_
19 # define _CUPS_CUPS_H_
20
21 /*
22 * Include necessary headers...
23 */
24
25 # include <sys/types.h>
26 # if defined(WIN32) && !defined(__CUPS_SSIZE_T_DEFINED)
27 # define __CUPS_SSIZE_T_DEFINED
28 /* Windows does not support the ssize_t type, so map it to off_t... */
29 typedef off_t ssize_t; /* @private@ */
30 # endif /* WIN32 && !__CUPS_SSIZE_T_DEFINED */
31
32 # include "ipp.h"
33 # include "ppd.h"
34 # include "language.h"
35
36
37 /*
38 * With GCC 3.0 and higher, we can mark old APIs "deprecated" so you get
39 * a warning at compile-time.
40 */
41
42 # if defined(__GNUC__) && __GNUC__ > 2
43 # define _CUPS_DEPRECATED __attribute__ ((__deprecated__))
44 # else
45 # define _CUPS_DEPRECATED
46 # endif /* __GNUC__ && __GNUC__ > 2 */
47
48
49 /*
50 * C++ magic...
51 */
52
53 # ifdef __cplusplus
54 extern "C" {
55 # endif /* __cplusplus */
56
57
58 /*
59 * Constants...
60 */
61
62 # define CUPS_VERSION 1.0400
63 # define CUPS_VERSION_MAJOR 1
64 # define CUPS_VERSION_MINOR 4
65 # define CUPS_VERSION_PATCH -1
66
67 # define CUPS_BC_FD 3 /* Back-channel file descriptor for select/poll */
68 # define CUPS_DATE_ANY (time_t)-1
69 # define CUPS_EXCLUDE_NONE (const char *)0
70 # define CUPS_FORMAT_AUTO "application/octet-stream"
71 # define CUPS_FORMAT_COMMAND "application/vnd.cups-command"
72 # define CUPS_FORMAT_PDF "application/pdf"
73 # define CUPS_FORMAT_POSTSCRIPT "application/postscript"
74 # define CUPS_FORMAT_RAW "application/vnd.cups-raw"
75 # define CUPS_FORMAT_TEXT "text/plain"
76 # define CUPS_HTTP_DEFAULT (http_t *)0
77 # define CUPS_INCLUDE_ALL (const char *)0
78 # define CUPS_JOBID_ALL -1
79 # define CUPS_JOBID_CURRENT 0
80 # define CUPS_LENGTH_VARIABLE (ssize_t)0
81 # define CUPS_TIMEOUT_DEFAULT 0
82 # define CUPS_WHICHJOBS_ALL -1
83 # define CUPS_WHICHJOBS_ACTIVE 0
84 # define CUPS_WHICHJOBS_COMPLETED 1
85
86
87 /*
88 * Types and structures...
89 */
90
91 typedef unsigned cups_ptype_t; /**** Printer type/capability bits ****/
92 enum cups_ptype_e /**** Printer type/capability bit constants ****/
93 { /* Not a typedef'd enum so we can OR */
94 CUPS_PRINTER_LOCAL = 0x0000, /* Local printer or class */
95 CUPS_PRINTER_CLASS = 0x0001, /* Printer class */
96 CUPS_PRINTER_REMOTE = 0x0002, /* Remote printer or class */
97 CUPS_PRINTER_BW = 0x0004, /* Can do B&W printing */
98 CUPS_PRINTER_COLOR = 0x0008, /* Can do color printing */
99 CUPS_PRINTER_DUPLEX = 0x0010, /* Can do duplexing */
100 CUPS_PRINTER_STAPLE = 0x0020, /* Can staple output */
101 CUPS_PRINTER_COPIES = 0x0040, /* Can do copies */
102 CUPS_PRINTER_COLLATE = 0x0080, /* Can collage copies */
103 CUPS_PRINTER_PUNCH = 0x0100, /* Can punch output */
104 CUPS_PRINTER_COVER = 0x0200, /* Can cover output */
105 CUPS_PRINTER_BIND = 0x0400, /* Can bind output */
106 CUPS_PRINTER_SORT = 0x0800, /* Can sort output */
107 CUPS_PRINTER_SMALL = 0x1000, /* Can do Letter/Legal/A4 */
108 CUPS_PRINTER_MEDIUM = 0x2000, /* Can do Tabloid/B/C/A3/A2 */
109 CUPS_PRINTER_LARGE = 0x4000, /* Can do D/E/A1/A0 */
110 CUPS_PRINTER_VARIABLE = 0x8000, /* Can do variable sizes */
111 CUPS_PRINTER_IMPLICIT = 0x10000, /* Implicit class */
112 CUPS_PRINTER_DEFAULT = 0x20000, /* Default printer on network */
113 CUPS_PRINTER_FAX = 0x40000, /* Fax queue */
114 CUPS_PRINTER_REJECTING = 0x80000, /* Printer is rejecting jobs */
115 CUPS_PRINTER_DELETE = 0x100000, /* Delete printer @since CUPS 1.2/Mac OS X 10.5@ */
116 CUPS_PRINTER_NOT_SHARED = 0x200000, /* Printer is not shared @since CUPS 1.2/Mac OS X 10.5@ */
117 CUPS_PRINTER_AUTHENTICATED = 0x400000,/* Printer requires authentication @since CUPS 1.2/Mac OS X 10.5@ */
118 CUPS_PRINTER_COMMANDS = 0x800000, /* Printer supports maintenance commands @since CUPS 1.2/Mac OS X 10.5@ */
119 CUPS_PRINTER_DISCOVERED = 0x1000000, /* Printer was automatically discovered and added @since CUPS 1.3/Mac OS X 10.5@ */
120 CUPS_PRINTER_SCANNER = 0x2000000, /* Scanner-only device @since CUPS 1.4/Mac OS X 10.6@ */
121 CUPS_PRINTER_MFP = 0x4000000, /* Printer with scanning capabilities @since CUPS 1.4/Mac OS X 10.6@ */
122 CUPS_PRINTER_OPTIONS = 0x6fffc /* ~(CLASS | REMOTE | IMPLICIT | DEFAULT | FAX | REJECTING | DELETE | NOT_SHARED | AUTHENTICATED | COMMANDS | DISCOVERED) @private@ */
123 };
124
125 typedef const char *(*cups_password_cb_t)(const char *prompt);
126 /**** Password callback ****/
127
128 typedef const char *(*cups_password_cb2_t)(const char *prompt, http_t *http,
129 const char *method,
130 const char *resource,
131 void *user_data);
132 /**** New password callback @since CUPS 1.4/Mac OS X 10.6@ ****/
133
134 typedef void (*cups_device_cb_t)(const char *device_class,
135 const char *device_id, const char *device_info,
136 const char *device_make_and_model,
137 const char *device_uri,
138 const char *device_location, void *user_data);
139 /**** Device callback @since CUPS 1.4/Mac OS X 10.6@ ****/
140
141 typedef struct cups_option_s /**** Printer Options ****/
142 {
143 char *name; /* Name of option */
144 char *value; /* Value of option */
145 } cups_option_t;
146
147 typedef struct cups_dest_s /**** Destination ****/
148 {
149 char *name, /* Printer or class name */
150 *instance; /* Local instance name or NULL */
151 int is_default; /* Is this printer the default? */
152 int num_options; /* Number of options */
153 cups_option_t *options; /* Options */
154 } cups_dest_t;
155
156 typedef struct cups_job_s /**** Job ****/
157 {
158 int id; /* The job ID */
159 char *dest; /* Printer or class name */
160 char *title; /* Title/job name */
161 char *user; /* User the submitted the job */
162 char *format; /* Document format */
163 ipp_jstate_t state; /* Job state */
164 int size; /* Size in kilobytes */
165 int priority; /* Priority (1-100) */
166 time_t completed_time; /* Time the job was completed */
167 time_t creation_time; /* Time the job was created */
168 time_t processing_time; /* Time the job was processed */
169 } cups_job_t;
170
171
172 /*
173 * Functions...
174 */
175
176 extern int cupsCancelJob(const char *name, int job_id);
177 extern ipp_t *cupsDoFileRequest(http_t *http, ipp_t *request,
178 const char *resource,
179 const char *filename);
180 extern ipp_t *cupsDoRequest(http_t *http, ipp_t *request,
181 const char *resource);
182 extern http_encryption_t cupsEncryption(void);
183 extern void cupsFreeJobs(int num_jobs, cups_job_t *jobs);
184 extern int cupsGetClasses(char ***classes) _CUPS_DEPRECATED;
185 extern const char *cupsGetDefault(void);
186 extern int cupsGetJobs(cups_job_t **jobs, const char *name,
187 int myjobs, int whichjobs);
188 extern const char *cupsGetPPD(const char *name);
189 extern int cupsGetPrinters(char ***printers) _CUPS_DEPRECATED;
190 extern ipp_status_t cupsLastError(void);
191 extern int cupsPrintFile(const char *name, const char *filename,
192 const char *title, int num_options,
193 cups_option_t *options);
194 extern int cupsPrintFiles(const char *name, int num_files,
195 const char **files, const char *title,
196 int num_options, cups_option_t *options);
197 extern char *cupsTempFile(char *filename, int len) _CUPS_DEPRECATED;
198 extern int cupsTempFd(char *filename, int len);
199
200 extern int cupsAddDest(const char *name, const char *instance,
201 int num_dests, cups_dest_t **dests);
202 extern void cupsFreeDests(int num_dests, cups_dest_t *dests);
203 extern cups_dest_t *cupsGetDest(const char *name, const char *instance,
204 int num_dests, cups_dest_t *dests);
205 extern int cupsGetDests(cups_dest_t **dests);
206 extern void cupsSetDests(int num_dests, cups_dest_t *dests);
207
208 extern int cupsAddOption(const char *name, const char *value,
209 int num_options, cups_option_t **options);
210 extern void cupsEncodeOptions(ipp_t *ipp, int num_options,
211 cups_option_t *options);
212 extern void cupsFreeOptions(int num_options, cups_option_t *options);
213 extern const char *cupsGetOption(const char *name, int num_options,
214 cups_option_t *options);
215 extern int cupsMarkOptions(ppd_file_t *ppd, int num_options,
216 cups_option_t *options);
217 extern int cupsParseOptions(const char *arg, int num_options,
218 cups_option_t **options);
219
220 extern const char *cupsGetPassword(const char *prompt);
221 extern const char *cupsServer(void);
222 extern void cupsSetEncryption(http_encryption_t e);
223 extern void cupsSetPasswordCB(cups_password_cb_t cb);
224 extern void cupsSetServer(const char *server);
225 extern void cupsSetUser(const char *user);
226 extern const char *cupsUser(void);
227
228 /**** New in CUPS 1.1.20 ****/
229 extern int cupsDoAuthentication(http_t *http, const char *method,
230 const char *resource) _CUPS_API_1_1_20;
231 extern http_status_t cupsGetFile(http_t *http, const char *resource,
232 const char *filename) _CUPS_API_1_1_20;
233 extern http_status_t cupsGetFd(http_t *http, const char *resource, int fd);
234 extern http_status_t cupsPutFile(http_t *http, const char *resource,
235 const char *filename) _CUPS_API_1_1_20;
236 extern http_status_t cupsPutFd(http_t *http, const char *resource, int fd) _CUPS_API_1_1_20;
237
238 /**** New in CUPS 1.1.21 ****/
239 extern const char *cupsGetDefault2(http_t *http) _CUPS_API_1_1_21;
240 extern int cupsGetDests2(http_t *http, cups_dest_t **dests) _CUPS_API_1_1_21;
241 extern int cupsGetJobs2(http_t *http, cups_job_t **jobs,
242 const char *name, int myjobs,
243 int whichjobs) _CUPS_API_1_1_21;
244 extern const char *cupsGetPPD2(http_t *http, const char *name) _CUPS_API_1_1_21;
245 extern int cupsPrintFile2(http_t *http, const char *name,
246 const char *filename,
247 const char *title, int num_options,
248 cups_option_t *options) _CUPS_API_1_1_21;
249 extern int cupsPrintFiles2(http_t *http, const char *name,
250 int num_files, const char **files,
251 const char *title, int num_options,
252 cups_option_t *options) _CUPS_API_1_1_21;
253 extern int cupsSetDests2(http_t *http, int num_dests,
254 cups_dest_t *dests) _CUPS_API_1_1_21;
255
256 /**** New in CUPS 1.2 ****/
257 extern ssize_t cupsBackChannelRead(char *buffer, size_t bytes,
258 double timeout) _CUPS_API_1_2;
259 extern ssize_t cupsBackChannelWrite(const char *buffer, size_t bytes,
260 double timeout) _CUPS_API_1_2;
261 extern void cupsEncodeOptions2(ipp_t *ipp, int num_options,
262 cups_option_t *options,
263 ipp_tag_t group_tag) _CUPS_API_1_2;
264 extern const char *cupsLastErrorString(void) _CUPS_API_1_2;
265 extern char *cupsNotifySubject(cups_lang_t *lang, ipp_t *event) _CUPS_API_1_2;
266 extern char *cupsNotifyText(cups_lang_t *lang, ipp_t *event) _CUPS_API_1_2;
267 extern int cupsRemoveOption(const char *name, int num_options,
268 cups_option_t **options) _CUPS_API_1_2;
269 extern cups_file_t *cupsTempFile2(char *filename, int len) _CUPS_API_1_2;
270
271 /**** New in CUPS 1.3 ****/
272 extern ipp_t *cupsDoIORequest(http_t *http, ipp_t *request,
273 const char *resource, int infile,
274 int outfile) _CUPS_API_1_3;
275 extern char *cupsGetServerPPD(http_t *http, const char *name) _CUPS_API_1_3;
276 extern int cupsRemoveDest(const char *name,
277 const char *instance,
278 int num_dests, cups_dest_t **dests) _CUPS_API_1_3;
279 extern void cupsSetDefaultDest(const char *name,
280 const char *instance,
281 int num_dests,
282 cups_dest_t *dests) _CUPS_API_1_3;
283
284 /**** New in CUPS 1.4 ****/
285 extern ipp_status_t cupsCancelJob2(http_t *http, const char *name,
286 int job_id, int purge) _CUPS_API_1_4;
287 extern int cupsCreateJob(http_t *http, const char *name,
288 const char *title, int num_options,
289 cups_option_t *options) _CUPS_API_1_4;
290 extern ipp_status_t cupsFinishDocument(http_t *http,
291 const char *name) _CUPS_API_1_4;
292 extern int cupsGetConflicts(ppd_file_t *ppd, const char *option,
293 const char *choice,
294 cups_option_t **options)
295 _CUPS_API_1_4;
296 extern ipp_status_t cupsGetDevices(http_t *http, int timeout,
297 const char *include_schemes,
298 const char *exclude_schemes,
299 cups_device_cb_t callback,
300 void *user_data) _CUPS_API_1_4;
301 extern cups_dest_t *cupsGetNamedDest(http_t *http, const char *name,
302 const char *instance) _CUPS_API_1_4;
303 extern const char *cupsGetPassword2(const char *prompt, http_t *http,
304 const char *method,
305 const char *resource) _CUPS_API_1_4;
306 extern http_status_t cupsGetPPD3(http_t *http, const char *name,
307 time_t *modtime, char *buffer,
308 size_t bufsize) _CUPS_API_1_4;
309 extern ipp_t *cupsGetResponse(http_t *http,
310 const char *resource) _CUPS_API_1_4;
311 extern ssize_t cupsReadResponseData(http_t *http, char *buffer,
312 size_t length) _CUPS_API_1_4;
313 extern int cupsResolveConflicts(ppd_file_t *ppd, const char *option,
314 const char *choice,
315 int *num_options,
316 cups_option_t **options)
317 _CUPS_API_1_4;
318 extern http_status_t cupsSendRequest(http_t *http, ipp_t *request,
319 const char *resource,
320 size_t length) _CUPS_API_1_4;
321 extern void cupsSetPasswordCB2(cups_password_cb2_t cb,
322 void *user_data) _CUPS_API_1_4;
323 extern http_status_t cupsStartDocument(http_t *http, const char *name,
324 int job_id, const char *docname,
325 const char *format,
326 int last_document) _CUPS_API_1_4;
327 extern http_status_t cupsWriteRequestData(http_t *http, const char *buffer,
328 size_t length) _CUPS_API_1_4;
329
330 # ifdef __cplusplus
331 }
332 # endif /* __cplusplus */
333
334 #endif /* !_CUPS_CUPS_H_ */
335
336 /*
337 * End of "$Id: cups.h 7847 2008-08-19 04:22:14Z mike $".
338 */