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 long long AF_read_longlong(AF
* f
) {
19 return ByteArray_readUnsignedLongLong(f
->b
);
22 int AF_read_int(AF
* f
) {
23 return ByteArray_readInt(f
->b
);
26 unsigned AF_read_uint(AF
* f
) {
27 return ByteArray_readUnsignedInt(f
->b
);
30 short AF_read_short(AF
* f
) {
31 return ByteArray_readShort(f
->b
);
34 unsigned short AF_read_ushort(AF
* f
) {
35 return ByteArray_readUnsignedShort(f
->b
);
38 int AF_read_uchar(AF
*f
) {
39 return ByteArray_readUnsignedByte(f
->b
);
42 off_t
AF_get_pos(AF
* f
) {
43 return ByteArray_get_position(f
->b
);
46 int AF_set_pos(AF
* f
, off_t x
) {
47 return ByteArray_set_position(f
->b
, x
);
50 int AF_dump_chunk_stream(AF
* a
, size_t start
, size_t len
, FILE* out
) {
52 ByteArray_set_position(a
->b
, start
);
54 size_t togo
= len
> sizeof(buf
) ? sizeof(buf
) : len
;
55 if(togo
!= (size_t) ByteArray_readMultiByte(a
->b
, buf
, togo
)) {
61 size_t n
= fwrite(p
, 1, togo
, out
);
70 int AF_dump_chunk(AF
* a
, size_t start
, size_t len
, char* fn
) {
71 FILE *out
= fopen(fn
, "wb");
73 int ret
= AF_dump_chunk_stream(a
, start
, len
, out
);
78 int AF_read_junk(AF
* a
, size_t l
) {
81 size_t togo = l > sizeof(buf) ? sizeof(buf) : l;
82 if(togo != (size_t) ByteArray_readMultiByte(a->b, buf, togo)) return 0;
87 return ByteArray_set_position(a
->b
, ByteArray_get_position(a
->b
) + l
);
90 int AF_read_string(AF
* a
, char* buf
, size_t max
) {
93 if(ByteArray_readMultiByte(a
->b
, buf
+ l
, 1) != 1)