]> git.ipfire.org Git - thirdparty/cups.git/blame - doc/help/api-admin.html
Update all references to OS X to macOS.
[thirdparty/cups.git] / doc / help / api-admin.html
CommitLineData
dffa3c74
MS
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2<html>
3<!-- SECTION: Programming -->
4<head>
5 <title>Administration APIs </title>
6 <meta name="keywords" content="Programming">
7 <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
8072030b 8 <meta name="creator" content="Mini-XML v2.7">
dffa3c74
MS
9<style type="text/css"><!--
10BODY {
11 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
12}
13
14H1, H2, H3, H4, H5, H6, P, TD, TH {
15 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
16}
17
18KBD {
19 font-family: monaco, courier, monospace;
20 font-weight: bold;
21}
22
23PRE {
24 font-family: monaco, courier, monospace;
25}
26
27PRE.command {
28 border: dotted thin #7f7f7f;
29 margin-left: 36pt;
30 padding: 10px;
31}
32
33P.compact {
34 margin: 0;
35}
36
37P.example {
38 font-style: italic;
39 margin-left: 36pt;
40}
41
42DL.man DD {
43 margin-left: 5em;
44}
45
46DL.man DT {
47 margin-left: 0;
48}
49
50PRE.man {
51 margin: 0;
52}
53
54PRE.example {
55 background: #eeeeee;
56 border: dotted thin #999999;
57 margin-left: 36pt;
58 padding: 10pt;
59}
60
61PRE.command EM, PRE.example EM {
62 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
63}
64
65P.command {
66 font-family: monaco, courier, monospace;
67 margin-left: 36pt;
68}
69
70P.formula {
71 font-style: italic;
72 margin-left: 36pt;
73}
74
75BLOCKQUOTE {
76 background: #eeeeee;
77 border: solid thin #999999;
78 padding: 10pt;
79}
80
81A IMG {
82 border: none;
83}
84
85A:link:hover IMG {
86 background: #f0f0f0;
87 border-radius: 10px;
88 -moz-border-radius: 10px;
89}
90
91A:link, A:visited {
92 font-weight: inherit;
93 text-decoration: none;
94}
95
96A:link:hover, A:visited:hover, A:active {
97 text-decoration: underline;
98}
99
100SUB, SUP {
101 font-size: 50%;
102}
103
104TR.data, TD.data, TR.data TD {
105 margin-top: 10pt;
106 padding: 5pt;
107 border-bottom: solid 1pt #999999;
108}
109
110TR.data TH {
111 border-bottom: solid 1pt #999999;
112 padding-top: 10pt;
113 padding-left: 5pt;
114 text-align: left;
115}
116
117DIV.table TABLE {
118 border: solid thin #999999;
119 border-collapse: collapse;
120 border-spacing: 0;
121 margin-left: auto;
122 margin-right: auto;
123}
124
125DIV.table CAPTION {
126 caption-side: top;
127 font-size: 120%;
128 font-style: italic;
129 font-weight: bold;
130 margin-left: auto;
131 margin-right: auto;
132}
133
134DIV.table TABLE TD {
135 border: solid thin #cccccc;
136 padding-top: 5pt;
137}
138
139DIV.table TABLE TH {
140 background: #cccccc;
141 border: none;
142 border-bottom: solid thin #999999;
143}
144
145DIV.figure TABLE {
146 margin-left: auto;
147 margin-right: auto;
148}
149
150DIV.figure CAPTION {
151 caption-side: bottom;
152 font-size: 120%;
153 font-style: italic;
154 font-weight: bold;
155 margin-left: auto;
156 margin-right: auto;
157}
158
159TH.label {
160 text-align: right;
161 vertical-align: top;
162}
163
164TH.sublabel {
165 text-align: right;
166 font-weight: normal;
167}
168
169HR {
170 border: solid thin;
171}
172
173SPAN.info {
174 background: black;
175 border: thin solid black;
176 color: white;
177 font-size: 80%;
178 font-style: italic;
179 font-weight: bold;
180 white-space: nowrap;
181}
182
183H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
184 float: right;
185 font-size: 100%;
186}
187
188H1.title {
189}
190
191H2.title, H3.title {
192 border-bottom: solid 2pt #000000;
193}
194
195DIV.indent, TABLE.indent {
196 margin-top: 2em;
197 margin-left: auto;
198 margin-right: auto;
199 width: 90%;
200}
201
202TABLE.indent {
203 border-collapse: collapse;
204}
205
206TABLE.indent TD, TABLE.indent TH {
207 padding: 0;
208}
209
210TABLE.list {
211 border-collapse: collapse;
212 margin-left: auto;
213 margin-right: auto;
214 width: 90%;
215}
216
217TABLE.list TH {
218 background: white;
219 border-bottom: solid thin #cccccc;
220 color: #444444;
221 padding-top: 10pt;
222 padding-left: 5pt;
223 text-align: left;
224 vertical-align: bottom;
225 white-space: nowrap;
226}
227
228TABLE.list TH A {
229 color: #4444cc;
230}
231
232TABLE.list TD {
233 border-bottom: solid thin #eeeeee;
234 padding-top: 5pt;
235 padding-left: 5pt;
236}
237
238TABLE.list TR:nth-child(even) {
239 background: #f8f8f8;
240}
241
242TABLE.list TR:nth-child(odd) {
243 background: #f4f4f4;
244}
245
246DT {
247 margin-left: 36pt;
248 margin-top: 12pt;
249}
250
251DD {
252 margin-left: 54pt;
253}
254
255DL.category DT {
256 font-weight: bold;
257}
258
259P.summary {
260 margin-left: 36pt;
261 font-family: monaco, courier, monospace;
262}
263
264DIV.summary TABLE {
265 border: solid thin #999999;
266 border-collapse: collapse;
267 border-spacing: 0;
268 margin: 10px;
269}
270
271DIV.summary TABLE TD, DIV.summary TABLE TH {
272 border: solid thin #999999;
273 padding: 5px;
274 text-align: left;
275 vertical-align: top;
276}
277
278DIV.summary TABLE THEAD TH {
279 background: #eeeeee;
280}
281
282/* API documentation styles... */
283div.body h1 {
284 margin: 0;
285}
286div.body h2 {
287 margin-top: 1.5em;
288}
289div.body h3, div.body h4, div.body h5 {
290 margin-bottom: 0.5em;
291 margin-top: 1.5em;
292}
293.class, .enumeration, .function, .struct, .typedef, .union {
294 border-bottom: solid thin #999999;
295 margin-bottom: 0;
296 margin-top: 2em;
297}
298.description {
299 margin-top: 0.5em;
300}
301code, p.code, pre, ul.code li {
302 font-family: monaco, courier, monospace;
303 font-size: 90%;
304}
305ul.code, ul.contents, ul.subcontents {
306 list-style-type: none;
307 margin: 0;
308 padding-left: 0;
309}
310ul.code li {
311 margin: 0;
312}
313ul.contents > li {
314 margin-top: 1em;
315}
316ul.contents li ul.code, ul.contents li ul.subcontents {
317 padding-left: 2em;
318}
319div.body dl {
320 margin-left: 0;
321 margin-top: 0;
322}
323div.body dt {
324 font-style: italic;
325 margin-left: 0;
326 margin-top: 0;
327}
328div.body dd {
329 margin-bottom: 0.5em;
330}
331
332/* This is just for the HTML files generated with the framedhelp target */
333div.contents {
334 background: #e8e8e8;
335 border: solid thin black;
336 padding: 10px;
337}
338div.contents h1 {
339 font-size: 110%;
340}
341div.contents h2 {
342 font-size: 100%;
343}
344div.contents ul.contents {
345 font-size: 80%;
346}
347div.contents ul.subcontents li {
348 margin-left: 1em;
349 text-indent: -1em;
350}
351--></style>
352</head>
353<body>
354<div class='body'>
355<!--
356 Administrative API header for CUPS.
357
358 Copyright 2016 by Apple Inc.
359
360 These coded instructions, statements, and computer programs are the
361 property of Apple Inc. and are protected by Federal copyright
362 law. Distribution and use rights are outlined in the file "LICENSE.txt"
363 which should have been included with this file. If this file is
364 file is missing or damaged, see the license at "http://www.cups.org/".
365-->
366
367<h1 class='title'>Administrative APIs</h1>
368
369<div class='summary'><table summary='General Information'>
370<thead>
371<tr>
372 <th>Header</th>
373 <th>cups/adminutil.h</th>
374</tr>
375</thead>
376<tbody>
377<tr>
378 <th>Library</th>
379 <td>-lcups</td>
380</tr>
381<tr>
382 <th>See Also</th>
383 <td>Programming: <a href='api-overview.html' target='_top'>Introduction to CUPS Programming</a><br>
384 Programming: <a href='api-cups.html' target='_top'>CUPS API</a><br>
385 Programming: <a href='api-httpipp.html' target='_top'>HTTP and IPP APIs</a></td>
386</tr>
387</tbody>
388</table></div>
389<h2 class="title">Contents</h2>
390<ul class="contents">
391<li><a href="#OVERVIEW">Overview</a><ul class="subcontents">
392 <li><a href="#SETTINGS">Scheduler Settings</a></li>
393 <li><a href="#DEVICES">Devices</a></li>
394</ul></li>
395<li><a href="#FUNCTIONS">Functions</a><ul class="code">
396 <li><a href="#cupsAdminCreateWindowsPPD" title="Create the Windows PPD file for a printer.">cupsAdminCreateWindowsPPD</a></li>
397 <li><a href="#cupsAdminExportSamba" title="Export a printer to Samba.">cupsAdminExportSamba</a></li>
398 <li><a href="#cupsAdminGetServerSettings" title="Get settings from the server.">cupsAdminGetServerSettings</a></li>
399 <li><a href="#cupsAdminSetServerSettings" title="Set settings on the server.">cupsAdminSetServerSettings</a></li>
400 <li><a href="#cupsGetDevices" title="Get available printer devices.">cupsGetDevices</a></li>
401</ul></li>
402<li><a href="#TYPES">Data Types</a><ul class="code">
403 <li><a href="#cups_device_cb_t" title="Device callback
404">cups_device_cb_t</a></li>
405</ul></li>
406</ul>
407<!--
408 Administrative API documentation for CUPS.
409
410 Copyright 2016 by Apple Inc.
411
412 These coded instructions, statements, and computer programs are the
413 property of Apple Inc. and are protected by Federal copyright
414 law. Distribution and use rights are outlined in the file "LICENSE.txt"
415 which should have been included with this file. If this file is
416 file is missing or damaged, see the license at "http://www.cups.org/".
417-->
418
419<h2 class="title"><a name="OVERVIEW">Overview</a></h2>
420
421<p>The administrative APIs provide convenience functions to perform certain administrative functions with the CUPS scheduler.</p>
422
423<blockquote><b>Note:<b>
424 <p>Administrative functions normally require administrative privileges to execute and must not be used in ordinary user applications!</p>
425</blockquote>
426
427<h3><a name="SETTINGS">Scheduler Settings</a></h3>
428
429<p>The <a href="#cupsAdminGetServerSettings"><code>cupsAdminGetServerSettings</code></a> and <a href="#cupsAdminSetServerSettings"><code>cupsAdminSetServerSettings</code></a> functions allow you to get and set simple directives and their values, respectively, in the <var>cupsd.conf</var> file for the CUPS scheduler. Settings are stored in CUPS option arrays which provide a simple list of string name/value pairs. While any simple <var>cupsd.conf</var> directive name can be specified, the following convenience names are also defined to control common complex directives:</p>
430
431<ul>
432 <li><code>CUPS_SERVER_DEBUG_LOGGING</code></li>: For <code>cupsAdminGetServerSettings</code>, a value of "1" means that the <code>LogLevel</code> directive is set to <code>debug</code> or <code>debug2</code> while a value of "0" means it is set to any other value. For <code>cupsAdminSetServerSettings</code> a value of "1" sets the <code>LogLeveL</code> to <code>debug</code> while a value of "0" sets it to <code>warn</code>.</li>
433 <li><code>CUPS_SERVER_REMOTE_ADMIN</code></li>: A value of "1" specifies that administrative requests are accepted from remote addresses while "0" specifies that requests are only accepted from local addresses (loopback interface and domain sockets).</li>
434 <li><code>CUPS_SERVER_REMOTE_ANY</code></li>: A value of "1" specifies that requests are accepts from any address while "0" specifies that requests are only accepted from the local subnet (when sharing is enabled) or local addresses (loopback interface and domain sockets).</li>
435 <li><code>CUPS_SERVER_SHARE_PRINTERS</code></li>: A value of "1" specifies that printer sharing is enabled for selected printers and remote requests are accepted while a value of "0" specifies that printer sharing is disables and remote requests are not accepted.</li>
436 <li><code>CUPS_SERVER_USER_CANCEL_ANY</code></li>: A value of "1" specifies that the default security policy allows any user to cancel any print job, regardless of the owner. A value of "0" specifies that only administrative users can cancel other user's jobs.</li>
437</ul>
438
439<blockquote><b>Note:</b>
440 <p>Changing settings will restart the CUPS scheduler.</p>
441 <p>When printer sharing or the web interface are enabled, the scheduler's launch-on-demand functionality is effectively disabled. This can affect power usage, system performance, and the security profile of a system.</p>
442</blockquote>
443
444<p>The recommended way to make changes to the <var>cupsd.conf</var> is to first call <a href="#cupsAdminGetServerSettings"><code>cupsAdminGetServerSettings</code></a>, make any changes to the returned option array, and then call <a href="#cupsAdminSetServerSettings"><code>cupsAdminSetServerSettings</code></a> to save those settings. For example, to enable the web interface:</p>
445
446<pre class="example">
447#include &lt;cups/cups.h&gt;
448#include &lt;cups/adminutil.h&gt;
449
450void
451enable_web_interface(void)
452{
453 int num_settings = 0; /* Number of settings */
454 cups_option_t *settings = NULL; /* Settings */
455
456
457 if (!<a href="#cupsAdminGetServerSettings">cupsAdminGetServerSettings</a>(CUPS_HTTP_DEFAULT, &amp;num_settings, &amp;settings))
458 {
459 fprintf(stderr, "ERROR: Unable to get server settings: %s\n", cupsLastErrorString());
460 return;
461 }
462
463 num_settings = <a href="api-cups.html#cupsAddOption">cupsAddOption</a>("WebInterface", "Yes", num_settings, &amp;settings);
464
465 if (!<a href="#cupsAdminSetServerSettings">cupsAdminSetServerSettings</a>(CUPS_HTTP_DEFAULT, num_settings, settings))
466 {
467 fprintf(stderr, "ERROR: Unable to set server settings: %s\n", cupsLastErrorString());
468 }
469
470 <a href="api-cups.html#cupsFreeOptions">cupsFreeOptions</a>(num_settings, settings);
471}
472</pre>
473
474<h3><a name="DEVICES">Devices</a></h3>
475
476<p>Printers can be discovered through the CUPS scheduler using the <a href="#cupsGetDevices"><code>cupsGetDevices</code></a> API. Typically this API is used to locate printers to add the the system. Each device that is found will cause a supplied callback function to be executed. For example, to list the available printer devices that can be found within 30 seconds:</p>
477
478<pre class="example">
479#include &lt;cups/cups.h&gt;
480#include &lt;cups/adminutil.h&gt;
481
482
483void
484get_devices_cb(
485 const char *device_class, /* I - Class */
486 const char *device_id, /* I - 1284 device ID */
487 const char *device_info, /* I - Description */
488 const char *device_make_and_model, /* I - Make and model */
489 const char *device_uri, /* I - Device URI */
490 const char *device_location, /* I - Location */
491 void *user_data) /* I - User data */
492{
493 puts(device_uri);
494}
495
496
497void
498show_devices(void)
499{
500 <a href="#cupsGetDevices">cupsGetDevices</a>(CUPS_HTTP_DEFAULT, 30, NULL, NULL, get_devices_cb, NULL);
501}
502</pre>
503<h2 class="title"><a name="FUNCTIONS">Functions</a></h2>
504<h3 class="function"><span class="info">&nbsp;DEPRECATED&nbsp;</span><a name="cupsAdminCreateWindowsPPD">cupsAdminCreateWindowsPPD</a></h3>
505<p class="description">Create the Windows PPD file for a printer.</p>
506<p class="code">
507char *cupsAdminCreateWindowsPPD (<br>
508&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
509&nbsp;&nbsp;&nbsp;&nbsp;const char *dest,<br>
510&nbsp;&nbsp;&nbsp;&nbsp;char *buffer,<br>
511&nbsp;&nbsp;&nbsp;&nbsp;int bufsize<br>
512);</p>
513<h4 class="parameters">Parameters</h4>
514<dl>
515<dt>http</dt>
516<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
517<dt>dest</dt>
518<dd class="description">Printer or class</dd>
519<dt>buffer</dt>
520<dd class="description">Filename buffer</dd>
521<dt>bufsize</dt>
522<dd class="description">Size of filename buffer</dd>
523</dl>
524<h4 class="returnvalue">Return Value</h4>
525<p class="description">PPD file or NULL</p>
526<h3 class="function"><span class="info">&nbsp;DEPRECATED&nbsp;</span><a name="cupsAdminExportSamba">cupsAdminExportSamba</a></h3>
527<p class="description">Export a printer to Samba.</p>
528<p class="code">
529int cupsAdminExportSamba (<br>
530&nbsp;&nbsp;&nbsp;&nbsp;const char *dest,<br>
531&nbsp;&nbsp;&nbsp;&nbsp;const char *ppd,<br>
532&nbsp;&nbsp;&nbsp;&nbsp;const char *samba_server,<br>
533&nbsp;&nbsp;&nbsp;&nbsp;const char *samba_user,<br>
534&nbsp;&nbsp;&nbsp;&nbsp;const char *samba_password,<br>
535&nbsp;&nbsp;&nbsp;&nbsp;FILE *logfile<br>
536);</p>
537<h4 class="parameters">Parameters</h4>
538<dl>
539<dt>dest</dt>
540<dd class="description">Destination to export</dd>
541<dt>ppd</dt>
542<dd class="description">PPD file</dd>
543<dt>samba_server</dt>
544<dd class="description">Samba server</dd>
545<dt>samba_user</dt>
546<dd class="description">Samba username</dd>
547<dt>samba_password</dt>
548<dd class="description">Samba password</dd>
549<dt>logfile</dt>
550<dd class="description">Log file, if any</dd>
551</dl>
552<h4 class="returnvalue">Return Value</h4>
553<p class="description">1 on success, 0 on failure</p>
8072030b 554<h3 class="function"><span class="info">&nbsp;CUPS 1.3/macOS 10.5&nbsp;</span><a name="cupsAdminGetServerSettings">cupsAdminGetServerSettings</a></h3>
dffa3c74
MS
555<p class="description">Get settings from the server.</p>
556<p class="code">
557int cupsAdminGetServerSettings (<br>
558&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
559&nbsp;&nbsp;&nbsp;&nbsp;int *num_settings,<br>
560&nbsp;&nbsp;&nbsp;&nbsp;cups_option_t **settings<br>
561);</p>
562<h4 class="parameters">Parameters</h4>
563<dl>
564<dt>http</dt>
565<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
566<dt>num_settings</dt>
567<dd class="description">Number of settings</dd>
568<dt>settings</dt>
569<dd class="description">Settings</dd>
570</dl>
571<h4 class="returnvalue">Return Value</h4>
572<p class="description">1 on success, 0 on failure</p>
573<h4 class="discussion">Discussion</h4>
574<p class="discussion">The returned settings should be freed with cupsFreeOptions() when
575you are done with them.
576
577</p>
8072030b 578<h3 class="function"><span class="info">&nbsp;CUPS 1.3/macOS 10.5&nbsp;</span><a name="cupsAdminSetServerSettings">cupsAdminSetServerSettings</a></h3>
dffa3c74
MS
579<p class="description">Set settings on the server.</p>
580<p class="code">
581int cupsAdminSetServerSettings (<br>
582&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
583&nbsp;&nbsp;&nbsp;&nbsp;int num_settings,<br>
584&nbsp;&nbsp;&nbsp;&nbsp;cups_option_t *settings<br>
585);</p>
586<h4 class="parameters">Parameters</h4>
587<dl>
588<dt>http</dt>
589<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
590<dt>num_settings</dt>
591<dd class="description">Number of settings</dd>
592<dt>settings</dt>
593<dd class="description">Settings</dd>
594</dl>
595<h4 class="returnvalue">Return Value</h4>
596<p class="description">1 on success, 0 on failure</p>
8072030b 597<h3 class="function"><span class="info">&nbsp;CUPS 1.4/macOS 10.6&nbsp;</span><a name="cupsGetDevices">cupsGetDevices</a></h3>
dffa3c74
MS
598<p class="description">Get available printer devices.</p>
599<p class="code">
600ipp_status_t cupsGetDevices (<br>
601&nbsp;&nbsp;&nbsp;&nbsp;http_t *http,<br>
602&nbsp;&nbsp;&nbsp;&nbsp;int timeout,<br>
603&nbsp;&nbsp;&nbsp;&nbsp;const char *include_schemes,<br>
604&nbsp;&nbsp;&nbsp;&nbsp;const char *exclude_schemes,<br>
605&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_device_cb_t">cups_device_cb_t</a> callback,<br>
606&nbsp;&nbsp;&nbsp;&nbsp;void *user_data<br>
607);</p>
608<h4 class="parameters">Parameters</h4>
609<dl>
610<dt>http</dt>
611<dd class="description">Connection to server or <code>CUPS_HTTP_DEFAULT</code></dd>
612<dt>timeout</dt>
613<dd class="description">Timeout in seconds or <code>CUPS_TIMEOUT_DEFAULT</code></dd>
614<dt>include_schemes</dt>
615<dd class="description">Comma-separated URI schemes to include or <code>CUPS_INCLUDE_ALL</code></dd>
616<dt>exclude_schemes</dt>
617<dd class="description">Comma-separated URI schemes to exclude or <code>CUPS_EXCLUDE_NONE</code></dd>
618<dt>callback</dt>
619<dd class="description">Callback function</dd>
620<dt>user_data</dt>
621<dd class="description">User data pointer</dd>
622</dl>
623<h4 class="returnvalue">Return Value</h4>
624<p class="description">Request status - <code>IPP_OK</code> on success.</p>
625<h4 class="discussion">Discussion</h4>
626<p class="discussion">This function sends a CUPS-Get-Devices request and streams the discovered
627devices to the specified callback function. The &quot;timeout&quot; parameter controls
628how long the request lasts, while the &quot;include_schemes&quot; and &quot;exclude_schemes&quot;
629parameters provide comma-delimited lists of backends to include or omit from
630the request respectively.
631
632</p>
633<h2 class="title"><a name="TYPES">Data Types</a></h2>
8072030b 634<h3 class="typedef"><span class="info">&nbsp;CUPS 1.4/macOS 10.6&nbsp;</span><a name="cups_device_cb_t">cups_device_cb_t</a></h3>
dffa3c74
MS
635<p class="description">Device callback
636</p>
637<p class="code">
638typedef void (*cups_device_cb_t)(const char *device_class, const char *device_id, const char *device_info, const char *device_make_and_model, const char *device_uri, const char *device_location, void *user_data);
639</p>
640</div>
641</body>
642</html>