Skip to content

Commit

Permalink
cabinfo now supports examining more than one file
Browse files Browse the repository at this point in the history
  • Loading branch information
kyz committed Jul 28, 2018
1 parent 81231d2 commit 5488de8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 25 deletions.
4 changes: 4 additions & 0 deletions cabextract/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2018-07-28 Stuart Caie <kyzer@cabextract.org.uk>

* src/cabinfo.c: cabinfo now supports examining more than one file

2018-07-17 Stuart Caie <kyzer@cabextract.org.uk>

* amibuild.sh: support using setlocale()/iconv() in the OS4 version.
Expand Down
48 changes: 23 additions & 25 deletions cabextract/src/cabinfo.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* cabinfo -- dumps useful information from cabinets
* (C) 2000-2016 Stuart Caie <kyzer@cabextract.org.uk>
* (C) 2000-2018 Stuart Caie <kyzer@cabextract.org.uk>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -63,8 +63,6 @@ void getinfo();
#define SKIP(offset) if (myseek((offset),SEEK_CUR)) return
#define SEEK(offset) if (myseek((offset),SEEK_SET)) return



int myread(void *buf, int length) {
FILELEN remain = filelen - GETOFFSET;
if (length > remain) length = (int) remain;
Expand All @@ -84,39 +82,27 @@ int myseek(FILELEN offset, int mode) {
}

int main(int argc, char *argv[]) {
int i;

printf("Cabinet information dumper by Stuart Caie <kyzer@cabextract.org.uk>\n");

if (argc <= 1) {
printf("Usage: %s <file.cab>\n", argv[0]);
return 1;
}

if (!(fh = fopen((filename = argv[1]), "rb"))) {
perror(filename);
return 1;
}

if (FSEEK(fh, 0, SEEK_END) != 0) {
perror(filename);
fclose(fh);
return 1;
}

filelen = FTELL(fh);

if (FSEEK(fh, 0, SEEK_SET) != 0) {
perror(filename);
fclose(fh);
return 1;
for (i = 1; i < argc; i++) {
if ((fh = fopen((filename = argv[i]), "rb"))) {
search();
fclose(fh);
}
else {
perror(filename);
}
}

printf("Examining file \"%s\" (%"LD" bytes)...\n", filename, filelen);
search();
fclose(fh);
return 0;
}


#define SEARCH_SIZE (32*1024)
unsigned char search_buf[SEARCH_SIZE];

Expand All @@ -126,6 +112,18 @@ void search() {
unsigned long cablen32 = 0, foffset32 = 0;
int state = 0;

if (FSEEK(fh, 0, SEEK_END) != 0) {
perror(filename);
return;
}
filelen = FTELL(fh);
if (FSEEK(fh, 0, SEEK_SET) != 0) {
perror(filename);
return;
}

printf("Examining file \"%s\" (%"LD" bytes)...\n", filename, filelen);

for (offset = 0; offset < filelen; offset += length) {
/* search length is either the full length of the search buffer,
* or the amount of data remaining to the end of the file,
Expand Down

0 comments on commit 5488de8

Please sign in to comment.