FreeCalypso > hg > ueda-linux
view ueda/libuschem/matchtomcl.c @ 139:bf188727e606
donl-rename-parts reader: no tEDAx-style escapes
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 07 Sep 2020 04:25:11 +0000 |
parents | cd92449fdb51 |
children |
line wrap: on
line source
/* * Logic to match uschem component instances to MCL components */ #include <sys/types.h> #include <stdio.h> #include <ctype.h> #include <strings.h> #include "../libueda/mcl.h" #include "schemstruct.h" extern struct component *find_comp_by_refdes(); extern char *get_comp_attr(); match_schem_to_mcl(schem) struct schem *schem; { register struct schemobj *obj; int errflag = 0; for (obj = schem->obj_next; obj != (struct schemobj *)schem; obj = obj->obj_next) if (obj->obj_type == OBJTYPE_COMPINST) if (match_compinst_to_mcl(schem, obj)) errflag = 1; if (errflag) exit(1); return(0); } match_compinst_to_mcl(schem, obj) struct schem *schem; register struct schemobj *obj; { char refdes[256]; register char *cp; register struct component *comp; strcpy(refdes, obj->compobj_instname); cp = index(refdes, '\0'); while (cp > refdes && islower(cp[-1])) cp--; *cp = '\0'; comp = find_comp_by_refdes(refdes); if (comp) { obj->compobj_mclcomp = comp; return(0); } else { fprintf(stderr, "%s: line %d: component %s not found in the MCL\n", schem->orig_filename, obj->obj_lineno, refdes); return(-1); } } char * get_compinst_attr(obj, attrname) struct schemobj *obj; register char *attrname; { register struct decoration *decor; for (decor = obj->obj_decorations; decor; decor = decor->decor_next) if (decor->decor_type == DECOR_TYPE_ATTR && !strcmp(decor->decorattr_name, attrname)) return(decor->decorattr_value); return(get_comp_attr(obj->compobj_mclcomp, attrname)); }