diff --git a/bin/src/compress.c b/bin/src/compress.c index 2bb46e9..7baea45 100644 --- a/bin/src/compress.c +++ b/bin/src/compress.c @@ -1,5 +1,6 @@ #include #include +#include #include const int MAXLENGTH = 0x300; @@ -149,10 +150,15 @@ int write_section(struct section section, char data[], char buf[], int loc) { int main(int argc, char *argv[]) { if (argc < 3) { - printf("Usage: %s infile outfile\n", argv[0]); + printf("Usage: %s infile outfile [start [length]]\n", argv[0]); return 1; } + off_t seek = 0; + if (argc > 3) { + seek = strtol(argv[3], NULL, 0); + } + FILE *inptr; if ((inptr = fopen(argv[1], "rb")) == NULL) { printf("%s does not exist.\n", argv[1]); @@ -170,10 +176,15 @@ int main(int argc, char *argv[]) { printf("Error stating file: %s\n", argv[1]); return 1; } - off_t size = buf.st_size; + off_t size = buf.st_size - seek; + if (argc > 4) { + size = strtol(argv[4], NULL, 0); + } char inbuf[size]; + fseek(inptr, seek, SEEK_SET); + if (fread(inbuf, 1, size, inptr) < size) { printf("Error reading file: %s\n", argv[1]); return 1; @@ -181,7 +192,6 @@ int main(int argc, char *argv[]) { fclose(inptr); - char outbuf[size * 2]; char m0data[MAXLENGTH]; diff --git a/bin/windows/compress.exe b/bin/windows/compress.exe index bd9d2fb..54c9b39 100644 Binary files a/bin/windows/compress.exe and b/bin/windows/compress.exe differ