]> git.ipfire.org Git - thirdparty/cups.git/blob - doc/help/api-filedir.html
Remove all of the Subversion keywords from various source files.
[thirdparty/cups.git] / doc / help / api-filedir.html
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>File and Directory APIs </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.7">
9 <style type="text/css"><!--
10 BODY {
11 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
12 }
13
14 H1, H2, H3, H4, H5, H6, P, TD, TH {
15 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
16 }
17
18 KBD {
19 font-family: monaco, courier, monospace;
20 font-weight: bold;
21 }
22
23 PRE {
24 font-family: monaco, courier, monospace;
25 }
26
27 PRE.command {
28 border: dotted thin #7f7f7f;
29 margin-left: 36pt;
30 padding: 10px;
31 }
32
33 P.compact {
34 margin: 0;
35 }
36
37 P.example {
38 font-style: italic;
39 margin-left: 36pt;
40 }
41
42 DL.man DD {
43 margin-left: 5em;
44 }
45
46 DL.man DT {
47 margin-left: 0;
48 }
49
50 PRE.man {
51 margin: 0;
52 }
53
54 PRE.example {
55 background: #eeeeee;
56 border: dotted thin #999999;
57 margin-left: 36pt;
58 padding: 10pt;
59 }
60
61 PRE.command EM, PRE.example EM {
62 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
63 }
64
65 P.command {
66 font-family: monaco, courier, monospace;
67 margin-left: 36pt;
68 }
69
70 P.formula {
71 font-style: italic;
72 margin-left: 36pt;
73 }
74
75 BLOCKQUOTE {
76 background: #eeeeee;
77 border: solid thin #999999;
78 padding: 10pt;
79 }
80
81 A IMG {
82 border: none;
83 }
84
85 A:link:hover IMG {
86 background: #f0f0f0;
87 border-radius: 10px;
88 -moz-border-radius: 10px;
89 }
90
91 A:link, A:visited {
92 font-weight: inherit;
93 text-decoration: none;
94 }
95
96 A:link:hover, A:visited:hover, A:active {
97 text-decoration: underline;
98 }
99
100 SUB, SUP {
101 font-size: 50%;
102 }
103
104 TR.data, TD.data, TR.data TD {
105 margin-top: 10pt;
106 padding: 5pt;
107 border-bottom: solid 1pt #999999;
108 }
109
110 TR.data TH {
111 border-bottom: solid 1pt #999999;
112 padding-top: 10pt;
113 padding-left: 5pt;
114 text-align: left;
115 }
116
117 DIV.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
125 DIV.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
134 DIV.table TABLE TD {
135 border: solid thin #cccccc;
136 padding-top: 5pt;
137 }
138
139 DIV.table TABLE TH {
140 background: #cccccc;
141 border: none;
142 border-bottom: solid thin #999999;
143 }
144
145 DIV.figure TABLE {
146 margin-left: auto;
147 margin-right: auto;
148 }
149
150 DIV.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
159 TH.label {
160 text-align: right;
161 vertical-align: top;
162 }
163
164 TH.sublabel {
165 text-align: right;
166 font-weight: normal;
167 }
168
169 HR {
170 border: solid thin;
171 }
172
173 SPAN.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
183 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
184 float: right;
185 font-size: 100%;
186 }
187
188 H1.title {
189 }
190
191 H2.title, H3.title {
192 border-bottom: solid 2pt #000000;
193 }
194
195 DIV.indent, TABLE.indent {
196 margin-top: 2em;
197 margin-left: auto;
198 margin-right: auto;
199 width: 90%;
200 }
201
202 TABLE.indent {
203 border-collapse: collapse;
204 }
205
206 TABLE.indent TD, TABLE.indent TH {
207 padding: 0;
208 }
209
210 TABLE.list {
211 border-collapse: collapse;
212 margin-left: auto;
213 margin-right: auto;
214 width: 90%;
215 }
216
217 TABLE.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
228 TABLE.list TH A {
229 color: #4444cc;
230 }
231
232 TABLE.list TD {
233 border-bottom: solid thin #eeeeee;
234 padding-top: 5pt;
235 padding-left: 5pt;
236 }
237
238 TABLE.list TR:nth-child(even) {
239 background: #f8f8f8;
240 }
241
242 TABLE.list TR:nth-child(odd) {
243 background: #f4f4f4;
244 }
245
246 DT {
247 margin-left: 36pt;
248 margin-top: 12pt;
249 }
250
251 DD {
252 margin-left: 54pt;
253 }
254
255 DL.category DT {
256 font-weight: bold;
257 }
258
259 P.summary {
260 margin-left: 36pt;
261 font-family: monaco, courier, monospace;
262 }
263
264 DIV.summary TABLE {
265 border: solid thin #999999;
266 border-collapse: collapse;
267 border-spacing: 0;
268 margin: 10px;
269 }
270
271 DIV.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
278 DIV.summary TABLE THEAD TH {
279 background: #eeeeee;
280 }
281
282 /* API documentation styles... */
283 div.body h1 {
284 margin: 0;
285 }
286 div.body h2 {
287 margin-top: 1.5em;
288 }
289 div.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 }
301 code, p.code, pre, ul.code li {
302 font-family: monaco, courier, monospace;
303 font-size: 90%;
304 }
305 ul.code, ul.contents, ul.subcontents {
306 list-style-type: none;
307 margin: 0;
308 padding-left: 0;
309 }
310 ul.code li {
311 margin: 0;
312 }
313 ul.contents > li {
314 margin-top: 1em;
315 }
316 ul.contents li ul.code, ul.contents li ul.subcontents {
317 padding-left: 2em;
318 }
319 div.body dl {
320 margin-left: 0;
321 margin-top: 0;
322 }
323 div.body dt {
324 font-style: italic;
325 margin-left: 0;
326 margin-top: 0;
327 }
328 div.body dd {
329 margin-bottom: 0.5em;
330 }
331
332 /* This is just for the HTML files generated with the framedhelp target */
333 div.contents {
334 background: #e8e8e8;
335 border: solid thin black;
336 padding: 10px;
337 }
338 div.contents h1 {
339 font-size: 110%;
340 }
341 div.contents h2 {
342 font-size: 100%;
343 }
344 div.contents ul.contents {
345 font-size: 80%;
346 }
347 div.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 File and Directory API header for CUPS.
357
358 Copyright 2008-2011 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'>File and Directory APIs</h1>
368
369 <div class='summary'><table summary='General Information'>
370 <thead>
371 <tr>
372 <th>Headers</th>
373 <th>cups/file.h<br>
374 cups/dir.h</th>
375 </tr>
376 </thead>
377 <tbody>
378 <tr>
379 <th>Library</th>
380 <td>-lcups</td>
381 </tr>
382 <tr>
383 <th>See Also</th>
384 <td>Programming: <a href='api-overview.html' target='_top'>Introduction to CUPS Programming</a><br>
385 Programming: <a href='api-cups.html' target='_top'>CUPS API</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></li>
392 <li><a href="#FUNCTIONS">Functions</a><ul class="code">
393 <li><a href="#cupsDirClose" title="Close a directory.">cupsDirClose</a></li>
394 <li><a href="#cupsDirOpen" title="Open a directory.">cupsDirOpen</a></li>
395 <li><a href="#cupsDirRead" title="Read the next directory entry.">cupsDirRead</a></li>
396 <li><a href="#cupsDirRewind" title="Rewind to the start of the directory.">cupsDirRewind</a></li>
397 <li><a href="#cupsFileClose" title="Close a CUPS file.">cupsFileClose</a></li>
398 <li><a href="#cupsFileCompression" title="Return whether a file is compressed.">cupsFileCompression</a></li>
399 <li><a href="#cupsFileEOF" title="Return the end-of-file status.">cupsFileEOF</a></li>
400 <li><a href="#cupsFileFind" title="Find a file using the specified path.">cupsFileFind</a></li>
401 <li><a href="#cupsFileFlush" title="Flush pending output.">cupsFileFlush</a></li>
402 <li><a href="#cupsFileGetChar" title="Get a single character from a file.">cupsFileGetChar</a></li>
403 <li><a href="#cupsFileGetConf" title="Get a line from a configuration file.">cupsFileGetConf</a></li>
404 <li><a href="#cupsFileGetLine" title="Get a CR and/or LF-terminated line that may
405 contain binary data.">cupsFileGetLine</a></li>
406 <li><a href="#cupsFileGets" title="Get a CR and/or LF-terminated line.">cupsFileGets</a></li>
407 <li><a href="#cupsFileLock" title="Temporarily lock access to a file.">cupsFileLock</a></li>
408 <li><a href="#cupsFileNumber" title="Return the file descriptor associated with a CUPS file.">cupsFileNumber</a></li>
409 <li><a href="#cupsFileOpen" title="Open a CUPS file.">cupsFileOpen</a></li>
410 <li><a href="#cupsFileOpenFd" title="Open a CUPS file using a file descriptor.">cupsFileOpenFd</a></li>
411 <li><a href="#cupsFilePeekChar" title="Peek at the next character from a file.">cupsFilePeekChar</a></li>
412 <li><a href="#cupsFilePrintf" title="Write a formatted string.">cupsFilePrintf</a></li>
413 <li><a href="#cupsFilePutChar" title="Write a character.">cupsFilePutChar</a></li>
414 <li><a href="#cupsFilePutConf" title="Write a configuration line.">cupsFilePutConf</a></li>
415 <li><a href="#cupsFilePuts" title="Write a string.">cupsFilePuts</a></li>
416 <li><a href="#cupsFileRead" title="Read from a file.">cupsFileRead</a></li>
417 <li><a href="#cupsFileRewind" title="Set the current file position to the beginning of the
418 file.">cupsFileRewind</a></li>
419 <li><a href="#cupsFileSeek" title="Seek in a file.">cupsFileSeek</a></li>
420 <li><a href="#cupsFileStderr" title="Return a CUPS file associated with stderr.">cupsFileStderr</a></li>
421 <li><a href="#cupsFileStdin" title="Return a CUPS file associated with stdin.">cupsFileStdin</a></li>
422 <li><a href="#cupsFileStdout" title="Return a CUPS file associated with stdout.">cupsFileStdout</a></li>
423 <li><a href="#cupsFileTell" title="Return the current file position.">cupsFileTell</a></li>
424 <li><a href="#cupsFileUnlock" title="Unlock access to a file.">cupsFileUnlock</a></li>
425 <li><a href="#cupsFileWrite" title="Write to a file.">cupsFileWrite</a></li>
426 </ul></li>
427 <li><a href="#TYPES">Data Types</a><ul class="code">
428 <li><a href="#cups_dentry_t" title="Directory entry type">cups_dentry_t</a></li>
429 <li><a href="#cups_dir_t" title="Directory type">cups_dir_t</a></li>
430 <li><a href="#cups_file_t" title="CUPS file type">cups_file_t</a></li>
431 </ul></li>
432 <li><a href="#STRUCTURES">Structures</a><ul class="code">
433 <li><a href="#cups_dentry_s" title="Directory entry type">cups_dentry_s</a></li>
434 </ul></li>
435 </ul>
436 <!--
437 File and directory API introduction for CUPS.
438
439 Copyright 2007-2011 by Apple Inc.
440 Copyright 1997-2005 by Easy Software Products, all rights reserved.
441
442 These coded instructions, statements, and computer programs are the
443 property of Apple Inc. and are protected by Federal copyright
444 law. Distribution and use rights are outlined in the file "LICENSE.txt"
445 which should have been included with this file. If this file is
446 file is missing or damaged, see the license at "http://www.cups.org/".
447 -->
448
449 <h2 class='title'><a name="OVERVIEW">Overview</a></h2>
450
451 <p>The CUPS file and directory APIs provide portable interfaces
452 for manipulating files and listing files and directories. Unlike
453 stdio <code>FILE</code> streams, the <code>cupsFile</code> functions
454 allow you to open more than 256 files at any given time. They
455 also manage the platform-specific details of locking, large file
456 support, line endings (CR, LF, or CR LF), and reading and writing
457 files using Flate ("gzip") compression. Finally, you can also
458 connect, read from, and write to network connections using the
459 <code>cupsFile</code> functions.</p>
460
461 <p>The <code>cupsDir</code> functions manage the platform-specific
462 details of directory access/listing and provide a convenient way
463 to get both a list of files and the information (permissions,
464 size, timestamp, etc.) for each of those files.</p>
465 <h2 class="title"><a name="FUNCTIONS">Functions</a></h2>
466 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsDirClose">cupsDirClose</a></h3>
467 <p class="description">Close a directory.</p>
468 <p class="code">
469 void cupsDirClose (<br>
470 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dir_t">cups_dir_t</a> *dp<br>
471 );</p>
472 <h4 class="parameters">Parameters</h4>
473 <dl>
474 <dt>dp</dt>
475 <dd class="description">Directory pointer</dd>
476 </dl>
477 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsDirOpen">cupsDirOpen</a></h3>
478 <p class="description">Open a directory.</p>
479 <p class="code">
480 <a href="#cups_dir_t">cups_dir_t</a> *cupsDirOpen (<br>
481 &nbsp;&nbsp;&nbsp;&nbsp;const char *directory<br>
482 );</p>
483 <h4 class="parameters">Parameters</h4>
484 <dl>
485 <dt>directory</dt>
486 <dd class="description">Directory name</dd>
487 </dl>
488 <h4 class="returnvalue">Return Value</h4>
489 <p class="description">Directory pointer or <code>NULL</code> if the directory could not be opened.</p>
490 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsDirRead">cupsDirRead</a></h3>
491 <p class="description">Read the next directory entry.</p>
492 <p class="code">
493 <a href="#cups_dentry_t">cups_dentry_t</a> *cupsDirRead (<br>
494 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dir_t">cups_dir_t</a> *dp<br>
495 );</p>
496 <h4 class="parameters">Parameters</h4>
497 <dl>
498 <dt>dp</dt>
499 <dd class="description">Directory pointer</dd>
500 </dl>
501 <h4 class="returnvalue">Return Value</h4>
502 <p class="description">Directory entry or <code>NULL</code> when there are no more</p>
503 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsDirRewind">cupsDirRewind</a></h3>
504 <p class="description">Rewind to the start of the directory.</p>
505 <p class="code">
506 void cupsDirRewind (<br>
507 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_dir_t">cups_dir_t</a> *dp<br>
508 );</p>
509 <h4 class="parameters">Parameters</h4>
510 <dl>
511 <dt>dp</dt>
512 <dd class="description">Directory pointer</dd>
513 </dl>
514 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileClose">cupsFileClose</a></h3>
515 <p class="description">Close a CUPS file.</p>
516 <p class="code">
517 int cupsFileClose (<br>
518 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
519 );</p>
520 <h4 class="parameters">Parameters</h4>
521 <dl>
522 <dt>fp</dt>
523 <dd class="description">CUPS file</dd>
524 </dl>
525 <h4 class="returnvalue">Return Value</h4>
526 <p class="description">0 on success, -1 on error</p>
527 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileCompression">cupsFileCompression</a></h3>
528 <p class="description">Return whether a file is compressed.</p>
529 <p class="code">
530 int cupsFileCompression (<br>
531 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
532 );</p>
533 <h4 class="parameters">Parameters</h4>
534 <dl>
535 <dt>fp</dt>
536 <dd class="description">CUPS file</dd>
537 </dl>
538 <h4 class="returnvalue">Return Value</h4>
539 <p class="description"><code>CUPS_FILE_NONE</code> or <code>CUPS_FILE_GZIP</code></p>
540 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileEOF">cupsFileEOF</a></h3>
541 <p class="description">Return the end-of-file status.</p>
542 <p class="code">
543 int cupsFileEOF (<br>
544 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
545 );</p>
546 <h4 class="parameters">Parameters</h4>
547 <dl>
548 <dt>fp</dt>
549 <dd class="description">CUPS file</dd>
550 </dl>
551 <h4 class="returnvalue">Return Value</h4>
552 <p class="description">1 on end of file, 0 otherwise</p>
553 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileFind">cupsFileFind</a></h3>
554 <p class="description">Find a file using the specified path.</p>
555 <p class="code">
556 const char *cupsFileFind (<br>
557 &nbsp;&nbsp;&nbsp;&nbsp;const char *filename,<br>
558 &nbsp;&nbsp;&nbsp;&nbsp;const char *path,<br>
559 &nbsp;&nbsp;&nbsp;&nbsp;int executable,<br>
560 &nbsp;&nbsp;&nbsp;&nbsp;char *buffer,<br>
561 &nbsp;&nbsp;&nbsp;&nbsp;int bufsize<br>
562 );</p>
563 <h4 class="parameters">Parameters</h4>
564 <dl>
565 <dt>filename</dt>
566 <dd class="description">File to find</dd>
567 <dt>path</dt>
568 <dd class="description">Colon/semicolon-separated path</dd>
569 <dt>executable</dt>
570 <dd class="description">1 = executable files, 0 = any file/dir</dd>
571 <dt>buffer</dt>
572 <dd class="description">Filename buffer</dd>
573 <dt>bufsize</dt>
574 <dd class="description">Size of filename buffer</dd>
575 </dl>
576 <h4 class="returnvalue">Return Value</h4>
577 <p class="description">Full path to file or <code>NULL</code> if not found</p>
578 <h4 class="discussion">Discussion</h4>
579 <p class="discussion">This function allows the paths in the path string to be separated by
580 colons (UNIX standard) or semicolons (Windows standard) and stores the
581 result in the buffer supplied. If the file cannot be found in any of
582 the supplied paths, <code>NULL</code> is returned. A <code>NULL</code> path only
583 matches the current directory.
584
585 </p>
586 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileFlush">cupsFileFlush</a></h3>
587 <p class="description">Flush pending output.</p>
588 <p class="code">
589 int cupsFileFlush (<br>
590 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
591 );</p>
592 <h4 class="parameters">Parameters</h4>
593 <dl>
594 <dt>fp</dt>
595 <dd class="description">CUPS file</dd>
596 </dl>
597 <h4 class="returnvalue">Return Value</h4>
598 <p class="description">0 on success, -1 on error</p>
599 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileGetChar">cupsFileGetChar</a></h3>
600 <p class="description">Get a single character from a file.</p>
601 <p class="code">
602 int cupsFileGetChar (<br>
603 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
604 );</p>
605 <h4 class="parameters">Parameters</h4>
606 <dl>
607 <dt>fp</dt>
608 <dd class="description">CUPS file</dd>
609 </dl>
610 <h4 class="returnvalue">Return Value</h4>
611 <p class="description">Character or -1 on end of file</p>
612 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileGetConf">cupsFileGetConf</a></h3>
613 <p class="description">Get a line from a configuration file.</p>
614 <p class="code">
615 char *cupsFileGetConf (<br>
616 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
617 &nbsp;&nbsp;&nbsp;&nbsp;char *buf,<br>
618 &nbsp;&nbsp;&nbsp;&nbsp;size_t buflen,<br>
619 &nbsp;&nbsp;&nbsp;&nbsp;char **value,<br>
620 &nbsp;&nbsp;&nbsp;&nbsp;int *linenum<br>
621 );</p>
622 <h4 class="parameters">Parameters</h4>
623 <dl>
624 <dt>fp</dt>
625 <dd class="description">CUPS file</dd>
626 <dt>buf</dt>
627 <dd class="description">String buffer</dd>
628 <dt>buflen</dt>
629 <dd class="description">Size of string buffer</dd>
630 <dt>value</dt>
631 <dd class="description">Pointer to value</dd>
632 <dt>linenum</dt>
633 <dd class="description">Current line number</dd>
634 </dl>
635 <h4 class="returnvalue">Return Value</h4>
636 <p class="description">Line read or <code>NULL</code> on end of file or error</p>
637 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileGetLine">cupsFileGetLine</a></h3>
638 <p class="description">Get a CR and/or LF-terminated line that may
639 contain binary data.</p>
640 <p class="code">
641 size_t cupsFileGetLine (<br>
642 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
643 &nbsp;&nbsp;&nbsp;&nbsp;char *buf,<br>
644 &nbsp;&nbsp;&nbsp;&nbsp;size_t buflen<br>
645 );</p>
646 <h4 class="parameters">Parameters</h4>
647 <dl>
648 <dt>fp</dt>
649 <dd class="description">File to read from</dd>
650 <dt>buf</dt>
651 <dd class="description">Buffer</dd>
652 <dt>buflen</dt>
653 <dd class="description">Size of buffer</dd>
654 </dl>
655 <h4 class="returnvalue">Return Value</h4>
656 <p class="description">Number of bytes on line or 0 on end of file</p>
657 <h4 class="discussion">Discussion</h4>
658 <p class="discussion">This function differs from <a href="#cupsFileGets"><code>cupsFileGets</code></a> in that the trailing CR
659 and LF are preserved, as is any binary data on the line. The buffer is
660 nul-terminated, however you should use the returned length to determine
661 the number of bytes on the line.
662
663 </p>
664 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileGets">cupsFileGets</a></h3>
665 <p class="description">Get a CR and/or LF-terminated line.</p>
666 <p class="code">
667 char *cupsFileGets (<br>
668 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
669 &nbsp;&nbsp;&nbsp;&nbsp;char *buf,<br>
670 &nbsp;&nbsp;&nbsp;&nbsp;size_t buflen<br>
671 );</p>
672 <h4 class="parameters">Parameters</h4>
673 <dl>
674 <dt>fp</dt>
675 <dd class="description">CUPS file</dd>
676 <dt>buf</dt>
677 <dd class="description">String buffer</dd>
678 <dt>buflen</dt>
679 <dd class="description">Size of string buffer</dd>
680 </dl>
681 <h4 class="returnvalue">Return Value</h4>
682 <p class="description">Line read or <code>NULL</code> on end of file or error</p>
683 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileLock">cupsFileLock</a></h3>
684 <p class="description">Temporarily lock access to a file.</p>
685 <p class="code">
686 int cupsFileLock (<br>
687 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
688 &nbsp;&nbsp;&nbsp;&nbsp;int block<br>
689 );</p>
690 <h4 class="parameters">Parameters</h4>
691 <dl>
692 <dt>fp</dt>
693 <dd class="description">CUPS file</dd>
694 <dt>block</dt>
695 <dd class="description">1 to wait for the lock, 0 to fail right away</dd>
696 </dl>
697 <h4 class="returnvalue">Return Value</h4>
698 <p class="description">0 on success, -1 on error</p>
699 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileNumber">cupsFileNumber</a></h3>
700 <p class="description">Return the file descriptor associated with a CUPS file.</p>
701 <p class="code">
702 int cupsFileNumber (<br>
703 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
704 );</p>
705 <h4 class="parameters">Parameters</h4>
706 <dl>
707 <dt>fp</dt>
708 <dd class="description">CUPS file</dd>
709 </dl>
710 <h4 class="returnvalue">Return Value</h4>
711 <p class="description">File descriptor</p>
712 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileOpen">cupsFileOpen</a></h3>
713 <p class="description">Open a CUPS file.</p>
714 <p class="code">
715 <a href="#cups_file_t">cups_file_t</a> *cupsFileOpen (<br>
716 &nbsp;&nbsp;&nbsp;&nbsp;const char *filename,<br>
717 &nbsp;&nbsp;&nbsp;&nbsp;const char *mode<br>
718 );</p>
719 <h4 class="parameters">Parameters</h4>
720 <dl>
721 <dt>filename</dt>
722 <dd class="description">Name of file</dd>
723 <dt>mode</dt>
724 <dd class="description">Open mode</dd>
725 </dl>
726 <h4 class="returnvalue">Return Value</h4>
727 <p class="description">CUPS file or <code>NULL</code> if the file or socket cannot be opened</p>
728 <h4 class="discussion">Discussion</h4>
729 <p class="discussion">The &quot;mode&quot; parameter can be &quot;r&quot; to read, &quot;w&quot; to write, overwriting any
730 existing file, &quot;a&quot; to append to an existing file or create a new file,
731 or &quot;s&quot; to open a socket connection.<br>
732 <br>
733 When opening for writing (&quot;w&quot;), an optional number from 1 to 9 can be
734 supplied which enables Flate compression of the file. Compression is
735 not supported for the &quot;a&quot; (append) mode.<br>
736 <br>
737 When opening a socket connection, the filename is a string of the form
738 &quot;address:port&quot; or &quot;hostname:port&quot;. The socket will make an IPv4 or IPv6
739 connection as needed, generally preferring IPv6 connections when there is
740 a choice.
741
742 </p>
743 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileOpenFd">cupsFileOpenFd</a></h3>
744 <p class="description">Open a CUPS file using a file descriptor.</p>
745 <p class="code">
746 <a href="#cups_file_t">cups_file_t</a> *cupsFileOpenFd (<br>
747 &nbsp;&nbsp;&nbsp;&nbsp;int fd,<br>
748 &nbsp;&nbsp;&nbsp;&nbsp;const char *mode<br>
749 );</p>
750 <h4 class="parameters">Parameters</h4>
751 <dl>
752 <dt>fd</dt>
753 <dd class="description">File descriptor</dd>
754 <dt>mode</dt>
755 <dd class="description">Open mode</dd>
756 </dl>
757 <h4 class="returnvalue">Return Value</h4>
758 <p class="description">CUPS file or <code>NULL</code> if the file could not be opened</p>
759 <h4 class="discussion">Discussion</h4>
760 <p class="discussion">The &quot;mode&quot; parameter can be &quot;r&quot; to read, &quot;w&quot; to write, &quot;a&quot; to append,
761 or &quot;s&quot; to treat the file descriptor as a bidirectional socket connection.<br>
762 <br>
763 When opening for writing (&quot;w&quot;), an optional number from 1 to 9 can be
764 supplied which enables Flate compression of the file. Compression is
765 not supported for the &quot;a&quot; (append) mode.
766
767 </p>
768 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFilePeekChar">cupsFilePeekChar</a></h3>
769 <p class="description">Peek at the next character from a file.</p>
770 <p class="code">
771 int cupsFilePeekChar (<br>
772 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
773 );</p>
774 <h4 class="parameters">Parameters</h4>
775 <dl>
776 <dt>fp</dt>
777 <dd class="description">CUPS file</dd>
778 </dl>
779 <h4 class="returnvalue">Return Value</h4>
780 <p class="description">Character or -1 on end of file</p>
781 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFilePrintf">cupsFilePrintf</a></h3>
782 <p class="description">Write a formatted string.</p>
783 <p class="code">
784 int cupsFilePrintf (<br>
785 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
786 &nbsp;&nbsp;&nbsp;&nbsp;const char *format,<br>
787 &nbsp;&nbsp;&nbsp;&nbsp;...<br>
788 );</p>
789 <h4 class="parameters">Parameters</h4>
790 <dl>
791 <dt>fp</dt>
792 <dd class="description">CUPS file</dd>
793 <dt>format</dt>
794 <dd class="description">Printf-style format string</dd>
795 <dt>...</dt>
796 <dd class="description">Additional args as necessary</dd>
797 </dl>
798 <h4 class="returnvalue">Return Value</h4>
799 <p class="description">Number of bytes written or -1 on error</p>
800 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFilePutChar">cupsFilePutChar</a></h3>
801 <p class="description">Write a character.</p>
802 <p class="code">
803 int cupsFilePutChar (<br>
804 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
805 &nbsp;&nbsp;&nbsp;&nbsp;int c<br>
806 );</p>
807 <h4 class="parameters">Parameters</h4>
808 <dl>
809 <dt>fp</dt>
810 <dd class="description">CUPS file</dd>
811 <dt>c</dt>
812 <dd class="description">Character to write</dd>
813 </dl>
814 <h4 class="returnvalue">Return Value</h4>
815 <p class="description">0 on success, -1 on error</p>
816 <h3 class="function"><span class="info">&nbsp;CUPS 1.4/OS X 10.6&nbsp;</span><a name="cupsFilePutConf">cupsFilePutConf</a></h3>
817 <p class="description">Write a configuration line.</p>
818 <p class="code">
819 ssize_t cupsFilePutConf (<br>
820 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
821 &nbsp;&nbsp;&nbsp;&nbsp;const char *directive,<br>
822 &nbsp;&nbsp;&nbsp;&nbsp;const char *value<br>
823 );</p>
824 <h4 class="parameters">Parameters</h4>
825 <dl>
826 <dt>fp</dt>
827 <dd class="description">CUPS file</dd>
828 <dt>directive</dt>
829 <dd class="description">Directive</dd>
830 <dt>value</dt>
831 <dd class="description">Value</dd>
832 </dl>
833 <h4 class="returnvalue">Return Value</h4>
834 <p class="description">Number of bytes written or -1 on error</p>
835 <h4 class="discussion">Discussion</h4>
836 <p class="discussion">This function handles any comment escaping of the value.
837
838 </p>
839 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFilePuts">cupsFilePuts</a></h3>
840 <p class="description">Write a string.</p>
841 <p class="code">
842 int cupsFilePuts (<br>
843 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
844 &nbsp;&nbsp;&nbsp;&nbsp;const char *s<br>
845 );</p>
846 <h4 class="parameters">Parameters</h4>
847 <dl>
848 <dt>fp</dt>
849 <dd class="description">CUPS file</dd>
850 <dt>s</dt>
851 <dd class="description">String to write</dd>
852 </dl>
853 <h4 class="returnvalue">Return Value</h4>
854 <p class="description">Number of bytes written or -1 on error</p>
855 <h4 class="discussion">Discussion</h4>
856 <p class="discussion">Like the <code>fputs</code> function, no newline is appended to the string.
857
858 </p>
859 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileRead">cupsFileRead</a></h3>
860 <p class="description">Read from a file.</p>
861 <p class="code">
862 ssize_t cupsFileRead (<br>
863 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
864 &nbsp;&nbsp;&nbsp;&nbsp;char *buf,<br>
865 &nbsp;&nbsp;&nbsp;&nbsp;size_t bytes<br>
866 );</p>
867 <h4 class="parameters">Parameters</h4>
868 <dl>
869 <dt>fp</dt>
870 <dd class="description">CUPS file</dd>
871 <dt>buf</dt>
872 <dd class="description">Buffer</dd>
873 <dt>bytes</dt>
874 <dd class="description">Number of bytes to read</dd>
875 </dl>
876 <h4 class="returnvalue">Return Value</h4>
877 <p class="description">Number of bytes read or -1 on error</p>
878 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileRewind">cupsFileRewind</a></h3>
879 <p class="description">Set the current file position to the beginning of the
880 file.</p>
881 <p class="code">
882 off_t cupsFileRewind (<br>
883 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
884 );</p>
885 <h4 class="parameters">Parameters</h4>
886 <dl>
887 <dt>fp</dt>
888 <dd class="description">CUPS file</dd>
889 </dl>
890 <h4 class="returnvalue">Return Value</h4>
891 <p class="description">New file position or -1 on error</p>
892 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileSeek">cupsFileSeek</a></h3>
893 <p class="description">Seek in a file.</p>
894 <p class="code">
895 off_t cupsFileSeek (<br>
896 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
897 &nbsp;&nbsp;&nbsp;&nbsp;off_t pos<br>
898 );</p>
899 <h4 class="parameters">Parameters</h4>
900 <dl>
901 <dt>fp</dt>
902 <dd class="description">CUPS file</dd>
903 <dt>pos</dt>
904 <dd class="description">Position in file</dd>
905 </dl>
906 <h4 class="returnvalue">Return Value</h4>
907 <p class="description">New file position or -1 on error</p>
908 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileStderr">cupsFileStderr</a></h3>
909 <p class="description">Return a CUPS file associated with stderr.</p>
910 <p class="code">
911 <a href="#cups_file_t">cups_file_t</a> *cupsFileStderr (void);</p>
912 <h4 class="returnvalue">Return Value</h4>
913 <p class="description">CUPS file</p>
914 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileStdin">cupsFileStdin</a></h3>
915 <p class="description">Return a CUPS file associated with stdin.</p>
916 <p class="code">
917 <a href="#cups_file_t">cups_file_t</a> *cupsFileStdin (void);</p>
918 <h4 class="returnvalue">Return Value</h4>
919 <p class="description">CUPS file</p>
920 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileStdout">cupsFileStdout</a></h3>
921 <p class="description">Return a CUPS file associated with stdout.</p>
922 <p class="code">
923 <a href="#cups_file_t">cups_file_t</a> *cupsFileStdout (void);</p>
924 <h4 class="returnvalue">Return Value</h4>
925 <p class="description">CUPS file</p>
926 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileTell">cupsFileTell</a></h3>
927 <p class="description">Return the current file position.</p>
928 <p class="code">
929 off_t cupsFileTell (<br>
930 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
931 );</p>
932 <h4 class="parameters">Parameters</h4>
933 <dl>
934 <dt>fp</dt>
935 <dd class="description">CUPS file</dd>
936 </dl>
937 <h4 class="returnvalue">Return Value</h4>
938 <p class="description">File position</p>
939 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileUnlock">cupsFileUnlock</a></h3>
940 <p class="description">Unlock access to a file.</p>
941 <p class="code">
942 int cupsFileUnlock (<br>
943 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp<br>
944 );</p>
945 <h4 class="parameters">Parameters</h4>
946 <dl>
947 <dt>fp</dt>
948 <dd class="description">CUPS file</dd>
949 </dl>
950 <h4 class="returnvalue">Return Value</h4>
951 <p class="description">0 on success, -1 on error</p>
952 <h3 class="function"><span class="info">&nbsp;CUPS 1.2/OS X 10.5&nbsp;</span><a name="cupsFileWrite">cupsFileWrite</a></h3>
953 <p class="description">Write to a file.</p>
954 <p class="code">
955 ssize_t cupsFileWrite (<br>
956 &nbsp;&nbsp;&nbsp;&nbsp;<a href="#cups_file_t">cups_file_t</a> *fp,<br>
957 &nbsp;&nbsp;&nbsp;&nbsp;const char *buf,<br>
958 &nbsp;&nbsp;&nbsp;&nbsp;size_t bytes<br>
959 );</p>
960 <h4 class="parameters">Parameters</h4>
961 <dl>
962 <dt>fp</dt>
963 <dd class="description">CUPS file</dd>
964 <dt>buf</dt>
965 <dd class="description">Buffer</dd>
966 <dt>bytes</dt>
967 <dd class="description">Number of bytes to write</dd>
968 </dl>
969 <h4 class="returnvalue">Return Value</h4>
970 <p class="description">Number of bytes written or -1 on error</p>
971 <h2 class="title"><a name="TYPES">Data Types</a></h2>
972 <h3 class="typedef"><a name="cups_dentry_t">cups_dentry_t</a></h3>
973 <p class="description">Directory entry type</p>
974 <p class="code">
975 typedef struct <a href="#cups_dentry_s">cups_dentry_s</a> cups_dentry_t;
976 </p>
977 <h3 class="typedef"><a name="cups_dir_t">cups_dir_t</a></h3>
978 <p class="description">Directory type</p>
979 <p class="code">
980 typedef struct _cups_dir_s cups_dir_t;
981 </p>
982 <h3 class="typedef"><a name="cups_file_t">cups_file_t</a></h3>
983 <p class="description">CUPS file type</p>
984 <p class="code">
985 typedef struct _cups_file_s cups_file_t;
986 </p>
987 <h2 class="title"><a name="STRUCTURES">Structures</a></h2>
988 <h3 class="struct"><a name="cups_dentry_s">cups_dentry_s</a></h3>
989 <p class="description">Directory entry type</p>
990 <p class="code">struct cups_dentry_s {<br>
991 &nbsp;&nbsp;&nbsp;&nbsp;struct stat fileinfo;<br>
992 &nbsp;&nbsp;&nbsp;&nbsp;char filename[260];<br>
993 };</p>
994 <h4 class="members">Members</h4>
995 <dl>
996 <dt>fileinfo </dt>
997 <dd class="description">File information</dd>
998 <dt>filename[260] </dt>
999 <dd class="description">File name</dd>
1000 </dl>
1001 </div>
1002 </body>
1003 </html>