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 /* Reads one character from the "io" file with similar semantics to fgetc. */
47 static inline int io__get_char(struct io *io) in io__get_char() argument
49 char *ptr = io->data; in io__get_char()
51 if (io->eof) in io__get_char()
54 if (ptr == io->end) { in io__get_char()
57 if (io->timeout_ms != 0) { in io__get_char()
60 .fd = io->fd, in io__get_char()
65 n = poll(pfds, 1, io->timeout_ms); in io__get_char()
73 io->eof = true; in io__get_char()
77 n = read(io->fd, io->buf, io->buf_len); in io__get_char()
80 io->eof = true; in io__get_char()
83 ptr = &io->buf[0]; in io__get_char()
84 io->end = &io->buf[n]; in io__get_char()
86 io->data = ptr + 1; in io__get_char()
91 * first character isn't hexadecimal returns -2, io->eof returns -1, otherwise
95 static inline int io__get_hex(struct io *io, __u64 *hex) in io__get_hex() argument
101 int ch = io__get_char(io); in io__get_hex()
120 * isn't a decimal returns -2, io->eof returns -1, otherwise returns the
124 static inline int io__get_dec(struct io *io, __u64 *dec) in io__get_dec() argument
130 int ch = io__get_char(io); in io__get_dec()
145 static inline ssize_t io__getdelim(struct io *io, char **line_out, size_t *line_len_out, int delim) in io__getdelim() argument
156 ch = io__get_char(io); in io__getdelim()
188 static inline ssize_t io__getline(struct io *io, char **line_out, size_t *line_len_out) in io__getline() argument
190 return io__getdelim(io, line_out, line_len_out, /*delim=*/'\n'); in io__getline()