1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-26 15:53:44 +02:00

b2/: add options to set file type on the command line

This commit is contained in:
Werner Almesberger 2012-04-30 20:11:53 -03:00
parent e99a9f4705
commit 450769e031
2 changed files with 21 additions and 13 deletions

View File

@ -83,4 +83,4 @@ spotless: clean
# ----- Experiments -----------------------------------------------------------
try:
$(VALGRIND) ./boom HIERARCHY CHAR
$(VALGRIND) ./boom HIERARCHY -c CHAR

View File

@ -13,6 +13,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
#include "lang.h"
@ -36,26 +37,33 @@ static void open_stdin(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);
}
int main(int argc, char **argv)
{
void (*parse)(void) = parse_hierarchy;
int i;
switch (argc) {
case 1:
break;
default:
open_stdin(argv[1]);
break;
}
parse_hierarchy();
for (i = 2; i < argc; i++) {
for (i = 1; i != argc; i++) {
if (*argv[i] == '-') {
if (!strcmp(argv[i], "-c"))
parse = parse_characteristics;
else if (!strcmp(argv[i], "-i"))
parse = parse_inventory;
else
usage(*argv);
} else {
open_stdin(argv[i]);
parse_characteristics();
parse();
}
}
return 0;
}