RoomFile: preliminary support for roomfiles >= kRoomVersion_350
[rofl0r-agsutils.git] / Clib32.h
blobbdfb4911e671acebfa3b23d2a02003888fc08329
1 #ifndef CLIB32_H
2 #define CLIB32_H
4 #include <stdio.h>
5 #include "./ByteArray.h"
7 #define MAX_FILES 10000
8 #define MAXMULTIFILES 25
10 struct MultiFileLib {
11 char data_filenames[MAXMULTIFILES][20];
12 size_t num_data_files;
13 char filenames[MAX_FILES][25];
14 unsigned offset[MAX_FILES];
15 unsigned length[MAX_FILES];
16 char file_datafile[MAX_FILES]; // number of datafile
17 size_t num_files;
20 struct MultiFileLibNew {
21 char data_filenames[MAXMULTIFILES][50];
22 size_t num_data_files;
23 char filenames[MAX_FILES][100];
24 unsigned offset[MAX_FILES];
25 unsigned length[MAX_FILES];
26 char file_datafile[MAX_FILES]; // number of datafile
27 size_t num_files;
30 struct AgsFile {
31 struct ByteArray f[MAXMULTIFILES];
32 struct MultiFileLibNew mflib;
33 int libversion;
34 char* fn;
35 char *dir;
36 off_t pack_off;
39 /* generic interface */
40 void AgsFile_init(struct AgsFile *buf, char* filename);
41 void AgsFile_close(struct AgsFile *f);
43 /* reader interface */
44 int AgsFile_open(struct AgsFile *buf);
46 int AgsFile_getVersion(struct AgsFile *f);
47 size_t AgsFile_getFileCount(struct AgsFile *f);
48 char *AgsFile_getFileName(struct AgsFile *f, size_t index);
49 size_t AgsFile_getOffset(struct AgsFile *f, size_t index);
50 size_t AgsFile_getFileSize(struct AgsFile *f, size_t index);
51 int AgsFile_getFileNumber(struct AgsFile *f, size_t index);
52 size_t AgsFile_getDataFileCount(struct AgsFile *f);
53 char *AgsFile_getDataFileName(struct AgsFile *f, size_t index);
54 int AgsFile_dump(struct AgsFile* f, size_t index, const char* outfn);
55 int AgsFile_extract(struct AgsFile* f, int multifileno, off_t start, size_t len, const char* outfn);
57 /* writer interface */
58 // the directory containing the files passed via setFile
59 void AgsFile_setSourceDir(struct AgsFile *f, char* sourcedir);
60 void AgsFile_setVersion(struct AgsFile *f, int version);
61 void AgsFile_setFileCount(struct AgsFile *f, size_t count);
62 int AgsFile_setFile(struct AgsFile *f, size_t index, char* fn);
63 void AgsFile_setDataFileCount(struct AgsFile *f, size_t count);
64 void AgsFile_setFileNumber(struct AgsFile *f, size_t index, int number);
65 int AgsFile_setDataFile(struct AgsFile *f, size_t index, char* fn);
66 int AgsFile_write(struct AgsFile *f);
68 #pragma RcB2 DEP "Clib32.c"
70 #endif