struct io { /* File descriptor being read/ */ int fd; /* Size of the read buffer. */ unsignedint buf_len; /* Pointer to storage for buffering read. */ char *buf; /* End of the storage. */ char *end; /* Currently accessed data pointer. */ char *data; /* Read timeout, 0 implies no timeout. */ int timeout_ms; /* Set true on when the end of file on read error. */ bool eof;
};
/* Reads one character from the "io" file with similar semantics to fgetc. */ staticinlineint io__get_char(struct io *io)
{ if (io->data == io->end) { int ret = io__fill_buffer(io);
if (ret) return ret;
} return *io->data++;
}
/* Read a hexadecimal value with no 0x prefix into the out argument hex. If the * first character isn't hexadecimal returns -2, io->eof returns -1, otherwise * returns the character after the hexadecimal value which may be -1 for eof. * If the read value is larger than a u64 the high-order bits will be dropped.
*/ staticinlineint io__get_hex(struct io *io, __u64 *hex)
{ bool first_read = true;
*hex = 0; while (true) { int ch = io__get_char(io);
/* Read a positive decimal value with out argument dec. If the first character * isn't a decimal returns -2, io->eof returns -1, otherwise returns the * character after the decimal value which may be -1 for eof. If the read value * is larger than a u64 the high-order bits will be dropped.
*/ staticinlineint io__get_dec(struct io *io, __u64 *dec)
{ bool first_read = true;
*dec = 0; while (true) { int ch = io__get_char(io);
/* Read up to and including the first delim. */ staticinline ssize_t io__getdelim(struct io *io, char **line_out, size_t *line_len_out, int delim)
{ char buf[128]; int buf_pos = 0; char *line = NULL, *temp;
size_t line_len = 0; int ch = 0;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.