view ueda/mclutils/getfps.c @ 126:a921e0e0b33f

uschem-symbols/DT[AC]114YE.pinout added
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 12 Jul 2020 01:37:42 +0000
parents d098f8548b44
children
line wrap: on
line source

/*
 * 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 <stdlib.h>
#include <string.h>
#include <strings.h>
#include <unistd.h>
#include "../libueda/mcl.h"

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);
}