FreeCalypso > hg > ueda-linux
comparison ueda/libuschem/matchtomcl.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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:cd92449fdb51 |
---|---|
1 /* | |
2 * Logic to match uschem component instances to MCL components | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <ctype.h> | |
8 #include <strings.h> | |
9 #include "../libueda/mcl.h" | |
10 #include "schemstruct.h" | |
11 | |
12 extern struct component *find_comp_by_refdes(); | |
13 extern char *get_comp_attr(); | |
14 | |
15 match_schem_to_mcl(schem) | |
16 struct schem *schem; | |
17 { | |
18 register struct schemobj *obj; | |
19 int errflag = 0; | |
20 | |
21 for (obj = schem->obj_next; obj != (struct schemobj *)schem; | |
22 obj = obj->obj_next) | |
23 if (obj->obj_type == OBJTYPE_COMPINST) | |
24 if (match_compinst_to_mcl(schem, obj)) | |
25 errflag = 1; | |
26 if (errflag) | |
27 exit(1); | |
28 return(0); | |
29 } | |
30 | |
31 match_compinst_to_mcl(schem, obj) | |
32 struct schem *schem; | |
33 register struct schemobj *obj; | |
34 { | |
35 char refdes[256]; | |
36 register char *cp; | |
37 register struct component *comp; | |
38 | |
39 strcpy(refdes, obj->compobj_instname); | |
40 cp = index(refdes, '\0'); | |
41 while (cp > refdes && islower(cp[-1])) | |
42 cp--; | |
43 *cp = '\0'; | |
44 comp = find_comp_by_refdes(refdes); | |
45 if (comp) { | |
46 obj->compobj_mclcomp = comp; | |
47 return(0); | |
48 } else { | |
49 fprintf(stderr, | |
50 "%s: line %d: component %s not found in the MCL\n", | |
51 schem->orig_filename, obj->obj_lineno, refdes); | |
52 return(-1); | |
53 } | |
54 } | |
55 | |
56 char * | |
57 get_compinst_attr(obj, attrname) | |
58 struct schemobj *obj; | |
59 register char *attrname; | |
60 { | |
61 register struct decoration *decor; | |
62 | |
63 for (decor = obj->obj_decorations; decor; decor = decor->decor_next) | |
64 if (decor->decor_type == DECOR_TYPE_ATTR && | |
65 !strcmp(decor->decorattr_name, attrname)) | |
66 return(decor->decorattr_value); | |
67 return(get_comp_attr(obj->compobj_mclcomp, attrname)); | |
68 } |