Lines Matching full:io

17 struct io {  struct
34 static inline void io__init(struct io *io, int fd, in io__init() argument
37 io->fd = fd; in io__init()
38 io->buf_len = buf_len; in io__init()
39 io->buf = buf; in io__init()
40 io->end = buf; in io__init()
41 io->data = buf; in io__init()
42 io->timeout_ms = 0; in io__init()
43 io->eof = false; in io__init()
46 /* Read from fd filling the buffer. Called when io->data == io->end. */
47 static inline int io__fill_buffer(struct io *io) in io__fill_buffer() argument
51 if (io->eof) in io__fill_buffer()
54 if (io->timeout_ms != 0) { in io__fill_buffer()
57 .fd = io->fd, in io__fill_buffer()
62 n = poll(pfds, 1, io->timeout_ms); in io__fill_buffer()
70 io->eof = true; in io__fill_buffer()
74 n = read(io->fd, io->buf, io->buf_len); in io__fill_buffer()
77 io->eof = true; in io__fill_buffer()
80 io->data = &io->buf[0]; in io__fill_buffer()
81 io->end = &io->buf[n]; in io__fill_buffer()
85 /* Reads one character from the "io" file with similar semantics to fgetc. */
86 static inline int io__get_char(struct io *io) in io__get_char() argument
88 if (io->data == io->end) { in io__get_char()
89 int ret = io__fill_buffer(io); in io__get_char()
94 return *io->data++; in io__get_char()
98 * first character isn't hexadecimal returns -2, io->eof returns -1, otherwise
102 static inline int io__get_hex(struct io *io, __u64 *hex) in io__get_hex() argument
108 int ch = io__get_char(io); in io__get_hex()
127 * isn't a decimal returns -2, io->eof returns -1, otherwise returns the
131 static inline int io__get_dec(struct io *io, __u64 *dec) in io__get_dec() argument
137 int ch = io__get_char(io); in io__get_dec()
152 static inline ssize_t io__getdelim(struct io *io, char **line_out, size_t *line_len_out, int delim) in io__getdelim() argument
163 ch = io__get_char(io); in io__getdelim()
195 static inline ssize_t io__getline(struct io *io, char **line_out, size_t *line_len_out) in io__getline() argument
197 return io__getdelim(io, line_out, line_len_out, /*delim=*/'\n'); in io__getline()