FreeCalypso > hg > ueda-linux
diff ueda/mclutils/getfps.c @ 0:cd92449fdb51
initial import of ueda and ifctf-part-lib from ifctfvax CVS
author | Space Falcon <falcon@ivan.Harhan.ORG> |
---|---|
date | Mon, 20 Jul 2015 00:24:37 +0000 |
parents | |
children | d098f8548b44 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ueda/mclutils/getfps.c Mon Jul 20 00:24:37 2015 +0000 @@ -0,0 +1,79 @@ +/* + * This program "gets" all footprints for the board. The footprint attributes + * are extracted from the MCL and a set of M4 macro calls is emitted on stdout + * which when run through M4 will produce all footprints for the board with the + * refdes and value filled in. + */ + +#include <stdio.h> +#include <strings.h> +#include "../libueda/mcl.h" + +extern char *optarg; + +extern char *MCLfile; +extern struct component components[]; +extern int ncomponents; +extern char *get_comp_attr(); + +int check_completeness; + +main(argc, argv) + char **argv; +{ + register int c; + register struct component *comp; + register char *footprint, *value; + + while ((c = getopt(argc, argv, "chM:")) != EOF) + switch (c) { + case 'c': + check_completeness++; + break; + case 'h': + puts("include(template.pcb)"); + break; + case 'M': + MCLfile = optarg; + break; + default: + /* getopt prints the error message */ + exit(1); + } + + read_MCL(); + + for (comp = components, c = 0; c < ncomponents; comp++, c++) { + footprint = get_comp_attr(comp, "footprint"); + if (!footprint) { + if (check_completeness) + fprintf(stderr, "%s has no footprint\n", + comp->name); + continue; + } + if (!strcmp(footprint, "none")) + continue; + if (!strcmp(footprint, "TBD")) { + if (check_completeness) + fprintf(stderr, "%s: footprint=TBD\n", + comp->name); + continue; + } + value = get_comp_attr(comp, "pcbvalue"); + if (!value) + value = get_comp_attr(comp, "value"); + if (!value) + value = get_comp_attr(comp, "device"); + if (!value) + value = get_comp_attr(comp, "manufacturer_part_number"); + if (!value) + value = ""; + if (strncmp(footprint, "file:", 5)) + printf("make_footprint(`%s',`%s',`%s')\n", footprint, + comp->name, value); + else + printf("make_footprint_file(`%s',`%s',`%s')\n", + footprint + 5, comp->name, value); + } + exit(0); +}