2 * Written 1999 Jan 29 by Josh Cogliati
3 * Modified by Bradley Bell, 2002, 2003
4 * This program is licensed under the terms of the GPL, version 2 or later
10 #include <sys/types.h>
15 main(int argc, char *argv[])
17 FILE *hogfile, *writefile;
24 if (argc > 1 && !strcmp(argv[1], "v")) {
31 printf("Usage: hogextract [v] hogfile [filename]\n"
32 "extracts all the files in hogfile into the current directory\n"
34 " v View files, don't extract\n");
37 hogfile = fopen(argv[1], "r");
38 stat(argv[1], &statbuf);
39 printf("%i\n", (int)statbuf.st_size);
40 buf = (char *)malloc(3);
41 fread(buf, 3, 1, hogfile);
42 printf("Extracting from: %s\n", argv[1]);
44 while(ftell(hogfile)<statbuf.st_size) {
45 fread(filename, 13, 1, hogfile);
46 fread(&len, sizeof(int), 1, hogfile);
47 if (argc > 2 && strcmp(argv[2], filename))
48 fseek(hogfile, len, SEEK_CUR);
50 printf("Filename: %s \tLength: %i\n", filename, len);
52 fseek(hogfile, len, SEEK_CUR);
54 buf = (char *)malloc(len);
56 printf("Unable to allocate memory\n");
58 fread(buf, len, 1, hogfile);
59 writefile = fopen(filename, "w");
60 fwrite(buf, len, 1, writefile);