]> git.ipfire.org Git - thirdparty/cups.git/blame - doc/help/api-filedir.html
Merge changes from CUPS 1.4svn-r7282.
[thirdparty/cups.git] / doc / help / api-filedir.html
CommitLineData
ef416fc2 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2<html>
3<!-- SECTION: Programming -->
4<head>
5a738aea
MS
5<title>File and Directory APIs</title>
6<meta name="keywords" content="Programming">
7<meta name="creator" content="Mini-XML v2.5">
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
30PRE.example {
31 background: #eeeeee;
32 border: dotted thin #999999;
33 margin-left: 36pt;
34 padding: 10px;
35}
36
37PRE.command EM, PRE.example EM {
38 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
39}
40
41P.command {
42 font-family: monaco, courier, monospace;
43 margin-left: 36pt;
44}
45
46P.formula {
47 font-style: italic;
48 margin-left: 36pt;
49}
50
51BLOCKQUOTE {
52 background: #cccccc;
53 border: solid thin #999999;
54 padding: 10pt;
55}
56
57A:link, A:visited {
58 text-decoration: none;
59 font-weight: bold;
60}
61
62A:link:hover, A:visited:hover, A:active {
63 text-decoration: underline;
64 font-weight: bold;
65}
66
67SUB, SUP {
68 font-size: 50%;
69}
70
71DIV.table TABLE {
72 border: solid thin #999999;
73 border-collapse: collapse;
74 border-spacing: 0;
75 margin-left: auto;
76 margin-right: auto;
77}
78
79DIV.table CAPTION {
80 caption-side: top;
81 font-size: 120%;
82 font-style: italic;
83 font-weight: bold;
84 margin-left: auto;
85 margin-right: auto;
86}
87
88DIV.table TABLE TD {
89 border: solid thin #cccccc;
90 padding-top: 5pt;
91}
92
93DIV.table TABLE TH {
94 background: #cccccc;
95 border: none;
96 border-bottom: solid thin #999999;
97}
98
99DIV.figure TABLE {
100 margin-left: auto;
101 margin-right: auto;
102}
103
104DIV.figure CAPTION {
105 caption-side: bottom;
106 font-size: 120%;
107 font-style: italic;
108 font-weight: bold;
109 margin-left: auto;
110 margin-right: auto;
111}
112
113TH.label {
114 padding-top: 5pt;
115 text-align: right;
116 vertical-align: top;
117}
118
119HR {
120 border: solid thin;
121}
122
123SPAN.info {
124 background: #000000;
125 border: thin solid #000000;
126 color: #ffffff;
127 font-size: 80%;
128 font-style: italic;
129 font-weight: bold;
130 white-space: nowrap;
131}
132
133H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
134 float: right;
135 font-size: 100%;
136}
137
138H2.title, H3.title {
139 border-bottom: solid 2pt #000000;
140}
141
142DT {
143 margin-left: 36pt;
144 margin-top: 12pt;
145}
146
147DD {
148 margin-left: 54pt;
149}
150
151DL.category DT {
152 font-weight: bold;
153}
154
155P.summary {
156 margin-left: 36pt;
157 font-family: monaco, courier, monospace;
158}
159
160SPAN.message {
161 font-style: italic;
162 font-size: smaller;
163}
164
165DIV.summary TABLE {
166 border: solid thin #999999;
167 border-collapse: collapse;
168 border-spacing: 0;
169 margin: 10px;
170}
171
172DIV.summary TABLE TD, DIV.summary TABLE TH {
173 border: solid thin #999999;
174 padding: 5px;
175 text-align: left;
176 vertical-align: top;
177}
178
179DIV.summary TABLE THEAD TH {
180 background: #eeeeee;
181}
182
183/* API documentation styles... */
184div.body h1 {
185 margin: 0;
186}
187div.body h2 {
188 margin-top: 1.5em;
189}
190div.body h3, div.body h4, div.body h5 {
191 margin-bottom: 0.5em;
192 margin-top: 1.5em;
193}
194.class, .enumeration, .function, .struct, .typedef, .union {
195 border-bottom: solid thin #999999;
196 margin-bottom: 0;
197 margin-top: 2em;
198}
199.description {
200 margin-top: 0.5em;
201}
202code, p.code, pre, ul.code li {
203 font-family: monaco, courier, monospace;
204 font-size: 90%;
205}
206ul.code, ul.contents, ul.subcontents {
207 list-style-type: none;
208 margin: 0;
209 padding-left: 0;
210}
211ul.code li {
212 margin: 0;
213}
214ul.contents > li {
215 margin-top: 1em;
216}
217ul.contents li ul.code, ul.contents li ul.subcontents {
218 padding-left: 2em;
219}
220div.body dl {
221 margin-left: 0;
222 margin-top: 0;
223}
224div.body dt {
225 font-style: italic;
226 margin-left: 0;
227 margin-top: 0;
228}
229div.body dd {
230 margin-bottom: 0.5em;
231}
232
233/* This is just for the HTML files generated with the framedhelp target */
234div.contents {
235 background: #e8e8e8;
236 border: solid thin black;
237 padding: 10px;
238}
239div.contents h1 {
240 font-size: 110%;
241}
242div.contents h2 {
243 font-size: 100%;
244}
245div.contents ul.contents {
246 font-size: 80%;
247}
248--></style>
ef416fc2 249</head>
250<body>
5a738aea
MS
251<div class='body'>
252<!--
253 "$Id: api-filedir.header 7279 2008-01-31 01:50:44Z mike $"
254
255 File and Directory API header for the Common UNIX Printing System (CUPS).
256
257 Copyright 2008 by Apple Inc.
258
259 These coded instructions, statements, and computer programs are the
260 property of Apple Inc. and are protected by Federal copyright
261 law. Distribution and use rights are outlined in the file "LICENSE.txt"
262 which should have been included with this file. If this file is
263 file is missing or damaged, see the license at "http://www.cups.org/".
264-->
265
266<h1 class="title">File and Directory APIs</h1>
267
268<div class='summary'><table summary='General Information'>
269<thead>
270<tr>
271 <th>Headers</th>
272 <th>cups/file.h<br>
273 cups/dir.h</th>
274</tr>
275</thead>
276<tbody>
277<tr>
278 <th>Library</th>
279 <td>-lcups</td>
280</tr>
281<tr>
282 <th>See Also</th>
283 <td>Programming: <a href='api-overview.html' target='_top'>Introduction to CUPS Programming</a><br>
284 Programming: <a href='api-cups.html' target='_top'>CUPS API</a></td>
285</tr>
286</tbody>
287</table></div>
288<h2 class="title">Contents</h2>
289<ul class="contents">
290</li>
291<li><a href="#OVERVIEW">Overview</a></li>
292<li><a href="#FUNCTIONS">Functions</a><ul class="code">
293<li><a href="#cupsDirClose" title="Close a directory.">cupsDirClose</a></li>
294<li><a href="#cupsDirOpen" title="Open a directory.">cupsDirOpen</a></li>
295<li><a href="#cupsDirRead" title="Read the next directory entry.">cupsDirRead</a></li>
296<li><a href="#cupsDirRewind" title="Rewind to the start of the directory.">cupsDirRewind</a></li>
297<li><a href="#cupsFileClose" title="Close a CUPS file.">cupsFileClose</a></li>
298<li><a href="#cupsFileCompression" title="Return whether a file is compressed.">cupsFileCompression</a></li>
299<li><a href="#cupsFileEOF" title="Return the end-of-file status.">cupsFileEOF</a></li>
300<li><a href="#cupsFileFind" title="Find a file using the specified path.">cupsFileFind</a></li>
301<li><a href="#cupsFileFlush" title="Flush pending output.">cupsFileFlush</a></li>
302<li><a href="#cupsFileGetChar" title="Get a single character from a file.">cupsFileGetChar</a></li>
303<li><a href="#cupsFileGetConf" title="Get a line from a configuration file...">cupsFileGetConf</a></li>
304<li><a href="#cupsFileGetLine" title="Get a CR and/or LF-terminated line that may
305contain binary data.">cupsFileGetLine</a></li>
306<li><a href="#cupsFileGets" title="Get a CR and/or LF-terminated line.">cupsFileGets</a></li>
307<li><a href="#cupsFileLock" title="Temporarily lock access to a file.">cupsFileLock</a></li>
308<li><a href="#cupsFileNumber" title="Return the file descriptor associated with a CUPS file.">cupsFileNumber</a></li>
309<li><a href="#cupsFileOpen" title="Open a CUPS file.">cupsFileOpen</a></li>
310<li><a href="#cupsFileOpenFd" title="Open a CUPS file using a file descriptor.">cupsFileOpenFd</a></li>
311<li><a href="#cupsFilePeekChar" title="Peek at the next character from a file.">cupsFilePeekChar</a></li>
312<li><a href="#cupsFilePrintf" title="Write a formatted string.">cupsFilePrintf</a></li>
313<li><a href="#cupsFilePutChar" title="Write a character.">cupsFilePutChar</a></li>
314<li><a href="#cupsFilePuts" title="Write a string.">cupsFilePuts</a></li>
315<li><a href="#cupsFileRead" title="Read from a file.">cupsFileRead</a></li>
316<li><a href="#cupsFileRewind" title="Set the current file position to the beginning of the
317file.">cupsFileRewind</a></li>
318<li><a href="#cupsFileSeek" title="Seek in a file.">cupsFileSeek</a></li>
319<li><a href="#cupsFileStderr" title="Return a CUPS file associated with stderr.">cupsFileStderr</a></li>
320<li><a href="#cupsFileStdin" title="Return a CUPS file associated with stdin.">cupsFileStdin</a></li>
321<li><a href="#cupsFileStdout" title="Return a CUPS file associated with stdout.">cupsFileStdout</a></li>
322<li><a href="#cupsFileTell" title="Return the current file position.">cupsFileTell</a></li>
323<li><a href="#cupsFileUnlock" title="Unlock access to a file.">cupsFileUnlock</a></li>
324<li><a href="#cupsFileWrite" title="Write to a file.">cupsFileWrite</a></li>
325</ul>
326<li><a href="#TYPES">Data Types</a><ul class="code">
327 <li><a href="#cups_dentry_t" title="Directory entry type">cups_dentry_t</a></li>
328 <li><a href="#cups_dir_t" title="Directory type">cups_dir_t</a></li>
329 <li><a href="#cups_file_t" title="CUPS file type">cups_file_t</a></li>
330</ul></li>
331<li><a href="#STRUCTURES">Structures</a><ul class="code">
332 <li><a href="#cups_dentry_s" title="Directory entry type">cups_dentry_s</a></li>
333</ul></li>
334</ul>
ef416fc2 335<!--
5a738aea 336 "$Id: api-filedir.shtml 7279 2008-01-31 01:50:44Z mike $"
ef416fc2 337
338 File and directory API introduction for the Common UNIX Printing System (CUPS).
339
5a738aea 340 Copyright 2007-2008 by Apple Inc.
bc44d920 341 Copyright 1997-2005 by Easy Software Products, all rights reserved.
ef416fc2 342
343 These coded instructions, statements, and computer programs are the
bc44d920 344 property of Apple Inc. and are protected by Federal copyright
345 law. Distribution and use rights are outlined in the file "LICENSE.txt"
346 which should have been included with this file. If this file is
347 file is missing or damaged, see the license at "http://www.cups.org/".
ef416fc2 348-->
349
5a738aea 350<h2 class='title'><a name="OVERVIEW">Overview</a></h2>
ef416fc2 351
352<p>The CUPS file and directory APIs provide portable interfaces
353for manipulating files and listing files and directories. Unlike
5a738aea 354stdio <code>FILE</code> streams, the <code>cupsFile</code> functions
ef416fc2 355allow you to open more than 256 files at any given time. They
356also manage the platform-specific details of locking, large file
357support, line endings (CR, LF, or CR LF), and reading and writing
358files using Flate ("gzip") compression. Finally, you can also
359connect, read from, and write to network connections using the
5a738aea 360<code>cupsFile</code> functions.</p>
ef416fc2 361
5a738aea 362<p>The <code>cupsDir</code> functions manage the platform-specific
ef416fc2 363details of directory access/listing and provide a convenient way
364to get both a list of files and the information (permissions,
365size, timestamp, etc.) for each of those files.</p>
5a738aea
MS
366<h2 class="title"><a name="FUNCTIONS">Functions</a></h2>
367<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsDirClose">cupsDirClose</a></h3>
368<p class="description">Close a directory.</p>
369<p class="code">
370void cupsDirClose (<br>
371&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dir_t">cups_dir_t</a> *dp<br>
372);</p>
373<h4 class="parameters">Parameters</h4>
374<dl>
375<dt>dp</dt>
376<dd class="description">Directory pointer</dd>
377</dl>
378<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsDirOpen">cupsDirOpen</a></h3>
379<p class="description">Open a directory.</p>
380<p class="code">
381<a href="#cups_dir_t">cups_dir_t</a> *cupsDirOpen (<br>
382&nbsp;&nbsp;&nbsp;&nbsp;const char *directory<br>
383);</p>
384<h4 class="parameters">Parameters</h4>
385<dl>
386<dt>directory</dt>
387<dd class="description">Directory name</dd>
388</dl>
389<h4 class="returnvalue">Return Value</h4>
390<p class="description">Directory pointer or <code>NULL</code> if the directory could not be opened.</p>
391<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsDirRead">cupsDirRead</a></h3>
392<p class="description">Read the next directory entry.</p>
393<p class="code">
394<a href="#cups_dentry_t">cups_dentry_t</a> *cupsDirRead (<br>
395&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dir_t">cups_dir_t</a> *dp<br>
396);</p>
397<h4 class="parameters">Parameters</h4>
398<dl>
399<dt>dp</dt>
400<dd class="description">Directory pointer</dd>
401</dl>
402<h4 class="returnvalue">Return Value</h4>
403<p class="description">Directory entry or <code>NULL</code> when there are no more</p>
404<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsDirRewind">cupsDirRewind</a></h3>
405<p class="description">Rewind to the start of the directory.</p>
406<p class="code">
407void cupsDirRewind (<br>
408&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dir_t">cups_dir_t</a> *dp<br>
409);</p>
410<h4 class="parameters">Parameters</h4>
411<dl>
412<dt>dp</dt>
413<dd class="description">Directory pointer</dd>
414</dl>
415<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileClose">cupsFileClose</a></h3>
416<p class="description">Close a CUPS file.</p>
417<p class="code">
418int cupsFileClose (<br>
419&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
420);</p>
421<h4 class="parameters">Parameters</h4>
422<dl>
423<dt>fp</dt>
424<dd class="description">CUPS file</dd>
425</dl>
426<h4 class="returnvalue">Return Value</h4>
427<p class="description">0 on success, -1 on error</p>
428<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileCompression">cupsFileCompression</a></h3>
429<p class="description">Return whether a file is compressed.</p>
430<p class="code">
431int cupsFileCompression (<br>
432&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
433);</p>
434<h4 class="parameters">Parameters</h4>
435<dl>
436<dt>fp</dt>
437<dd class="description">CUPS file</dd>
438</dl>
439<h4 class="returnvalue">Return Value</h4>
440<p class="description"><code>CUPS_FILE_NONE</code> or <code>CUPS_FILE_GZIP</code></p>
441<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileEOF">cupsFileEOF</a></h3>
442<p class="description">Return the end-of-file status.</p>
443<p class="code">
444int cupsFileEOF (<br>
445&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
446);</p>
447<h4 class="parameters">Parameters</h4>
448<dl>
449<dt>fp</dt>
450<dd class="description">CUPS file</dd>
451</dl>
452<h4 class="returnvalue">Return Value</h4>
453<p class="description">1 on end of file, 0 otherwise</p>
454<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileFind">cupsFileFind</a></h3>
455<p class="description">Find a file using the specified path.</p>
456<p class="code">
457const char *cupsFileFind (<br>
458&nbsp;&nbsp;&nbsp;&nbsp;const char *filename,<br>
459&nbsp;&nbsp;&nbsp;&nbsp;const char *path,<br>
460&nbsp;&nbsp;&nbsp;&nbsp;int executable,<br>
461&nbsp;&nbsp;&nbsp;&nbsp;char *buffer,<br>
462&nbsp;&nbsp;&nbsp;&nbsp;int bufsize<br>
463);</p>
464<h4 class="parameters">Parameters</h4>
465<dl>
466<dt>filename</dt>
467<dd class="description">File to find</dd>
468<dt>path</dt>
469<dd class="description">Colon/semicolon-separated path</dd>
470<dt>executable</dt>
471<dd class="description">1 = executable files, 0 = any file/dir</dd>
472<dt>buffer</dt>
473<dd class="description">Filename buffer</dd>
474<dt>bufsize</dt>
475<dd class="description">Size of filename buffer</dd>
476</dl>
477<h4 class="returnvalue">Return Value</h4>
478<p class="description">Full path to file or <code>NULL</code> if not found</p>
479<h4 class="discussion">Discussion</h4>
480<p class="discussion">This function allows the paths in the path string to be separated by
481colons (UNIX standard) or semicolons (Windows standard) and stores the
482result in the buffer supplied. If the file cannot be found in any of
483the supplied paths, <code>NULL</code> is returned. A <code>NULL</code> path only
484matches the current directory.
ef416fc2 485
5a738aea
MS
486</p>
487<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileFlush">cupsFileFlush</a></h3>
488<p class="description">Flush pending output.</p>
489<p class="code">
490int cupsFileFlush (<br>
491&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
492);</p>
493<h4 class="parameters">Parameters</h4>
494<dl>
495<dt>fp</dt>
496<dd class="description">CUPS file</dd>
497</dl>
498<h4 class="returnvalue">Return Value</h4>
499<p class="description">0 on success, -1 on error</p>
500<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileGetChar">cupsFileGetChar</a></h3>
501<p class="description">Get a single character from a file.</p>
502<p class="code">
503int cupsFileGetChar (<br>
504&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
505);</p>
506<h4 class="parameters">Parameters</h4>
507<dl>
508<dt>fp</dt>
509<dd class="description">CUPS file</dd>
510</dl>
511<h4 class="returnvalue">Return Value</h4>
512<p class="description">Character or -1 on end of file</p>
513<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileGetConf">cupsFileGetConf</a></h3>
514<p class="description">Get a line from a configuration file...</p>
515<p class="code">
516char *cupsFileGetConf (<br>
517&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
518&nbsp;&nbsp;&nbsp;&nbsp;char *buf,<br>
519&nbsp;&nbsp;&nbsp;&nbsp;size_t buflen,<br>
520&nbsp;&nbsp;&nbsp;&nbsp;char **value,<br>
521&nbsp;&nbsp;&nbsp;&nbsp;int *linenum<br>
522);</p>
523<h4 class="parameters">Parameters</h4>
524<dl>
525<dt>fp</dt>
526<dd class="description">CUPS file</dd>
527<dt>buf</dt>
528<dd class="description">String buffer</dd>
529<dt>buflen</dt>
530<dd class="description">Size of string buffer</dd>
531<dt>value</dt>
532<dd class="description">Pointer to value</dd>
533<dt>linenum</dt>
534<dd class="description">Current line number</dd>
535</dl>
536<h4 class="returnvalue">Return Value</h4>
537<p class="description">Line read or <code>NULL</code> on end of file or error</p>
538<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileGetLine">cupsFileGetLine</a></h3>
539<p class="description">Get a CR and/or LF-terminated line that may
540contain binary data.</p>
541<p class="code">
542size_t cupsFileGetLine (<br>
543&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
544&nbsp;&nbsp;&nbsp;&nbsp;char *buf,<br>
545&nbsp;&nbsp;&nbsp;&nbsp;size_t buflen<br>
546);</p>
547<h4 class="parameters">Parameters</h4>
548<dl>
549<dt>fp</dt>
550<dd class="description">File to read from</dd>
551<dt>buf</dt>
552<dd class="description">Buffer</dd>
553<dt>buflen</dt>
554<dd class="description">Size of buffer</dd>
555</dl>
556<h4 class="returnvalue">Return Value</h4>
557<p class="description">Number of bytes on line or 0 on end of file</p>
558<h4 class="discussion">Discussion</h4>
559<p class="discussion">This function differs from <a href="#cupsFileGets"><code>cupsFileGets</code></a> in that the trailing CR
560and LF are preserved, as is any binary data on the line. The buffer is
561nul-terminated, however you should use the returned length to determine
562the number of bytes on the line.
ef416fc2 563
5a738aea
MS
564</p>
565<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileGets">cupsFileGets</a></h3>
566<p class="description">Get a CR and/or LF-terminated line.</p>
567<p class="code">
568char *cupsFileGets (<br>
569&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
570&nbsp;&nbsp;&nbsp;&nbsp;char *buf,<br>
571&nbsp;&nbsp;&nbsp;&nbsp;size_t buflen<br>
572);</p>
573<h4 class="parameters">Parameters</h4>
574<dl>
575<dt>fp</dt>
576<dd class="description">CUPS file</dd>
577<dt>buf</dt>
578<dd class="description">String buffer</dd>
579<dt>buflen</dt>
580<dd class="description">Size of string buffer</dd>
581</dl>
582<h4 class="returnvalue">Return Value</h4>
583<p class="description">Line read or <code>NULL</code> on end of file or error</p>
584<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileLock">cupsFileLock</a></h3>
585<p class="description">Temporarily lock access to a file.</p>
586<p class="code">
587int cupsFileLock (<br>
588&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
589&nbsp;&nbsp;&nbsp;&nbsp;int block<br>
590);</p>
591<h4 class="parameters">Parameters</h4>
592<dl>
593<dt>fp</dt>
594<dd class="description">CUPS file</dd>
595<dt>block</dt>
596<dd class="description">1 to wait for the lock, 0 to fail right away</dd>
597</dl>
598<h4 class="returnvalue">Return Value</h4>
599<p class="description">0 on success, -1 on error</p>
600<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileNumber">cupsFileNumber</a></h3>
601<p class="description">Return the file descriptor associated with a CUPS file.</p>
602<p class="code">
603int cupsFileNumber (<br>
604&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
605);</p>
606<h4 class="parameters">Parameters</h4>
607<dl>
608<dt>fp</dt>
609<dd class="description">CUPS file</dd>
610</dl>
611<h4 class="returnvalue">Return Value</h4>
612<p class="description">File descriptor</p>
613<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileOpen">cupsFileOpen</a></h3>
614<p class="description">Open a CUPS file.</p>
615<p class="code">
616<a href="#cups_file_t">cups_file_t</a> *cupsFileOpen (<br>
617&nbsp;&nbsp;&nbsp;&nbsp;const char *filename,<br>
618&nbsp;&nbsp;&nbsp;&nbsp;const char *mode<br>
619);</p>
620<h4 class="parameters">Parameters</h4>
621<dl>
622<dt>filename</dt>
623<dd class="description">Name of file</dd>
624<dt>mode</dt>
625<dd class="description">Open mode</dd>
626</dl>
627<h4 class="returnvalue">Return Value</h4>
628<p class="description">CUPS file or <code>NULL</code> if the file or socket cannot be opened</p>
629<h4 class="discussion">Discussion</h4>
630<p class="discussion">The &quot;mode&quot; parameter can be &quot;r&quot; to read, &quot;w&quot; to write, overwriting any
631existing file, &quot;a&quot; to append to an existing file or create a new file,
632or &quot;s&quot; to open a socket connection.<br>
633<br>
634When opening for writing (&quot;w&quot;) or appending (&quot;a&quot;), an optional number from
6351 to 9 can be supplied which enables Flate compression of the file.<br>
636<br>
637When opening a socket connection, the filename is a string of the form
638&quot;address:port&quot; or &quot;hostname:port&quot;. The socket will make an IPv4 or IPv6
639connection as needed, generally preferring IPv6 connections when there is
640a choice.
ef416fc2 641
5a738aea
MS
642</p>
643<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileOpenFd">cupsFileOpenFd</a></h3>
644<p class="description">Open a CUPS file using a file descriptor.</p>
645<p class="code">
646<a href="#cups_file_t">cups_file_t</a> *cupsFileOpenFd (<br>
647&nbsp;&nbsp;&nbsp;&nbsp;int fd,<br>
648&nbsp;&nbsp;&nbsp;&nbsp;const char *mode<br>
649);</p>
650<h4 class="parameters">Parameters</h4>
651<dl>
652<dt>fd</dt>
653<dd class="description">File descriptor</dd>
654<dt>mode</dt>
655<dd class="description">Open mode</dd>
656</dl>
657<h4 class="returnvalue">Return Value</h4>
658<p class="description">CUPS file or <code>NULL</code> if the file could not be opened</p>
659<h4 class="discussion">Discussion</h4>
660<p class="discussion">The &quot;mode&quot; parameter can be &quot;r&quot; to read, &quot;a&quot; or &quot;w&quot; to write, or &quot;s&quot;
661to treat the file descriptor as a bidirectional socket connection.<br>
662<br>
663When opening for writing (&quot;w&quot;) or appending (&quot;a&quot;), an optional number from
6641 to 9 can be supplied which enables Flate compression of the file.
ef416fc2 665
5a738aea
MS
666</p>
667<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFilePeekChar">cupsFilePeekChar</a></h3>
668<p class="description">Peek at the next character from a file.</p>
669<p class="code">
670int cupsFilePeekChar (<br>
671&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
672);</p>
673<h4 class="parameters">Parameters</h4>
674<dl>
675<dt>fp</dt>
676<dd class="description">CUPS file</dd>
677</dl>
678<h4 class="returnvalue">Return Value</h4>
679<p class="description">Character or -1 on end of file</p>
680<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFilePrintf">cupsFilePrintf</a></h3>
681<p class="description">Write a formatted string.</p>
682<p class="code">
683int cupsFilePrintf (<br>
684&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
685&nbsp;&nbsp;&nbsp;&nbsp;const char *format,<br>
686&nbsp;&nbsp;&nbsp;&nbsp;...<br>
687);</p>
688<h4 class="parameters">Parameters</h4>
689<dl>
690<dt>fp</dt>
691<dd class="description">CUPS file</dd>
692<dt>format</dt>
693<dd class="description">Printf-style format string</dd>
694<dt>...</dt>
695<dd class="description">Additional args as necessary</dd>
696</dl>
697<h4 class="returnvalue">Return Value</h4>
698<p class="description">Number of bytes written or -1 on error</p>
699<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFilePutChar">cupsFilePutChar</a></h3>
700<p class="description">Write a character.</p>
701<p class="code">
702int cupsFilePutChar (<br>
703&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
704&nbsp;&nbsp;&nbsp;&nbsp;int c<br>
705);</p>
706<h4 class="parameters">Parameters</h4>
707<dl>
708<dt>fp</dt>
709<dd class="description">CUPS file</dd>
710<dt>c</dt>
711<dd class="description">Character to write</dd>
712</dl>
713<h4 class="returnvalue">Return Value</h4>
714<p class="description">0 on success, -1 on error</p>
715<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFilePuts">cupsFilePuts</a></h3>
716<p class="description">Write a string.</p>
717<p class="code">
718int cupsFilePuts (<br>
719&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
720&nbsp;&nbsp;&nbsp;&nbsp;const char *s<br>
721);</p>
722<h4 class="parameters">Parameters</h4>
723<dl>
724<dt>fp</dt>
725<dd class="description">CUPS file</dd>
726<dt>s</dt>
727<dd class="description">String to write</dd>
728</dl>
729<h4 class="returnvalue">Return Value</h4>
730<p class="description">Number of bytes written or -1 on error</p>
731<h4 class="discussion">Discussion</h4>
732<p class="discussion">Like the <code>fputs</code> function, no newline is appended to the string.
ef416fc2 733
5a738aea
MS
734</p>
735<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileRead">cupsFileRead</a></h3>
736<p class="description">Read from a file.</p>
737<p class="code">
738ssize_t cupsFileRead (<br>
739&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
740&nbsp;&nbsp;&nbsp;&nbsp;char *buf,<br>
741&nbsp;&nbsp;&nbsp;&nbsp;size_t bytes<br>
742);</p>
743<h4 class="parameters">Parameters</h4>
744<dl>
745<dt>fp</dt>
746<dd class="description">CUPS file</dd>
747<dt>buf</dt>
748<dd class="description">Buffer</dd>
749<dt>bytes</dt>
750<dd class="description">Number of bytes to read</dd>
751</dl>
752<h4 class="returnvalue">Return Value</h4>
753<p class="description">Number of bytes read or -1 on error</p>
754<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileRewind">cupsFileRewind</a></h3>
755<p class="description">Set the current file position to the beginning of the
756file.</p>
757<p class="code">
758off_t cupsFileRewind (<br>
759&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
760);</p>
761<h4 class="parameters">Parameters</h4>
762<dl>
763<dt>fp</dt>
764<dd class="description">CUPS file</dd>
765</dl>
766<h4 class="returnvalue">Return Value</h4>
767<p class="description">New file position or -1 on error</p>
768<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileSeek">cupsFileSeek</a></h3>
769<p class="description">Seek in a file.</p>
770<p class="code">
771off_t cupsFileSeek (<br>
772&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
773&nbsp;&nbsp;&nbsp;&nbsp;off_t pos<br>
774);</p>
775<h4 class="parameters">Parameters</h4>
776<dl>
777<dt>fp</dt>
778<dd class="description">CUPS file</dd>
779<dt>pos</dt>
780<dd class="description">Position in file</dd>
781</dl>
782<h4 class="returnvalue">Return Value</h4>
783<p class="description">New file position or -1 on error</p>
784<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileStderr">cupsFileStderr</a></h3>
785<p class="description">Return a CUPS file associated with stderr.</p>
786<p class="code">
787<a href="#cups_file_t">cups_file_t</a> *cupsFileStderr (void);</p>
788<h4 class="returnvalue">Return Value</h4>
789<p class="description">CUPS file</p>
790<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileStdin">cupsFileStdin</a></h3>
791<p class="description">Return a CUPS file associated with stdin.</p>
792<p class="code">
793<a href="#cups_file_t">cups_file_t</a> *cupsFileStdin (void);</p>
794<h4 class="returnvalue">Return Value</h4>
795<p class="description">CUPS file</p>
796<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileStdout">cupsFileStdout</a></h3>
797<p class="description">Return a CUPS file associated with stdout.</p>
798<p class="code">
799<a href="#cups_file_t">cups_file_t</a> *cupsFileStdout (void);</p>
800<h4 class="returnvalue">Return Value</h4>
801<p class="description">CUPS file</p>
802<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileTell">cupsFileTell</a></h3>
803<p class="description">Return the current file position.</p>
804<p class="code">
805off_t cupsFileTell (<br>
806&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
807);</p>
808<h4 class="parameters">Parameters</h4>
809<dl>
810<dt>fp</dt>
811<dd class="description">CUPS file</dd>
812</dl>
813<h4 class="returnvalue">Return Value</h4>
814<p class="description">File position</p>
815<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileUnlock">cupsFileUnlock</a></h3>
816<p class="description">Unlock access to a file.</p>
817<p class="code">
818int cupsFileUnlock (<br>
819&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
820);</p>
821<h4 class="parameters">Parameters</h4>
822<dl>
823<dt>fp</dt>
824<dd class="description">CUPS file</dd>
825</dl>
826<h4 class="returnvalue">Return Value</h4>
827<p class="description">0 on success, -1 on error</p>
828<h3 class="function"><span class="info">&nbsp;CUPS 1.2&nbsp;</span><a name="cupsFileWrite">cupsFileWrite</a></h3>
829<p class="description">Write to a file.</p>
830<p class="code">
831ssize_t cupsFileWrite (<br>
832&nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
833&nbsp;&nbsp;&nbsp;&nbsp;const char *buf,<br>
834&nbsp;&nbsp;&nbsp;&nbsp;size_t bytes<br>
835);</p>
836<h4 class="parameters">Parameters</h4>
837<dl>
838<dt>fp</dt>
839<dd class="description">CUPS file</dd>
840<dt>buf</dt>
841<dd class="description">Buffer</dd>
842<dt>bytes</dt>
843<dd class="description">Number of bytes to write</dd>
844</dl>
845<h4 class="returnvalue">Return Value</h4>
846<p class="description">Number of bytes written or -1 on error</p>
847<h2 class="title"><a name="TYPES">Data Types</a></h2>
848<h3 class="typedef"><a name="cups_dentry_t">cups_dentry_t</a></h3>
849<p class="description">Directory entry type</p>
850<p class="code">
851typedef struct <a href="#cups_dentry_s">cups_dentry_s</a> cups_dentry_t;
852</p>
853<h3 class="typedef"><a name="cups_dir_t">cups_dir_t</a></h3>
854<p class="description">Directory type</p>
855<p class="code">
ef416fc2 856typedef struct _cups_dir_s cups_dir_t;
5a738aea
MS
857</p>
858<h3 class="typedef"><a name="cups_file_t">cups_file_t</a></h3>
859<p class="description">CUPS file type</p>
860<p class="code">
ef416fc2 861typedef struct _cups_file_s cups_file_t;
5a738aea
MS
862</p>
863<h2 class="title"><a name="STRUCTURES">Structures</a></h2>
864<h3 class="struct"><a name="cups_dentry_s">cups_dentry_s</a></h3>
865<p class="description">Directory entry type</p>
866<p class="code">struct cups_dentry_s {<br>
867&nbsp;&nbsp;&nbsp;&nbsp;struct stat fileinfo;<br>
868&nbsp;&nbsp;&nbsp;&nbsp;char filename[260];<br>
869};</p>
870<h4 class="members">Members</h4>
871<dl>
872<dt>fileinfo </dt>
873<dd class="description">File information</dd>
874<dt>filename[260] </dt>
875<dd class="description">File name</dd>
876</dl>
877</div>
ef416fc2 878</body>
879</html>