DEADSOFTWARE

portability: avoid errors on some compilers
[flatwaifu.git] / src / common / streams.c
1 #include "common/streams.h"
2 #include "common/endianness.h"
4 #include <stddef.h>
5 #include <stdint.h>
7 long stream_getpos (Stream *s) {
8 return s->getpos(s);
9 }
11 void stream_setpos (Stream *s, long pos) {
12 s->setpos(s, pos);
13 }
15 long stream_getlen (Stream *s) {
16 return s->getlen(s);
17 }
19 void stream_read (void *data, size_t size, size_t n, Stream *r) {
20 r->read(r, data, size, n);
21 }
23 int8_t stream_read8 (Stream *r) {
24 int8_t x;
25 r->read(r, &x, 1, 1);
26 return x;
27 }
29 int16_t stream_read16 (Stream *r) {
30 int16_t x;
31 r->read(r, &x, 2, 1);
32 return short2host(x);
33 }
35 int32_t stream_read32 (Stream *r) {
36 int32_t x;
37 r->read(r, &x, 4, 1);
38 return int2host(x);
39 }
41 void stream_write (const void *data, size_t size, size_t n, Stream *w) {
42 w->write(w, data, size, n);
43 }
45 void stream_write8 (int8_t x, Stream *w) {
46 w->write(w, &x, 1, 1);
47 }
49 void stream_write16 (int16_t x, Stream *w) {
50 int16_t y = short2host(x);
51 w->write(w, &y, 2, 1);
52 }
54 void stream_write32 (int32_t x, Stream *w) {
55 int32_t y = int2host(x);
56 w->write(w, &y, 4, 1);
57 }