source: lib/libtraceio.h @ 4bd8a5b

Last change on this file since 4bd8a5b was 306f91c, checked in by Perry Lorier <perry@…>, 15 years ago

Fix problems with zlib in the new build environment

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