comparison ueda/unet-bind/enterinst.c @ 101:ffab0a4424ad

ueda: unet-bind program moved into sensibly named unet-bind subdir
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 29 Sep 2019 22:42:41 +0000
parents ueda/sverp-bind/enterinst.c@ce887659d12e
children
comparison
equal deleted inserted replaced
100:071b24bca546 101:ffab0a4424ad
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <strings.h>
5 #include "struct.h"
6
7 extern char *copystr();
8 extern struct instance *enter_instance();
9
10 process_hier_attr(oc, hier)
11 register struct outcomp *oc;
12 char *hier;
13 {
14 register struct instance *inst;
15
16 if (!strncmp(hier, "flip:", 5)) {
17 if (oc->npins != 2 || oc->grid_pkg) {
18 fprintf(stderr,
19 "error: hier=flip:... makes no sense for %s\n",
20 oc->name);
21 exit(1);
22 }
23 oc->reverse_2pin = 1;
24 hier += 5;
25 }
26 oc->altname = hier;
27 inst = enter_instance(hier);
28 inst->outcomp = oc;
29 }
30
31 process_slotmap_attr(oc, slotmap_file)
32 struct outcomp *oc;
33 char *slotmap_file;
34 {
35 FILE *stream;
36 char linebuf[256];
37 int lineno;
38 register char *cp;
39 char *instname, *slot;
40 register struct instance *inst;
41
42 stream = fopen(slotmap_file, "r");
43 if (!stream) {
44 perror(slotmap_file);
45 exit(1);
46 }
47 for (lineno = 1; fgets(linebuf, sizeof linebuf, stream); lineno++) {
48 cp = index(linebuf, '\n');
49 if (!cp) {
50 fprintf(stderr,
51 "error: %s line %d is too long or unterminated\n",
52 slotmap_file, lineno);
53 exit(1);
54 }
55 *cp = '\0';
56 for (cp = linebuf; isspace(*cp); cp++)
57 ;
58 if (*cp == '\0' || *cp == '#')
59 continue;
60 instname = cp;
61 while (*cp && !isspace(*cp))
62 cp++;
63 if (*cp)
64 *cp++ = '\0';
65 while (isspace(*cp))
66 cp++;
67 if (*cp == '\0' || *cp == '#')
68 slot = 0;
69 else {
70 slot = cp;
71 while (*cp && !isspace(*cp))
72 cp++;
73 if (*cp)
74 *cp++ = '\0';
75 }
76 inst = enter_instance(instname);
77 inst->outcomp = oc;
78 if (slot)
79 slot = copystr(slot);
80 inst->slot = slot;
81 }
82 fclose(stream);
83 }