| 117 | } |
| 118 | |
| 119 | static inline size_t rioRead(rio *r, void *buf, size_t len) { |
| 120 | if (r->flags & RIO_FLAG_READ_ERROR) return 0; |
| 121 | while (len) { |
| 122 | size_t bytes_to_read = (r->max_processing_chunk && r->max_processing_chunk < len) ? r->max_processing_chunk : len; |
| 123 | if (r->read(r,buf,bytes_to_read) == 0) { |
| 124 | r->flags |= RIO_FLAG_READ_ERROR; |
| 125 | return 0; |
| 126 | } |
| 127 | if (r->update_cksum) r->update_cksum(r,buf,bytes_to_read); |
| 128 | buf = (char*)buf + bytes_to_read; |
| 129 | len -= bytes_to_read; |
| 130 | r->processed_bytes += bytes_to_read; |
| 131 | } |
| 132 | return 1; |
| 133 | } |
| 134 | |
| 135 | static inline off_t rioTell(rio *r) { |
| 136 | return r->tell(r); |
no test coverage detected