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.11">
9 <meta name=
"author" content=
"Unknown">
10 <meta name=
"copyright" content=
"Unknown">
11 <style type=
"text/css"><!--
13 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
16 H1, H2, H3, H4, H5, H6, P, TD, TH {
17 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
21 font-family: monaco, courier, monospace;
26 font-family: monaco, courier, monospace;
30 border: dotted thin #7f7f7f;
58 border: dotted thin #999999;
63 PRE.command EM, PRE.example EM {
64 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
68 font-family: monaco, courier, monospace;
79 border: solid thin #999999;
90 -moz-border-radius: 10px;
95 text-decoration: none;
98 A:link:hover, A:visited:hover, A:active {
99 text-decoration: underline;
106 TR.data, TD.data, TR.data TD {
109 border-bottom: solid 1pt #999999;
113 border-bottom: solid 1pt #999999;
120 border: solid thin #999999;
121 border-collapse: collapse;
137 border: solid thin #cccccc;
144 border-bottom: solid thin #999999;
153 caption-side: bottom;
177 border: thin solid black;
185 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
194 border-bottom: solid 2pt #000000;
197 DIV.indent, TABLE.indent {
205 border-collapse: collapse;
208 TABLE.indent TD, TABLE.indent TH {
213 border-collapse: collapse;
221 border-bottom: solid thin #cccccc;
226 vertical-align: bottom;
235 border-bottom: solid thin #eeeeee;
240 TABLE.list TR:nth-child(even) {
244 TABLE.list TR:nth-child(odd) {
263 font-family: monaco, courier, monospace;
267 border: solid thin #999999;
268 border-collapse: collapse;
273 DIV.summary TABLE TD, DIV.summary TABLE TH {
274 border: solid thin #999999;
280 DIV.summary TABLE THEAD TH {
284 /* API documentation styles... */
291 div.body h3, div.body h4, div.body h5 {
292 margin-bottom: 0.5em;
295 .class, .enumeration, .function, .struct, .typedef, .union {
296 border-bottom: solid thin #999999;
303 code, p.code, pre, ul.code li {
304 font-family: monaco, courier, monospace;
307 ul.code, ul.contents, ul.subcontents {
308 list-style-type: none;
318 ul.contents li ul.code, ul.contents li ul.subcontents {
331 margin-bottom: 0.5em;
334 /* This is just for the HTML files generated with the framedhelp target */
337 border: solid thin black;
346 div.contents ul.contents {
349 div.contents ul.subcontents li {
357 File and Directory API header for CUPS.
359 Copyright 2008-2011 by Apple Inc.
361 These coded instructions, statements, and computer programs are the
362 property of Apple Inc. and are protected by Federal copyright
363 law. Distribution and use rights are outlined in the file "LICENSE.txt"
364 which should have been included with this file. If this file is
365 file is missing or damaged, see the license at "http://www.cups.org/".
368 <h1 class='title'
>File and Directory APIs
</h1>
370 <div class='summary'
><table summary='General Information'
>
385 <td>Programming:
<a href='api-overview.html' target='_top'
>Introduction to CUPS Programming
</a><br>
386 Programming:
<a href='api-cups.html' target='_top'
>CUPS API
</a></td>
390 <div class=
"contents">
391 <h2 class=
"title">Contents
</h2>
392 <ul class=
"contents">
393 <li><a href=
"#OVERVIEW">Overview
</a></li>
394 <li><a href=
"#FUNCTIONS">Functions
</a><ul class=
"subcontents">
395 <li><a href=
"#cupsDirClose">cupsDirClose
</a></li>
396 <li><a href=
"#cupsDirOpen">cupsDirOpen
</a></li>
397 <li><a href=
"#cupsDirRead">cupsDirRead
</a></li>
398 <li><a href=
"#cupsDirRewind">cupsDirRewind
</a></li>
399 <li><a href=
"#cupsFileClose">cupsFileClose
</a></li>
400 <li><a href=
"#cupsFileCompression">cupsFileCompression
</a></li>
401 <li><a href=
"#cupsFileEOF">cupsFileEOF
</a></li>
402 <li><a href=
"#cupsFileFind">cupsFileFind
</a></li>
403 <li><a href=
"#cupsFileFlush">cupsFileFlush
</a></li>
404 <li><a href=
"#cupsFileGetChar">cupsFileGetChar
</a></li>
405 <li><a href=
"#cupsFileGetConf">cupsFileGetConf
</a></li>
406 <li><a href=
"#cupsFileGetLine">cupsFileGetLine
</a></li>
407 <li><a href=
"#cupsFileGets">cupsFileGets
</a></li>
408 <li><a href=
"#cupsFileLock">cupsFileLock
</a></li>
409 <li><a href=
"#cupsFileNumber">cupsFileNumber
</a></li>
410 <li><a href=
"#cupsFileOpen">cupsFileOpen
</a></li>
411 <li><a href=
"#cupsFileOpenFd">cupsFileOpenFd
</a></li>
412 <li><a href=
"#cupsFilePeekChar">cupsFilePeekChar
</a></li>
413 <li><a href=
"#cupsFilePrintf">cupsFilePrintf
</a></li>
414 <li><a href=
"#cupsFilePutChar">cupsFilePutChar
</a></li>
415 <li><a href=
"#cupsFilePutConf">cupsFilePutConf
</a></li>
416 <li><a href=
"#cupsFilePuts">cupsFilePuts
</a></li>
417 <li><a href=
"#cupsFileRead">cupsFileRead
</a></li>
418 <li><a href=
"#cupsFileRewind">cupsFileRewind
</a></li>
419 <li><a href=
"#cupsFileSeek">cupsFileSeek
</a></li>
420 <li><a href=
"#cupsFileStderr">cupsFileStderr
</a></li>
421 <li><a href=
"#cupsFileStdin">cupsFileStdin
</a></li>
422 <li><a href=
"#cupsFileStdout">cupsFileStdout
</a></li>
423 <li><a href=
"#cupsFileTell">cupsFileTell
</a></li>
424 <li><a href=
"#cupsFileUnlock">cupsFileUnlock
</a></li>
425 <li><a href=
"#cupsFileWrite">cupsFileWrite
</a></li>
427 <li><a href=
"#TYPES">Data Types
</a><ul class=
"subcontents">
428 <li><a href=
"#cups_dentry_t">cups_dentry_t
</a></li>
429 <li><a href=
"#cups_dir_t">cups_dir_t
</a></li>
430 <li><a href=
"#cups_file_t">cups_file_t
</a></li>
432 <li><a href=
"#STRUCTURES">Structures
</a><ul class=
"subcontents">
433 <li><a href=
"#cups_dentry_s">cups_dentry_s
</a></li>
439 File and directory API introduction for CUPS.
441 Copyright 2007-2011 by Apple Inc.
442 Copyright 1997-2005 by Easy Software Products, all rights reserved.
444 These coded instructions, statements, and computer programs are the
445 property of Apple Inc. and are protected by Federal copyright
446 law. Distribution and use rights are outlined in the file "LICENSE.txt"
447 which should have been included with this file. If this file is
448 file is missing or damaged, see the license at "http://www.cups.org/".
451 <h2 class='title'
><a name=
"OVERVIEW">Overview
</a></h2>
453 <p>The CUPS file and directory APIs provide portable interfaces
454 for manipulating files and listing files and directories. Unlike
455 stdio
<code>FILE
</code> streams, the
<code>cupsFile
</code> functions
456 allow you to open more than
256 files at any given time. They
457 also manage the platform-specific details of locking, large file
458 support, line endings (CR, LF, or CR LF), and reading and writing
459 files using Flate (
"gzip") compression. Finally, you can also
460 connect, read from, and write to network connections using the
461 <code>cupsFile
</code> functions.
</p>
463 <p>The
<code>cupsDir
</code> functions manage the platform-specific
464 details of directory access/listing and provide a convenient way
465 to get both a list of files and the information (permissions,
466 size, timestamp, etc.) for each of those files.
</p>
467 <h2 class=
"title"><a id=
"FUNCTIONS">Functions
</a></h2>
468 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsDirClose">cupsDirClose
</a></h3>
469 <p class=
"description">Close a directory.
</p>
471 void cupsDirClose (
<br />
472     <a href=
"#cups_dir_t">cups_dir_t
</a> *dp
<br />
474 <h4 class=
"parameters">Parameters
</h4>
477 <dd class=
"description">Directory pointer
</dd>
479 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsDirOpen">cupsDirOpen
</a></h3>
480 <p class=
"description">Open a directory.
</p>
482 <a href=
"#cups_dir_t">cups_dir_t
</a> *cupsDirOpen (
<br />
483     const char *directory
<br />
485 <h4 class=
"parameters">Parameters
</h4>
488 <dd class=
"description">Directory name
</dd>
490 <h4 class=
"returnvalue">Return Value
</h4>
491 <p class=
"description">Directory pointer or
<code>NULL
</code> if the directory could not be opened.
</p>
492 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsDirRead">cupsDirRead
</a></h3>
493 <p class=
"description">Read the next directory entry.
</p>
495 <a href=
"#cups_dentry_t">cups_dentry_t
</a> *cupsDirRead (
<br />
496     <a href=
"#cups_dir_t">cups_dir_t
</a> *dp
<br />
498 <h4 class=
"parameters">Parameters
</h4>
501 <dd class=
"description">Directory pointer
</dd>
503 <h4 class=
"returnvalue">Return Value
</h4>
504 <p class=
"description">Directory entry or
<code>NULL
</code> when there are no more
</p>
505 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsDirRewind">cupsDirRewind
</a></h3>
506 <p class=
"description">Rewind to the start of the directory.
</p>
508 void cupsDirRewind (
<br />
509     <a href=
"#cups_dir_t">cups_dir_t
</a> *dp
<br />
511 <h4 class=
"parameters">Parameters
</h4>
514 <dd class=
"description">Directory pointer
</dd>
516 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileClose">cupsFileClose
</a></h3>
517 <p class=
"description">Close a CUPS file.
</p>
519 int cupsFileClose (
<br />
520     <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br />
522 <h4 class=
"parameters">Parameters
</h4>
525 <dd class=
"description">CUPS file
</dd>
527 <h4 class=
"returnvalue">Return Value
</h4>
528 <p class=
"description">0 on success, -
1 on error
</p>
529 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileCompression">cupsFileCompression
</a></h3>
530 <p class=
"description">Return whether a file is compressed.
</p>
532 int cupsFileCompression (
<br />
533     <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br />
535 <h4 class=
"parameters">Parameters
</h4>
538 <dd class=
"description">CUPS file
</dd>
540 <h4 class=
"returnvalue">Return Value
</h4>
541 <p class=
"description"><code>CUPS_FILE_NONE
</code> or
<code>CUPS_FILE_GZIP
</code></p>
542 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileEOF">cupsFileEOF
</a></h3>
543 <p class=
"description">Return the end-of-file status.
</p>
545 int cupsFileEOF (
<br />
546     <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br />
548 <h4 class=
"parameters">Parameters
</h4>
551 <dd class=
"description">CUPS file
</dd>
553 <h4 class=
"returnvalue">Return Value
</h4>
554 <p class=
"description">1 on end of file,
0 otherwise
</p>
555 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileFind">cupsFileFind
</a></h3>
556 <p class=
"description">Find a file using the specified path.
</p>
558 const char *cupsFileFind (
<br />
559     const char *filename,
<br />
560     const char *path,
<br />
561     int executable,
<br />
562     char *buffer,
<br />
563     int bufsize
<br />
565 <h4 class=
"parameters">Parameters
</h4>
568 <dd class=
"description">File to find
</dd>
570 <dd class=
"description">Colon/semicolon-separated path
</dd>
572 <dd class=
"description">1 = executable files,
0 = any file/dir
</dd>
574 <dd class=
"description">Filename buffer
</dd>
576 <dd class=
"description">Size of filename buffer
</dd>
578 <h4 class=
"returnvalue">Return Value
</h4>
579 <p class=
"description">Full path to file or
<code>NULL
</code> if not found
</p>
580 <h4 class=
"discussion">Discussion
</h4>
581 <p class=
"discussion">This function allows the paths in the path string to be separated by
582 colons (UNIX standard) or semicolons (Windows standard) and stores the
583 result in the buffer supplied. If the file cannot be found in any of
584 the supplied paths,
<code>NULL
</code> is returned. A
<code>NULL
</code> path only
585 matches the current directory.
588 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileFlush">cupsFileFlush
</a></h3>
589 <p class=
"description">Flush pending output.
</p>
591 int cupsFileFlush (
<br />
592     <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br />
594 <h4 class=
"parameters">Parameters
</h4>
597 <dd class=
"description">CUPS file
</dd>
599 <h4 class=
"returnvalue">Return Value
</h4>
600 <p class=
"description">0 on success, -
1 on error
</p>
601 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileGetChar">cupsFileGetChar
</a></h3>
602 <p class=
"description">Get a single character from a file.
</p>
604 int cupsFileGetChar (
<br />
605     <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br />
607 <h4 class=
"parameters">Parameters
</h4>
610 <dd class=
"description">CUPS file
</dd>
612 <h4 class=
"returnvalue">Return Value
</h4>
613 <p class=
"description">Character or -
1 on end of file
</p>
614 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileGetConf">cupsFileGetConf
</a></h3>
615 <p class=
"description">Get a line from a configuration file.
</p>
617 char *cupsFileGetConf (
<br />
618     <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br />
619     char *buf,
<br />
620     size_t buflen,
<br />
621     char **value,
<br />
622     int *linenum
<br />
624 <h4 class=
"parameters">Parameters
</h4>
627 <dd class=
"description">CUPS file
</dd>
629 <dd class=
"description">String buffer
</dd>
631 <dd class=
"description">Size of string buffer
</dd>
633 <dd class=
"description">Pointer to value
</dd>
635 <dd class=
"description">Current line number
</dd>
637 <h4 class=
"returnvalue">Return Value
</h4>
638 <p class=
"description">Line read or
<code>NULL
</code> on end of file or error
</p>
639 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileGetLine">cupsFileGetLine
</a></h3>
640 <p class=
"description">Get a CR and/or LF-terminated line that may
641 contain binary data.
</p>
643 size_t cupsFileGetLine (
<br />
644     <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br />
645     char *buf,
<br />
646     size_t buflen
<br />
648 <h4 class=
"parameters">Parameters
</h4>
651 <dd class=
"description">File to read from
</dd>
653 <dd class=
"description">Buffer
</dd>
655 <dd class=
"description">Size of buffer
</dd>
657 <h4 class=
"returnvalue">Return Value
</h4>
658 <p class=
"description">Number of bytes on line or
0 on end of file
</p>
659 <h4 class=
"discussion">Discussion
</h4>
660 <p class=
"discussion">This function differs from
<a href=
"#cupsFileGets"><code>cupsFileGets
</code></a> in that the trailing CR
661 and LF are preserved, as is any binary data on the line. The buffer is
662 nul-terminated, however you should use the returned length to determine
663 the number of bytes on the line.
666 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileGets">cupsFileGets
</a></h3>
667 <p class=
"description">Get a CR and/or LF-terminated line.
</p>
669 char *cupsFileGets (
<br />
670     <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br />
671     char *buf,
<br />
672     size_t buflen
<br />
674 <h4 class=
"parameters">Parameters
</h4>
677 <dd class=
"description">CUPS file
</dd>
679 <dd class=
"description">String buffer
</dd>
681 <dd class=
"description">Size of string buffer
</dd>
683 <h4 class=
"returnvalue">Return Value
</h4>
684 <p class=
"description">Line read or
<code>NULL
</code> on end of file or error
</p>
685 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileLock">cupsFileLock
</a></h3>
686 <p class=
"description">Temporarily lock access to a file.
</p>
688 int cupsFileLock (
<br />
689     <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br />
690     int block
<br />
692 <h4 class=
"parameters">Parameters
</h4>
695 <dd class=
"description">CUPS file
</dd>
697 <dd class=
"description">1 to wait for the lock,
0 to fail right away
</dd>
699 <h4 class=
"returnvalue">Return Value
</h4>
700 <p class=
"description">0 on success, -
1 on error
</p>
701 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileNumber">cupsFileNumber
</a></h3>
702 <p class=
"description">Return the file descriptor associated with a CUPS file.
</p>
704 int cupsFileNumber (
<br />
705     <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br />
707 <h4 class=
"parameters">Parameters
</h4>
710 <dd class=
"description">CUPS file
</dd>
712 <h4 class=
"returnvalue">Return Value
</h4>
713 <p class=
"description">File descriptor
</p>
714 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileOpen">cupsFileOpen
</a></h3>
715 <p class=
"description">Open a CUPS file.
</p>
717 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileOpen (
<br />
718     const char *filename,
<br />
719     const char *mode
<br />
721 <h4 class=
"parameters">Parameters
</h4>
724 <dd class=
"description">Name of file
</dd>
726 <dd class=
"description">Open mode
</dd>
728 <h4 class=
"returnvalue">Return Value
</h4>
729 <p class=
"description">CUPS file or
<code>NULL
</code> if the file or socket cannot be opened
</p>
730 <h4 class=
"discussion">Discussion
</h4>
731 <p class=
"discussion">The
"mode
" parameter can be
"r
" to read,
"w
" to write, overwriting any
732 existing file,
"a
" to append to an existing file or create a new file,
733 or
"s
" to open a socket connection.
<br>
735 When opening for writing (
"w
"), an optional number from
1 to
9 can be
736 supplied which enables Flate compression of the file. Compression is
737 not supported for the
"a
" (append) mode.
<br>
739 When opening a socket connection, the filename is a string of the form
740 "address:port
" or
"hostname:port
". The socket will make an IPv4 or IPv6
741 connection as needed, generally preferring IPv6 connections when there is
745 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileOpenFd">cupsFileOpenFd
</a></h3>
746 <p class=
"description">Open a CUPS file using a file descriptor.
</p>
748 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileOpenFd (
<br />
749     int fd,
<br />
750     const char *mode
<br />
752 <h4 class=
"parameters">Parameters
</h4>
755 <dd class=
"description">File descriptor
</dd>
757 <dd class=
"description">Open mode
</dd>
759 <h4 class=
"returnvalue">Return Value
</h4>
760 <p class=
"description">CUPS file or
<code>NULL
</code> if the file could not be opened
</p>
761 <h4 class=
"discussion">Discussion
</h4>
762 <p class=
"discussion">The
"mode
" parameter can be
"r
" to read,
"w
" to write,
"a
" to append,
763 or
"s
" to treat the file descriptor as a bidirectional socket connection.
<br>
765 When opening for writing (
"w
"), an optional number from
1 to
9 can be
766 supplied which enables Flate compression of the file. Compression is
767 not supported for the
"a
" (append) mode.
770 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFilePeekChar">cupsFilePeekChar
</a></h3>
771 <p class=
"description">Peek at the next character from a file.
</p>
773 int cupsFilePeekChar (
<br />
774     <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br />
776 <h4 class=
"parameters">Parameters
</h4>
779 <dd class=
"description">CUPS file
</dd>
781 <h4 class=
"returnvalue">Return Value
</h4>
782 <p class=
"description">Character or -
1 on end of file
</p>
783 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFilePrintf">cupsFilePrintf
</a></h3>
784 <p class=
"description">Write a formatted string.
</p>
786 int cupsFilePrintf (
<br />
787     <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br />
788     const char *format,
<br />
789     ...
<br />
791 <h4 class=
"parameters">Parameters
</h4>
794 <dd class=
"description">CUPS file
</dd>
796 <dd class=
"description">Printf-style format string
</dd>
798 <dd class=
"description">Additional args as necessary
</dd>
800 <h4 class=
"returnvalue">Return Value
</h4>
801 <p class=
"description">Number of bytes written or -
1 on error
</p>
802 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFilePutChar">cupsFilePutChar
</a></h3>
803 <p class=
"description">Write a character.
</p>
805 int cupsFilePutChar (
<br />
806     <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br />
807     int c
<br />
809 <h4 class=
"parameters">Parameters
</h4>
812 <dd class=
"description">CUPS file
</dd>
814 <dd class=
"description">Character to write
</dd>
816 <h4 class=
"returnvalue">Return Value
</h4>
817 <p class=
"description">0 on success, -
1 on error
</p>
818 <h3 class=
"function"><span class=
"info"> CUPS
1.4/macOS
10.6 </span><a id=
"cupsFilePutConf">cupsFilePutConf
</a></h3>
819 <p class=
"description">Write a configuration line.
</p>
821 ssize_t cupsFilePutConf (
<br />
822     <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br />
823     const char *directive,
<br />
824     const char *value
<br />
826 <h4 class=
"parameters">Parameters
</h4>
829 <dd class=
"description">CUPS file
</dd>
831 <dd class=
"description">Directive
</dd>
833 <dd class=
"description">Value
</dd>
835 <h4 class=
"returnvalue">Return Value
</h4>
836 <p class=
"description">Number of bytes written or -
1 on error
</p>
837 <h4 class=
"discussion">Discussion
</h4>
838 <p class=
"discussion">This function handles any comment escaping of the value.
841 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFilePuts">cupsFilePuts
</a></h3>
842 <p class=
"description">Write a string.
</p>
844 int cupsFilePuts (
<br />
845     <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br />
846     const char *s
<br />
848 <h4 class=
"parameters">Parameters
</h4>
851 <dd class=
"description">CUPS file
</dd>
853 <dd class=
"description">String to write
</dd>
855 <h4 class=
"returnvalue">Return Value
</h4>
856 <p class=
"description">Number of bytes written or -
1 on error
</p>
857 <h4 class=
"discussion">Discussion
</h4>
858 <p class=
"discussion">Like the
<code>fputs
</code> function, no newline is appended to the string.
861 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileRead">cupsFileRead
</a></h3>
862 <p class=
"description">Read from a file.
</p>
864 ssize_t cupsFileRead (
<br />
865     <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br />
866     char *buf,
<br />
867     size_t bytes
<br />
869 <h4 class=
"parameters">Parameters
</h4>
872 <dd class=
"description">CUPS file
</dd>
874 <dd class=
"description">Buffer
</dd>
876 <dd class=
"description">Number of bytes to read
</dd>
878 <h4 class=
"returnvalue">Return Value
</h4>
879 <p class=
"description">Number of bytes read or -
1 on error
</p>
880 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileRewind">cupsFileRewind
</a></h3>
881 <p class=
"description">Set the current file position to the beginning of the
884 off_t cupsFileRewind (
<br />
885     <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br />
887 <h4 class=
"parameters">Parameters
</h4>
890 <dd class=
"description">CUPS file
</dd>
892 <h4 class=
"returnvalue">Return Value
</h4>
893 <p class=
"description">New file position or -
1 on error
</p>
894 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileSeek">cupsFileSeek
</a></h3>
895 <p class=
"description">Seek in a file.
</p>
897 off_t cupsFileSeek (
<br />
898     <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br />
899     off_t pos
<br />
901 <h4 class=
"parameters">Parameters
</h4>
904 <dd class=
"description">CUPS file
</dd>
906 <dd class=
"description">Position in file
</dd>
908 <h4 class=
"returnvalue">Return Value
</h4>
909 <p class=
"description">New file position or -
1 on error
</p>
910 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileStderr">cupsFileStderr
</a></h3>
911 <p class=
"description">Return a CUPS file associated with stderr.
</p>
913 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileStderr (void);
</p>
914 <h4 class=
"returnvalue">Return Value
</h4>
915 <p class=
"description">CUPS file
</p>
916 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileStdin">cupsFileStdin
</a></h3>
917 <p class=
"description">Return a CUPS file associated with stdin.
</p>
919 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileStdin (void);
</p>
920 <h4 class=
"returnvalue">Return Value
</h4>
921 <p class=
"description">CUPS file
</p>
922 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileStdout">cupsFileStdout
</a></h3>
923 <p class=
"description">Return a CUPS file associated with stdout.
</p>
925 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileStdout (void);
</p>
926 <h4 class=
"returnvalue">Return Value
</h4>
927 <p class=
"description">CUPS file
</p>
928 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileTell">cupsFileTell
</a></h3>
929 <p class=
"description">Return the current file position.
</p>
931 off_t cupsFileTell (
<br />
932     <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br />
934 <h4 class=
"parameters">Parameters
</h4>
937 <dd class=
"description">CUPS file
</dd>
939 <h4 class=
"returnvalue">Return Value
</h4>
940 <p class=
"description">File position
</p>
941 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileUnlock">cupsFileUnlock
</a></h3>
942 <p class=
"description">Unlock access to a file.
</p>
944 int cupsFileUnlock (
<br />
945     <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br />
947 <h4 class=
"parameters">Parameters
</h4>
950 <dd class=
"description">CUPS file
</dd>
952 <h4 class=
"returnvalue">Return Value
</h4>
953 <p class=
"description">0 on success, -
1 on error
</p>
954 <h3 class=
"function"><span class=
"info"> CUPS
1.2/macOS
10.5 </span><a id=
"cupsFileWrite">cupsFileWrite
</a></h3>
955 <p class=
"description">Write to a file.
</p>
957 ssize_t cupsFileWrite (
<br />
958     <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br />
959     const char *buf,
<br />
960     size_t bytes
<br />
962 <h4 class=
"parameters">Parameters
</h4>
965 <dd class=
"description">CUPS file
</dd>
967 <dd class=
"description">Buffer
</dd>
969 <dd class=
"description">Number of bytes to write
</dd>
971 <h4 class=
"returnvalue">Return Value
</h4>
972 <p class=
"description">Number of bytes written or -
1 on error
</p>
973 <h2 class=
"title"><a id=
"TYPES">Data Types
</a></h2>
974 <h3 class=
"typedef"><a id=
"cups_dentry_t">cups_dentry_t
</a></h3>
975 <p class=
"description">Directory entry type
</p>
977 typedef struct
<a href=
"#cups_dentry_s">cups_dentry_s
</a> cups_dentry_t;
979 <h3 class=
"typedef"><a id=
"cups_dir_t">cups_dir_t
</a></h3>
980 <p class=
"description">Directory type
</p>
982 typedef struct _cups_dir_s cups_dir_t;
984 <h3 class=
"typedef"><a id=
"cups_file_t">cups_file_t
</a></h3>
985 <p class=
"description">CUPS file type
</p>
987 typedef struct _cups_file_s cups_file_t;
989 <h2 class=
"title"><a id=
"STRUCTURES">Structures
</a></h2>
990 <h3 class=
"struct"><a id=
"cups_dentry_s">cups_dentry_s
</a></h3>
991 <p class=
"description">Directory entry type
</p>
992 <p class=
"code">struct cups_dentry_s {
<br />
993     struct stat fileinfo;
<br />
994     char filename[
260];
<br />
996 <h4 class=
"members">Members
</h4>
999 <dd class=
"description">File information
</dd>
1000 <dt>filename[
260]
</dt>
1001 <dd class=
"description">File name
</dd>