1
0
mirror of git://projects.qi-hardware.com/cae-tools.git synced 2025-01-03 22:20:17 +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:
Werner Almesberger 2010-12-14 16:17:29 -03:00
parent 86c27dbe7c
commit fe50addf65

View File

@ -21,14 +21,33 @@
#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)
{
fprintf(stderr,
"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"
" -g input format is KiCad Gerber, not gnuplot\n"
, name, name);
, name, name, name);
exit(1);
}
@ -36,6 +55,7 @@ static void usage(const char *name)
int main(int argc, char **argv)
{
char *in = NULL, *out = NULL;
char *end;
int gerber = 0, dog_bone = 0;
double r;
struct path *paths;
@ -61,8 +81,17 @@ int main(int argc, char **argv)
in = argv[optind+1];
/* fall through */
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;
case 0:
run_script(NULL);
return 0;
default:
usage(*argv);
}