source: lib/libtraceio.h @ dd06159

Last change on this file since dd06159 was 6ed6c4a, checked in by Brendon Jones <brendonj@…>, 15 years ago

Windows portability fixes.

Windows doesn't have a gettimeofday function, provided an alternate
path that uses _ftime with _timeb structs. This only provides
millisecond resolution rather than microsecond.

Added a few checks to make sure headers that aren't present in
Windows don't get included.

Added new files to the Visual Studio project/solution.

Modified the windows config file to include a few more #defines that
were needed to make pcap support build properly.

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