43 if (reader->
cur < reader->
end) {
44 return *reader->
cur++;
69 #if MICROPY_READER_POSIX 75 typedef struct _mp_reader_posix_t {
84 mp_reader_posix_t *reader = (mp_reader_posix_t*)
data;
85 if (reader->pos >= reader->len) {
86 if (reader->len == 0) {
89 int n = read(reader->fd, reader->buf,
sizeof(reader->buf));
98 return reader->buf[reader->pos++];
101 STATIC void mp_reader_posix_close(
void *
data) {
102 mp_reader_posix_t *reader = (mp_reader_posix_t*)
data;
103 if (reader->close_fd) {
110 mp_reader_posix_t *rp =
m_new_obj(mp_reader_posix_t);
111 rp->close_fd = close_fd;
113 int n = read(rp->fd, rp->buf,
sizeof(rp->buf));
123 reader->
readbyte = mp_reader_posix_readbyte;
124 reader->
close = mp_reader_posix_close;
128 int fd = open(filename, O_RDONLY, 0644);
struct _mp_reader_mem_t mp_reader_mem_t
STATIC mp_uint_t mp_reader_mem_readbyte(void *data)
void mp_reader_new_file_from_fd(mp_reader_t *reader, int fd, bool close_fd)
#define m_del(type, ptr, num)
void mp_reader_new_file(mp_reader_t *reader, const char *filename)
#define m_del_obj(type, ptr)
NORETURN void mp_raise_OSError(int errno_)
void(* close)(void *data)
mp_uint_t(* readbyte)(void *data)
void mp_reader_new_mem(mp_reader_t *reader, const byte *buf, size_t len, size_t free_len)
STATIC void mp_reader_mem_close(void *data)