source: lib/libtraceio.h @ 3fcb8b4

Last change on this file since 3fcb8b4 was 3fcb8b4, checked in by Shane Alcock <salcock@…>, 15 years ago

Added a couple of necessary fixes for FreeBSD compilation - defining PATH_MAX and including unistd.h for ssize_t and off_t
stdbool.h is no longer included if you're compiling as C++ as this causes conflicts under OpenBSD

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