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