From b1e78c40ba8ee19ae80c7ef785bf19896becf8a8 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Mon, 26 Aug 2002 07:51:24 +0000 Subject: [PATCH] added [v]iew option --- utilities/hogextract.c | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/utilities/hogextract.c b/utilities/hogextract.c index eeef59a0..20cb0fca 100644 --- a/utilities/hogextract.c +++ b/utilities/hogextract.c @@ -1,6 +1,9 @@ /* * Written 1999 Jan 29 by Josh Cogliati * I grant this program to public domain. + * + * Modified by Bradley Bell, 2002 + * All modifications under GPL, version 2 or later */ #include @@ -17,10 +20,19 @@ main(int argc, char *argv[]) char filename[13]; char *buf; struct stat statbuf; + int v = 0; + + if (argc > 1 && !strcmp(argv[1], "v")) { + v = 1; + argc--; + argv++; + } if (argc != 2) { - printf("Usage: hogextract hogfile\n" - "extracts all the files in hogfile into the current directory\n"); + printf("Usage: hogextract [v] hogfile\n" + "extracts all the files in hogfile into the current directory\n" + "Options:\n" + " v View files, don't extract\n"); exit(0); } hogfile = fopen(argv[1], "r"); @@ -34,15 +46,19 @@ main(int argc, char *argv[]) fread(filename, 13, 1, hogfile); fread(&len, sizeof(int), 1, hogfile); printf("Filename: %s \tLength: %i\n", filename, len); - buf = (char *)malloc(len); - if (buf == NULL) { - printf("Unable to allocate memory\n"); - } else { - fread(buf, len, 1, hogfile); - writefile = fopen(filename, "w"); - fwrite(buf, len, 1, writefile); - fclose(writefile); - free(buf); + if (v) + fseek(hogfile, len, SEEK_CUR); + else { + buf = (char *)malloc(len); + if (buf == NULL) { + printf("Unable to allocate memory\n"); + } else { + fread(buf, len, 1, hogfile); + writefile = fopen(filename, "w"); + fwrite(buf, len, 1, writefile); + fclose(writefile); + free(buf); + } } } fclose(hogfile); -- 2.39.2