2 * "$Id: cups.h 6870 2007-08-27 21:13:35Z mike $"
4 * API definitions for the Common UNIX Printing System (CUPS).
6 * Copyright 2007-2008 by Apple Inc.
7 * Copyright 1997-2007 by Easy Software Products.
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/".
15 * This file is subject to the Apple OS-Developed Software exception.
19 # define _CUPS_CUPS_H_
22 * Include necessary headers...
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 */
34 # include "language.h"
38 * With GCC 3.0 and higher, we can mark old APIs "deprecated" so you get
39 * a warning at compile-time.
42 # if defined(__GNUC__) && __GNUC__ > 2
43 # define _CUPS_DEPRECATED __attribute__ ((__deprecated__))
45 # define _CUPS_DEPRECATED
46 # endif /* __GNUC__ && __GNUC__ > 2 */
55 # endif /* __cplusplus */
62 # define CUPS_VERSION 1.0399
63 # define CUPS_VERSION_MAJOR 1
64 # define CUPS_VERSION_MINOR 4
65 # define CUPS_VERSION_PATCH -1
67 # define CUPS_DATE_ANY (time_t)-1
68 # define CUPS_FORMAT_AUTO "application/octet-stream"
69 # define CUPS_FORMAT_PDF "application/pdf"
70 # define CUPS_FORMAT_POSTSCRIPT "application/postscript"
71 # define CUPS_FORMAT_RAW "application/vnd.cups-raw"
72 # define CUPS_FORMAT_TEXT "text/plain"
73 # define CUPS_HTTP_DEFAULT (http_t *)0
74 # define CUPS_JOBID_ALL -1
75 # define CUPS_JOBID_CURRENT 0
76 # define CUPS_LENGTH_VARIABLE (ssize_t)0
77 # define CUPS_WHICHJOBS_ALL -1
78 # define CUPS_WHICHJOBS_ACTIVE 0
79 # define CUPS_WHICHJOBS_COMPLETED 1
83 * Types and structures...
86 typedef unsigned cups_ptype_t
; /**** Printer type/capability bits ****/
87 enum cups_ptype_e
/**** Printer type/capability bit constants ****/
88 { /* Not a typedef'd enum so we can OR */
89 CUPS_PRINTER_LOCAL
= 0x0000, /* Local printer or class */
90 CUPS_PRINTER_CLASS
= 0x0001, /* Printer class */
91 CUPS_PRINTER_REMOTE
= 0x0002, /* Remote printer or class */
92 CUPS_PRINTER_BW
= 0x0004, /* Can do B&W printing */
93 CUPS_PRINTER_COLOR
= 0x0008, /* Can do color printing */
94 CUPS_PRINTER_DUPLEX
= 0x0010, /* Can do duplexing */
95 CUPS_PRINTER_STAPLE
= 0x0020, /* Can staple output */
96 CUPS_PRINTER_COPIES
= 0x0040, /* Can do copies */
97 CUPS_PRINTER_COLLATE
= 0x0080, /* Can collage copies */
98 CUPS_PRINTER_PUNCH
= 0x0100, /* Can punch output */
99 CUPS_PRINTER_COVER
= 0x0200, /* Can cover output */
100 CUPS_PRINTER_BIND
= 0x0400, /* Can bind output */
101 CUPS_PRINTER_SORT
= 0x0800, /* Can sort output */
102 CUPS_PRINTER_SMALL
= 0x1000, /* Can do Letter/Legal/A4 */
103 CUPS_PRINTER_MEDIUM
= 0x2000, /* Can do Tabloid/B/C/A3/A2 */
104 CUPS_PRINTER_LARGE
= 0x4000, /* Can do D/E/A1/A0 */
105 CUPS_PRINTER_VARIABLE
= 0x8000, /* Can do variable sizes */
106 CUPS_PRINTER_IMPLICIT
= 0x10000, /* Implicit class */
107 CUPS_PRINTER_DEFAULT
= 0x20000, /* Default printer on network */
108 CUPS_PRINTER_FAX
= 0x40000, /* Fax queue */
109 CUPS_PRINTER_REJECTING
= 0x80000, /* Printer is rejecting jobs */
110 CUPS_PRINTER_DELETE
= 0x100000, /* Delete printer @since CUPS 1.2@ */
111 CUPS_PRINTER_NOT_SHARED
= 0x200000, /* Printer is not shared @since CUPS 1.2@ */
112 CUPS_PRINTER_AUTHENTICATED
= 0x400000,/* Printer requires authentication @since CUPS 1.2@ */
113 CUPS_PRINTER_COMMANDS
= 0x800000, /* Printer supports maintenance commands @since CUPS 1.2@ */
114 CUPS_PRINTER_DISCOVERED
= 0x1000000, /* Printer was automatically discovered and added @since CUPS 1.3@ */
115 CUPS_PRINTER_OPTIONS
= 0x6fffc /* ~(CLASS | REMOTE | IMPLICIT | DEFAULT | FAX | REJECTING | DELETE | NOT_SHARED | AUTHENTICATED | COMMANDS | DISCOVERED) @private@ */
118 typedef const char *(*cups_password_cb_t
)(const char *);
119 /**** Password callback ****/
121 typedef struct cups_option_s
/**** Printer Options ****/
123 char *name
; /* Name of option */
124 char *value
; /* Value of option */
127 typedef struct cups_dest_s
/**** Destination ****/
129 char *name
, /* Printer or class name */
130 *instance
; /* Local instance name or NULL */
131 int is_default
; /* Is this printer the default? */
132 int num_options
; /* Number of options */
133 cups_option_t
*options
; /* Options */
136 typedef struct cups_job_s
/**** Job ****/
138 int id
; /* The job ID */
139 char *dest
; /* Printer or class name */
140 char *title
; /* Title/job name */
141 char *user
; /* User the submitted the job */
142 char *format
; /* Document format */
143 ipp_jstate_t state
; /* Job state */
144 int size
; /* Size in kilobytes */
145 int priority
; /* Priority (1-100) */
146 time_t completed_time
; /* Time the job was completed */
147 time_t creation_time
; /* Time the job was created */
148 time_t processing_time
; /* Time the job was processed */
156 extern int cupsCancelJob(const char *name
, int job_id
);
157 extern ipp_t
*cupsDoFileRequest(http_t
*http
, ipp_t
*request
,
158 const char *resource
,
159 const char *filename
);
160 extern ipp_t
*cupsDoRequest(http_t
*http
, ipp_t
*request
,
161 const char *resource
);
162 extern http_encryption_t
cupsEncryption(void);
163 extern void cupsFreeJobs(int num_jobs
, cups_job_t
*jobs
);
164 extern int cupsGetClasses(char ***classes
) _CUPS_DEPRECATED
;
165 extern const char *cupsGetDefault(void);
166 extern int cupsGetJobs(cups_job_t
**jobs
, const char *name
,
167 int myjobs
, int whichjobs
);
168 extern const char *cupsGetPPD(const char *name
);
169 extern int cupsGetPrinters(char ***printers
) _CUPS_DEPRECATED
;
170 extern ipp_status_t
cupsLastError(void);
171 extern int cupsPrintFile(const char *name
, const char *filename
,
172 const char *title
, int num_options
,
173 cups_option_t
*options
);
174 extern int cupsPrintFiles(const char *name
, int num_files
,
175 const char **files
, const char *title
,
176 int num_options
, cups_option_t
*options
);
177 extern char *cupsTempFile(char *filename
, int len
) _CUPS_DEPRECATED
;
178 extern int cupsTempFd(char *filename
, int len
);
180 extern int cupsAddDest(const char *name
, const char *instance
,
181 int num_dests
, cups_dest_t
**dests
);
182 extern void cupsFreeDests(int num_dests
, cups_dest_t
*dests
);
183 extern cups_dest_t
*cupsGetDest(const char *name
, const char *instance
,
184 int num_dests
, cups_dest_t
*dests
);
185 extern int cupsGetDests(cups_dest_t
**dests
);
186 extern void cupsSetDests(int num_dests
, cups_dest_t
*dests
);
188 extern int cupsAddOption(const char *name
, const char *value
,
189 int num_options
, cups_option_t
**options
);
190 extern void cupsEncodeOptions(ipp_t
*ipp
, int num_options
,
191 cups_option_t
*options
);
192 extern void cupsFreeOptions(int num_options
, cups_option_t
*options
);
193 extern const char *cupsGetOption(const char *name
, int num_options
,
194 cups_option_t
*options
);
195 extern int cupsMarkOptions(ppd_file_t
*ppd
, int num_options
,
196 cups_option_t
*options
);
197 extern int cupsParseOptions(const char *arg
, int num_options
,
198 cups_option_t
**options
);
200 extern const char *cupsGetPassword(const char *prompt
);
201 extern const char *cupsServer(void);
202 extern void cupsSetEncryption(http_encryption_t e
);
203 extern void cupsSetPasswordCB(cups_password_cb_t cb
);
204 extern void cupsSetServer(const char *server
);
205 extern void cupsSetUser(const char *user
);
206 extern const char *cupsUser(void);
208 /**** New in CUPS 1.1.20 ****/
209 extern int cupsDoAuthentication(http_t
*http
, const char *method
,
210 const char *resource
) _CUPS_API_1_1_20
;
211 extern http_status_t
cupsGetFile(http_t
*http
, const char *resource
,
212 const char *filename
) _CUPS_API_1_1_20
;
213 extern http_status_t
cupsGetFd(http_t
*http
, const char *resource
, int fd
);
214 extern http_status_t
cupsPutFile(http_t
*http
, const char *resource
,
215 const char *filename
) _CUPS_API_1_1_20
;
216 extern http_status_t
cupsPutFd(http_t
*http
, const char *resource
, int fd
) _CUPS_API_1_1_20
;
218 /**** New in CUPS 1.1.21 ****/
219 extern const char *cupsGetDefault2(http_t
*http
) _CUPS_API_1_1_21
;
220 extern int cupsGetDests2(http_t
*http
, cups_dest_t
**dests
) _CUPS_API_1_1_21
;
221 extern int cupsGetJobs2(http_t
*http
, cups_job_t
**jobs
,
222 const char *name
, int myjobs
,
223 int whichjobs
) _CUPS_API_1_1_21
;
224 extern const char *cupsGetPPD2(http_t
*http
, const char *name
) _CUPS_API_1_1_21
;
225 extern int cupsPrintFile2(http_t
*http
, const char *name
,
226 const char *filename
,
227 const char *title
, int num_options
,
228 cups_option_t
*options
) _CUPS_API_1_1_21
;
229 extern int cupsPrintFiles2(http_t
*http
, const char *name
,
230 int num_files
, const char **files
,
231 const char *title
, int num_options
,
232 cups_option_t
*options
) _CUPS_API_1_1_21
;
233 extern int cupsSetDests2(http_t
*http
, int num_dests
,
234 cups_dest_t
*dests
) _CUPS_API_1_1_21
;
236 /**** New in CUPS 1.2 ****/
237 extern ssize_t
cupsBackChannelRead(char *buffer
, size_t bytes
,
238 double timeout
) _CUPS_API_1_2
;
239 extern ssize_t
cupsBackChannelWrite(const char *buffer
, size_t bytes
,
240 double timeout
) _CUPS_API_1_2
;
241 extern void cupsEncodeOptions2(ipp_t
*ipp
, int num_options
,
242 cups_option_t
*options
,
243 ipp_tag_t group_tag
) _CUPS_API_1_2
;
244 extern const char *cupsLastErrorString(void) _CUPS_API_1_2
;
245 extern char *cupsNotifySubject(cups_lang_t
*lang
, ipp_t
*event
) _CUPS_API_1_2
;
246 extern char *cupsNotifyText(cups_lang_t
*lang
, ipp_t
*event
) _CUPS_API_1_2
;
247 extern int cupsRemoveOption(const char *name
, int num_options
,
248 cups_option_t
**options
) _CUPS_API_1_2
;
249 extern cups_file_t
*cupsTempFile2(char *filename
, int len
) _CUPS_API_1_2
;
251 /**** New in CUPS 1.3 ****/
252 extern ipp_t
*cupsDoIORequest(http_t
*http
, ipp_t
*request
,
253 const char *resource
, int infile
,
254 int outfile
) _CUPS_API_1_3
;
255 extern char *cupsGetServerPPD(http_t
*http
, const char *name
) _CUPS_API_1_3
;
256 extern int cupsRemoveDest(const char *name
,
257 const char *instance
,
258 int num_dests
, cups_dest_t
**dests
) _CUPS_API_1_3
;
259 extern void cupsSetDefaultDest(const char *name
,
260 const char *instance
,
262 cups_dest_t
*dests
) _CUPS_API_1_3
;
264 /**** New in CUPS 1.4 ****/
265 extern ipp_status_t
cupsCancelJob2(http_t
*http
, const char *name
,
266 int job_id
, int purge
) _CUPS_API_1_4
;
267 extern int cupsCreateJob(http_t
*http
, const char *name
,
268 const char *title
, int num_options
,
269 cups_option_t
*options
) _CUPS_API_1_4
;
270 extern ipp_status_t
cupsFinishDocument(http_t
*http
,
271 const char *name
) _CUPS_API_1_4
;
272 extern cups_dest_t
*cupsGetNamedDest(http_t
*http
, const char *name
,
273 const char *instance
) _CUPS_API_1_4
;
274 extern http_status_t
cupsGetPPD3(http_t
*http
, const char *name
,
275 time_t *modtime
, char *buffer
,
276 size_t bufsize
) _CUPS_API_1_4
;
277 extern ipp_t
*cupsGetResponse(http_t
*http
,
278 const char *resource
) _CUPS_API_1_4
;
279 extern ssize_t
cupsReadResponseData(http_t
*http
, char *buffer
,
280 size_t length
) _CUPS_API_1_4
;
281 extern http_status_t
cupsSendRequest(http_t
*http
, ipp_t
*request
,
282 const char *resource
,
283 size_t length
) _CUPS_API_1_4
;
284 extern http_status_t
cupsStartDocument(http_t
*http
, const char *name
,
285 int job_id
, const char *docname
,
287 int last_document
) _CUPS_API_1_4
;
288 extern http_status_t
cupsWriteRequestData(http_t
*http
, const char *buffer
,
289 size_t length
) _CUPS_API_1_4
;
293 # endif /* __cplusplus */
295 #endif /* !_CUPS_CUPS_H_ */
298 * End of "$Id: cups.h 6870 2007-08-27 21:13:35Z mike $".