1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
3 <!-- SECTION: Programming -->
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"><!--
11 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
14 H1, H2, H3, H4, H5, H6, P, TD, TH {
15 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
19 font-family: monaco, courier, monospace;
24 font-family: monaco, courier, monospace;
28 border: dotted thin #7f7f7f;
56 border: dotted thin #999999;
61 PRE.command EM, PRE.example EM {
62 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
66 font-family: monaco, courier, monospace;
77 border: solid thin #999999;
88 -moz-border-radius: 10px;
93 text-decoration: none;
96 A:link:hover, A:visited:hover, A:active {
97 text-decoration: underline;
104 TR.data, TD.data, TR.data TD {
107 border-bottom: solid 1pt #999999;
111 border-bottom: solid 1pt #999999;
118 border: solid thin #999999;
119 border-collapse: collapse;
135 border: solid thin #cccccc;
142 border-bottom: solid thin #999999;
151 caption-side: bottom;
175 border: thin solid black;
183 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
192 border-bottom: solid 2pt #000000;
195 DIV.indent, TABLE.indent {
203 border-collapse: collapse;
206 TABLE.indent TD, TABLE.indent TH {
211 border-collapse: collapse;
219 border-bottom: solid thin #cccccc;
224 vertical-align: bottom;
233 border-bottom: solid thin #eeeeee;
238 TABLE.list TR:nth-child(even) {
242 TABLE.list TR:nth-child(odd) {
261 font-family: monaco, courier, monospace;
265 border: solid thin #999999;
266 border-collapse: collapse;
271 DIV.summary TABLE TD, DIV.summary TABLE TH {
272 border: solid thin #999999;
278 DIV.summary TABLE THEAD TH {
282 /* API documentation styles... */
289 div.body h3, div.body h4, div.body h5 {
290 margin-bottom: 0.5em;
293 .class, .enumeration, .function, .struct, .typedef, .union {
294 border-bottom: solid thin #999999;
301 code, p.code, pre, ul.code li {
302 font-family: monaco, courier, monospace;
305 ul.code, ul.contents, ul.subcontents {
306 list-style-type: none;
316 ul.contents li ul.code, ul.contents li ul.subcontents {
329 margin-bottom: 0.5em;
332 /* This is just for the HTML files generated with the framedhelp target */
335 border: solid thin black;
344 div.contents ul.contents {
347 div.contents ul.subcontents li {
356 File and Directory API header for CUPS.
358 Copyright 2008-2011 by Apple Inc.
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/".
367 <h1 class='title'
>File and Directory APIs
</h1>
369 <div class='summary'
><table summary='General Information'
>
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>
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>
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>
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>
437 File and directory API introduction for CUPS.
439 Copyright 2007-2011 by Apple Inc.
440 Copyright 1997-2005 by Easy Software Products, all rights reserved.
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/".
449 <h2 class='title'
><a name=
"OVERVIEW">Overview
</a></h2>
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>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsDirClose">cupsDirClose
</a></h3>
467 <p class=
"description">Close a directory.
</p>
469 void cupsDirClose (
<br>
470 <a href=
"#cups_dir_t">cups_dir_t
</a> *dp
<br>
472 <h4 class=
"parameters">Parameters
</h4>
475 <dd class=
"description">Directory pointer
</dd>
477 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsDirOpen">cupsDirOpen
</a></h3>
478 <p class=
"description">Open a directory.
</p>
480 <a href=
"#cups_dir_t">cups_dir_t
</a> *cupsDirOpen (
<br>
481 const char *directory
<br>
483 <h4 class=
"parameters">Parameters
</h4>
486 <dd class=
"description">Directory name
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsDirRead">cupsDirRead
</a></h3>
491 <p class=
"description">Read the next directory entry.
</p>
493 <a href=
"#cups_dentry_t">cups_dentry_t
</a> *cupsDirRead (
<br>
494 <a href=
"#cups_dir_t">cups_dir_t
</a> *dp
<br>
496 <h4 class=
"parameters">Parameters
</h4>
499 <dd class=
"description">Directory pointer
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsDirRewind">cupsDirRewind
</a></h3>
504 <p class=
"description">Rewind to the start of the directory.
</p>
506 void cupsDirRewind (
<br>
507 <a href=
"#cups_dir_t">cups_dir_t
</a> *dp
<br>
509 <h4 class=
"parameters">Parameters
</h4>
512 <dd class=
"description">Directory pointer
</dd>
514 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileClose">cupsFileClose
</a></h3>
515 <p class=
"description">Close a CUPS file.
</p>
517 int cupsFileClose (
<br>
518 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
520 <h4 class=
"parameters">Parameters
</h4>
523 <dd class=
"description">CUPS file
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileCompression">cupsFileCompression
</a></h3>
528 <p class=
"description">Return whether a file is compressed.
</p>
530 int cupsFileCompression (
<br>
531 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
533 <h4 class=
"parameters">Parameters
</h4>
536 <dd class=
"description">CUPS file
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileEOF">cupsFileEOF
</a></h3>
541 <p class=
"description">Return the end-of-file status.
</p>
543 int cupsFileEOF (
<br>
544 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
546 <h4 class=
"parameters">Parameters
</h4>
549 <dd class=
"description">CUPS file
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileFind">cupsFileFind
</a></h3>
554 <p class=
"description">Find a file using the specified path.
</p>
556 const char *cupsFileFind (
<br>
557 const char *filename,
<br>
558 const char *path,
<br>
559 int executable,
<br>
560 char *buffer,
<br>
561 int bufsize
<br>
563 <h4 class=
"parameters">Parameters
</h4>
566 <dd class=
"description">File to find
</dd>
568 <dd class=
"description">Colon/semicolon-separated path
</dd>
570 <dd class=
"description">1 = executable files,
0 = any file/dir
</dd>
572 <dd class=
"description">Filename buffer
</dd>
574 <dd class=
"description">Size of filename buffer
</dd>
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.
586 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileFlush">cupsFileFlush
</a></h3>
587 <p class=
"description">Flush pending output.
</p>
589 int cupsFileFlush (
<br>
590 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
592 <h4 class=
"parameters">Parameters
</h4>
595 <dd class=
"description">CUPS file
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileGetChar">cupsFileGetChar
</a></h3>
600 <p class=
"description">Get a single character from a file.
</p>
602 int cupsFileGetChar (
<br>
603 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
605 <h4 class=
"parameters">Parameters
</h4>
608 <dd class=
"description">CUPS file
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileGetConf">cupsFileGetConf
</a></h3>
613 <p class=
"description">Get a line from a configuration file.
</p>
615 char *cupsFileGetConf (
<br>
616 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
617 char *buf,
<br>
618 size_t buflen,
<br>
619 char **value,
<br>
620 int *linenum
<br>
622 <h4 class=
"parameters">Parameters
</h4>
625 <dd class=
"description">CUPS file
</dd>
627 <dd class=
"description">String buffer
</dd>
629 <dd class=
"description">Size of string buffer
</dd>
631 <dd class=
"description">Pointer to value
</dd>
633 <dd class=
"description">Current line number
</dd>
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"> CUPS
1.2/OS X
10.5 </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>
641 size_t cupsFileGetLine (
<br>
642 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
643 char *buf,
<br>
644 size_t buflen
<br>
646 <h4 class=
"parameters">Parameters
</h4>
649 <dd class=
"description">File to read from
</dd>
651 <dd class=
"description">Buffer
</dd>
653 <dd class=
"description">Size of buffer
</dd>
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.
664 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileGets">cupsFileGets
</a></h3>
665 <p class=
"description">Get a CR and/or LF-terminated line.
</p>
667 char *cupsFileGets (
<br>
668 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
669 char *buf,
<br>
670 size_t buflen
<br>
672 <h4 class=
"parameters">Parameters
</h4>
675 <dd class=
"description">CUPS file
</dd>
677 <dd class=
"description">String buffer
</dd>
679 <dd class=
"description">Size of string buffer
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileLock">cupsFileLock
</a></h3>
684 <p class=
"description">Temporarily lock access to a file.
</p>
686 int cupsFileLock (
<br>
687 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
688 int block
<br>
690 <h4 class=
"parameters">Parameters
</h4>
693 <dd class=
"description">CUPS file
</dd>
695 <dd class=
"description">1 to wait for the lock,
0 to fail right away
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileNumber">cupsFileNumber
</a></h3>
700 <p class=
"description">Return the file descriptor associated with a CUPS file.
</p>
702 int cupsFileNumber (
<br>
703 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
705 <h4 class=
"parameters">Parameters
</h4>
708 <dd class=
"description">CUPS file
</dd>
710 <h4 class=
"returnvalue">Return Value
</h4>
711 <p class=
"description">File descriptor
</p>
712 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileOpen">cupsFileOpen
</a></h3>
713 <p class=
"description">Open a CUPS file.
</p>
715 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileOpen (
<br>
716 const char *filename,
<br>
717 const char *mode
<br>
719 <h4 class=
"parameters">Parameters
</h4>
722 <dd class=
"description">Name of file
</dd>
724 <dd class=
"description">Open mode
</dd>
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
"mode
" parameter can be
"r
" to read,
"w
" to write, overwriting any
730 existing file,
"a
" to append to an existing file or create a new file,
731 or
"s
" to open a socket connection.
<br>
733 When opening for writing (
"w
"), 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
"a
" (append) mode.
<br>
737 When opening a socket connection, the filename is a string of the form
738 "address:port
" or
"hostname:port
". The socket will make an IPv4 or IPv6
739 connection as needed, generally preferring IPv6 connections when there is
743 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileOpenFd">cupsFileOpenFd
</a></h3>
744 <p class=
"description">Open a CUPS file using a file descriptor.
</p>
746 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileOpenFd (
<br>
747 int fd,
<br>
748 const char *mode
<br>
750 <h4 class=
"parameters">Parameters
</h4>
753 <dd class=
"description">File descriptor
</dd>
755 <dd class=
"description">Open mode
</dd>
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
"mode
" parameter can be
"r
" to read,
"w
" to write,
"a
" to append,
761 or
"s
" to treat the file descriptor as a bidirectional socket connection.
<br>
763 When opening for writing (
"w
"), 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
"a
" (append) mode.
768 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFilePeekChar">cupsFilePeekChar
</a></h3>
769 <p class=
"description">Peek at the next character from a file.
</p>
771 int cupsFilePeekChar (
<br>
772 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
774 <h4 class=
"parameters">Parameters
</h4>
777 <dd class=
"description">CUPS file
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFilePrintf">cupsFilePrintf
</a></h3>
782 <p class=
"description">Write a formatted string.
</p>
784 int cupsFilePrintf (
<br>
785 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
786 const char *format,
<br>
787 ...
<br>
789 <h4 class=
"parameters">Parameters
</h4>
792 <dd class=
"description">CUPS file
</dd>
794 <dd class=
"description">Printf-style format string
</dd>
796 <dd class=
"description">Additional args as necessary
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFilePutChar">cupsFilePutChar
</a></h3>
801 <p class=
"description">Write a character.
</p>
803 int cupsFilePutChar (
<br>
804 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
805 int c
<br>
807 <h4 class=
"parameters">Parameters
</h4>
810 <dd class=
"description">CUPS file
</dd>
812 <dd class=
"description">Character to write
</dd>
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"> CUPS
1.4/OS X
10.6 </span><a name=
"cupsFilePutConf">cupsFilePutConf
</a></h3>
817 <p class=
"description">Write a configuration line.
</p>
819 ssize_t cupsFilePutConf (
<br>
820 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
821 const char *directive,
<br>
822 const char *value
<br>
824 <h4 class=
"parameters">Parameters
</h4>
827 <dd class=
"description">CUPS file
</dd>
829 <dd class=
"description">Directive
</dd>
831 <dd class=
"description">Value
</dd>
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.
839 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFilePuts">cupsFilePuts
</a></h3>
840 <p class=
"description">Write a string.
</p>
842 int cupsFilePuts (
<br>
843 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
844 const char *s
<br>
846 <h4 class=
"parameters">Parameters
</h4>
849 <dd class=
"description">CUPS file
</dd>
851 <dd class=
"description">String to write
</dd>
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.
859 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileRead">cupsFileRead
</a></h3>
860 <p class=
"description">Read from a file.
</p>
862 ssize_t cupsFileRead (
<br>
863 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
864 char *buf,
<br>
865 size_t bytes
<br>
867 <h4 class=
"parameters">Parameters
</h4>
870 <dd class=
"description">CUPS file
</dd>
872 <dd class=
"description">Buffer
</dd>
874 <dd class=
"description">Number of bytes to read
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileRewind">cupsFileRewind
</a></h3>
879 <p class=
"description">Set the current file position to the beginning of the
882 off_t cupsFileRewind (
<br>
883 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
885 <h4 class=
"parameters">Parameters
</h4>
888 <dd class=
"description">CUPS file
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileSeek">cupsFileSeek
</a></h3>
893 <p class=
"description">Seek in a file.
</p>
895 off_t cupsFileSeek (
<br>
896 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
897 off_t pos
<br>
899 <h4 class=
"parameters">Parameters
</h4>
902 <dd class=
"description">CUPS file
</dd>
904 <dd class=
"description">Position in file
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileStderr">cupsFileStderr
</a></h3>
909 <p class=
"description">Return a CUPS file associated with stderr.
</p>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileStdin">cupsFileStdin
</a></h3>
915 <p class=
"description">Return a CUPS file associated with stdin.
</p>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileStdout">cupsFileStdout
</a></h3>
921 <p class=
"description">Return a CUPS file associated with stdout.
</p>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileTell">cupsFileTell
</a></h3>
927 <p class=
"description">Return the current file position.
</p>
929 off_t cupsFileTell (
<br>
930 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
932 <h4 class=
"parameters">Parameters
</h4>
935 <dd class=
"description">CUPS file
</dd>
937 <h4 class=
"returnvalue">Return Value
</h4>
938 <p class=
"description">File position
</p>
939 <h3 class=
"function"><span class=
"info"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileUnlock">cupsFileUnlock
</a></h3>
940 <p class=
"description">Unlock access to a file.
</p>
942 int cupsFileUnlock (
<br>
943 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
945 <h4 class=
"parameters">Parameters
</h4>
948 <dd class=
"description">CUPS file
</dd>
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"> CUPS
1.2/OS X
10.5 </span><a name=
"cupsFileWrite">cupsFileWrite
</a></h3>
953 <p class=
"description">Write to a file.
</p>
955 ssize_t cupsFileWrite (
<br>
956 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
957 const char *buf,
<br>
958 size_t bytes
<br>
960 <h4 class=
"parameters">Parameters
</h4>
963 <dd class=
"description">CUPS file
</dd>
965 <dd class=
"description">Buffer
</dd>
967 <dd class=
"description">Number of bytes to write
</dd>
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>
975 typedef struct
<a href=
"#cups_dentry_s">cups_dentry_s
</a> cups_dentry_t;
977 <h3 class=
"typedef"><a name=
"cups_dir_t">cups_dir_t
</a></h3>
978 <p class=
"description">Directory type
</p>
980 typedef struct _cups_dir_s cups_dir_t;
982 <h3 class=
"typedef"><a name=
"cups_file_t">cups_file_t
</a></h3>
983 <p class=
"description">CUPS file type
</p>
985 typedef struct _cups_file_s cups_file_t;
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 struct stat fileinfo;
<br>
992 char filename[
260];
<br>
994 <h4 class=
"members">Members
</h4>
997 <dd class=
"description">File information
</dd>
998 <dt>filename[
260]
</dt>
999 <dd class=
"description">File name
</dd>