source: lib/libtraceio.h @ e5c2bc4

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

Redo the build system for libtrace3

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[8f45780]1/** @file
2 * Internal IO compatibility shim
3 */
[edb18ce]4#ifndef LIBTRACEIO_H
5#define LIBTRACEIO_H 1
6#include "config.h"
[e5c2bc4]7#ifdef HAVE_ZLIB
[edb18ce]8#include <zlib.h>
9#else
10#include <stdio.h>
11#endif
12
[3fcb8b4]13#include <unistd.h>
14
[edb18ce]15typedef struct libtrace_io_t libtrace_io_t;
16
[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);
[698a217]47
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);
59
60#endif
Note: See TracBrowser for help on using the repository browser.