view ueda/libueda/mclacc.c @ 55:e93375570f91

pads2gpcb/decals.c: saving of silk lines and arcs implemented
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Sun, 31 Jan 2016 02:14:57 +0000
parents c91e7a30fab3
children
line wrap: on
line source

/*
 * These are the libueda routines for accessing the parsed MCL.
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "mcl.h"

extern struct component components[], partdefs[];
extern int ncomponents, npartdefs;

struct component *
find_partdef_by_name(partname)
	register char *partname;
{
	register struct component *part;
	register int i;

	for (part = partdefs, i = 0; i < npartdefs; part++, i++)
		if (!strcmp(part->name, partname))
			return(part);
	return(NULL);
}

char *
get_comp_attr(comp, attrname)
	struct component *comp;
	char *attrname;
{
	register struct attrib *attr;
	register int i;

	for (; comp; comp = comp->partdef) {
		attr = comp->attrs;
		for (i = 0; i < comp->nattrs; attr++, i++)
			if (!strcmp(attr->name, attrname))
				return(attr->value);
		if (comp->partdef == comp)
			break;
	}
	return(NULL);
}

char *
get_comp_multiattr(comp, attrname, cntp)
	struct component *comp;
	char *attrname;
	int *cntp;
{
	register struct attrib *attrs;
	register int i;

	attrs = comp->attrs;
	for (i = *cntp; i < comp->nattrs; i++)
		if (!strcmp(attrs[i].name, attrname)) {
			*cntp = i + 1;
			return(attrs[i].value);
		}
	return(NULL);
}