Lines Matching refs:io
17 struct io {
34 static inline void io__init(struct io *io, int fd,
37 io->fd = fd;
38 io->buf_len = buf_len;
39 io->buf = buf;
40 io->end = buf;
41 io->data = buf;
42 io->timeout_ms = 0;
43 io->eof = false;
46 /* Reads one character from the "io" file with similar semantics to fgetc. */
47 static inline int io__get_char(struct io *io)
49 char *ptr = io->data;
51 if (io->eof)
54 if (ptr == io->end) {
57 if (io->timeout_ms != 0) {
60 .fd = io->fd,
65 n = poll(pfds, 1, io->timeout_ms);
73 io->eof = true;
77 n = read(io->fd, io->buf, io->buf_len);
80 io->eof = true;
83 ptr = &io->buf[0];
84 io->end = &io->buf[n];
86 io->data = ptr + 1;
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)
101 int ch = io__get_char(io);
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)
130 int ch = io__get_char(io);
145 static inline ssize_t io__getdelim(struct io *io, char **line_out, size_t *line_len_out, int delim)
156 ch = io__get_char(io);
188 static inline ssize_t io__getline(struct io *io, char **line_out, size_t *line_len_out)
190 return io__getdelim(io, line_out, line_len_out, /*delim=*/'\n');