annotate ueda/sverp-bind/enterinst.c @ 14:068ea2458c5d

unet-bind: instance entry implemented
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sun, 02 Aug 2015 00:34:30 +0000
parents
children dda8e455c863
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
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 extern struct instance *enter_instance();
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9 process_hier_attr(oc, hier)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10 register struct outcomp *oc;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 char *hier;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12 {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 register struct instance *inst;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15 oc->altname = hier;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16 inst = enter_instance(hier);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17 inst->outcomp = oc;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 }
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 process_slotmap_attr(oc, slotmap_file)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 struct outcomp *oc;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 char *slotmap_file;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24 FILE *stream;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25 char linebuf[256];
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 int lineno;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 register char *cp;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 char *instname, *slot;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29 register struct instance *inst;
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 stream = fopen(slotmap_file, "r");
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 if (!stream) {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 perror(slotmap_file);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 exit(1);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 for (lineno = 1; fgets(linebuf, sizeof linebuf, stream); lineno++) {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37 cp = index(linebuf, '\n');
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 if (!cp) {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 fprintf(stderr,
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40 "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
41 slotmap_file, lineno);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42 exit(1);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 *cp = '\0';
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 for (cp = linebuf; isspace(*cp); cp++)
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 if (*cp == '\0' || *cp == '#')
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
48 continue;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
49 instname = cp;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
50 while (*cp && !isspace(*cp))
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
51 cp++;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
52 if (*cp)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
53 *cp++ = '\0';
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
54 while (isspace(*cp))
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
55 cp++;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
56 if (*cp == '\0' || *cp == '#')
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
57 slot = 0;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
58 else {
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
59 slot = cp;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
60 while (*cp && !isspace(*cp))
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
61 cp++;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
62 if (*cp)
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
63 *cp++ = '\0';
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
64 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
65 inst = enter_instance(instname);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
66 inst->outcomp = oc;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
67 inst->slot = slot;
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
68 }
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
69 fclose(stream);
068ea2458c5d unet-bind: instance entry implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
70 }