3 int AF_open(AF
*f
, const char* fn
) {
6 ByteArray_set_endian(f
->b
, BAE_LITTLE
);
7 return ByteArray_open_file(f
->b
, fn
);
10 void AF_close(AF
* f
) {
11 ByteArray_close_file(f
->b
);
14 ssize_t
AF_read(AF
* f
, void* buf
, size_t len
) {
15 return ByteArray_readMultiByte(f
->b
, buf
, len
);
18 int AF_read_int(AF
* f
) {
19 return ByteArray_readInt(f
->b
);
22 unsigned AF_read_uint(AF
* f
) {
23 return ByteArray_readUnsignedInt(f
->b
);
26 short AF_read_short(AF
* f
) {
27 return ByteArray_readShort(f
->b
);
30 unsigned short AF_read_ushort(AF
* f
) {
31 return ByteArray_readUnsignedShort(f
->b
);
34 off_t
AF_get_pos(AF
* f
) {
35 return ByteArray_get_position(f
->b
);
38 int AF_set_pos(AF
* f
, off_t x
) {
39 return ByteArray_set_position(f
->b
, x
);
42 int AF_dump_chunk_stream(AF
* a
, size_t start
, size_t len
, FILE* out
) {
44 ByteArray_set_position(a
->b
, start
);
46 size_t togo
= len
> sizeof(buf
) ? sizeof(buf
) : len
;
47 if(togo
!= (size_t) ByteArray_readMultiByte(a
->b
, buf
, togo
)) {
53 size_t n
= fwrite(p
, 1, togo
, out
);
62 int AF_dump_chunk(AF
* a
, size_t start
, size_t len
, char* fn
) {
63 FILE *out
= fopen(fn
, "w");
65 int ret
= AF_dump_chunk_stream(a
, start
, len
, out
);
70 int AF_read_junk(AF
* a
, size_t l
) {
73 size_t togo = l > sizeof(buf) ? sizeof(buf) : l;
74 if(togo != (size_t) ByteArray_readMultiByte(a->b, buf, togo)) return 0;
78 return ByteArray_set_position(a
->b
, ByteArray_get_position(a
->b
) + l
);
81 int AF_read_string(AF
* a
, char* buf
, size_t max
) {
84 if(ByteArray_readMultiByte(a
->b
, buf
+ l
, 1) != 1)