annotate ueda/sverp-bind/enterinst.c @ 22:c7ebd6179f5d

ueda-bind: output implemented
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sun, 02 Aug 2015 07:21:06 +0000
parents dda8e455c863
children ce887659d12e
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
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16 oc->altname = hier;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17 inst = enter_instance(hier);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 inst->outcomp = oc;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
19 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 process_slotmap_attr(oc, slotmap_file)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 struct outcomp *oc;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 char *slotmap_file;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25 FILE *stream;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 char linebuf[256];
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 int lineno;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 register char *cp;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 char *instname, *slot;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30 register struct instance *inst;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 stream = fopen(slotmap_file, "r");
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 if (!stream) {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 perror(slotmap_file);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 exit(1);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 for (lineno = 1; fgets(linebuf, sizeof linebuf, stream); lineno++) {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 cp = index(linebuf, '\n');
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 if (!cp) {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40 fprintf(stderr,
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41 "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
42 slotmap_file, lineno);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 exit(1);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 *cp = '\0';
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 for (cp = linebuf; isspace(*cp); cp++)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
47 ;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 if (*cp == '\0' || *cp == '#')
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 continue;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50 instname = cp;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 while (*cp && !isspace(*cp))
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 cp++;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53 if (*cp)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 *cp++ = '\0';
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 while (isspace(*cp))
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 cp++;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 if (*cp == '\0' || *cp == '#')
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58 slot = 0;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 else {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 slot = 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 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66 inst = enter_instance(instname);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 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
68 if (slot)
dda8e455c863 unet-bind works to the point of reporting unbound instances
Space Falcon <falcon@ivan.Harhan.ORG>
parents: 14
diff changeset
69 slot = copystr(slot);
14
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 inst->slot = slot;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
71 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
72 fclose(stream);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
73 }