]> git.ipfire.org Git - thirdparty/cups.git/blob - doc/help/api-filedir.html
Load cups into easysw/current.
[thirdparty/cups.git] / doc / help / api-filedir.html
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
2 <html>
3 <!-- SECTION: Programming -->
4 <head>
5 <title>File and Directory APIs</title>
6 <meta name='keywords' content='Programming'>
7 <meta name='creator' content='Mini-XML v2.3'>
8 <style type='text/css'><!--
9 h1, h2, h3, p { font-family: sans-serif; text-align: justify; }
10 tt, pre a:link, pre a:visited, tt a:link, tt a:visited { font-weight: bold; color: #7f0000; }
11 pre { font-weight: bold; color: #7f0000; margin-left: 2em; }
12 span.info { background: #000000; border: solid thin #000000; color: #ffffff; font-size: 80%; font-style: italic; font-weight: bold; white-space: nowrap; }
13 h3 span.info { float: right; font-size: 100%; }
14 h1.title, h2.title, h3.title { border-bottom: solid 2px #000000; }
15 --></style>
16 </head>
17 <body>
18 <!--
19 "$Id: api-filedir.shtml 5138 2006-02-21 10:49:06Z mike $"
20
21 File and directory API introduction for the Common UNIX Printing System (CUPS).
22
23 Copyright 1997-2005 by Easy Software Products.
24
25 These coded instructions, statements, and computer programs are the
26 property of Easy Software Products and are protected by Federal
27 copyright law. Distribution and use rights are outlined in the file
28 "LICENSE.txt" which should have been included with this file. If this
29 file is missing or damaged please contact Easy Software Products
30 at:
31
32 Attn: CUPS Licensing Information
33 Easy Software Products
34 44141 Airport View Drive, Suite 204
35 Hollywood, Maryland 20636 USA
36
37 Voice: (301) 373-9600
38 EMail: cups-info@cups.org
39 WWW: http://www.cups.org
40 -->
41
42 <h2 class='title'>Introduction</h2>
43
44 <p>The CUPS file and directory APIs provide portable interfaces
45 for manipulating files and listing files and directories. Unlike
46 stdio <tt>FILE</tt> streams, the <tt>cupsFile</tt> functions
47 allow you to open more than 256 files at any given time. They
48 also manage the platform-specific details of locking, large file
49 support, line endings (CR, LF, or CR LF), and reading and writing
50 files using Flate ("gzip") compression. Finally, you can also
51 connect, read from, and write to network connections using the
52 <tt>cupsFile</tt> functions.</p>
53
54 <p>The <tt>cupsDir</tt> functions manage the platform-specific
55 details of directory access/listing and provide a convenient way
56 to get both a list of files and the information (permissions,
57 size, timestamp, etc.) for each of those files.</p>
58
59 <p>The CUPS scheduler (<tt>cupsd</tt>), <tt>mailto</tt> notifier,
60 and many of the CUPS API functions use these functions for
61 everything except console (stdin, stdout, stderr) I/O.</p>
62
63 <h2 class='title'>General Usage</h2>
64
65 <p>The <var>&lt;cups/dir.h&gt;</var> and
66 <var>&lt;cups/file.h&gt;</var> header files must be included to
67 use the <tt>cupsDir</tt> and <tt>cupsFile</tt> functions,
68 respectively.</p>
69
70 <p>Programs using these functions must be linked to the CUPS
71 library: <var>libcups.a</var>, <var>libcups.so.2</var>,
72 <var>libcups.2.dylib</var>, <var>libcups_s.a</var>, or
73 <var>libcups2.lib</var> depending on the platform. The following
74 command compiles <var>myprogram.c</var> using GCC and the CUPS
75 library:</p>
76
77 <pre class='command'>
78 <kbd>gcc -o myprogram myprogram.c -lcups</kbd>
79 </pre>
80
81 <h2 class='title'>Compatibility</h2>
82
83 <p>All of these functions require CUPS 1.2 or higher.</p>
84 <h2 class='title'>Contents</h2>
85 <ul>
86 <li><a href='#FUNCTIONS'>Functions</a></li>
87 <li><a href='#STRUCTURES'>Structures</a></li>
88 <li><a href='#TYPES'>Types</a></li>
89 </ul>
90 <!-- NEW PAGE -->
91 <h2 class='title'><a name='FUNCTIONS'>Functions</a></h2>
92 <ul>
93 <li><a href='#cupsDirClose'><tt>cupsDirClose()</tt></a> </li>
94 <li><a href='#cupsDirOpen'><tt>cupsDirOpen()</tt></a> </li>
95 <li><a href='#cupsDirRead'><tt>cupsDirRead()</tt></a> </li>
96 <li><a href='#cupsDirRewind'><tt>cupsDirRewind()</tt></a> </li>
97 <li><a href='#cupsFileClose'><tt>cupsFileClose()</tt></a> </li>
98 <li><a href='#cupsFileCompression'><tt>cupsFileCompression()</tt></a> </li>
99 <li><a href='#cupsFileEOF'><tt>cupsFileEOF()</tt></a> </li>
100 <li><a href='#cupsFileFind'><tt>cupsFileFind()</tt></a> </li>
101 <li><a href='#cupsFileFlush'><tt>cupsFileFlush()</tt></a> </li>
102 <li><a href='#cupsFileGetChar'><tt>cupsFileGetChar()</tt></a> </li>
103 <li><a href='#cupsFileGetConf'><tt>cupsFileGetConf()</tt></a> </li>
104 <li><a href='#cupsFileGets'><tt>cupsFileGets()</tt></a> </li>
105 <li><a href='#cupsFileLock'><tt>cupsFileLock()</tt></a> </li>
106 <li><a href='#cupsFileNumber'><tt>cupsFileNumber()</tt></a> </li>
107 <li><a href='#cupsFileOpen'><tt>cupsFileOpen()</tt></a> </li>
108 <li><a href='#cupsFileOpenFd'><tt>cupsFileOpenFd()</tt></a> </li>
109 <li><a href='#cupsFilePeekChar'><tt>cupsFilePeekChar()</tt></a> </li>
110 <li><a href='#cupsFilePrintf'><tt>cupsFilePrintf()</tt></a> </li>
111 <li><a href='#cupsFilePutChar'><tt>cupsFilePutChar()</tt></a> </li>
112 <li><a href='#cupsFilePuts'><tt>cupsFilePuts()</tt></a> </li>
113 <li><a href='#cupsFileRead'><tt>cupsFileRead()</tt></a> </li>
114 <li><a href='#cupsFileRewind'><tt>cupsFileRewind()</tt></a> </li>
115 <li><a href='#cupsFileSeek'><tt>cupsFileSeek()</tt></a> </li>
116 <li><a href='#cupsFileTell'><tt>cupsFileTell()</tt></a> </li>
117 <li><a href='#cupsFileUnlock'><tt>cupsFileUnlock()</tt></a> </li>
118 <li><a href='#cupsFileWrite'><tt>cupsFileWrite()</tt></a> </li>
119 </ul>
120 <!-- NEW PAGE -->
121 <h3 class='title'><a name='cupsDirClose'>cupsDirClose()</a></h3>
122 <h4>Description</h4>
123 <p>Close a directory.</p>
124 <h4>Syntax</h4>
125 <pre>
126 void
127 cupsDirClose(
128 <a href='#cups_dir_t'>cups_dir_t</a> * dp);
129 </pre>
130 <h4>Arguments</h4>
131 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
132 <thead><tr><th>Name</th><th>Description</th></tr></thead>
133 <tbody>
134 <tr><td><tt>dp</tt></td><td>Directory</td></tr>
135 </tbody></table></div>
136 <h4>Returns</h4>
137 <p>Nothing.</p>
138 <!-- NEW PAGE -->
139 <h3 class='title'><a name='cupsDirOpen'>cupsDirOpen()</a></h3>
140 <h4>Description</h4>
141 <p>Open a directory.</p>
142 <h4>Syntax</h4>
143 <pre>
144 <a href='#cups_dir_t'>cups_dir_t</a> *
145 cupsDirOpen(
146 const char * directory);
147 </pre>
148 <h4>Arguments</h4>
149 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
150 <thead><tr><th>Name</th><th>Description</th></tr></thead>
151 <tbody>
152 <tr><td><tt>directory</tt></td><td>Directory name</td></tr>
153 </tbody></table></div>
154 <h4>Returns</h4>
155 <p>Directory</p>
156 <!-- NEW PAGE -->
157 <h3 class='title'><a name='cupsDirRead'>cupsDirRead()</a></h3>
158 <h4>Description</h4>
159 <p>Read the next directory entry.</p>
160 <h4>Syntax</h4>
161 <pre>
162 <a href='#cups_dentry_t'>cups_dentry_t</a> *
163 cupsDirRead(
164 <a href='#cups_dir_t'>cups_dir_t</a> * dp);
165 </pre>
166 <h4>Arguments</h4>
167 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
168 <thead><tr><th>Name</th><th>Description</th></tr></thead>
169 <tbody>
170 <tr><td><tt>dp</tt></td><td>Directory</td></tr>
171 </tbody></table></div>
172 <h4>Returns</h4>
173 <p>Directory entry</p>
174 <!-- NEW PAGE -->
175 <h3 class='title'><a name='cupsDirRewind'>cupsDirRewind()</a></h3>
176 <h4>Description</h4>
177 <p>Rewind to the start of the directory.</p>
178 <h4>Syntax</h4>
179 <pre>
180 void
181 cupsDirRewind(
182 <a href='#cups_dir_t'>cups_dir_t</a> * dp);
183 </pre>
184 <h4>Arguments</h4>
185 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
186 <thead><tr><th>Name</th><th>Description</th></tr></thead>
187 <tbody>
188 <tr><td><tt>dp</tt></td><td>Directory</td></tr>
189 </tbody></table></div>
190 <h4>Returns</h4>
191 <p>Nothing.</p>
192 <!-- NEW PAGE -->
193 <h3 class='title'><a name='cupsFileClose'>cupsFileClose()</a></h3>
194 <h4>Description</h4>
195 <p>Close a CUPS file.</p>
196 <h4>Syntax</h4>
197 <pre>
198 int
199 cupsFileClose(
200 <a href='#cups_file_t'>cups_file_t</a> * fp);
201 </pre>
202 <h4>Arguments</h4>
203 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
204 <thead><tr><th>Name</th><th>Description</th></tr></thead>
205 <tbody>
206 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
207 </tbody></table></div>
208 <h4>Returns</h4>
209 <p>0 on success, -1 on error</p>
210 <!-- NEW PAGE -->
211 <h3 class='title'><a name='cupsFileCompression'>cupsFileCompression()</a></h3>
212 <h4>Description</h4>
213 <p>Return whether a file is compressed.</p>
214 <h4>Syntax</h4>
215 <pre>
216 int
217 cupsFileCompression(
218 <a href='#cups_file_t'>cups_file_t</a> * fp);
219 </pre>
220 <h4>Arguments</h4>
221 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
222 <thead><tr><th>Name</th><th>Description</th></tr></thead>
223 <tbody>
224 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
225 </tbody></table></div>
226 <h4>Returns</h4>
227 <p>CUPS_FILE_NONE or CUPS_FILE_GZIP</p>
228 <!-- NEW PAGE -->
229 <h3 class='title'><a name='cupsFileEOF'>cupsFileEOF()</a></h3>
230 <h4>Description</h4>
231 <p>Return the end-of-file status.</p>
232 <h4>Syntax</h4>
233 <pre>
234 int
235 cupsFileEOF(
236 <a href='#cups_file_t'>cups_file_t</a> * fp);
237 </pre>
238 <h4>Arguments</h4>
239 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
240 <thead><tr><th>Name</th><th>Description</th></tr></thead>
241 <tbody>
242 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
243 </tbody></table></div>
244 <h4>Returns</h4>
245 <p>1 on EOF, 0 otherwise</p>
246 <!-- NEW PAGE -->
247 <h3 class='title'><a name='cupsFileFind'>cupsFileFind()</a></h3>
248 <h4>Description</h4>
249 <p>Find a file using the specified path.
250
251 This function allows the paths in the path string to be separated by
252 colons (UNIX standard) or semicolons (Windows standard) and stores the
253 result in the buffer supplied. If the file cannot be found in any of
254 the supplied paths, NULL is returned. A NULL path only matches the
255 current directory.</p>
256 <h4>Syntax</h4>
257 <pre>
258 const char *
259 cupsFileFind(
260 const char * filename,
261 const char * path,
262 int executable,
263 char * buffer,
264 int bufsize);
265 </pre>
266 <h4>Arguments</h4>
267 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
268 <thead><tr><th>Name</th><th>Description</th></tr></thead>
269 <tbody>
270 <tr><td><tt>filename</tt></td><td>File to find</td></tr>
271 <tr><td><tt>path</tt></td><td>Colon/semicolon-separated path</td></tr>
272 <tr><td><tt>executable</tt></td><td>1 = executable files, 0 = any file/dir</td></tr>
273 <tr><td><tt>buffer</tt></td><td>Filename buffer</td></tr>
274 <tr><td><tt>bufsize</tt></td><td>Size of filename buffer</td></tr>
275 </tbody></table></div>
276 <h4>Returns</h4>
277 <p>Full path to file or NULL</p>
278 <!-- NEW PAGE -->
279 <h3 class='title'><a name='cupsFileFlush'>cupsFileFlush()</a></h3>
280 <h4>Description</h4>
281 <p>Flush pending output.</p>
282 <h4>Syntax</h4>
283 <pre>
284 int
285 cupsFileFlush(
286 <a href='#cups_file_t'>cups_file_t</a> * fp);
287 </pre>
288 <h4>Arguments</h4>
289 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
290 <thead><tr><th>Name</th><th>Description</th></tr></thead>
291 <tbody>
292 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
293 </tbody></table></div>
294 <h4>Returns</h4>
295 <p>0 on success, -1 on error</p>
296 <!-- NEW PAGE -->
297 <h3 class='title'><a name='cupsFileGetChar'>cupsFileGetChar()</a></h3>
298 <h4>Description</h4>
299 <p>Get a single character from a file.</p>
300 <h4>Syntax</h4>
301 <pre>
302 int
303 cupsFileGetChar(
304 <a href='#cups_file_t'>cups_file_t</a> * fp);
305 </pre>
306 <h4>Arguments</h4>
307 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
308 <thead><tr><th>Name</th><th>Description</th></tr></thead>
309 <tbody>
310 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
311 </tbody></table></div>
312 <h4>Returns</h4>
313 <p>Character or -1 on EOF</p>
314 <!-- NEW PAGE -->
315 <h3 class='title'><a name='cupsFileGetConf'>cupsFileGetConf()</a></h3>
316 <h4>Description</h4>
317 <p>Get a line from a configuration file...</p>
318 <h4>Syntax</h4>
319 <pre>
320 char *
321 cupsFileGetConf(
322 <a href='#cups_file_t'>cups_file_t</a> * fp,
323 char * buf,
324 size_t buflen,
325 char ** value,
326 int * linenum);
327 </pre>
328 <h4>Arguments</h4>
329 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
330 <thead><tr><th>Name</th><th>Description</th></tr></thead>
331 <tbody>
332 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
333 <tr><td><tt>buf</tt></td><td>String buffer</td></tr>
334 <tr><td><tt>buflen</tt></td><td>Size of string buffer</td></tr>
335 <tr><td><tt>value</tt></td><td>Pointer to value</td></tr>
336 <tr><td><tt>linenum</tt></td><td>Current line number</td></tr>
337 </tbody></table></div>
338 <h4>Returns</h4>
339 <p>Line read or NULL on eof/error</p>
340 <!-- NEW PAGE -->
341 <h3 class='title'><a name='cupsFileGets'>cupsFileGets()</a></h3>
342 <h4>Description</h4>
343 <p>Get a CR and/or LF-terminated line.</p>
344 <h4>Syntax</h4>
345 <pre>
346 char *
347 cupsFileGets(
348 <a href='#cups_file_t'>cups_file_t</a> * fp,
349 char * buf,
350 size_t buflen);
351 </pre>
352 <h4>Arguments</h4>
353 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
354 <thead><tr><th>Name</th><th>Description</th></tr></thead>
355 <tbody>
356 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
357 <tr><td><tt>buf</tt></td><td>String buffer</td></tr>
358 <tr><td><tt>buflen</tt></td><td>Size of string buffer</td></tr>
359 </tbody></table></div>
360 <h4>Returns</h4>
361 <p>Line read or NULL on eof/error</p>
362 <!-- NEW PAGE -->
363 <h3 class='title'><a name='cupsFileLock'>cupsFileLock()</a></h3>
364 <h4>Description</h4>
365 <p>Temporarily lock access to a file.</p>
366 <h4>Syntax</h4>
367 <pre>
368 int
369 cupsFileLock(
370 <a href='#cups_file_t'>cups_file_t</a> * fp,
371 int block);
372 </pre>
373 <h4>Arguments</h4>
374 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
375 <thead><tr><th>Name</th><th>Description</th></tr></thead>
376 <tbody>
377 <tr><td><tt>fp</tt></td><td>File to lock</td></tr>
378 <tr><td><tt>block</tt></td><td>1 to wait for the lock, 0 to fail right away</td></tr>
379 </tbody></table></div>
380 <h4>Returns</h4>
381 <p>0 on success, -1 on error</p>
382 <!-- NEW PAGE -->
383 <h3 class='title'><a name='cupsFileNumber'>cupsFileNumber()</a></h3>
384 <h4>Description</h4>
385 <p>Return the file descriptor associated with a CUPS file.</p>
386 <h4>Syntax</h4>
387 <pre>
388 int
389 cupsFileNumber(
390 <a href='#cups_file_t'>cups_file_t</a> * fp);
391 </pre>
392 <h4>Arguments</h4>
393 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
394 <thead><tr><th>Name</th><th>Description</th></tr></thead>
395 <tbody>
396 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
397 </tbody></table></div>
398 <h4>Returns</h4>
399 <p>File descriptor</p>
400 <!-- NEW PAGE -->
401 <h3 class='title'><a name='cupsFileOpen'>cupsFileOpen()</a></h3>
402 <h4>Description</h4>
403 <p>Open a CUPS file.</p>
404 <h4>Syntax</h4>
405 <pre>
406 <a href='#cups_file_t'>cups_file_t</a> *
407 cupsFileOpen(
408 const char * filename,
409 const char * mode);
410 </pre>
411 <h4>Arguments</h4>
412 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
413 <thead><tr><th>Name</th><th>Description</th></tr></thead>
414 <tbody>
415 <tr><td><tt>filename</tt></td><td>Name of file</td></tr>
416 <tr><td><tt>mode</tt></td><td>Open mode</td></tr>
417 </tbody></table></div>
418 <h4>Returns</h4>
419 <p>CUPS file or NULL</p>
420 <!-- NEW PAGE -->
421 <h3 class='title'><a name='cupsFileOpenFd'>cupsFileOpenFd()</a></h3>
422 <h4>Description</h4>
423 <p>Open a CUPS file using a file descriptor.</p>
424 <h4>Syntax</h4>
425 <pre>
426 <a href='#cups_file_t'>cups_file_t</a> *
427 cupsFileOpenFd(
428 int fd,
429 const char * mode);
430 </pre>
431 <h4>Arguments</h4>
432 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
433 <thead><tr><th>Name</th><th>Description</th></tr></thead>
434 <tbody>
435 <tr><td><tt>fd</tt></td><td>File descriptor</td></tr>
436 <tr><td><tt>mode</tt></td><td>Open mode</td></tr>
437 </tbody></table></div>
438 <h4>Returns</h4>
439 <p>CUPS file or NULL</p>
440 <!-- NEW PAGE -->
441 <h3 class='title'><a name='cupsFilePeekChar'>cupsFilePeekChar()</a></h3>
442 <h4>Description</h4>
443 <p>Peek at the next character from a file.</p>
444 <h4>Syntax</h4>
445 <pre>
446 int
447 cupsFilePeekChar(
448 <a href='#cups_file_t'>cups_file_t</a> * fp);
449 </pre>
450 <h4>Arguments</h4>
451 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
452 <thead><tr><th>Name</th><th>Description</th></tr></thead>
453 <tbody>
454 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
455 </tbody></table></div>
456 <h4>Returns</h4>
457 <p>Character or -1 on EOF</p>
458 <!-- NEW PAGE -->
459 <h3 class='title'><a name='cupsFilePrintf'>cupsFilePrintf()</a></h3>
460 <h4>Description</h4>
461 <p>Write a formatted string.</p>
462 <h4>Syntax</h4>
463 <pre>
464 int
465 cupsFilePrintf(
466 <a href='#cups_file_t'>cups_file_t</a> * fp,
467 const char * format,
468 ...);
469 </pre>
470 <h4>Arguments</h4>
471 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
472 <thead><tr><th>Name</th><th>Description</th></tr></thead>
473 <tbody>
474 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
475 <tr><td><tt>format</tt></td><td>Printf-style format string</td></tr>
476 <tr><td><tt>...</tt></td><td>Additional args as necessary</td></tr>
477 </tbody></table></div>
478 <h4>Returns</h4>
479 <p>Number of bytes written or -1</p>
480 <!-- NEW PAGE -->
481 <h3 class='title'><a name='cupsFilePutChar'>cupsFilePutChar()</a></h3>
482 <h4>Description</h4>
483 <p>Write a character.</p>
484 <h4>Syntax</h4>
485 <pre>
486 int
487 cupsFilePutChar(
488 <a href='#cups_file_t'>cups_file_t</a> * fp,
489 int c);
490 </pre>
491 <h4>Arguments</h4>
492 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
493 <thead><tr><th>Name</th><th>Description</th></tr></thead>
494 <tbody>
495 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
496 <tr><td><tt>c</tt></td><td>Character to write</td></tr>
497 </tbody></table></div>
498 <h4>Returns</h4>
499 <p>0 on success, -1 on error</p>
500 <!-- NEW PAGE -->
501 <h3 class='title'><a name='cupsFilePuts'>cupsFilePuts()</a></h3>
502 <h4>Description</h4>
503 <p>Write a string.</p>
504 <h4>Syntax</h4>
505 <pre>
506 int
507 cupsFilePuts(
508 <a href='#cups_file_t'>cups_file_t</a> * fp,
509 const char * s);
510 </pre>
511 <h4>Arguments</h4>
512 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
513 <thead><tr><th>Name</th><th>Description</th></tr></thead>
514 <tbody>
515 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
516 <tr><td><tt>s</tt></td><td>String to write</td></tr>
517 </tbody></table></div>
518 <h4>Returns</h4>
519 <p>Number of bytes written or -1</p>
520 <!-- NEW PAGE -->
521 <h3 class='title'><a name='cupsFileRead'>cupsFileRead()</a></h3>
522 <h4>Description</h4>
523 <p>Read from a file.</p>
524 <h4>Syntax</h4>
525 <pre>
526 <a href='#ssize_t'>ssize_t</a>
527 cupsFileRead(
528 <a href='#cups_file_t'>cups_file_t</a> * fp,
529 char * buf,
530 size_t bytes);
531 </pre>
532 <h4>Arguments</h4>
533 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
534 <thead><tr><th>Name</th><th>Description</th></tr></thead>
535 <tbody>
536 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
537 <tr><td><tt>buf</tt></td><td>Buffer</td></tr>
538 <tr><td><tt>bytes</tt></td><td>Number of bytes to read</td></tr>
539 </tbody></table></div>
540 <h4>Returns</h4>
541 <p>Number of bytes read or -1</p>
542 <!-- NEW PAGE -->
543 <h3 class='title'><a name='cupsFileRewind'>cupsFileRewind()</a></h3>
544 <h4>Description</h4>
545 <p>Rewind a file.</p>
546 <h4>Syntax</h4>
547 <pre>
548 off_t
549 cupsFileRewind(
550 <a href='#cups_file_t'>cups_file_t</a> * fp);
551 </pre>
552 <h4>Arguments</h4>
553 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
554 <thead><tr><th>Name</th><th>Description</th></tr></thead>
555 <tbody>
556 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
557 </tbody></table></div>
558 <h4>Returns</h4>
559 <p>New file position or -1</p>
560 <!-- NEW PAGE -->
561 <h3 class='title'><a name='cupsFileSeek'>cupsFileSeek()</a></h3>
562 <h4>Description</h4>
563 <p>Seek in a file.</p>
564 <h4>Syntax</h4>
565 <pre>
566 off_t
567 cupsFileSeek(
568 <a href='#cups_file_t'>cups_file_t</a> * fp,
569 off_t pos);
570 </pre>
571 <h4>Arguments</h4>
572 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
573 <thead><tr><th>Name</th><th>Description</th></tr></thead>
574 <tbody>
575 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
576 <tr><td><tt>pos</tt></td><td>Position in file</td></tr>
577 </tbody></table></div>
578 <h4>Returns</h4>
579 <p>New file position or -1</p>
580 <!-- NEW PAGE -->
581 <h3 class='title'><a name='cupsFileTell'>cupsFileTell()</a></h3>
582 <h4>Description</h4>
583 <p>Return the current file position.</p>
584 <h4>Syntax</h4>
585 <pre>
586 off_t
587 cupsFileTell(
588 <a href='#cups_file_t'>cups_file_t</a> * fp);
589 </pre>
590 <h4>Arguments</h4>
591 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
592 <thead><tr><th>Name</th><th>Description</th></tr></thead>
593 <tbody>
594 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
595 </tbody></table></div>
596 <h4>Returns</h4>
597 <p>File position</p>
598 <!-- NEW PAGE -->
599 <h3 class='title'><a name='cupsFileUnlock'>cupsFileUnlock()</a></h3>
600 <h4>Description</h4>
601 <p>Unlock access to a file.</p>
602 <h4>Syntax</h4>
603 <pre>
604 int
605 cupsFileUnlock(
606 <a href='#cups_file_t'>cups_file_t</a> * fp);
607 </pre>
608 <h4>Arguments</h4>
609 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
610 <thead><tr><th>Name</th><th>Description</th></tr></thead>
611 <tbody>
612 <tr><td><tt>fp</tt></td><td>File to lock</td></tr>
613 </tbody></table></div>
614 <h4>Returns</h4>
615 <p>0 on success, -1 on error</p>
616 <!-- NEW PAGE -->
617 <h3 class='title'><a name='cupsFileWrite'>cupsFileWrite()</a></h3>
618 <h4>Description</h4>
619 <p>Write to a file.</p>
620 <h4>Syntax</h4>
621 <pre>
622 <a href='#ssize_t'>ssize_t</a>
623 cupsFileWrite(
624 <a href='#cups_file_t'>cups_file_t</a> * fp,
625 const char * buf,
626 size_t bytes);
627 </pre>
628 <h4>Arguments</h4>
629 <div class='table'><table align='center' border='1' width='80%' cellpadding='5' cellspacing='0'>
630 <thead><tr><th>Name</th><th>Description</th></tr></thead>
631 <tbody>
632 <tr><td><tt>fp</tt></td><td>CUPS file</td></tr>
633 <tr><td><tt>buf</tt></td><td>Buffer</td></tr>
634 <tr><td><tt>bytes</tt></td><td>Number of bytes to write</td></tr>
635 </tbody></table></div>
636 <h4>Returns</h4>
637 <p>Number of bytes written</p>
638 <!-- NEW PAGE -->
639 <h2 class='title'><a name='STRUCTURES'>Structures</a></h2>
640 <ul>
641 <li><a href='#cups_dentry_s'><tt>cups_dentry_s</tt></a> </li>
642 </ul>
643 <!-- NEW PAGE -->
644 <h3 class='title'><a name='cups_dentry_s'>cups_dentry_s</a></h3>
645 <h4>Description</h4>
646 <p>Directory entry type</p>
647 <h4>Definition</h4>
648 <pre>
649 struct cups_dentry_s
650 {
651 struct stat fileinfo;
652 char filename[260];
653 };
654 </pre>
655 <h4>Members</h4>
656 <div class='table'><table align='center' border='1' width='80%'>
657 <thead><tr><th>Name</th><th>Description</th></tr></thead>
658 <tbody>
659 <tr><td><tt>fileinfo</tt> </td><td>File information</td></tr>
660 <tr><td><tt>filename[260]</tt> </td><td>File name</td></tr>
661 </tbody></table></div>
662 <!-- NEW PAGE -->
663 <h2 class='title'><a name='TYPES'>Types</a></h2>
664 <ul>
665 <li><a href='#cups_dentry_t'><tt>cups_dentry_t</tt></a> </li>
666 <li><a href='#cups_dir_t'><tt>cups_dir_t</tt></a> </li>
667 <li><a href='#cups_file_t'><tt>cups_file_t</tt></a> </li>
668 </ul>
669 <!-- NEW PAGE -->
670 <h3 class='title'><a name='cups_dentry_t'>cups_dentry_t</a></h3>
671 <h4>Description</h4>
672 <p>Directory entry type</p>
673 <h4>Definition</h4>
674 <pre>
675 typedef struct <a href='#cups_dentry_s'>cups_dentry_s</a> cups_dentry_t;
676 </pre>
677 <!-- NEW PAGE -->
678 <h3 class='title'><a name='cups_dir_t'>cups_dir_t</a></h3>
679 <h4>Description</h4>
680 <p>Directory type</p>
681 <h4>Definition</h4>
682 <pre>
683 typedef struct _cups_dir_s cups_dir_t;
684 </pre>
685 <!-- NEW PAGE -->
686 <h3 class='title'><a name='cups_file_t'>cups_file_t</a></h3>
687 <h4>Description</h4>
688 <p>CUPS file type</p>
689 <h4>Definition</h4>
690 <pre>
691 typedef struct _cups_file_s cups_file_t;
692 </pre>
693 </body>
694 </html>