mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-12-23 14:19:53 +02:00
sch2fig/: new option -C file to "cat" a file (also works with git)
This provides quick access to the git-file mechanism.
This commit is contained in:
parent
7cfb2d72be
commit
77ac119136
@ -21,6 +21,13 @@
|
||||
#include "file.h"
|
||||
|
||||
|
||||
bool file_cat(void *user, const char *line)
|
||||
{
|
||||
printf("%s", line);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
static void read_from_file(FILE *file,
|
||||
bool (*parse)(void *user, const char *line), void *user)
|
||||
{
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
bool file_cat(void *user, const char *line);
|
||||
void file_read(const char *name, bool (*parse)(void *user, const char *line),
|
||||
void *user);
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "cro.h"
|
||||
#include "diff.h"
|
||||
#include "gfx.h"
|
||||
#include "file.h"
|
||||
#include "lib.h"
|
||||
#include "sch.h"
|
||||
#include "main.h"
|
||||
@ -41,7 +42,8 @@ static struct gfx_ops const *ops_list[] = {
|
||||
void usage(const char *name)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s [-r] [-v ...] [file.lib ...] file.sch -- driver_spec\n\n"
|
||||
"usage: %s [-r] [-v ...] [file.lib ...] file.sch -- driver_spec\n"
|
||||
" %s [-v ...] -C file\n\n"
|
||||
" FIG driver spec:\n"
|
||||
" fig [-t template.fig] [var=value ...]\n"
|
||||
" Cairo PNG driver spec:\n"
|
||||
@ -50,7 +52,7 @@ void usage(const char *name)
|
||||
" pdf [-o output.pdf] [-s scale]\n"
|
||||
" Diff driver spec:\n"
|
||||
" diff [-o output.pdf] [-s scale] [file.lib ...] file.sch\n"
|
||||
, name);
|
||||
, name, name);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -60,6 +62,7 @@ int main(int argc, char *const *argv)
|
||||
struct lib lib;
|
||||
struct sch_ctx sch_ctx;
|
||||
bool recurse = 0;
|
||||
const char *cat = NULL;
|
||||
char c;
|
||||
int arg, dashdash;
|
||||
int gfx_argc;
|
||||
@ -70,7 +73,7 @@ int main(int argc, char *const *argv)
|
||||
if (!strcmp(argv[dashdash], "--"))
|
||||
break;
|
||||
|
||||
while ((c = getopt(dashdash, argv, "rv")) != EOF)
|
||||
while ((c = getopt(dashdash, argv, "rvC:")) != EOF)
|
||||
switch (c) {
|
||||
case 'r':
|
||||
recurse = 1;
|
||||
@ -78,10 +81,20 @@ int main(int argc, char *const *argv)
|
||||
case 'v':
|
||||
verbose++;
|
||||
break;
|
||||
case 'C':
|
||||
cat = optarg;
|
||||
break;
|
||||
default:
|
||||
usage(*argv);
|
||||
}
|
||||
|
||||
if (cat) {
|
||||
if (argc != optind)
|
||||
usage(*argv);
|
||||
file_read(cat, file_cat, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dashdash - optind < 1)
|
||||
usage(*argv);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user