]> git.ipfire.org Git - thirdparty/cups.git/blame - doc/help/api-overview.html
Save work on new CUPS Programming Manual.
[thirdparty/cups.git] / doc / help / api-overview.html
CommitLineData
abacc52b 1<!doctype html>
5a738aea
MS
2<html>
3<!-- SECTION: Programming -->
abacc52b
MS
4 <head>
5 <title>Introduction to CUPS Programming</title>
6 <meta name="keywords" content="Programming">
7 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
8 <meta name="creator" content="Mini-XML v2.11">
9 <meta name="author" content="Unknown">
10 <meta name="copyright" content="Unknown">
11 <style type="text/css"><!--
5a738aea
MS
12BODY {
13 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
14}
15
16H1, H2, H3, H4, H5, H6, P, TD, TH {
17 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
18}
19
20KBD {
21 font-family: monaco, courier, monospace;
22 font-weight: bold;
23}
24
25PRE {
26 font-family: monaco, courier, monospace;
27}
28
29PRE.command {
10d09e33 30 border: dotted thin #7f7f7f;
5a738aea 31 margin-left: 36pt;
10d09e33 32 padding: 10px;
5a738aea
MS
33}
34
f11a948a
MS
35P.compact {
36 margin: 0;
37}
38
e4572d57
MS
39P.example {
40 font-style: italic;
41 margin-left: 36pt;
42}
ca6b43fc 43
240214ef
MS
44DL.man DD {
45 margin-left: 5em;
46}
47
48DL.man DT {
49 margin-left: 0;
50}
51
52PRE.man {
53 margin: 0;
54}
55
5a738aea
MS
56PRE.example {
57 background: #eeeeee;
58 border: dotted thin #999999;
59 margin-left: 36pt;
178cb736 60 padding: 10pt;
5a738aea
MS
61}
62
63PRE.command EM, PRE.example EM {
64 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
65}
66
67P.command {
68 font-family: monaco, courier, monospace;
69 margin-left: 36pt;
70}
71
72P.formula {
73 font-style: italic;
74 margin-left: 36pt;
75}
76
77BLOCKQUOTE {
178cb736 78 background: #eeeeee;
5a738aea
MS
79 border: solid thin #999999;
80 padding: 10pt;
81}
82
e4572d57
MS
83A IMG {
84 border: none;
85}
86
87A:link:hover IMG {
88 background: #f0f0f0;
89 border-radius: 10px;
90 -moz-border-radius: 10px;
91}
92
5a738aea 93A:link, A:visited {
ca6b43fc 94 font-weight: inherit;
5a738aea 95 text-decoration: none;
5a738aea
MS
96}
97
98A:link:hover, A:visited:hover, A:active {
99 text-decoration: underline;
5a738aea
MS
100}
101
102SUB, SUP {
103 font-size: 50%;
104}
105
e4572d57
MS
106TR.data, TD.data, TR.data TD {
107 margin-top: 10pt;
108 padding: 5pt;
109 border-bottom: solid 1pt #999999;
110}
111
112TR.data TH {
113 border-bottom: solid 1pt #999999;
114 padding-top: 10pt;
115 padding-left: 5pt;
116 text-align: left;
117}
118
5a738aea
MS
119DIV.table TABLE {
120 border: solid thin #999999;
121 border-collapse: collapse;
122 border-spacing: 0;
123 margin-left: auto;
124 margin-right: auto;
125}
126
127DIV.table CAPTION {
128 caption-side: top;
129 font-size: 120%;
130 font-style: italic;
131 font-weight: bold;
132 margin-left: auto;
133 margin-right: auto;
134}
135
136DIV.table TABLE TD {
137 border: solid thin #cccccc;
138 padding-top: 5pt;
139}
140
141DIV.table TABLE TH {
142 background: #cccccc;
143 border: none;
144 border-bottom: solid thin #999999;
145}
146
147DIV.figure TABLE {
148 margin-left: auto;
149 margin-right: auto;
150}
151
152DIV.figure CAPTION {
153 caption-side: bottom;
154 font-size: 120%;
155 font-style: italic;
156 font-weight: bold;
157 margin-left: auto;
158 margin-right: auto;
159}
160
161TH.label {
5a738aea
MS
162 text-align: right;
163 vertical-align: top;
164}
165
e4572d57
MS
166TH.sublabel {
167 text-align: right;
168 font-weight: normal;
169}
170
5a738aea
MS
171HR {
172 border: solid thin;
173}
174
175SPAN.info {
e4572d57
MS
176 background: black;
177 border: thin solid black;
178 color: white;
5a738aea
MS
179 font-size: 80%;
180 font-style: italic;
181 font-weight: bold;
182 white-space: nowrap;
183}
184
185H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
186 float: right;
187 font-size: 100%;
188}
189
178cb736
MS
190H1.title {
191}
192
5a738aea
MS
193H2.title, H3.title {
194 border-bottom: solid 2pt #000000;
195}
196
e4572d57
MS
197DIV.indent, TABLE.indent {
198 margin-top: 2em;
199 margin-left: auto;
200 margin-right: auto;
201 width: 90%;
202}
203
204TABLE.indent {
205 border-collapse: collapse;
206}
207
208TABLE.indent TD, TABLE.indent TH {
209 padding: 0;
210}
211
212TABLE.list {
213 border-collapse: collapse;
214 margin-left: auto;
215 margin-right: auto;
216 width: 90%;
217}
218
219TABLE.list TH {
220 background: white;
221 border-bottom: solid thin #cccccc;
222 color: #444444;
223 padding-top: 10pt;
224 padding-left: 5pt;
225 text-align: left;
226 vertical-align: bottom;
227 white-space: nowrap;
228}
229
230TABLE.list TH A {
231 color: #4444cc;
232}
233
234TABLE.list TD {
235 border-bottom: solid thin #eeeeee;
236 padding-top: 5pt;
237 padding-left: 5pt;
238}
239
240TABLE.list TR:nth-child(even) {
241 background: #f8f8f8;
242}
243
244TABLE.list TR:nth-child(odd) {
245 background: #f4f4f4;
246}
247
5a738aea
MS
248DT {
249 margin-left: 36pt;
250 margin-top: 12pt;
251}
252
253DD {
254 margin-left: 54pt;
255}
256
257DL.category DT {
258 font-weight: bold;
259}
260
261P.summary {
262 margin-left: 36pt;
263 font-family: monaco, courier, monospace;
264}
265
5a738aea
MS
266DIV.summary TABLE {
267 border: solid thin #999999;
268 border-collapse: collapse;
269 border-spacing: 0;
270 margin: 10px;
271}
272
273DIV.summary TABLE TD, DIV.summary TABLE TH {
274 border: solid thin #999999;
275 padding: 5px;
276 text-align: left;
277 vertical-align: top;
278}
279
280DIV.summary TABLE THEAD TH {
281 background: #eeeeee;
282}
283
284/* API documentation styles... */
285div.body h1 {
286 margin: 0;
287}
288div.body h2 {
289 margin-top: 1.5em;
290}
291div.body h3, div.body h4, div.body h5 {
292 margin-bottom: 0.5em;
293 margin-top: 1.5em;
294}
295.class, .enumeration, .function, .struct, .typedef, .union {
296 border-bottom: solid thin #999999;
297 margin-bottom: 0;
298 margin-top: 2em;
299}
300.description {
301 margin-top: 0.5em;
302}
303code, p.code, pre, ul.code li {
304 font-family: monaco, courier, monospace;
305 font-size: 90%;
306}
307ul.code, ul.contents, ul.subcontents {
308 list-style-type: none;
309 margin: 0;
310 padding-left: 0;
311}
312ul.code li {
313 margin: 0;
314}
315ul.contents > li {
316 margin-top: 1em;
317}
318ul.contents li ul.code, ul.contents li ul.subcontents {
319 padding-left: 2em;
320}
321div.body dl {
322 margin-left: 0;
323 margin-top: 0;
324}
325div.body dt {
326 font-style: italic;
327 margin-left: 0;
328 margin-top: 0;
329}
330div.body dd {
331 margin-bottom: 0.5em;
332}
333
334/* This is just for the HTML files generated with the framedhelp target */
335div.contents {
336 background: #e8e8e8;
337 border: solid thin black;
338 padding: 10px;
339}
340div.contents h1 {
341 font-size: 110%;
342}
343div.contents h2 {
344 font-size: 100%;
345}
346div.contents ul.contents {
347 font-size: 80%;
348}
ac884b6a
MS
349div.contents ul.subcontents li {
350 margin-left: 1em;
351 text-indent: -1em;
352}
5a738aea 353--></style>
abacc52b
MS
354 </head>
355 <body>
5a738aea 356<!--
321d8d57 357 Introduction to CUPS programming header for CUPS.
5a738aea 358
dffa3c74 359 Copyright 2008-2016 by Apple Inc.
5a738aea
MS
360
361 These coded instructions, statements, and computer programs are the
362 property of Apple Inc. and are protected by Federal copyright
363 law. Distribution and use rights are outlined in the file "LICENSE.txt"
364 which should have been included with this file. If this file is
365 file is missing or damaged, see the license at "http://www.cups.org/".
366-->
367
178cb736
MS
368<h1 class='title'>Introduction to CUPS Programming</h1>
369
5a738aea
MS
370<div class='summary'><table summary='General Information'>
371<thead>
372<tr>
373 <th>Headers</th>
374 <th>cups/cups.h<br>
dffa3c74 375 cups/adminutil.h<br>
5a738aea 376 cups/array.h<br>
5a738aea
MS
377 cups/dir.h<br>
378 cups/file.h<br>
dffa3c74
MS
379 cups/http.h<br>
380 cups/ipp.h<br>
381 cups/language.h<br>
5a738aea 382 cups/ppd.h<br>
dffa3c74
MS
383 cups/pwg.h<br>
384 cups/raster.h</th>
5a738aea
MS
385</tr>
386</thead>
387<tbody>
388<tr>
389 <th>Libraries</th>
dffa3c74 390 <td>-lcups</td>
5a738aea
MS
391</tr>
392<tr>
393 <th>See Also</th>
e4572d57
MS
394 <td>Programming: <a href='raster-driver.html' target='_top'>Developing Raster Printer Drivers</a><br>
395 Programming: <a href='postscript-driver.html' target='_top'>Developing PostScript Printer Drivers</a><br>
396 Programming: <a href='api-filter.html' target='_top'>Filter and Backend Programming</a><br>
397 Programming: <a href='ppd-compiler.html' target='_top'>Introduction to the PPD Compiler</a><br>
dffa3c74 398 Programming: <a href='api-admin.html' target='_top'>Administrative APIs</a><br>
5a738aea 399 Programming: <a href='api-array.html' target='_top'>Array API</a><br>
e4572d57 400 Programming: <a href='api-cups.html' target='_top'>CUPS API</a><br>
5a738aea 401 Programming: <a href='api-filedir.html' target='_top'>File and Directory APIs</a><br>
5a738aea 402 Programming: <a href='api-httpipp.html' target='_top'>HTTP and IPP APIs</a><br>
dffa3c74 403 Programming: <a href='api-ppd.html' target='_top'>PPD API (DEPRECATED)</a><br>
e4572d57
MS
404 Programming: <a href='api-raster.html' target='_top'>Raster API</a><br>
405 References: <a href='ref-ppdcfile.html' target='_top'>PPD Compiler Driver Information File Reference</a><br>
406 Specifications: <a href='spec-ppd.html' target='_top'>CUPS PPD Extensions</a></td>
5a738aea
MS
407</tr>
408</tbody>
409</table></div>
abacc52b
MS
410 <div class="contents">
411 <h2 class="title">Contents</h2>
412 <ul class="contents">
413 <li><a href="#OVERVIEW">Overview</a></li>
414 <li><a href="#COMPILING">Compiling Programs</a><ul class="subcontents">
415 <li><a href="#XCODE">Compiling with Xcode</a></li>
416 <li><a href="#COMMANDLINE">Compiling with GCC</a></li>
417 </ul></li>
418 <li><a href="#WHERETOGO">Where to Go Next</a></li>
419 </ul>
420 </div>
421 <div class="body">
5a738aea 422<!--
eac3a0a0 423 Introduction to CUPS programming content for CUPS.
5a738aea 424
eac3a0a0 425 Copyright 2008-2011 by Apple Inc.
5a738aea
MS
426
427 These coded instructions, statements, and computer programs are the
428 property of Apple Inc. and are protected by Federal copyright
429 law. Distribution and use rights are outlined in the file "LICENSE.txt"
430 which should have been included with this file. If this file is
431 file is missing or damaged, see the license at "http://www.cups.org/".
432-->
433
434<h2 class="title"><a name="OVERVIEW">Overview</a></h2>
435
436<p>CUPS provides two libraries that interface with the different parts of the
437printing system. The "cups" library provides all of the common application and
438filter functions while the "cupsimage" library provides all of the imaging
439functions used in raster printer drivers. The "cups" library functions are
440accessed by including the <var>&lt;cups/cups.h&gt;</var> header, while
441"cupsimage" functions are found in the <var>&lt;cups/raster.h&gt;</var>
442header.</p>
443
444<h2 class="title"><a name="COMPILING">Compiling Programs</a></h2>
445
446<p>The CUPS libraries can be used from any C, C++, or Objective C program.
447The method of compiling against the libraries varies depending on the
448operating system and installation of CUPS. The following sections show how
449to compile a simple program (shown below) in two common environments.</p>
450
451<p>The following simple program lists the available printers on the system:</p>
452
453<pre class="example">
454#include &lt;stdio.h&gt;
455#include &lt;cups/cups.h&gt;
456
457int main(void)
458{
459 int i;
460 cups_dest_t *dests, *dest;
461 int num_dests = cupsGetDests(&amp;dests);
462
463 for (i = num_dests, dest = dests; i &gt; 0; i --, dest ++)
464 {
465 if (dest->instance)
466 printf("%s/%s\n", dest->name, dest->instance);
467 else
468 puts(dest->name);
469 }
470
471 return (0);
472}
473</pre>
474
475<h3><a name="XCODE">Compiling with Xcode</a></h3>
476
477<p>In Xcode, choose <var>New Project...</var> from the <var>File</var> menu,
478then select the <var>Standard Tool</var> project type under <var>Command Line
479Utility</var>. Click <var>Next</var> and choose a project directory. Click
480<var>Next</var> to create the project.</p>
481
482<p>In the project window, double-click on the <var>Targets</var> group and
483control-click on the simple target to show the context menu. Choose
484<var>Existing Framework...</var> from the <var>Add</var> submenu. When the file
485chooser sheet appears, press the <kbd>/</kbd> key and enter "/usr/lib". Scroll
486down the file list and select the <var>libcups.dylib</var> file. Click the
487<var>Add</var> button in the file chooser and attributes sheets.</p>
488
489<p>In the project window, double-click on the <var>main.c</var> source file.
490Replace the template source code with the listing above and save it. Click the
491<var>Build and Go</var> button to build the sample program and run it.</p>
492
493<h3><a name="COMMANDLINE">Compiling with GCC</a></h3>
494
495<p>From the command-line, create a file called <var>sample.c</var> using your
496favorite editor and then run the following command to compile it with GCC and
497run it:</p>
498
499<pre class="command">
500gcc -o simple `cups-config --cflags` simple.c `cups-config --libs`
501./simple
502</pre>
503
504<p>The <code>cups-config</code> command provides the compiler flags
505("cups-config --cflags") and libraries ("cups-config --libs") needed for the
506local system.</p>
507
508<h2 class="title"><a name="WHERETOGO">Where to Go Next</a></h2>
509
510<p>If you are developing a print filter, driver, or backend, see the
511<a href="api-filter.html" target="_top">Filter and Backend Programming</a>
512guide. Raster printer driver developers should also read the
513<a href="api-raster.html" target="_top">Raster API</a> reference.</p>
abacc52b
MS
514 </div>
515 </body>
5a738aea 516</html>