FreeCalypso > hg > ueda-linux
view ueda/mclutils/bomtally.c @ 122:7faa5994befb
CONN__CUI_SJ1-4251x-SMT.fp added
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 05 Jul 2020 19:06:13 +0000 |
parents | 88cdef7e6b1b |
children |
line wrap: on
line source
/* * This code generates a tallied form of the BOM from the MCL, * to be used for generation of various BOM output formats. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <strings.h> #include <unistd.h> #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); }