Lines Matching +full:buffered +full:- +full:positive
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Lightweight buffered reading library.
31 io->fd = fd; in io__init()
32 io->buf_len = buf_len; in io__init()
33 io->buf = buf; in io__init()
34 io->end = buf; in io__init()
35 io->data = buf; in io__init()
36 io->eof = false; in io__init()
42 char *ptr = io->data; in io__get_char()
44 if (io->eof) in io__get_char()
45 return -1; in io__get_char()
47 if (ptr == io->end) { in io__get_char()
48 ssize_t n = read(io->fd, io->buf, io->buf_len); in io__get_char()
51 io->eof = true; in io__get_char()
52 return -1; in io__get_char()
54 ptr = &io->buf[0]; in io__get_char()
55 io->end = &io->buf[n]; in io__get_char()
57 io->data = ptr + 1; in io__get_char()
62 * first character isn't hexadecimal returns -2, io->eof returns -1, otherwise
63 * returns the character after the hexadecimal value which may be -1 for eof.
64 * If the read value is larger than a u64 the high-order bits will be dropped.
77 *hex = (*hex << 4) | (ch - '0'); in io__get_hex()
79 *hex = (*hex << 4) | (ch - 'a' + 10); in io__get_hex()
81 *hex = (*hex << 4) | (ch - 'A' + 10); in io__get_hex()
83 return -2; in io__get_hex()
90 /* Read a positive decimal value with out argument dec. If the first character
91 * isn't a decimal returns -2, io->eof returns -1, otherwise returns the
92 * character after the decimal value which may be -1 for eof. If the read value
93 * is larger than a u64 the high-order bits will be dropped.
106 *dec = (*dec * 10) + ch - '0'; in io__get_dec()
108 return -2; in io__get_dec()