1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-30 06:59:23 +02:00

sch2fig/: option -v (can be repeated) for progress and debugging output

This commit is contained in:
Werner Almesberger 2016-08-02 06:31:23 -03:00
parent 5d0596d0b7
commit 47792182b7
3 changed files with 24 additions and 2 deletions

View File

@ -15,6 +15,7 @@
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "main.h"
#include "file.h" #include "file.h"
@ -30,6 +31,8 @@ void file_read(const char *name, bool (*parse)(void *user, const char *line),
perror(name); perror(name);
exit(1); exit(1);
} }
if (verbose)
fprintf(stderr, "reading %s\n", name);
while (fgets(buf, sizeof(buf), file)) { while (fgets(buf, sizeof(buf), file)) {
nl = strchr(buf, '\n'); nl = strchr(buf, '\n');
if (nl) if (nl)

View File

@ -27,6 +27,9 @@
#include "main.h" #include "main.h"
int verbose = 0;
static struct gfx_ops const *ops_list[] = { static struct gfx_ops const *ops_list[] = {
&fig_ops, &fig_ops,
&cro_png_ops, &cro_png_ops,
@ -38,7 +41,7 @@ static struct gfx_ops const *ops_list[] = {
void usage(const char *name) void usage(const char *name)
{ {
fprintf(stderr, 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 driver spec:\n"
" fig [-t template.fig] [var=value ...]\n" " fig [-t template.fig] [var=value ...]\n"
" Cairo PNG driver spec:\n" " Cairo PNG driver spec:\n"
@ -67,11 +70,14 @@ int main(int argc, char *const *argv)
if (!strcmp(argv[dashdash], "--")) if (!strcmp(argv[dashdash], "--"))
break; break;
while ((c = getopt(dashdash, argv, "r")) != EOF) while ((c = getopt(dashdash, argv, "rv")) != EOF)
switch (c) { switch (c) {
case 'r': case 'r':
recurse = 1; recurse = 1;
break; break;
case 'v':
verbose++;
break;
default: default:
usage(*argv); usage(*argv);
} }

View File

@ -13,6 +13,19 @@
#ifndef MAIN_H #ifndef MAIN_H
#define MAIN_H #define MAIN_H
#include <stdbool.h>
/*
* 0: no progress indications
* 1: reasonable progress indications
* 2: verbose output
* > 2: go wild !
*/
extern int verbose;
void usage(const char *name); void usage(const char *name);
#endif /* !MAIN_H */ #endif /* !MAIN_H */