mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-28 18:45:20 +02:00
fped.c: cleaned up batch mode selection; batch modes are now mutually exclusive
This commit is contained in:
parent
f0c0ae779a
commit
6ca5c22ea4
76
fped.c
76
fped.c
@ -67,23 +67,32 @@ static void load_file(const char *name)
|
|||||||
static void usage(const char *name)
|
static void usage(const char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [-k] [-p|-P [-s scale] [-1 package]] [-T [-T]] [cpp_option ...]\n"
|
"usage: %s [batch_mode] [cpp_option ...] [in_file [out_file]]\n\n"
|
||||||
" %*s [in_file [out_file]]\n\n"
|
"Batch mode options:\n"
|
||||||
" -1 name output only the specified package\n"
|
|
||||||
" -k write KiCad output, then exit\n"
|
" -k write KiCad output, then exit\n"
|
||||||
" -p write Postscript output, then exit\n"
|
" -p write Postscript output, then exit\n"
|
||||||
" -P write Postscript output (full page), then exit\n"
|
" -P [-s scale] [-1 package]\n"
|
||||||
" -s scale scale factor for -P (default: auto-scale)\n"
|
" write Postscript output (full page), then exit\n"
|
||||||
|
" -1 name output only the specified package\n"
|
||||||
|
" -s scale scale factor for -P (default: auto-scale)\n"
|
||||||
" -T test mode. Load file, then exit\n"
|
" -T test mode. Load file, then exit\n"
|
||||||
" -T -T test mode. Load file, dump to stdout, then exit\n"
|
" -T -T test mode. Load file, dump to stdout, then exit\n\n"
|
||||||
|
"Common options:\n"
|
||||||
" cpp_option -Idir, -Dname[=value], or -Uname\n"
|
" cpp_option -Idir, -Dname[=value], or -Uname\n"
|
||||||
, name, (int) strlen(name), "");
|
, name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
enum {
|
||||||
|
batch_none = 0,
|
||||||
|
batch_kicad,
|
||||||
|
batch_ps,
|
||||||
|
batch_ps_fullpage,
|
||||||
|
batch_test
|
||||||
|
} batch = batch_none;
|
||||||
char *name = *argv;
|
char *name = *argv;
|
||||||
char **fake_argv;
|
char **fake_argv;
|
||||||
char *args[2];
|
char *args[2];
|
||||||
@ -91,11 +100,8 @@ int main(int argc, char **argv)
|
|||||||
char opt[] = "-?";
|
char opt[] = "-?";
|
||||||
char *end;
|
char *end;
|
||||||
int error;
|
int error;
|
||||||
int batch = 0;
|
|
||||||
int test_mode = 0;
|
int test_mode = 0;
|
||||||
const char *one = NULL;
|
const char *one = NULL;
|
||||||
int batch_write_kicad = 0;
|
|
||||||
int batch_write_ps = 0, batch_write_ps_fullpage = 0;
|
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt(argc, argv, "1:kps:D:I:PTU:")) != EOF)
|
while ((c = getopt(argc, argv, "1:kps:D:I:PTU:")) != EOF)
|
||||||
@ -104,23 +110,29 @@ int main(int argc, char **argv)
|
|||||||
one = optarg;
|
one = optarg;
|
||||||
break;
|
break;
|
||||||
case 'k':
|
case 'k':
|
||||||
batch_write_kicad = 1;
|
if (batch)
|
||||||
|
usage(*argv);
|
||||||
|
batch = batch_kicad;
|
||||||
break;
|
break;
|
||||||
case 'p':
|
case 'p':
|
||||||
batch_write_ps = 1;
|
if (batch)
|
||||||
|
usage(*argv);
|
||||||
|
batch = batch_ps;
|
||||||
break;
|
break;
|
||||||
case 'P':
|
case 'P':
|
||||||
batch_write_ps_fullpage = 1;
|
if (batch)
|
||||||
|
usage(*argv);
|
||||||
|
batch = batch_ps_fullpage;
|
||||||
break;
|
break;
|
||||||
case 's':
|
case 's':
|
||||||
if (!batch_write_ps_fullpage)
|
if (batch != batch_ps_fullpage)
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
postscript_params.zoom = strtod(optarg, &end);
|
postscript_params.zoom = strtod(optarg, &end);
|
||||||
if (*end)
|
if (*end)
|
||||||
usage(*argv);
|
usage(*argv);
|
||||||
break;
|
break;
|
||||||
case 'T':
|
case 'T':
|
||||||
batch = 1;
|
batch = batch_test;
|
||||||
test_mode++;
|
test_mode++;
|
||||||
break;
|
break;
|
||||||
case 'D':
|
case 'D':
|
||||||
@ -134,15 +146,9 @@ int main(int argc, char **argv)
|
|||||||
usage(name);
|
usage(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (batch_write_ps && batch_write_ps_fullpage)
|
if (one && batch != batch_ps && batch != batch_ps_fullpage)
|
||||||
usage(name);
|
usage(name);
|
||||||
|
|
||||||
if (one && !(batch_write_ps || batch_write_ps_fullpage))
|
|
||||||
usage(name);
|
|
||||||
|
|
||||||
if (batch_write_kicad || batch_write_ps || batch_write_ps_fullpage)
|
|
||||||
batch = 1;
|
|
||||||
|
|
||||||
if (!batch) {
|
if (!batch) {
|
||||||
args[0] = name;
|
args[0] = name;
|
||||||
args[1] = NULL;
|
args[1] = NULL;
|
||||||
@ -179,19 +185,27 @@ int main(int argc, char **argv)
|
|||||||
if (!instantiate())
|
if (!instantiate())
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (batch_write_kicad)
|
switch (batch) {
|
||||||
write_kicad();
|
case batch_none:
|
||||||
if (batch_write_ps)
|
|
||||||
write_ps(one);
|
|
||||||
if (batch_write_ps_fullpage)
|
|
||||||
write_ps_fullpage(one);
|
|
||||||
if (!batch) {
|
|
||||||
error = gui_main();
|
error = gui_main();
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
}
|
break;
|
||||||
if (test_mode > 1)
|
case batch_kicad:
|
||||||
|
write_kicad();
|
||||||
|
break;
|
||||||
|
case batch_ps:
|
||||||
|
write_ps(one);
|
||||||
|
break;
|
||||||
|
case batch_ps_fullpage:
|
||||||
|
write_ps_fullpage(one);
|
||||||
|
break;
|
||||||
|
case batch_test:
|
||||||
dump(stdout, NULL);
|
dump(stdout, NULL);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
purge();
|
purge();
|
||||||
inst_revert();
|
inst_revert();
|
||||||
|
Loading…
Reference in New Issue
Block a user