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
|
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include <sys/stat.h>
#include <unistd.h>
#include <sys/types.h>
#include <fcntl.h>
#include "parser.h"
#include "test.h"
int main(int argc, char *argv[])
{
BOOL ret;
char *fname, *test;
int fd;
struct stat st;
prs_struct ps;
if (argc < 3) {
printf("usage: vluke <structure> <file>\n");
exit(1);
}
test = argv[1];
fname = argv[2];
fd = open(fname,O_RDONLY);
fstat(fd, &st);
prs_init(&ps, 0, 4, MARSHALL);
ps.is_dynamic=True;
prs_read(&ps, fd, st.st_size, 0);
ps.data_offset = 0;
ps.buffer_size = ps.grow_size;
ps.io = UNMARSHALL;
ret = run_test(test, &ps);
printf("\nret=%s\n", ret?"OK":"Bad");
printf("Trailer is %d bytes\n\n", ps.grow_size - ps.data_offset);
if (ps.grow_size - ps.data_offset > 0) {
dump_data(0, ps.data_p + ps.data_offset, ps.grow_size - ps.data_offset);
}
return !ret;
}
|