2 * Written 1999 Jan 29 by Josh Cogliati
3 * I grant this program to public domain.
5 * Modified for mvl by Bradley Bell, 2002
6 * All modifications under GPL, version 2 or later
11 #include <sys/types.h>
18 main(int argc, char *argv[])
20 FILE *mvlfile, *writefile;
21 int i, nfiles, len[MAX_FILES];
22 char filename[MAX_FILES][13];
27 if (argc > 1 && !strcmp(argv[1], "v")) {
34 printf("Usage: mvlextract [v] mvlfile [filename]\n"
35 "extracts all the files in mvlfile into the current directory\n"
37 " v View files, don't extract\n");
40 mvlfile = fopen(argv[1], "r");
41 stat(argv[1], &statbuf);
42 printf("%i\n", (int)statbuf.st_size);
43 buf = (char *)malloc(4);
44 fread(buf, 4, 1, mvlfile);
45 fread(&nfiles, 4, 1, mvlfile);
46 printf("Extracting from: %s\n", argv[1]);
48 for (i = 0; i < nfiles; i++) {
49 fread(filename[i], 13, 1, mvlfile);
50 fread(&len[i], 4, 1, mvlfile);
51 if (argc == 2 || !strcmp(argv[2], filename[i]))
52 printf("Filename: %s \tLength: %i\n", filename[i], len[i]);
56 for (i = 0; i < nfiles; i++) {
57 if (argc > 2 && strcmp(argv[2], filename[i]))
58 fseek(mvlfile, len[i], SEEK_CUR);
60 if (ftell(mvlfile) > statbuf.st_size) {
61 printf("Error, end of file\n");
64 buf = (char *)malloc(len[i]);
66 printf("Unable to allocate memory\n");
68 fread(buf, len[i], 1, mvlfile);
69 writefile = fopen(filename[i], "w");
70 fwrite(buf, len[i], 1, writefile);