mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-04 23:43:43 +02:00
b2/: add options to set file type on the command line
This commit is contained in:
parent
e99a9f4705
commit
450769e031
@ -83,4 +83,4 @@ spotless: clean
|
|||||||
# ----- Experiments -----------------------------------------------------------
|
# ----- Experiments -----------------------------------------------------------
|
||||||
|
|
||||||
try:
|
try:
|
||||||
$(VALGRIND) ./boom HIERARCHY CHAR
|
$(VALGRIND) ./boom HIERARCHY -c CHAR
|
||||||
|
32
b2/boom.c
32
b2/boom.c
@ -13,6 +13,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include "lang.h"
|
#include "lang.h"
|
||||||
@ -36,26 +37,33 @@ static void open_stdin(const char *name)
|
|||||||
|
|
||||||
static void usage(const char *name)
|
static void usage(const char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "usage: %s [file ...]\n", name);
|
fprintf(stderr,
|
||||||
|
"usage: %s file [[-type] file ...] ...\n\n"
|
||||||
|
" file types:\n"
|
||||||
|
" -c characteristics\n"
|
||||||
|
" -i inventory\n"
|
||||||
|
, name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
|
void (*parse)(void) = parse_hierarchy;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
switch (argc) {
|
for (i = 1; i != argc; i++) {
|
||||||
case 1:
|
if (*argv[i] == '-') {
|
||||||
break;
|
if (!strcmp(argv[i], "-c"))
|
||||||
default:
|
parse = parse_characteristics;
|
||||||
open_stdin(argv[1]);
|
else if (!strcmp(argv[i], "-i"))
|
||||||
break;
|
parse = parse_inventory;
|
||||||
}
|
else
|
||||||
parse_hierarchy();
|
usage(*argv);
|
||||||
for (i = 2; i < argc; i++) {
|
} else {
|
||||||
open_stdin(argv[i]);
|
open_stdin(argv[i]);
|
||||||
parse_characteristics();
|
parse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user