From 47792182b7d669413ec64c667be41844fbf36ab3 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Tue, 2 Aug 2016 06:31:23 -0300 Subject: [PATCH] sch2fig/: option -v (can be repeated) for progress and debugging output --- sch2fig/file.c | 3 +++ sch2fig/main.c | 10 ++++++++-- sch2fig/main.h | 13 +++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/sch2fig/file.c b/sch2fig/file.c index c94536c..e322d91 100644 --- a/sch2fig/file.c +++ b/sch2fig/file.c @@ -15,6 +15,7 @@ #include #include +#include "main.h" #include "file.h" @@ -30,6 +31,8 @@ void file_read(const char *name, bool (*parse)(void *user, const char *line), perror(name); exit(1); } + if (verbose) + fprintf(stderr, "reading %s\n", name); while (fgets(buf, sizeof(buf), file)) { nl = strchr(buf, '\n'); if (nl) diff --git a/sch2fig/main.c b/sch2fig/main.c index 42f6809..db59f96 100644 --- a/sch2fig/main.c +++ b/sch2fig/main.c @@ -27,6 +27,9 @@ #include "main.h" +int verbose = 0; + + static struct gfx_ops const *ops_list[] = { &fig_ops, &cro_png_ops, @@ -38,7 +41,7 @@ static struct gfx_ops const *ops_list[] = { void usage(const char *name) { fprintf(stderr, -"usage: %s [-r] [file.lib ...] file.sch -- driver_spec\n\n" +"usage: %s [-r] [-v ...] [file.lib ...] file.sch -- driver_spec\n\n" " FIG driver spec:\n" " fig [-t template.fig] [var=value ...]\n" " Cairo PNG driver spec:\n" @@ -67,11 +70,14 @@ int main(int argc, char *const *argv) if (!strcmp(argv[dashdash], "--")) break; - while ((c = getopt(dashdash, argv, "r")) != EOF) + while ((c = getopt(dashdash, argv, "rv")) != EOF) switch (c) { case 'r': recurse = 1; break; + case 'v': + verbose++; + break; default: usage(*argv); } diff --git a/sch2fig/main.h b/sch2fig/main.h index eb3587c..4a3bdc1 100644 --- a/sch2fig/main.h +++ b/sch2fig/main.h @@ -13,6 +13,19 @@ #ifndef MAIN_H #define MAIN_H +#include + + +/* + * 0: no progress indications + * 1: reasonable progress indications + * 2: verbose output + * > 2: go wild ! + */ + +extern int verbose; + + void usage(const char *name); #endif /* !MAIN_H */