• Home
  • Raw
  • Download

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()
49 char *ptr = io->data; in io__get_char()
51 if (io->eof) in io__get_char()
52 return -1; 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()
70 n = -1; in io__get_char()
73 io->eof = true; in io__get_char()
74 return -1; 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()
81 return -1; 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
92 * returns the character after the hexadecimal value which may be -1 for eof.
93 * If the read value is larger than a u64 the high-order bits will be dropped.
106 *hex = (*hex << 4) | (ch - '0'); in io__get_hex()
108 *hex = (*hex << 4) | (ch - 'a' + 10); in io__get_hex()
110 *hex = (*hex << 4) | (ch - 'A' + 10); in io__get_hex()
112 return -2; in io__get_hex()
119 /* Read a positive decimal value with out argument dec. If the first character
120 * isn't a decimal returns -2, io->eof returns -1, otherwise returns the
121 * character after the decimal value which may be -1 for eof. If the read value
122 * is larger than a u64 the high-order bits will be dropped.
135 *dec = (*dec * 10) + ch - '0'; in io__get_dec()
137 return -2; in io__get_dec()
184 return -ENOMEM; in io__getline()