annotate ueda/sverp-bind/enterinst.c @ 95:f708e8a99f16

ifctf-part-lib/footprints/TAN-R-59XD.fp: created based on E-Sample and FCDEV3B versions
author Mychaela Falconia <falcon@freecalypso.org>
date Wed, 25 Sep 2019 20:13:49 +0000
parents ce887659d12e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 #include <stdio.h>
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 #include <stdlib.h>
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 #include <string.h>
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4 #include <strings.h>
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5 #include "struct.h"
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6
20
dda8e455c863 unet-bind works to the point of reporting unbound instances
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 14
diff changeset
7 extern char *copystr();
14
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8 extern struct instance *enter_instance();
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10 process_hier_attr(oc, hier)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 register struct outcomp *oc;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12 char *hier;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14 register struct instance *inst;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15
37
ce887659d12e unet-bind: implemented hier=flip:... hack for 2-pin components
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 20
diff changeset
16 if (!strncmp(hier, "flip:", 5)) {
ce887659d12e unet-bind: implemented hier=flip:... hack for 2-pin components
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 20
diff changeset
17 if (oc->npins != 2 || oc->grid_pkg) {
ce887659d12e unet-bind: implemented hier=flip:... hack for 2-pin components
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 20
diff changeset
18 fprintf(stderr,
ce887659d12e unet-bind: implemented hier=flip:... hack for 2-pin components
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 20
diff changeset
19 "error: hier=flip:... makes no sense for %s\n",
ce887659d12e unet-bind: implemented hier=flip:... hack for 2-pin components
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 20
diff changeset
20 oc->name);
ce887659d12e unet-bind: implemented hier=flip:... hack for 2-pin components
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 20
diff changeset
21 exit(1);
ce887659d12e unet-bind: implemented hier=flip:... hack for 2-pin components
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 20
diff changeset
22 }
ce887659d12e unet-bind: implemented hier=flip:... hack for 2-pin components
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 20
diff changeset
23 oc->reverse_2pin = 1;
ce887659d12e unet-bind: implemented hier=flip:... hack for 2-pin components
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 20
diff changeset
24 hier += 5;
ce887659d12e unet-bind: implemented hier=flip:... hack for 2-pin components
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 20
diff changeset
25 }
14
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 oc->altname = hier;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 inst = enter_instance(hier);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 inst->outcomp = oc;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 process_slotmap_attr(oc, slotmap_file)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 struct outcomp *oc;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 char *slotmap_file;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 FILE *stream;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 char linebuf[256];
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 int lineno;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 register char *cp;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 char *instname, *slot;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40 register struct instance *inst;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 stream = fopen(slotmap_file, "r");
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 if (!stream) {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 perror(slotmap_file);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 exit(1);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47 for (lineno = 1; fgets(linebuf, sizeof linebuf, stream); lineno++) {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 cp = index(linebuf, '\n');
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 if (!cp) {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50 fprintf(stderr,
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 "error: %s line %d is too long or unterminated\n",
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 slotmap_file, lineno);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53 exit(1);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 *cp = '\0';
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 for (cp = linebuf; isspace(*cp); cp++)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 ;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58 if (*cp == '\0' || *cp == '#')
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 continue;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 instname = cp;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 while (*cp && !isspace(*cp))
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62 cp++;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 if (*cp)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 *cp++ = '\0';
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 while (isspace(*cp))
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66 cp++;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 if (*cp == '\0' || *cp == '#')
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 slot = 0;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 else {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 slot = cp;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 while (*cp && !isspace(*cp))
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 cp++;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
73 if (*cp)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
74 *cp++ = '\0';
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
75 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
76 inst = enter_instance(instname);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
77 inst->outcomp = oc;
20
dda8e455c863 unet-bind works to the point of reporting unbound instances
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 14
diff changeset
78 if (slot)
dda8e455c863 unet-bind works to the point of reporting unbound instances
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 14
diff changeset
79 slot = copystr(slot);
14
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
80 inst->slot = slot;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
81 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
82 fclose(stream);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
83 }