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
14 #include <sys/types.h>
18 #define SWAPINT(x) (((x)<<24) | (((uint)(x)) >> 24) | (((x) &0x0000ff00) << 8) | (((x) & 0x00ff0000) >> 8))
21 main(int argc, char *argv[])
23 FILE *hogfile, *writefile;
30 if (argc > 1 && !strcmp(argv[1], "v")) {
37 printf("Usage: hogextract [v] hogfile [filename]\n"
38 "extracts all the files in hogfile into the current directory\n"
40 " v View files, don't extract\n");
43 hogfile = fopen(argv[1], "rb");
44 stat(argv[1], &statbuf);
45 printf("%i\n", (int)statbuf.st_size);
46 buf = (char *)malloc(3);
47 fread(buf, 3, 1, hogfile);
48 printf("Extracting from: %s\n", argv[1]);
50 while(ftell(hogfile)<statbuf.st_size) {
51 fread(filename, 13, 1, hogfile);
52 fread(&len, 1, 4, hogfile);
53 #ifdef WORDS_BIGENDIAN
56 if (argc > 2 && strcmp(argv[2], filename))
57 fseek(hogfile, len, SEEK_CUR);
59 printf("Filename: %s \tLength: %i\n", filename, len);
61 fseek(hogfile, len, SEEK_CUR);
63 buf = (char *)malloc(len);
65 printf("Unable to allocate memory\n");
67 fread(buf, len, 1, hogfile);
68 writefile = fopen(filename, "wb");
69 fwrite(buf, len, 1, writefile);