8 #define LBX_MAGIC 0x0000fead
16 struct lbx_state *lbx_fopen(FILE *f)
18 struct lbx_state *new = NULL;
19 uint16_t nfiles, version;
22 if (fread(&nfiles, sizeof nfiles, 1, f) != 1) return NULL;
23 if (fread(&magic, sizeof magic, 1, f) != 1) return NULL;
24 if (fread(&version, sizeof version, 1, f) != 1) return NULL;
26 nfiles = letohs(nfiles);
27 magic = letohl(magic);
28 version = letohs(version);
30 if (magic != LBX_MAGIC)
33 new = malloc(sizeof *new + (nfiles+1)*(sizeof *new->offsets));
37 *new = (struct lbx_state){
42 if (fread(new->offsets, sizeof *new->offsets, nfiles+1, f) != nfiles+1)
43 return free(new), NULL;
48 struct lbx_state *lbx_open(const char *path)
50 struct lbx_state *new = NULL;
53 if ((f = fopen(path, "rb")))
59 void lbx_close(struct lbx_state *lbx)