source: lib/libtraceio.h @ 698a217

4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change on this file since 698a217 was 698a217, checked in by Perry Lorier <perry@…>, 15 years ago

Fix the stdio error handling
Document better the libtraceio API. See the trac wiki for more information.

  • Property mode set to 100644
File size: 1.7 KB
Line 
1#ifndef LIBTRACEIO_H
2#define LIBTRACEIO_H 1
3#include "config.h"
4#ifdef HAVE_ZLIB
5#include <zlib.h>
6#else
7#include <stdio.h>
8#endif
9
10typedef struct libtrace_io_t libtrace_io_t;
11
12/** read a block from a file
13 * @param io    the io file object
14 * @param buf   the buffer to read into
15 * @param len   the number of bytes to read
16 *
17 * @returns -1 on error (with errno set), 0 on eof, otherwise the number of bytes
18 *      read.
19 */
20ssize_t libtrace_io_read(libtrace_io_t *io, void *buf, size_t len);
21/** open a file from a file descriptor (like fdopen(3))
22 * @param fd    file descriptor to read
23 * @param mode  text string to represent what mode to read the file in.
24 *
25 * @returns io object, or NULL on error.
26 */
27libtrace_io_t *libtrace_io_fdopen(int fd, const char *mode);
28/** open a file from a path name
29 * @param path  pathname to read
30 * @param mode  text string to represent what mode to read the file in.
31 *
32 * @returns io object, or NULL on error.
33 */
34libtrace_io_t *libtrace_io_open(const char *path, const char *mode);
35/** close a file and free all of it's resources.
36 * @param io    io object
37 *
38 * This function doesn't return anything.  In theory it could return an error
39 * but seriously, if it did return an error, what would you do about it?
40 */
41void libtrace_io_close(libtrace_io_t *io);
42
43/** write a block of data to a file
44 * @param io    libtrace io object to write to
45 * @param buf   buffer to write to
46 * @param len   number of bytes to write
47 *
48 * @returns the number of bytes successfully written, or -1 on error with
49 * errno set
50 */
51ssize_t libtrace_io_write(libtrace_io_t *io, const void *buf, size_t len);
52off_t libtrace_io_seek(libtrace_io_t *io, off_t offset, int whence);
53ssize_t libtrace_io_tell(libtrace_io_t *io);
54
55#endif
Note: See TracBrowser for help on using the repository browser.