agssim: factor null check out of vm_run()
[rofl0r-agsutils.git] / File.h
blob3bfb2f634024a1dfc7b98821e0fbd5f49a241e38
1 #ifndef FILE_H
2 #define FILE_H
3 #include <stddef.h>
4 #include <stdio.h>
5 #include "ByteArray.h"
7 typedef struct AgsFile {
8 struct ByteArray b_b;
9 struct ByteArray *b;
10 } AF;
12 /* 0: error, 1: success */
13 int AF_open(AF *f, const char* fn);
14 void AF_close(AF* f);
16 off_t AF_get_pos(AF* f);
17 int AF_set_pos(AF* f, off_t x);
19 ssize_t AF_read(AF* f, void* buf, size_t len);
20 int AF_read_int(AF* f);
21 unsigned AF_read_uint(AF* f);
22 short AF_read_short(AF* f);
23 unsigned short AF_read_ushort(AF* f);
24 int AF_read_string(AF* a, char* buf, size_t max);
26 /* dumps file contents between start and start+len into fn */
27 int AF_dump_chunk(AF* a, size_t start, size_t len, char* fn);
28 int AF_dump_chunk_stream(AF* a, size_t start, size_t len, FILE* out);
29 /* "swallows" or skips l bytes, i.e. advances the offset */
30 int AF_read_junk(AF* a, size_t l);
32 #pragma RcB2 DEP "File.c"
34 #endif