Lines Matching +full:buffered +full:- +full:positive
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Lightweight buffered reading library.
32 io->fd = fd; in io__init()
33 io->buf_len = buf_len; in io__init()
34 io->buf = buf; in io__init()
35 io->end = buf; in io__init()
36 io->data = buf; in io__init()
37 io->eof = false; in io__init()
43 char *ptr = io->data; in io__get_char()
45 if (io->eof) in io__get_char()
46 return -1; in io__get_char()
48 if (ptr == io->end) { in io__get_char()
49 ssize_t n = read(io->fd, io->buf, io->buf_len); in io__get_char()
52 io->eof = true; in io__get_char()
53 return -1; in io__get_char()
55 ptr = &io->buf[0]; in io__get_char()
56 io->end = &io->buf[n]; in io__get_char()
58 io->data = ptr + 1; in io__get_char()
63 * first character isn't hexadecimal returns -2, io->eof returns -1, otherwise
64 * returns the character after the hexadecimal value which may be -1 for eof.
65 * If the read value is larger than a u64 the high-order bits will be dropped.
78 *hex = (*hex << 4) | (ch - '0'); in io__get_hex()
80 *hex = (*hex << 4) | (ch - 'a' + 10); in io__get_hex()
82 *hex = (*hex << 4) | (ch - 'A' + 10); in io__get_hex()
84 return -2; in io__get_hex()
91 /* Read a positive decimal value with out argument dec. If the first character
92 * isn't a decimal returns -2, io->eof returns -1, otherwise returns the
93 * character after the decimal value which may be -1 for eof. If the read value
94 * is larger than a u64 the high-order bits will be dropped.
107 *dec = (*dec * 10) + ch - '0'; in io__get_dec()
109 return -2; in io__get_dec()