* Added -v (verbose) command line option.
authorUrban Wallasch <urban.wallasch@freenet.de>
Fri, 15 Nov 2019 13:25:32 +0000 (14:25 +0100)
committerUrban Wallasch <urban.wallasch@freenet.de>
Fri, 15 Nov 2019 13:25:32 +0000 (14:25 +0100)
riffx.c

diff --git a/riffx.c b/riffx.c
index bf237f42975682ac8892c87129a16b35238d0cb6..a5197905b62ed404de12035a7d6cb9e9acce7e19 100644 (file)
--- a/riffx.c
+++ b/riffx.c
@@ -147,15 +147,18 @@ static inline uint32_t get_ui32(const void *p) {
 static struct {
     int use_basename;
     int use_label;
+    int verbose;
 } cfg = {
     0,
     0,
+    0,
 };
 
 static inline void usage(const char *argv0) {
     LOG("Usage: %s [-b] infile ... [outdir]\n"
         "  -b : create flat output directory\n"
         "  -l : use extracted labels in filenames (unreliable!)\n"
+        "  -v : be more verbose\n"
         , argv0);
     exit(EXIT_FAILURE);
 }
@@ -163,7 +166,7 @@ static inline void usage(const char *argv0) {
 static inline int config(int argc, char *argv[]) {
     int opt;
 
-    while ((opt = getopt(argc, argv, "+:bl")) != -1) {
+    while ((opt = getopt(argc, argv, "+:blv")) != -1) {
         switch (opt) {
         case 'b':
            cfg.use_basename = 1;
@@ -171,6 +174,9 @@ static inline int config(int argc, char *argv[]) {
         case 'l':
            cfg.use_label = 1;
            break;
+        case 'v':
+           cfg.verbose = 1;
+           break;
         default: /* '?' || ':' */
            usage(argv[0]);
            break;
@@ -227,7 +233,8 @@ static inline int dump(const char *prefix, size_t id, const void *b, size_t len)
     /* Construct file name from prefix and label or id: */
     lab = cfg.use_label ? labl(b, len) : "";
     snprintf(of, sizeof of, "%s%06zu%s%s%s", prefix, id, *lab?"_":"", lab, SUFFIX);
-    //LOG(" -> %s\n", of);
+    if (cfg.verbose)
+        LOG(": %8zu -> %s\n", len, of);
     /* Caveat: This will overwrite any existing file with the same name! */
     fd = creat(of, 0644);
     if (0 > fd){
@@ -263,7 +270,7 @@ int extract(int fd, const char *pfx) {
         rsize = get_ui32(riff + 4) + 8; /* + 'RIFF' + uint32 */
         if ((off_t)rsize > remsize)
             rsize = remsize;
-        LOG("\rEntry %4zu: %8zu ", id, rsize);
+        LOG("\rEntry %4zu", id);
         dump(pfx, id, riff, rsize);
         ++id;
         /* Skip 'RIFF'; skipping rsize would be correct, but the size info