1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
3 <!-- SECTION: Programming -->
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"><!--
10 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
13 H1, H2, H3, H4, H5, H6, P, TD, TH {
14 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
18 font-family: monaco, courier, monospace;
23 font-family: monaco, courier, monospace;
32 border: dotted thin #999999;
37 PRE.command EM, PRE.example EM {
38 font-family: lucida grande, geneva, helvetica, arial, sans-serif;
42 font-family: monaco, courier, monospace;
53 border: solid thin #999999;
59 text-decoration: none;
62 A:link:hover, A:visited:hover, A:active {
63 text-decoration: underline;
71 border: solid thin #999999;
72 border-collapse: collapse;
88 border: solid thin #cccccc;
95 border-bottom: solid thin #999999;
104 caption-side: bottom;
124 border: thin solid #000000;
132 H2 SPAN.info, H3 SPAN.info, H4 SPAN.info {
138 border-bottom: solid 2pt #000000;
156 font-family: monaco, courier, monospace;
165 border: solid thin #999999;
166 border-collapse: collapse;
171 DIV.summary TABLE TD, DIV.summary TABLE TH {
172 border: solid thin #999999;
178 DIV.summary TABLE THEAD TH {
182 /* API documentation styles... */
189 div.body h3, div.body h4, div.body h5 {
190 margin-bottom: 0.5em;
193 .class, .enumeration, .function, .struct, .typedef, .union {
194 border-bottom: solid thin #999999;
201 code, p.code, pre, ul.code li {
202 font-family: monaco, courier, monospace;
205 ul.code, ul.contents, ul.subcontents {
206 list-style-type: none;
216 ul.contents li ul.code, ul.contents li ul.subcontents {
229 margin-bottom: 0.5em;
232 /* This is just for the HTML files generated with the framedhelp target */
235 border: solid thin black;
244 div.contents ul.contents {
247 div.contents ul.subcontents li {
256 "$Id: api-filedir.header 7279 2008-01-31 01:50:44Z mike $"
258 File and Directory API header for the Common UNIX Printing System (CUPS).
260 Copyright 2008 by Apple Inc.
262 These coded instructions, statements, and computer programs are the
263 property of Apple Inc. and are protected by Federal copyright
264 law. Distribution and use rights are outlined in the file "LICENSE.txt"
265 which should have been included with this file. If this file is
266 file is missing or damaged, see the license at "http://www.cups.org/".
269 <h1 class=
"title">File and Directory APIs
</h1>
271 <div class='summary'
><table summary='General Information'
>
286 <td>Programming:
<a href='api-overview.html' target='_top'
>Introduction to CUPS Programming
</a><br>
287 Programming:
<a href='api-cups.html' target='_top'
>CUPS API
</a></td>
291 <h2 class=
"title">Contents
</h2>
292 <ul class=
"contents">
294 <li><a href=
"#OVERVIEW">Overview
</a></li>
295 <li><a href=
"#FUNCTIONS">Functions
</a><ul class=
"code">
296 <li><a href=
"#cupsDirClose" title=
"Close a directory.">cupsDirClose
</a></li>
297 <li><a href=
"#cupsDirOpen" title=
"Open a directory.">cupsDirOpen
</a></li>
298 <li><a href=
"#cupsDirRead" title=
"Read the next directory entry.">cupsDirRead
</a></li>
299 <li><a href=
"#cupsDirRewind" title=
"Rewind to the start of the directory.">cupsDirRewind
</a></li>
300 <li><a href=
"#cupsFileClose" title=
"Close a CUPS file.">cupsFileClose
</a></li>
301 <li><a href=
"#cupsFileCompression" title=
"Return whether a file is compressed.">cupsFileCompression
</a></li>
302 <li><a href=
"#cupsFileEOF" title=
"Return the end-of-file status.">cupsFileEOF
</a></li>
303 <li><a href=
"#cupsFileFind" title=
"Find a file using the specified path.">cupsFileFind
</a></li>
304 <li><a href=
"#cupsFileFlush" title=
"Flush pending output.">cupsFileFlush
</a></li>
305 <li><a href=
"#cupsFileGetChar" title=
"Get a single character from a file.">cupsFileGetChar
</a></li>
306 <li><a href=
"#cupsFileGetConf" title=
"Get a line from a configuration file...">cupsFileGetConf
</a></li>
307 <li><a href=
"#cupsFileGetLine" title=
"Get a CR and/or LF-terminated line that may
308 contain binary data.">cupsFileGetLine
</a></li>
309 <li><a href=
"#cupsFileGets" title=
"Get a CR and/or LF-terminated line.">cupsFileGets
</a></li>
310 <li><a href=
"#cupsFileLock" title=
"Temporarily lock access to a file.">cupsFileLock
</a></li>
311 <li><a href=
"#cupsFileNumber" title=
"Return the file descriptor associated with a CUPS file.">cupsFileNumber
</a></li>
312 <li><a href=
"#cupsFileOpen" title=
"Open a CUPS file.">cupsFileOpen
</a></li>
313 <li><a href=
"#cupsFileOpenFd" title=
"Open a CUPS file using a file descriptor.">cupsFileOpenFd
</a></li>
314 <li><a href=
"#cupsFilePeekChar" title=
"Peek at the next character from a file.">cupsFilePeekChar
</a></li>
315 <li><a href=
"#cupsFilePrintf" title=
"Write a formatted string.">cupsFilePrintf
</a></li>
316 <li><a href=
"#cupsFilePutChar" title=
"Write a character.">cupsFilePutChar
</a></li>
317 <li><a href=
"#cupsFilePutConf" title=
"Write a configuration line.">cupsFilePutConf
</a></li>
318 <li><a href=
"#cupsFilePuts" title=
"Write a string.">cupsFilePuts
</a></li>
319 <li><a href=
"#cupsFileRead" title=
"Read from a file.">cupsFileRead
</a></li>
320 <li><a href=
"#cupsFileRewind" title=
"Set the current file position to the beginning of the
321 file.">cupsFileRewind
</a></li>
322 <li><a href=
"#cupsFileSeek" title=
"Seek in a file.">cupsFileSeek
</a></li>
323 <li><a href=
"#cupsFileStderr" title=
"Return a CUPS file associated with stderr.">cupsFileStderr
</a></li>
324 <li><a href=
"#cupsFileStdin" title=
"Return a CUPS file associated with stdin.">cupsFileStdin
</a></li>
325 <li><a href=
"#cupsFileStdout" title=
"Return a CUPS file associated with stdout.">cupsFileStdout
</a></li>
326 <li><a href=
"#cupsFileTell" title=
"Return the current file position.">cupsFileTell
</a></li>
327 <li><a href=
"#cupsFileUnlock" title=
"Unlock access to a file.">cupsFileUnlock
</a></li>
328 <li><a href=
"#cupsFileWrite" title=
"Write to a file.">cupsFileWrite
</a></li>
330 <li><a href=
"#TYPES">Data Types
</a><ul class=
"code">
331 <li><a href=
"#cups_dentry_t" title=
"Directory entry type">cups_dentry_t
</a></li>
332 <li><a href=
"#cups_dir_t" title=
"Directory type">cups_dir_t
</a></li>
333 <li><a href=
"#cups_file_t" title=
"CUPS file type">cups_file_t
</a></li>
335 <li><a href=
"#STRUCTURES">Structures
</a><ul class=
"code">
336 <li><a href=
"#cups_dentry_s" title=
"Directory entry type">cups_dentry_s
</a></li>
340 "$Id: api-filedir.shtml 7279 2008-01-31 01:50:44Z mike $"
342 File and directory API introduction for the Common UNIX Printing System (CUPS).
344 Copyright 2007-2008 by Apple Inc.
345 Copyright 1997-2005 by Easy Software Products, all rights reserved.
347 These coded instructions, statements, and computer programs are the
348 property of Apple Inc. and are protected by Federal copyright
349 law. Distribution and use rights are outlined in the file "LICENSE.txt"
350 which should have been included with this file. If this file is
351 file is missing or damaged, see the license at "http://www.cups.org/".
354 <h2 class='title'
><a name=
"OVERVIEW">Overview
</a></h2>
356 <p>The CUPS file and directory APIs provide portable interfaces
357 for manipulating files and listing files and directories. Unlike
358 stdio
<code>FILE
</code> streams, the
<code>cupsFile
</code> functions
359 allow you to open more than
256 files at any given time. They
360 also manage the platform-specific details of locking, large file
361 support, line endings (CR, LF, or CR LF), and reading and writing
362 files using Flate (
"gzip") compression. Finally, you can also
363 connect, read from, and write to network connections using the
364 <code>cupsFile
</code> functions.
</p>
366 <p>The
<code>cupsDir
</code> functions manage the platform-specific
367 details of directory access/listing and provide a convenient way
368 to get both a list of files and the information (permissions,
369 size, timestamp, etc.) for each of those files.
</p>
370 <h2 class=
"title"><a name=
"FUNCTIONS">Functions
</a></h2>
371 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsDirClose">cupsDirClose
</a></h3>
372 <p class=
"description">Close a directory.
</p>
374 void cupsDirClose (
<br>
375 <a href=
"#cups_dir_t">cups_dir_t
</a> *dp
<br>
377 <h4 class=
"parameters">Parameters
</h4>
380 <dd class=
"description">Directory pointer
</dd>
382 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsDirOpen">cupsDirOpen
</a></h3>
383 <p class=
"description">Open a directory.
</p>
385 <a href=
"#cups_dir_t">cups_dir_t
</a> *cupsDirOpen (
<br>
386 const char *directory
<br>
388 <h4 class=
"parameters">Parameters
</h4>
391 <dd class=
"description">Directory name
</dd>
393 <h4 class=
"returnvalue">Return Value
</h4>
394 <p class=
"description">Directory pointer or
<code>NULL
</code> if the directory could not be opened.
</p>
395 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsDirRead">cupsDirRead
</a></h3>
396 <p class=
"description">Read the next directory entry.
</p>
398 <a href=
"#cups_dentry_t">cups_dentry_t
</a> *cupsDirRead (
<br>
399 <a href=
"#cups_dir_t">cups_dir_t
</a> *dp
<br>
401 <h4 class=
"parameters">Parameters
</h4>
404 <dd class=
"description">Directory pointer
</dd>
406 <h4 class=
"returnvalue">Return Value
</h4>
407 <p class=
"description">Directory entry or
<code>NULL
</code> when there are no more
</p>
408 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsDirRewind">cupsDirRewind
</a></h3>
409 <p class=
"description">Rewind to the start of the directory.
</p>
411 void cupsDirRewind (
<br>
412 <a href=
"#cups_dir_t">cups_dir_t
</a> *dp
<br>
414 <h4 class=
"parameters">Parameters
</h4>
417 <dd class=
"description">Directory pointer
</dd>
419 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileClose">cupsFileClose
</a></h3>
420 <p class=
"description">Close a CUPS file.
</p>
422 int cupsFileClose (
<br>
423 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
425 <h4 class=
"parameters">Parameters
</h4>
428 <dd class=
"description">CUPS file
</dd>
430 <h4 class=
"returnvalue">Return Value
</h4>
431 <p class=
"description">0 on success, -
1 on error
</p>
432 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileCompression">cupsFileCompression
</a></h3>
433 <p class=
"description">Return whether a file is compressed.
</p>
435 int cupsFileCompression (
<br>
436 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
438 <h4 class=
"parameters">Parameters
</h4>
441 <dd class=
"description">CUPS file
</dd>
443 <h4 class=
"returnvalue">Return Value
</h4>
444 <p class=
"description"><code>CUPS_FILE_NONE
</code> or
<code>CUPS_FILE_GZIP
</code></p>
445 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileEOF">cupsFileEOF
</a></h3>
446 <p class=
"description">Return the end-of-file status.
</p>
448 int cupsFileEOF (
<br>
449 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
451 <h4 class=
"parameters">Parameters
</h4>
454 <dd class=
"description">CUPS file
</dd>
456 <h4 class=
"returnvalue">Return Value
</h4>
457 <p class=
"description">1 on end of file,
0 otherwise
</p>
458 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileFind">cupsFileFind
</a></h3>
459 <p class=
"description">Find a file using the specified path.
</p>
461 const char *cupsFileFind (
<br>
462 const char *filename,
<br>
463 const char *path,
<br>
464 int executable,
<br>
465 char *buffer,
<br>
466 int bufsize
<br>
468 <h4 class=
"parameters">Parameters
</h4>
471 <dd class=
"description">File to find
</dd>
473 <dd class=
"description">Colon/semicolon-separated path
</dd>
475 <dd class=
"description">1 = executable files,
0 = any file/dir
</dd>
477 <dd class=
"description">Filename buffer
</dd>
479 <dd class=
"description">Size of filename buffer
</dd>
481 <h4 class=
"returnvalue">Return Value
</h4>
482 <p class=
"description">Full path to file or
<code>NULL
</code> if not found
</p>
483 <h4 class=
"discussion">Discussion
</h4>
484 <p class=
"discussion">This function allows the paths in the path string to be separated by
485 colons (UNIX standard) or semicolons (Windows standard) and stores the
486 result in the buffer supplied. If the file cannot be found in any of
487 the supplied paths,
<code>NULL
</code> is returned. A
<code>NULL
</code> path only
488 matches the current directory.
491 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileFlush">cupsFileFlush
</a></h3>
492 <p class=
"description">Flush pending output.
</p>
494 int cupsFileFlush (
<br>
495 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
497 <h4 class=
"parameters">Parameters
</h4>
500 <dd class=
"description">CUPS file
</dd>
502 <h4 class=
"returnvalue">Return Value
</h4>
503 <p class=
"description">0 on success, -
1 on error
</p>
504 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileGetChar">cupsFileGetChar
</a></h3>
505 <p class=
"description">Get a single character from a file.
</p>
507 int cupsFileGetChar (
<br>
508 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
510 <h4 class=
"parameters">Parameters
</h4>
513 <dd class=
"description">CUPS file
</dd>
515 <h4 class=
"returnvalue">Return Value
</h4>
516 <p class=
"description">Character or -
1 on end of file
</p>
517 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileGetConf">cupsFileGetConf
</a></h3>
518 <p class=
"description">Get a line from a configuration file...
</p>
520 char *cupsFileGetConf (
<br>
521 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
522 char *buf,
<br>
523 size_t buflen,
<br>
524 char **value,
<br>
525 int *linenum
<br>
527 <h4 class=
"parameters">Parameters
</h4>
530 <dd class=
"description">CUPS file
</dd>
532 <dd class=
"description">String buffer
</dd>
534 <dd class=
"description">Size of string buffer
</dd>
536 <dd class=
"description">Pointer to value
</dd>
538 <dd class=
"description">Current line number
</dd>
540 <h4 class=
"returnvalue">Return Value
</h4>
541 <p class=
"description">Line read or
<code>NULL
</code> on end of file or error
</p>
542 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileGetLine">cupsFileGetLine
</a></h3>
543 <p class=
"description">Get a CR and/or LF-terminated line that may
544 contain binary data.
</p>
546 size_t cupsFileGetLine (
<br>
547 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
548 char *buf,
<br>
549 size_t buflen
<br>
551 <h4 class=
"parameters">Parameters
</h4>
554 <dd class=
"description">File to read from
</dd>
556 <dd class=
"description">Buffer
</dd>
558 <dd class=
"description">Size of buffer
</dd>
560 <h4 class=
"returnvalue">Return Value
</h4>
561 <p class=
"description">Number of bytes on line or
0 on end of file
</p>
562 <h4 class=
"discussion">Discussion
</h4>
563 <p class=
"discussion">This function differs from
<a href=
"#cupsFileGets"><code>cupsFileGets
</code></a> in that the trailing CR
564 and LF are preserved, as is any binary data on the line. The buffer is
565 nul-terminated, however you should use the returned length to determine
566 the number of bytes on the line.
569 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileGets">cupsFileGets
</a></h3>
570 <p class=
"description">Get a CR and/or LF-terminated line.
</p>
572 char *cupsFileGets (
<br>
573 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
574 char *buf,
<br>
575 size_t buflen
<br>
577 <h4 class=
"parameters">Parameters
</h4>
580 <dd class=
"description">CUPS file
</dd>
582 <dd class=
"description">String buffer
</dd>
584 <dd class=
"description">Size of string buffer
</dd>
586 <h4 class=
"returnvalue">Return Value
</h4>
587 <p class=
"description">Line read or
<code>NULL
</code> on end of file or error
</p>
588 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileLock">cupsFileLock
</a></h3>
589 <p class=
"description">Temporarily lock access to a file.
</p>
591 int cupsFileLock (
<br>
592 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
593 int block
<br>
595 <h4 class=
"parameters">Parameters
</h4>
598 <dd class=
"description">CUPS file
</dd>
600 <dd class=
"description">1 to wait for the lock,
0 to fail right away
</dd>
602 <h4 class=
"returnvalue">Return Value
</h4>
603 <p class=
"description">0 on success, -
1 on error
</p>
604 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileNumber">cupsFileNumber
</a></h3>
605 <p class=
"description">Return the file descriptor associated with a CUPS file.
</p>
607 int cupsFileNumber (
<br>
608 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
610 <h4 class=
"parameters">Parameters
</h4>
613 <dd class=
"description">CUPS file
</dd>
615 <h4 class=
"returnvalue">Return Value
</h4>
616 <p class=
"description">File descriptor
</p>
617 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileOpen">cupsFileOpen
</a></h3>
618 <p class=
"description">Open a CUPS file.
</p>
620 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileOpen (
<br>
621 const char *filename,
<br>
622 const char *mode
<br>
624 <h4 class=
"parameters">Parameters
</h4>
627 <dd class=
"description">Name of file
</dd>
629 <dd class=
"description">Open mode
</dd>
631 <h4 class=
"returnvalue">Return Value
</h4>
632 <p class=
"description">CUPS file or
<code>NULL
</code> if the file or socket cannot be opened
</p>
633 <h4 class=
"discussion">Discussion
</h4>
634 <p class=
"discussion">The
"mode
" parameter can be
"r
" to read,
"w
" to write, overwriting any
635 existing file,
"a
" to append to an existing file or create a new file,
636 or
"s
" to open a socket connection.
<br>
638 When opening for writing (
"w
"), an optional number from
1 to
9 can be
639 supplied which enables Flate compression of the file. Compression is
640 not supported for the
"a
" (append) mode.
<br>
642 When opening a socket connection, the filename is a string of the form
643 "address:port
" or
"hostname:port
". The socket will make an IPv4 or IPv6
644 connection as needed, generally preferring IPv6 connections when there is
648 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileOpenFd">cupsFileOpenFd
</a></h3>
649 <p class=
"description">Open a CUPS file using a file descriptor.
</p>
651 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileOpenFd (
<br>
652 int fd,
<br>
653 const char *mode
<br>
655 <h4 class=
"parameters">Parameters
</h4>
658 <dd class=
"description">File descriptor
</dd>
660 <dd class=
"description">Open mode
</dd>
662 <h4 class=
"returnvalue">Return Value
</h4>
663 <p class=
"description">CUPS file or
<code>NULL
</code> if the file could not be opened
</p>
664 <h4 class=
"discussion">Discussion
</h4>
665 <p class=
"discussion">The
"mode
" parameter can be
"r
" to read,
"w
" to write,
"a
" to append,
666 or
"s
" to treat the file descriptor as a bidirectional socket connection.
<br>
668 When opening for writing (
"w
"), an optional number from
1 to
9 can be
669 supplied which enables Flate compression of the file. Compression is
670 not supported for the
"a
" (append) mode.
673 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFilePeekChar">cupsFilePeekChar
</a></h3>
674 <p class=
"description">Peek at the next character from a file.
</p>
676 int cupsFilePeekChar (
<br>
677 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
679 <h4 class=
"parameters">Parameters
</h4>
682 <dd class=
"description">CUPS file
</dd>
684 <h4 class=
"returnvalue">Return Value
</h4>
685 <p class=
"description">Character or -
1 on end of file
</p>
686 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFilePrintf">cupsFilePrintf
</a></h3>
687 <p class=
"description">Write a formatted string.
</p>
689 int cupsFilePrintf (
<br>
690 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
691 const char *format,
<br>
692 ...
<br>
694 <h4 class=
"parameters">Parameters
</h4>
697 <dd class=
"description">CUPS file
</dd>
699 <dd class=
"description">Printf-style format string
</dd>
701 <dd class=
"description">Additional args as necessary
</dd>
703 <h4 class=
"returnvalue">Return Value
</h4>
704 <p class=
"description">Number of bytes written or -
1 on error
</p>
705 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFilePutChar">cupsFilePutChar
</a></h3>
706 <p class=
"description">Write a character.
</p>
708 int cupsFilePutChar (
<br>
709 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
710 int c
<br>
712 <h4 class=
"parameters">Parameters
</h4>
715 <dd class=
"description">CUPS file
</dd>
717 <dd class=
"description">Character to write
</dd>
719 <h4 class=
"returnvalue">Return Value
</h4>
720 <p class=
"description">0 on success, -
1 on error
</p>
721 <h3 class=
"function"><span class=
"info"> CUPS
1.4 </span><a name=
"cupsFilePutConf">cupsFilePutConf
</a></h3>
722 <p class=
"description">Write a configuration line.
</p>
724 ssize_t cupsFilePutConf (
<br>
725 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
726 const char *directive,
<br>
727 const char *value
<br>
729 <h4 class=
"parameters">Parameters
</h4>
732 <dd class=
"description">CUPS file
</dd>
734 <dd class=
"description">Directive
</dd>
736 <dd class=
"description">Value
</dd>
738 <h4 class=
"returnvalue">Return Value
</h4>
739 <p class=
"description">Number of bytes written or -
1 on error
</p>
740 <h4 class=
"discussion">Discussion
</h4>
741 <p class=
"discussion">This function handles any comment escaping of the value.
744 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFilePuts">cupsFilePuts
</a></h3>
745 <p class=
"description">Write a string.
</p>
747 int cupsFilePuts (
<br>
748 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
749 const char *s
<br>
751 <h4 class=
"parameters">Parameters
</h4>
754 <dd class=
"description">CUPS file
</dd>
756 <dd class=
"description">String to write
</dd>
758 <h4 class=
"returnvalue">Return Value
</h4>
759 <p class=
"description">Number of bytes written or -
1 on error
</p>
760 <h4 class=
"discussion">Discussion
</h4>
761 <p class=
"discussion">Like the
<code>fputs
</code> function, no newline is appended to the string.
764 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileRead">cupsFileRead
</a></h3>
765 <p class=
"description">Read from a file.
</p>
767 ssize_t cupsFileRead (
<br>
768 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
769 char *buf,
<br>
770 size_t bytes
<br>
772 <h4 class=
"parameters">Parameters
</h4>
775 <dd class=
"description">CUPS file
</dd>
777 <dd class=
"description">Buffer
</dd>
779 <dd class=
"description">Number of bytes to read
</dd>
781 <h4 class=
"returnvalue">Return Value
</h4>
782 <p class=
"description">Number of bytes read or -
1 on error
</p>
783 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileRewind">cupsFileRewind
</a></h3>
784 <p class=
"description">Set the current file position to the beginning of the
787 off_t cupsFileRewind (
<br>
788 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
790 <h4 class=
"parameters">Parameters
</h4>
793 <dd class=
"description">CUPS file
</dd>
795 <h4 class=
"returnvalue">Return Value
</h4>
796 <p class=
"description">New file position or -
1 on error
</p>
797 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileSeek">cupsFileSeek
</a></h3>
798 <p class=
"description">Seek in a file.
</p>
800 off_t cupsFileSeek (
<br>
801 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
802 off_t pos
<br>
804 <h4 class=
"parameters">Parameters
</h4>
807 <dd class=
"description">CUPS file
</dd>
809 <dd class=
"description">Position in file
</dd>
811 <h4 class=
"returnvalue">Return Value
</h4>
812 <p class=
"description">New file position or -
1 on error
</p>
813 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileStderr">cupsFileStderr
</a></h3>
814 <p class=
"description">Return a CUPS file associated with stderr.
</p>
816 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileStderr (void);
</p>
817 <h4 class=
"returnvalue">Return Value
</h4>
818 <p class=
"description">CUPS file
</p>
819 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileStdin">cupsFileStdin
</a></h3>
820 <p class=
"description">Return a CUPS file associated with stdin.
</p>
822 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileStdin (void);
</p>
823 <h4 class=
"returnvalue">Return Value
</h4>
824 <p class=
"description">CUPS file
</p>
825 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileStdout">cupsFileStdout
</a></h3>
826 <p class=
"description">Return a CUPS file associated with stdout.
</p>
828 <a href=
"#cups_file_t">cups_file_t
</a> *cupsFileStdout (void);
</p>
829 <h4 class=
"returnvalue">Return Value
</h4>
830 <p class=
"description">CUPS file
</p>
831 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileTell">cupsFileTell
</a></h3>
832 <p class=
"description">Return the current file position.
</p>
834 off_t cupsFileTell (
<br>
835 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
837 <h4 class=
"parameters">Parameters
</h4>
840 <dd class=
"description">CUPS file
</dd>
842 <h4 class=
"returnvalue">Return Value
</h4>
843 <p class=
"description">File position
</p>
844 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileUnlock">cupsFileUnlock
</a></h3>
845 <p class=
"description">Unlock access to a file.
</p>
847 int cupsFileUnlock (
<br>
848 <a href=
"#cups_file_t">cups_file_t
</a> *fp
<br>
850 <h4 class=
"parameters">Parameters
</h4>
853 <dd class=
"description">CUPS file
</dd>
855 <h4 class=
"returnvalue">Return Value
</h4>
856 <p class=
"description">0 on success, -
1 on error
</p>
857 <h3 class=
"function"><span class=
"info"> CUPS
1.2 </span><a name=
"cupsFileWrite">cupsFileWrite
</a></h3>
858 <p class=
"description">Write to a file.
</p>
860 ssize_t cupsFileWrite (
<br>
861 <a href=
"#cups_file_t">cups_file_t
</a> *fp,
<br>
862 const char *buf,
<br>
863 size_t bytes
<br>
865 <h4 class=
"parameters">Parameters
</h4>
868 <dd class=
"description">CUPS file
</dd>
870 <dd class=
"description">Buffer
</dd>
872 <dd class=
"description">Number of bytes to write
</dd>
874 <h4 class=
"returnvalue">Return Value
</h4>
875 <p class=
"description">Number of bytes written or -
1 on error
</p>
876 <h2 class=
"title"><a name=
"TYPES">Data Types
</a></h2>
877 <h3 class=
"typedef"><a name=
"cups_dentry_t">cups_dentry_t
</a></h3>
878 <p class=
"description">Directory entry type
</p>
880 typedef struct
<a href=
"#cups_dentry_s">cups_dentry_s
</a> cups_dentry_t;
882 <h3 class=
"typedef"><a name=
"cups_dir_t">cups_dir_t
</a></h3>
883 <p class=
"description">Directory type
</p>
885 typedef struct _cups_dir_s cups_dir_t;
887 <h3 class=
"typedef"><a name=
"cups_file_t">cups_file_t
</a></h3>
888 <p class=
"description">CUPS file type
</p>
890 typedef struct _cups_file_s cups_file_t;
892 <h2 class=
"title"><a name=
"STRUCTURES">Structures
</a></h2>
893 <h3 class=
"struct"><a name=
"cups_dentry_s">cups_dentry_s
</a></h3>
894 <p class=
"description">Directory entry type
</p>
895 <p class=
"code">struct cups_dentry_s {
<br>
896 struct stat fileinfo;
<br>
897 char filename[
260];
<br>
899 <h4 class=
"members">Members
</h4>
902 <dd class=
"description">File information
</dd>
903 <dt>filename[
260]
</dt>
904 <dd class=
"description">File name
</dd>