FreeCalypso > hg > freecalypso-reveng
annotate fir/rdcommon.c @ 403:50c0fac9a4a8
compal/boot/c118-dfboot.disasm: new analysis
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 15 Jan 2023 00:54:33 +0000 |
parents | 9b3e5be96bab |
children |
rev | line source |
---|---|
376
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This C file is not a compilation unit in itself, but is the common piece |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * (a set of static variables and functions) included in the librftab modules |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 * responsible for reading different kinds of ASCII tables. |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #define MAX_FIELDS_PER_LINE 64 |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 static char *filename; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 static FILE *rdfile; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 static unsigned lineno; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 static char linebuf[256], *line_fields[MAX_FIELDS_PER_LINE]; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 static unsigned line_nfields, line_field_ptr; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 static int |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 read_line() |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 { |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 char *cp; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 if (!fgets(linebuf, sizeof linebuf, rdfile)) |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 return(0); |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 lineno++; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 cp = linebuf; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 for (line_nfields = 0; ; ) { |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 while (isspace(*cp)) |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 cp++; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 if (*cp == '\0' || *cp == '#') |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 break; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (line_nfields >= MAX_FIELDS_PER_LINE) { |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 fprintf(stderr, |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 "%s line %d: too many fields on one line\n", |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 filename, lineno); |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 return(-1); |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 } |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 line_fields[line_nfields++] = cp; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 while (*cp && !isspace(*cp)) |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 cp++; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 if (*cp) |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 *cp++ = '\0'; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 } |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 return(1); |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 } |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 static |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 get_field(retp) |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 char **retp; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 { |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 int rc; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 if (line_field_ptr < line_nfields) { |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 *retp = line_fields[line_field_ptr++]; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 return(1); |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 do { |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 rc = read_line(); |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 if (rc <= 0) |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 return(rc); |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 } while (!line_nfields); |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 *retp = line_fields[0]; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 line_field_ptr = 1; |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 return(1); |
9b3e5be96bab
fir2freq: a tool for analyzing captured FIR coefficient sets
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 } |