# HG changeset patch # User Mychaela Falconia # Date 1487878034 0 # Node ID 88cdef7e6b1b8613e5fd37111ad17fe3fe52c0e9 # Parent 20c6f84c75e71b38d932d34a547cd98aa469ae7a BOM tallying code factored out of ueda-mkbom diff -r 20c6f84c75e7 -r 88cdef7e6b1b ueda/mclutils/Makefile --- a/ueda/mclutils/Makefile Thu Feb 23 19:18:16 2017 +0000 +++ b/ueda/mclutils/Makefile Thu Feb 23 19:27:14 2017 +0000 @@ -9,8 +9,8 @@ getfps: getfps.o ${LIBUEDA} ${CC} ${CFLAGS} -o $@ $@.o ${LIBUEDA} -mkbom: mkbom.o seqrefdes.o ${LIBUEDA} - ${CC} ${CFLAGS} -o $@ $@.o seqrefdes.o ${LIBUEDA} +mkbom: mkbom.o bomtally.o seqrefdes.o ${LIBUEDA} + ${CC} ${CFLAGS} -o $@ $@.o bomtally.o seqrefdes.o ${LIBUEDA} shortbom: shortbom.o ${LIBUEDA} ${CC} ${CFLAGS} -o $@ $@.o ${LIBUEDA} diff -r 20c6f84c75e7 -r 88cdef7e6b1b ueda/mclutils/bomtally.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ueda/mclutils/bomtally.c Thu Feb 23 19:27:14 2017 +0000 @@ -0,0 +1,111 @@ +/* + * This code generates a tallied form of the BOM from the MCL, + * to be used for generation of various BOM output formats. + */ + +#include +#include +#include +#include +#include +#include "../libueda/mcl.h" +#include "bomstruct.h" + +extern struct component components[]; +extern int ncomponents; +extern char *get_comp_attr(); +extern struct component *find_partdef_by_name(); + +extern int check_completeness, refdes_lists; +extern struct bompart *bomhead; + +tally_parts() +{ + int c; + register struct component *comp; + register char *attr; + struct component *socket; + + for (comp = components, c = 0; c < ncomponents; comp++, c++) { + if (!check_component_popopt(comp)) + continue; + if (comp->partdef == NULL) { + attr = get_comp_attr(comp, "part"); + if (attr && !strcmp(attr, "none")) + continue; + if (check_completeness) + fprintf(stderr, "%s has no part defined\n", + comp->name); + continue; + } + add_part_to_bom(comp->partdef, comp->name); + attr = get_comp_attr(comp, "socket"); + if (attr) { + socket = find_partdef_by_name(attr); + if (socket) + add_part_to_bom(socket, comp->name); + else + fprintf(stderr, + "%s: socket part %s not found\n", + comp->name, attr); + } + } +} + +add_part_to_bom(part, refdes) + struct component *part; + char *refdes; +{ + register struct bompart *bp, **bpp; + + for (bpp = &bomhead; bp = *bpp; bpp = &bp->next) + if (bp->part == part) { + bp->qty++; + if (refdes_lists) + add_refdes_to_bompart(bp, refdes); + return; + } + /* new part */ + bp = (struct bompart *) malloc(sizeof(struct bompart)); + if (bp == NULL) { + perror("malloc"); + exit(1); + } + bp->part = part; + bp->qty = 1; + bp->next = NULL; + bp->refdeslist = NULL; + *bpp = bp; + if (refdes_lists) + add_refdes_to_bompart(bp, refdes); +} + +add_refdes_to_bompart(bp, refdes) + struct bompart *bp; + char *refdes; +{ + register struct refdeslist *le, **lep; + + if (!bp->refdeslist) { + lep = &bp->refdeslist; + goto add_new; + } + for (le = bp->refdeslist; le->next; le = le->next) + ; + if (is_refdes_sequential(le->last, refdes)) { + le->last = refdes; + return(1); + } + lep = &le->next; +add_new: + le = (struct refdeslist *) malloc(sizeof(struct refdeslist)); + if (!le) { + perror("malloc"); + exit(1); + } + le->first = refdes; + le->last = refdes; + le->next = NULL; + *lep = le; + return(0); +} diff -r 20c6f84c75e7 -r 88cdef7e6b1b ueda/mclutils/mkbom.c --- a/ueda/mclutils/mkbom.c Thu Feb 23 19:18:16 2017 +0000 +++ b/ueda/mclutils/mkbom.c Thu Feb 23 19:27:14 2017 +0000 @@ -11,10 +11,7 @@ #include "bomstruct.h" extern char *MCLfile; -extern struct component components[]; -extern int ncomponents; extern char *get_comp_attr(), *get_comp_multiattr(); -extern struct component *find_partdef_by_name(); int check_completeness, refdes_lists; struct bompart *bomhead; @@ -54,97 +51,6 @@ exit(0); } -tally_parts() -{ - int c; - register struct component *comp; - register char *attr; - struct component *socket; - - for (comp = components, c = 0; c < ncomponents; comp++, c++) { - if (!check_component_popopt(comp)) - continue; - if (comp->partdef == NULL) { - attr = get_comp_attr(comp, "part"); - if (attr && !strcmp(attr, "none")) - continue; - if (check_completeness) - fprintf(stderr, "%s has no part defined\n", - comp->name); - continue; - } - add_part_to_bom(comp->partdef, comp->name); - attr = get_comp_attr(comp, "socket"); - if (attr) { - socket = find_partdef_by_name(attr); - if (socket) - add_part_to_bom(socket, comp->name); - else - fprintf(stderr, - "%s: socket part %s not found\n", - comp->name, attr); - } - } -} - -add_part_to_bom(part, refdes) - struct component *part; - char *refdes; -{ - register struct bompart *bp, **bpp; - - for (bpp = &bomhead; bp = *bpp; bpp = &bp->next) - if (bp->part == part) { - bp->qty++; - add_refdes_to_bompart(bp, refdes); - return; - } - /* new part */ - bp = (struct bompart *) malloc(sizeof(struct bompart)); - if (bp == NULL) { - perror("malloc"); - exit(1); - } - bp->part = part; - bp->qty = 1; - bp->next = NULL; - bp->refdeslist = NULL; - *bpp = bp; - add_refdes_to_bompart(bp, refdes); -} - -add_refdes_to_bompart(bp, refdes) - struct bompart *bp; - char *refdes; -{ - register struct refdeslist *le, **lep; - - if (!refdes_lists) - return; - if (!bp->refdeslist) { - lep = &bp->refdeslist; - goto add_new; - } - for (le = bp->refdeslist; le->next; le = le->next) - ; - if (is_refdes_sequential(le->last, refdes)) { - le->last = refdes; - return(1); - } - lep = &le->next; -add_new: - le = (struct refdeslist *) malloc(sizeof(struct refdeslist)); - if (!le) { - perror("malloc"); - exit(1); - } - le->first = refdes; - le->last = refdes; - le->next = NULL; - *lep = le; - return(0); -} - output() { register int i;