Lines Matching refs:io
37 #include "io.h"
39 struct io {
46 io_error(struct io *io)
48 fprintf(stderr, "%s\n", archive_error_string(io->a));
49 io_close(io);
52 static struct io *
55 struct io *io = calloc(1, sizeof(*io));
58 if (!io)
61 io->a = archive_read_new();
62 ret = archive_read_support_filter_gzip(io->a);
64 io_error(io);
68 ret = archive_read_support_filter_none(io->a);
70 io_error(io);
74 ret = archive_read_support_format_all(io->a);
76 io_error(io);
80 ret = archive_read_support_format_raw(io->a);
82 io_error(io);
86 return io;
89 struct io *
92 struct io *io = io_new();
95 if (!io)
98 ret = archive_read_open_filename(io->a, filename, 10240);
100 io_error(io);
104 ret = archive_read_next_header(io->a, &io->entry);
106 io_error(io);
110 return io;
113 struct io *
116 struct io *io = io_new();
119 if (!io)
122 ret = archive_read_open_fd(io->a, fd, 10240);
124 io_error(io);
128 ret = archive_read_next_header(io->a, &io->entry);
130 io_error(io);
134 return io;
138 io_close(struct io *io)
140 archive_read_free(io->a);
141 free(io);
145 io_offset(struct io *io)
147 return io->offset;
152 io_readn(struct io *io, void *buf, int nbytes)
157 int n = archive_read_data(io->a, ptr, nbytes);
159 fprintf(stderr, "%s\n", archive_error_string(io->a));
167 io->offset += n;