Lines Matching +full:buffered +full:- +full:positive

1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Lightweight buffered reading library.
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. */
51 if (io->eof) in io__fill_buffer()
52 return -1; 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()
67 n = -1; in io__fill_buffer()
70 io->eof = true; in io__fill_buffer()
71 return -1; 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()
78 return -1; in io__fill_buffer()
80 io->data = &io->buf[0]; in io__fill_buffer()
81 io->end = &io->buf[n]; in io__fill_buffer()
88 if (io->data == io->end) { 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
99 * returns the character after the hexadecimal value which may be -1 for eof.
100 * If the read value is larger than a u64 the high-order bits will be dropped.
113 *hex = (*hex << 4) | (ch - '0'); in io__get_hex()
115 *hex = (*hex << 4) | (ch - 'a' + 10); in io__get_hex()
117 *hex = (*hex << 4) | (ch - 'A' + 10); in io__get_hex()
119 return -2; in io__get_hex()
126 /* Read a positive decimal value with out argument dec. If the first character
127 * isn't a decimal returns -2, io->eof returns -1, otherwise returns the
128 * character after the decimal value which may be -1 for eof. If the read value
129 * is larger than a u64 the high-order bits will be dropped.
142 *dec = (*dec * 10) + ch - '0'; in io__get_dec()
144 return -2; in io__get_dec()
192 return -ENOMEM; in io__getdelim()