From 2e90d290437cde37b817fc479835b77c138828be Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Tue, 27 Aug 2002 08:05:14 +0000 Subject: [PATCH] allow specifying file to extract --- utilities/hogextract.c | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/utilities/hogextract.c b/utilities/hogextract.c index 20cb0fca..7c3d571f 100644 --- a/utilities/hogextract.c +++ b/utilities/hogextract.c @@ -28,8 +28,8 @@ main(int argc, char *argv[]) argv++; } - if (argc != 2) { - printf("Usage: hogextract [v] hogfile\n" + if (argc < 2) { + printf("Usage: hogextract [v] hogfile [filename]\n" "extracts all the files in hogfile into the current directory\n" "Options:\n" " v View files, don't extract\n"); @@ -45,19 +45,23 @@ main(int argc, char *argv[]) while(ftell(hogfile) 2 && strcmp(argv[2], filename)) 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); + printf("Filename: %s \tLength: %i\n", filename, len); + 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); + } } } } -- 2.39.2