Skip to content

Commit

Permalink
Add version information and CLI option to print it
Browse files Browse the repository at this point in the history
This may optionally include metadata (such as the short hash of
the commit being built) by defining VERSION_META with the relevant
data at build time.

The initial release was tagged as 1.0. Per semantic versioning, the
addition of the -v flag is technically a breaking change, so
update to 2.0.0.
  • Loading branch information
0x09 committed Oct 21, 2022
1 parent 196d615 commit 278b7a8
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions jbfinspect.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
Parsing code for Jasc Browser Files generated by Paint Shop Pro et al.
Format is documented below, and again in the binary.
The author disclaims all copyright on this code.
*/

#define VERSION_STRING "2.0.0"

/*
JBF format description:
Integers are little endian except where specified
Where fixed length C-strings are specified, beyond first NUL is garbage
Expand Down Expand Up @@ -544,30 +548,34 @@ const char* type_lookup(uint32_t code) {
}

void usage(char* self, bool h) {
printf("Usage: %s [-orqDh] [-d path] pspbrwse.jbf\n",self);
printf("Usage: %s [-orqDhv] [-d path] pspbrwse.jbf\n",self);
if(h) puts("List or extract the contents of Jasc thumbnail caches.\n\n"
" -d Extract thumbnails to given directory.\n"
" -o Highlight orphaned files. With -d, only extract these.\n"
" -r When extracting files, recreate path found in jbf under pwd or directory given by -d.\n"
" Useful for batch processing with e.g. find.\n"
" -q Don't list contents.\n"
" -D Print format documentation.\n"
" -h Show this help.\n");
" -h Show this help.\n"
" -v Show version information.\n");
exit(0);
}

int main(int argc, char* argv[]) {
int opt;
char* outdir = NULL;
bool orphaned_check = false, recreate = false, quiet = false;
while((opt = getopt(argc,argv,"roqd:hD")) != -1)
while((opt = getopt(argc,argv,"roqd:hDv")) != -1)
switch(opt) {
case 'o': orphaned_check = true; break;
case 'r': recreate = true; break;
case 'd': outdir = optarg; break;
case 'q': quiet = true; break;
case 'D': puts(doc); return 0;
case 'h': usage(argv[0],1);
case 'v':
puts("version " VERSION_STRING VERSION_META);
exit(0);
default : usage(argv[0],0);
}
if(argc - optind != 1)
Expand Down

0 comments on commit 278b7a8

Please sign in to comment.