mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-27 00:14:04 +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"
|
#include "file.h"
|
||||||
|
|
||||||
|
|
||||||
|
bool file_cat(void *user, const char *line)
|
||||||
|
{
|
||||||
|
printf("%s", line);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void read_from_file(FILE *file,
|
static void read_from_file(FILE *file,
|
||||||
bool (*parse)(void *user, const char *line), void *user)
|
bool (*parse)(void *user, const char *line), void *user)
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#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 file_read(const char *name, bool (*parse)(void *user, const char *line),
|
||||||
void *user);
|
void *user);
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "cro.h"
|
#include "cro.h"
|
||||||
#include "diff.h"
|
#include "diff.h"
|
||||||
#include "gfx.h"
|
#include "gfx.h"
|
||||||
|
#include "file.h"
|
||||||
#include "lib.h"
|
#include "lib.h"
|
||||||
#include "sch.h"
|
#include "sch.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
@ -41,7 +42,8 @@ static struct gfx_ops const *ops_list[] = {
|
|||||||
void usage(const char *name)
|
void usage(const char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
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 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"
|
||||||
@ -50,7 +52,7 @@ void usage(const char *name)
|
|||||||
" pdf [-o output.pdf] [-s scale]\n"
|
" pdf [-o output.pdf] [-s scale]\n"
|
||||||
" Diff driver spec:\n"
|
" Diff driver spec:\n"
|
||||||
" diff [-o output.pdf] [-s scale] [file.lib ...] file.sch\n"
|
" diff [-o output.pdf] [-s scale] [file.lib ...] file.sch\n"
|
||||||
, name);
|
, name, name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +62,7 @@ int main(int argc, char *const *argv)
|
|||||||
struct lib lib;
|
struct lib lib;
|
||||||
struct sch_ctx sch_ctx;
|
struct sch_ctx sch_ctx;
|
||||||
bool recurse = 0;
|
bool recurse = 0;
|
||||||
|
const char *cat = NULL;
|
||||||
char c;
|
char c;
|
||||||
int arg, dashdash;
|
int arg, dashdash;
|
||||||
int gfx_argc;
|
int gfx_argc;
|
||||||
@ -70,7 +73,7 @@ int main(int argc, char *const *argv)
|
|||||||
if (!strcmp(argv[dashdash], "--"))
|
if (!strcmp(argv[dashdash], "--"))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
while ((c = getopt(dashdash, argv, "rv")) != EOF)
|
while ((c = getopt(dashdash, argv, "rvC:")) != EOF)
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'r':
|
case 'r':
|
||||||
recurse = 1;
|
recurse = 1;
|
||||||
@ -78,10 +81,20 @@ int main(int argc, char *const *argv)
|
|||||||
case 'v':
|
case 'v':
|
||||||
verbose++;
|
verbose++;
|
||||||
break;
|
break;
|
||||||
|
case 'C':
|
||||||
|
cat = optarg;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (cat) {
|
||||||
|
if (argc != optind)
|
||||||
|
usage(*argv);
|
||||||
|
file_read(cat, file_cat, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (dashdash - optind < 1)
|
if (dashdash - optind < 1)
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user