FreeCalypso > hg > ueda-linux
comparison ueda/mclutils/csvattr.c @ 131:125fc4ef7eb0
ueda-csvattr program written, compiles
| author | Mychaela Falconia <falcon@freecalypso.org> |
|---|---|
| date | Mon, 31 Aug 2020 00:01:59 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 130:c165882efdf1 | 131:125fc4ef7eb0 |
|---|---|
| 1 /* | |
| 2 * This program generates a CSV output listing all components in their | |
| 3 * MCL order and carrying a selected set of attributes as columns. | |
| 4 */ | |
| 5 | |
| 6 #include <stdio.h> | |
| 7 #include <stdlib.h> | |
| 8 #include <string.h> | |
| 9 #include <strings.h> | |
| 10 #include <unistd.h> | |
| 11 #include "../libueda/mcl.h" | |
| 12 | |
| 13 extern char *MCLfile; | |
| 14 extern struct component components[]; | |
| 15 extern int ncomponents; | |
| 16 extern char *get_comp_attr(); | |
| 17 | |
| 18 main(argc, argv) | |
| 19 char **argv; | |
| 20 { | |
| 21 extern int optind; | |
| 22 register int c, ai; | |
| 23 register struct component *comp; | |
| 24 register char *attr; | |
| 25 | |
| 26 while ((c = getopt(argc, argv, "M:")) != EOF) | |
| 27 switch (c) { | |
| 28 case 'M': | |
| 29 MCLfile = optarg; | |
| 30 break; | |
| 31 default: | |
| 32 /* getopt prints the error message */ | |
| 33 exit(1); | |
| 34 } | |
| 35 | |
| 36 read_MCL(); | |
| 37 /* emit CSV header */ | |
| 38 fputs("Refdes", stdout); | |
| 39 for (ai = optind; ai < argc; ai++) | |
| 40 printf(",%s", argv[ai]); | |
| 41 putchar('\n'); | |
| 42 | |
| 43 for (comp = components, c = 0; c < ncomponents; comp++, c++) { | |
| 44 fputs(comp->name, stdout); | |
| 45 for (ai = optind; ai < argc; ai++) { | |
| 46 attr = get_comp_attr(comp, argv[ai]); | |
| 47 if (!attr) | |
| 48 attr = ""; | |
| 49 printf(",%s", attr); | |
| 50 } | |
| 51 putchar('\n'); | |
| 52 } | |
| 53 exit(0); | |
| 54 } |
