FreeCalypso > hg > freecalypso-reveng
annotate blobstat/readclass.c @ 382:4307b57229d3
miscprog: tone-convert written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 10 Nov 2021 00:04:12 +0000 |
parents | 23e5b940cb8b |
children |
rev | line source |
---|---|
293
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 #include <sys/types.h> |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 #include <ctype.h> |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 #include <string.h> |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 #include <strings.h> |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 #include <stdio.h> |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <stdlib.h> |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include "struct.h" |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 extern struct category *category_list; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 extern struct libentry *libentry_list; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 static struct category * |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 find_or_create_cat(catname) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 char *catname; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 struct category *p, **pp; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 char *buf; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 for (pp = &category_list; p = *pp; pp = &p->next) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 if (!strcmp(p->name, catname)) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 return(p); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 buf = malloc(sizeof(struct category) + strlen(catname) + 1); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 if (!buf) { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 perror("malloc"); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 exit(1); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 } |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 p = (struct category *) buf; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 p->name = buf + sizeof(struct category); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 strcpy(p->name, catname); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 p->accum = 0; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 p->next = 0; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 *pp = p; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 return(p); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 static |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 add_whole_lib(libname, cat) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 char *libname; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 struct category *cat; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 struct libentry *p, **pp; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 char *buf; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 for (pp = &libentry_list; p = *pp; pp = &p->next) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 if (!strcmp(p->libname, libname)) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 return(-1); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 buf = malloc(sizeof(struct libentry) + strlen(libname) + 1); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (!buf) { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 perror("malloc"); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 exit(1); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 p = (struct libentry *) buf; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 p->libname = buf + sizeof(struct libentry); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 strcpy(p->libname, libname); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 p->member = 0; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 p->cat = cat; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 p->next = 0; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 *pp = p; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 return(0); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 } |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 static |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 add_lib_member(libname, member, cat) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 char *libname, *member; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 struct category *cat; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 struct libentry *p, **pp; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 char *buf; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 for (pp = &libentry_list; p = *pp; pp = &p->next) { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 if (strcmp(p->libname, libname)) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 continue; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 if (!p->member || !strcmp(p->member, member)) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 return(-1); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 } |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 buf = malloc(sizeof(struct libentry) + strlen(libname) + |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 strlen(member) + 2); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 if (!buf) { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 perror("malloc"); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 exit(1); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 } |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 p = (struct libentry *) buf; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 buf += sizeof(struct libentry); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 p->libname = buf; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 strcpy(p->libname, libname); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 buf += strlen(libname) + 1; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 p->member = buf; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 strcpy(p->member, member); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 p->cat = cat; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 p->next = 0; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 *pp = p; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 return(0); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 } |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 static void |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 process_line(linebuf, lineno, filename_for_errs) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 char *linebuf, *filename_for_errs; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 int lineno; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 char *cp, *libname, *member, *catname; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 struct category *cat; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 int rc; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 for (cp = linebuf; isspace(*cp); cp++) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 ; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 if (*cp == '\0' || *cp == '#') |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 return; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 for (libname = cp; *cp && !isspace(*cp); cp++) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 ; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 if (!*cp) { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 inv: fprintf(stderr, "%s line %d: invalid syntax\n", |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 filename_for_errs, lineno); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 exit(1); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 } |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
115 *cp++ = '\0'; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
116 while (isspace(*cp)) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
117 cp++; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
118 if (*cp == '\0' || *cp == '#') |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
119 goto inv; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
120 for (catname = cp; *cp && !isspace(*cp); cp++) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
121 ; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
122 if (*cp) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
123 *cp++ = '\0'; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
124 while (isspace(*cp)) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
125 cp++; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
126 if (*cp != '\0' && *cp != '#') |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
127 goto inv; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
128 member = index(libname, ':'); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
129 if (member) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
130 *member++ = '\0'; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
131 cat = find_or_create_cat(catname); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
132 if (member) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
133 rc = add_lib_member(libname, member, cat); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
134 else |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
135 rc = add_whole_lib(libname, cat); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
136 if (rc < 0) { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
137 fprintf(stderr, |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 "%s line %d: conflict with earlier declaration\n", |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 filename_for_errs, lineno); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 exit(1); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 } |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 } |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 read_class_file(filename) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 char *filename; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 FILE *inf; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 int lineno; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 char linebuf[512]; |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 inf = fopen(filename, "r"); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 if (!inf) { |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 perror(filename); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 exit(1); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 } |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 for (lineno = 1; fgets(linebuf, sizeof linebuf, inf); lineno++) |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 process_line(linebuf, lineno, filename); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 fclose(inf); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 return(0); |
23e5b940cb8b
blobstat: mostly complete
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 } |