mirror of
git://projects.qi-hardware.com/cae-tools.git
synced 2025-01-03 22:10:15 +02:00
cameo: added invocation with an optional script
- cameo.c (usage, main): third form of invocation: cameo [script] - cameo.c (run_script, main): run yyparse
This commit is contained in:
parent
86c27dbe7c
commit
fe50addf65
@ -21,14 +21,33 @@
|
|||||||
#include "gerber.h"
|
#include "gerber.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern int yyparse(void);
|
||||||
|
extern FILE *yyin;
|
||||||
|
|
||||||
|
|
||||||
|
static void run_script(const char *file)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (file) {
|
||||||
|
yyin = fopen(file, "r");
|
||||||
|
if (!yyin) {
|
||||||
|
perror(file);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
yyparse();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void usage(const char *name)
|
static void usage(const char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [-d] r_mm [in.gnuplot [out.gnuplot]]\n"
|
"usage: %s [-d] r_mm [in.gnuplot [out.gnuplot]]\n"
|
||||||
" %s -g [-d] r_mm [in.gerber [out.gnuplot]]\n\n"
|
" %s -g [-d] r_mm [in.gerber [out.gnuplot]]\n"
|
||||||
|
" %s [script]\n\n"
|
||||||
" -d put a dog-bone notch in each concave external corner\n"
|
" -d put a dog-bone notch in each concave external corner\n"
|
||||||
" -g input format is KiCad Gerber, not gnuplot\n"
|
" -g input format is KiCad Gerber, not gnuplot\n"
|
||||||
, name, name);
|
, name, name, name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,6 +55,7 @@ static void usage(const char *name)
|
|||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
char *in = NULL, *out = NULL;
|
char *in = NULL, *out = NULL;
|
||||||
|
char *end;
|
||||||
int gerber = 0, dog_bone = 0;
|
int gerber = 0, dog_bone = 0;
|
||||||
double r;
|
double r;
|
||||||
struct path *paths;
|
struct path *paths;
|
||||||
@ -61,8 +81,17 @@ int main(int argc, char **argv)
|
|||||||
in = argv[optind+1];
|
in = argv[optind+1];
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 1:
|
case 1:
|
||||||
r = atof(argv[optind]);
|
r = strtod(argv[optind], &end);
|
||||||
|
if (*end) {
|
||||||
|
if (argc-optind != 1)
|
||||||
|
usage(*argv);
|
||||||
|
run_script(argv[optind]);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
case 0:
|
||||||
|
run_script(NULL);
|
||||||
|
return 0;
|
||||||
default:
|
default:
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user