mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-22 20:53:44 +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 -----------------------------------------------------------
|
||||
|
||||
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 <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++) {
|
||||
open_stdin(argv[i]);
|
||||
parse_characteristics();
|
||||
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();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user