# HG changeset patch # User Mychaela Falconia # Date 1598832119 0 # Node ID 125fc4ef7eb061eae1da140e3ebdf2be8704089f # Parent c165882efdf127f691e3809cbcb045fc2bd80982 ueda-csvattr program written, compiles diff -r c165882efdf1 -r 125fc4ef7eb0 .hgignore --- a/.hgignore Thu Jul 30 19:56:24 2020 +0000 +++ b/.hgignore Mon Aug 31 00:01:59 2020 +0000 @@ -2,6 +2,7 @@ \.[oa]$ +^ueda/mclutils/csvattr$ ^ueda/mclutils/csvbom$ ^ueda/mclutils/getfps$ ^ueda/mclutils/mkbom$ diff -r c165882efdf1 -r 125fc4ef7eb0 ueda/mclutils/Makefile --- a/ueda/mclutils/Makefile Thu Jul 30 19:56:24 2020 +0000 +++ b/ueda/mclutils/Makefile Mon Aug 31 00:01:59 2020 +0000 @@ -1,11 +1,14 @@ CC= gcc CFLAGS= -O2 -PROGS= csvbom getfps mkbom shortbom +PROGS= csvattr csvbom getfps mkbom shortbom LIBUEDA=../libueda/libueda.a BINDIR= /usr/local/bin all: ${PROGS} +csvattr: csvattr.o ${LIBUEDA} + ${CC} ${CFLAGS} -o $@ $@.o ${LIBUEDA} + csvbom: csvbom.o bomtally.o seqrefdes.o ${LIBUEDA} ${CC} ${CFLAGS} -o $@ $@.o bomtally.o seqrefdes.o ${LIBUEDA} @@ -19,6 +22,7 @@ ${CC} ${CFLAGS} -o $@ $@.o ${LIBUEDA} install: + install -c -o bin -g bin -m 755 csvattr ${BINDIR}/ueda-csvattr install -c -o bin -g bin -m 755 csvbom ${BINDIR}/ueda-csvbom install -c -o bin -g bin -m 755 getfps ${BINDIR}/ueda-getfps install -c -o bin -g bin -m 755 mkbom ${BINDIR}/ueda-mkbom diff -r c165882efdf1 -r 125fc4ef7eb0 ueda/mclutils/csvattr.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ueda/mclutils/csvattr.c Mon Aug 31 00:01:59 2020 +0000 @@ -0,0 +1,54 @@ +/* + * This program generates a CSV output listing all components in their + * MCL order and carrying a selected set of attributes as columns. + */ + +#include +#include +#include +#include +#include +#include "../libueda/mcl.h" + +extern char *MCLfile; +extern struct component components[]; +extern int ncomponents; +extern char *get_comp_attr(); + +main(argc, argv) + char **argv; +{ + extern int optind; + register int c, ai; + register struct component *comp; + register char *attr; + + while ((c = getopt(argc, argv, "M:")) != EOF) + switch (c) { + case 'M': + MCLfile = optarg; + break; + default: + /* getopt prints the error message */ + exit(1); + } + + read_MCL(); + /* emit CSV header */ + fputs("Refdes", stdout); + for (ai = optind; ai < argc; ai++) + printf(",%s", argv[ai]); + putchar('\n'); + + for (comp = components, c = 0; c < ncomponents; comp++, c++) { + fputs(comp->name, stdout); + for (ai = optind; ai < argc; ai++) { + attr = get_comp_attr(comp, argv[ai]); + if (!attr) + attr = ""; + printf(",%s", attr); + } + putchar('\n'); + } + exit(0); +}