FreeCalypso > hg > freecalypso-tools
annotate librftab/rftablerd.c @ 286:88a4ebed160d
fc-tmsync converted to link with librftab
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 18 Nov 2017 00:26:24 +0000 |
parents | 64bb50fc470f |
children | a0f79bba0ad8 |
rev | line source |
---|---|
121
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
281
feb2ee302d25
librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
280
diff
changeset
|
2 * Reading RF tables from formatted ASCII files: used for the rftw command |
feb2ee302d25
librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
280
diff
changeset
|
3 * in fc-tmsh, for the upload-rf-table command in fc-fsio, and in the |
feb2ee302d25
librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
280
diff
changeset
|
4 * standalone fc-cal2bin utility. |
121
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 */ |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <sys/types.h> |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <ctype.h> |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <stdio.h> |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <string.h> |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include <strings.h> |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include <stdlib.h> |
281
feb2ee302d25
librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
280
diff
changeset
|
13 #include "../rvinterf/include/exitcodes.h" |
121
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 #define MAX_FIELDS_PER_LINE 64 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 static char *filename; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 static FILE *rdfile; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 static unsigned lineno; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 static char linebuf[256], *line_fields[MAX_FIELDS_PER_LINE]; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 static unsigned line_nfields, line_field_ptr; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 static char *format; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 static u_char *writeptr; |
281
feb2ee302d25
librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
280
diff
changeset
|
24 static unsigned written_size, maxsize; |
121
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 static int |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 read_line() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 char *cp; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 if (!fgets(linebuf, sizeof linebuf, rdfile)) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 return(0); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 lineno++; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 cp = linebuf; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 for (line_nfields = 0; ; ) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 while (isspace(*cp)) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 cp++; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 if (*cp == '\0' || *cp == '#') |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 break; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 if (line_nfields >= MAX_FIELDS_PER_LINE) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 printf("%s line %d: too many fields on one line\n", |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 filename, lineno); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 return(-1); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 line_fields[line_nfields++] = cp; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 while (*cp && !isspace(*cp)) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 cp++; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 if (*cp) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 *cp++ = '\0'; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 return(1); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 get_field(retp) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 char **retp; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 int rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 if (line_field_ptr < line_nfields) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 *retp = line_fields[line_field_ptr++]; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 return(1); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 do { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 rc = read_line(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 if (rc <= 0) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 } while (!line_nfields); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 *retp = line_fields[0]; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 line_field_ptr = 1; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 return(1); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 process_number(size) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 char *field; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 int rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 u_long number; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 rc = get_field(&field); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 if (rc < 0) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 return(ERROR_USAGE); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 if (!rc) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 printf("error: %s is too short for table format %s\n", |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 filename, format); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 return(ERROR_USAGE); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
89 if (field[0] == '-') |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
90 number = strtol(field, 0, 0); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
91 else |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
92 number = strtoul(field, 0, 0); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
93 switch (size) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
94 case 1: |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
95 *writeptr++ = number; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
96 break; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
97 case 2: |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
98 *writeptr++ = number; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
99 *writeptr++ = number >> 8; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
100 break; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
101 case 4: |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
102 *writeptr++ = number; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
103 *writeptr++ = number >> 8; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
104 *writeptr++ = number >> 16; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
105 *writeptr++ = number >> 24; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
106 break; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
107 default: |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
108 abort(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
109 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
110 written_size += size; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
111 return(0); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
112 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
113 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
114 static |
283
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
115 expect_keyword(kw) |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
116 char *kw; |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
117 { |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
118 char *field; |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
119 int rc; |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
120 |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
121 rc = get_field(&field); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
122 if (rc < 0) |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
123 return(ERROR_USAGE); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
124 if (!rc) { |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
125 printf("error: %s is too short for table format %s\n", |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
126 filename, format); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
127 return(ERROR_USAGE); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
128 } |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
129 if (strcmp(field, kw)) { |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
130 printf("%s line %d: expected %s keyword\n", filename, lineno, |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
131 kw); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
132 return(ERROR_USAGE); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
133 } |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
134 return(0); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
135 } |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
136 |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
137 static |
121
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
138 ensure_eof() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
139 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
140 char *field; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
141 int rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
142 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
143 rc = get_field(&field); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
144 if (rc < 0) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
145 return(ERROR_USAGE); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
146 if (rc) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
147 printf("error: %s is too long for table format %s\n", |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
148 filename, format); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
149 return(ERROR_USAGE); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
150 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
151 return(0); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
152 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
153 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
154 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
155 read_agc_table() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
156 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
157 int i, rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
158 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
159 for (i = 0; i < 20; i++) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
160 rc = process_number(2); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
161 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
162 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
163 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
164 return ensure_eof(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
165 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
166 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
167 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
168 read_afcparams() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
169 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
170 int i, rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
171 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
172 for (i = 0; i < 4; i++) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
173 rc = process_number(4); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
174 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
175 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
176 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
177 for (i = 0; i < 4; i++) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
178 rc = process_number(2); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
179 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
180 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
181 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
182 return ensure_eof(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
183 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
184 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
185 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
186 read_agc_global_params() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
187 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
188 int i, rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
189 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
190 for (i = 0; i < 4; i++) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
191 rc = process_number(2); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
192 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
193 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
194 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
195 return ensure_eof(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
196 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
197 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
198 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
199 read_il2agc() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
200 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
201 int i, rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
202 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
203 for (i = 0; i < 121; i++) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
204 rc = process_number(1); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
205 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
206 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
207 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
208 return ensure_eof(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
209 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
210 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
211 static |
283
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
212 read_tx_ramps() |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
213 { |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
214 int i, j, rc; |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
215 |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
216 if (maxsize < 512) { |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
217 printf("error: tx-ramps table not allowed in this context\n"); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
218 return(ERROR_USAGE); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
219 } |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
220 for (i = 0; i < 16; i++) { |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
221 rc = expect_keyword("ramp-up"); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
222 if (rc) |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
223 return(rc); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
224 for (j = 0; j < 16; j++) { |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
225 rc = process_number(1); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
226 if (rc) |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
227 return(rc); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
228 } |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
229 rc = expect_keyword("ramp-down"); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
230 if (rc) |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
231 return(rc); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
232 for (j = 0; j < 16; j++) { |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
233 rc = process_number(1); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
234 if (rc) |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
235 return(rc); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
236 } |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
237 } |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
238 return ensure_eof(); |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
239 } |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
240 |
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
241 static |
121
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
242 read_tx_levels() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
243 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
244 int i, rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
245 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
246 for (i = 0; i < 32; i++) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
247 rc = process_number(2); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
248 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
249 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
250 rc = process_number(1); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
251 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
252 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
253 rc = process_number(1); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
254 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
255 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
256 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
257 return ensure_eof(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
258 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
259 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
260 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
261 read_tx_calchan() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
262 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
263 int i, rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
264 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
265 for (i = 0; i < 64; i++) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
266 rc = process_number(2); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
267 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
268 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
269 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
270 return ensure_eof(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
271 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
272 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
273 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
274 read_tx_caltemp() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
275 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
276 int i, rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
277 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
278 for (i = 0; i < 20; i++) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
279 rc = process_number(2); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
280 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
281 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
282 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
283 return ensure_eof(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
284 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
285 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
286 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
287 read_rx_calchan() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
288 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
289 int i, rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
290 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
291 for (i = 0; i < 20; i++) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
292 rc = process_number(2); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
293 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
294 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
295 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
296 return ensure_eof(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
297 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
298 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
299 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
300 read_rx_caltemp() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
301 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
302 int i, rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
303 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
304 for (i = 0; i < 22; i++) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
305 rc = process_number(2); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
306 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
307 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
308 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
309 return ensure_eof(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
310 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
311 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
312 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
313 read_rx_agc_params() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
314 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
315 int i, rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
316 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
317 for (i = 0; i < 4; i++) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
318 rc = process_number(2); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
319 if (rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
320 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
321 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
322 return ensure_eof(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
323 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
324 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
325 static |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
326 read_raw_table() |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
327 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
328 int rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
329 char *field; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
330 u_long number; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
331 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
332 for (;;) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
333 rc = get_field(&field); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
334 if (rc < 0) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
335 return(ERROR_USAGE); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
336 if (!rc) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
337 break; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
338 number = strtoul(field, 0, 16); |
281
feb2ee302d25
librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
280
diff
changeset
|
339 if (written_size >= maxsize) { |
121
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
340 printf("error: raw table %s exceeds maximum size\n", |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
341 filename); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
342 return(ERROR_USAGE); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
343 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
344 *writeptr++ = number; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
345 written_size++; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
346 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
347 if (!written_size) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
348 printf("error: raw table %s is empty\n", filename); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
349 return(ERROR_USAGE); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
350 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
351 return(0); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
352 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
353 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
354 static struct table_format { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
355 char *kw; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
356 int (*handler)(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
357 } table_formats[] = { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
358 {"agc-table", read_agc_table}, |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
359 {"afcparams", read_afcparams}, |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
360 {"agc-global-params", read_agc_global_params}, |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
361 {"il2agc", read_il2agc}, |
283
64bb50fc470f
librftab reader: implemented reading of Tx ramps tables
Mychaela Falconia <falcon@freecalypso.org>
parents:
281
diff
changeset
|
362 {"tx-ramps", read_tx_ramps}, |
121
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
363 {"tx-levels", read_tx_levels}, |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
364 {"tx-calchan", read_tx_calchan}, |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
365 {"tx-caltemp", read_tx_caltemp}, |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
366 {"rx-calchan", read_rx_calchan}, |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
367 {"rx-caltemp", read_rx_caltemp}, |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
368 {"rx-agc-params", read_rx_agc_params}, |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
369 {"raw", read_raw_table}, |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
370 {0, 0} |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
371 }; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
372 |
281
feb2ee302d25
librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
280
diff
changeset
|
373 read_rf_table_ext(filename_arg, rdbuf, allow_large, format_ret, size_ret) |
121
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
374 char *filename_arg; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
375 u_char *rdbuf; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
376 char **format_ret; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
377 unsigned *size_ret; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
378 { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
379 char *field; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
380 int rc; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
381 struct table_format *tp; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
382 |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
383 filename = filename_arg; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
384 rdfile = fopen(filename, "r"); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
385 if (!rdfile) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
386 perror(filename); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
387 return(ERROR_UNIX); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
388 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
389 lineno = 0; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
390 line_nfields = 0; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
391 rc = get_field(&field); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
392 if (rc <= 0) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
393 not_valid_rftable: |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
394 printf("error: %s is not a valid RF table file\n", filename); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
395 fclose(rdfile); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
396 return(ERROR_USAGE); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
397 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
398 if (strcmp(field, "rf_table")) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
399 goto not_valid_rftable; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
400 rc = get_field(&field); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
401 if (rc <= 0) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
402 goto not_valid_rftable; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
403 for (tp = table_formats; tp->kw; tp++) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
404 if (!strcmp(tp->kw, field)) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
405 break; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
406 if (!tp->kw) { |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
407 printf("error: table format \"%s\" not recognized\n", field); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
408 fclose(rdfile); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
409 return(ERROR_USAGE); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
410 } |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
411 format = tp->kw; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
412 if (format_ret) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
413 *format_ret = format; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
414 writeptr = rdbuf; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
415 written_size = 0; |
281
feb2ee302d25
librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
280
diff
changeset
|
416 if (allow_large) |
feb2ee302d25
librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
280
diff
changeset
|
417 maxsize = 512; |
feb2ee302d25
librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
280
diff
changeset
|
418 else |
feb2ee302d25
librftab compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
280
diff
changeset
|
419 maxsize = 128; |
121
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
420 rc = tp->handler(); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
421 fclose(rdfile); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
422 if (size_ret) |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
423 *size_ret = written_size; |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
424 return(rc); |
4070847293a9
fc-tmsh: RF table reading code implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
425 } |
127
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
426 |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
427 static |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
428 process_txramp_number() |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
429 { |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
430 char *field; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
431 int rc; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
432 u_long number; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
433 |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
434 rc = get_field(&field); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
435 if (rc < 0) |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
436 return(ERROR_USAGE); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
437 if (!rc) { |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
438 printf("error: %s is too short for a Tx ramp template\n", |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
439 filename); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
440 return(ERROR_USAGE); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
441 } |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
442 number = strtoul(field, 0, 0); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
443 *writeptr++ = number; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
444 return(0); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
445 } |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
446 |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
447 static |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
448 read_txramp_16num() |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
449 { |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
450 int i, rc; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
451 |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
452 for (i = 0; i < 16; i++) { |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
453 rc = process_txramp_number(); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
454 if (rc) |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
455 return(rc); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
456 } |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
457 return(0); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
458 } |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
459 |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
460 read_tx_ramp_template(filename_arg, rdbuf) |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
461 char *filename_arg; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
462 u_char *rdbuf; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
463 { |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
464 char *field; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
465 int rc; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
466 |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
467 filename = filename_arg; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
468 rdfile = fopen(filename, "r"); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
469 if (!rdfile) { |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
470 perror(filename); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
471 return(ERROR_UNIX); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
472 } |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
473 lineno = 0; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
474 line_nfields = 0; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
475 rc = get_field(&field); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
476 if (rc <= 0) { |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
477 not_valid_ramp_file: |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
478 printf("error: %s is not a valid Tx ramp template file\n", |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
479 filename); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
480 fclose(rdfile); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
481 return(ERROR_USAGE); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
482 } |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
483 if (strcmp(field, "ramp-up")) |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
484 goto not_valid_ramp_file; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
485 writeptr = rdbuf; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
486 rc = read_txramp_16num(); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
487 if (rc) { |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
488 fclose(rdfile); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
489 return(rc); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
490 } |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
491 rc = get_field(&field); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
492 if (rc <= 0) |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
493 goto not_valid_ramp_file; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
494 if (strcmp(field, "ramp-down")) |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
495 goto not_valid_ramp_file; |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
496 rc = read_txramp_16num(); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
497 if (rc) { |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
498 fclose(rdfile); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
499 return(rc); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
500 } |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
501 rc = get_field(&field); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
502 fclose(rdfile); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
503 if (rc < 0) |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
504 return(ERROR_USAGE); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
505 if (rc) { |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
506 printf("error: %s is too long for a Tx ramp template\n", |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
507 filename); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
508 return(ERROR_USAGE); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
509 } |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
510 return(0); |
db7fc16bac1e
fc-tmsh: implemented reading of Tx ramp template files
Mychaela Falconia <falcon@freecalypso.org>
parents:
121
diff
changeset
|
511 } |