2 * Written 1999 Jan 29 by Josh Cogliati
3 * I grant this program to public domain.
5 * Modified by Bradley Bell, 2002
6 * All modifications under GPL, version 2 or later
11 #include <sys/types.h>
16 main(int argc, char *argv[])
18 FILE *hogfile, *writefile;
25 if (argc > 1 && !strcmp(argv[1], "v")) {
32 printf("Usage: hogextract [v] hogfile [filename]\n"
33 "extracts all the files in hogfile into the current directory\n"
35 " v View files, don't extract\n");
38 hogfile = fopen(argv[1], "r");
39 stat(argv[1], &statbuf);
40 printf("%i\n", (int)statbuf.st_size);
41 buf = (char *)malloc(3);
42 fread(buf, 3, 1, hogfile);
43 printf("Extracting from: %s\n", argv[1]);
45 while(ftell(hogfile)<statbuf.st_size) {
46 fread(filename, 13, 1, hogfile);
47 fread(&len, sizeof(int), 1, hogfile);
48 if (argc > 2 && strcmp(argv[2], filename))
49 fseek(hogfile, len, SEEK_CUR);
51 printf("Filename: %s \tLength: %i\n", filename, len);
53 fseek(hogfile, len, SEEK_CUR);
55 buf = (char *)malloc(len);
57 printf("Unable to allocate memory\n");
59 fread(buf, len, 1, hogfile);
60 writefile = fopen(filename, "w");
61 fwrite(buf, len, 1, writefile);