1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#include <stdio.h>
#include <stdlib.h>
#include "mpq-bios.h"
#include "mpq-file.h"
#include "mpq-fs.h"
#include "mpq-errors.h"
int main(int argc, char ** argv) {
struct mpq_archive_t * t1;
char * fname = "test.mpq";
struct mpq_file_t * f1;
mpqlib_init();
if (argc == 2)
fname = argv[1];
t1 = mpqlib_open_archive(fname);
if (!t1) {
printf("Open error: %s.\n", mpqlib_error());
perror("Details");
exit(-1);
}
mpqlib_printtables(t1);
f1 = mpqlib_open_filename(t1, "(listfile)");
if (f1) {
int size;
char * b;
printf("Found (listfile), trying to read.\n");
size = mpqlib_seek(f1, 0, MPQLIB_SEEK_END);
mpqlib_seek(f1, 0, MPQLIB_SEEK_SET);
printf("Filesize seems to be: %d.\n", size);
b = (char *) malloc(size + 1);
b[size] = 0;
mpqlib_read(f1, b, size);
printf("Dumping:\n");
printf("%s", b);
printf("\nDone.\n");
mpqlib_close(f1);
}
mpqlib_fs_add_archive(t1);
f1 = mpqlib_fs_open("Interface\\FrameXML\\WorldMapFrame.lua");
if (f1) {
int size;
char * b;
printf("Found!\n");
size = mpqlib_seek(f1, 0, MPQLIB_SEEK_END);
mpqlib_seek(f1, 0, MPQLIB_SEEK_SET);
printf("Filesize seems to be: %d.\n", size);
b = (char *) malloc(size + 1);
b[size] = 0;
mpqlib_read(f1, b, size);
printf("Dumping:\n");
printf("%s", b);
printf("\nDone.\n");
mpqlib_close(f1);
}
mpqlib_close_archive(t1);
return 0;
}
|