FreeCalypso > hg > ueda-linux
comparison 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 |
comparison
equal
deleted
inserted
replaced
13:1f3283f8e482 | 14:068ea2458c5d |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include <strings.h> | |
5 #include "struct.h" | |
6 | |
7 extern struct instance *enter_instance(); | |
8 | |
9 process_hier_attr(oc, hier) | |
10 register struct outcomp *oc; | |
11 char *hier; | |
12 { | |
13 register struct instance *inst; | |
14 | |
15 oc->altname = hier; | |
16 inst = enter_instance(hier); | |
17 inst->outcomp = oc; | |
18 } | |
19 | |
20 process_slotmap_attr(oc, slotmap_file) | |
21 struct outcomp *oc; | |
22 char *slotmap_file; | |
23 { | |
24 FILE *stream; | |
25 char linebuf[256]; | |
26 int lineno; | |
27 register char *cp; | |
28 char *instname, *slot; | |
29 register struct instance *inst; | |
30 | |
31 stream = fopen(slotmap_file, "r"); | |
32 if (!stream) { | |
33 perror(slotmap_file); | |
34 exit(1); | |
35 } | |
36 for (lineno = 1; fgets(linebuf, sizeof linebuf, stream); lineno++) { | |
37 cp = index(linebuf, '\n'); | |
38 if (!cp) { | |
39 fprintf(stderr, | |
40 "error: %s line %d is too long or unterminated\n", | |
41 slotmap_file, lineno); | |
42 exit(1); | |
43 } | |
44 *cp = '\0'; | |
45 for (cp = linebuf; isspace(*cp); cp++) | |
46 ; | |
47 if (*cp == '\0' || *cp == '#') | |
48 continue; | |
49 instname = cp; | |
50 while (*cp && !isspace(*cp)) | |
51 cp++; | |
52 if (*cp) | |
53 *cp++ = '\0'; | |
54 while (isspace(*cp)) | |
55 cp++; | |
56 if (*cp == '\0' || *cp == '#') | |
57 slot = 0; | |
58 else { | |
59 slot = cp; | |
60 while (*cp && !isspace(*cp)) | |
61 cp++; | |
62 if (*cp) | |
63 *cp++ = '\0'; | |
64 } | |
65 inst = enter_instance(instname); | |
66 inst->outcomp = oc; | |
67 inst->slot = slot; | |
68 } | |
69 fclose(stream); | |
70 } |