annotate ffstools/cal2text/main.c @ 184:b8599a1d5813

fc-vcxo-param: bug in lin_b2 computation
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 13 Apr 2017 04:58:58 +0000
parents d41edd329670
children 329c31f7c797
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
142
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * The main() function for fc-cal2text lives here.
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/param.h>
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/file.h>
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/stat.h>
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdio.h>
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdlib.h>
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <unistd.h>
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 char *input_dir_base, *output_dir_base;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 extern void write_afcdac_ascii();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 extern void write_stdmap_ascii();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 extern void write_afcparams_table();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 extern void write_agcwords_table();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 extern void write_agcglobals_table();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 extern void write_il2agc_table();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 extern void write_tx_levels_table();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 extern void write_tx_calchan_table();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 extern void write_tx_caltemp_table();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 extern void write_rx_calchan_table();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 extern void write_rx_caltemp_table();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 extern void write_rx_agcparams_table();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 extern void write_tx_ramp();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 struct output_chunk {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 unsigned offset;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 char *outfile;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 void (*conv_func)();
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 static struct output_chunk afcdac_handling = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 0, "afcdac", write_afcdac_ascii
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 static struct output_chunk stdmap_handling = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 0, "stdmap", write_stdmap_ascii
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43 static struct output_chunk afcparams_handling = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 0, "afcparams", write_afcparams_table
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 static struct output_chunk agcglobals_handling = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 0, "agcglobals", write_agcglobals_table
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 static struct output_chunk il2agc_handling[3] = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 {0, "il2agc-pwr", write_il2agc_table},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 {121, "il2agc-max", write_il2agc_table},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 {242, "il2agc-av", write_il2agc_table},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57 static struct output_chunk agcwords_handling = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 0, "agcwords", write_agcwords_table
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 static struct output_chunk tx_ramps_handling[16] = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62 {0x000, "ramp00", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 {0x020, "ramp01", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 {0x040, "ramp02", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 {0x060, "ramp03", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 {0x080, "ramp04", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 {0x0A0, "ramp05", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68 {0x0C0, "ramp06", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 {0x0E0, "ramp07", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 {0x100, "ramp08", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 {0x120, "ramp09", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 {0x140, "ramp10", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 {0x160, "ramp11", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 {0x180, "ramp12", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 {0x1A0, "ramp13", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76 {0x1C0, "ramp14", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 {0x1E0, "ramp15", write_tx_ramp},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 static struct output_chunk tx_levels_handling = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 0, "levels", write_tx_levels_table
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 static struct output_chunk tx_calchan_handling = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 0, "calchan", write_tx_calchan_table
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 static struct output_chunk tx_caltemp_handling = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 0, "caltemp", write_tx_caltemp_table
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 static struct output_chunk rx_calchan_handling = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 0, "calchan", write_rx_calchan_table
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 static struct output_chunk rx_caltemp_handling = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 0, "caltemp", write_rx_caltemp_table
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 static struct output_chunk rx_agcparams_handling = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 0, "agcparams", write_rx_agcparams_table
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104 static struct input_file {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 char *filename;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 unsigned expect_size;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 char *outdir;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 struct output_chunk *handling;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 unsigned nchunks;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 } input_file_list[] = {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 {"afcdac", 2, "global", &afcdac_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112 {"stdmap", 2, "global", &stdmap_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 {"afcparams", 24, "global", &afcparams_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 {"rx/agcglobals", 8, "global", &agcglobals_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 {"rx/il2agc", 363, "global", il2agc_handling, 3},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 {"rx/agcwords", 40, "global", &agcwords_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 {"tx/ramps.850", 512, "tx-850", tx_ramps_handling, 16},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119 {"tx/levels.850", 128, "tx-850", &tx_levels_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 {"tx/calchan.850", 128, "tx-850", &tx_calchan_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 {"tx/caltemp.850", 40, "tx-850", &tx_caltemp_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 {"rx/calchan.850", 40, "rx-850", &rx_calchan_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 {"rx/caltemp.850", 44, "rx-850", &rx_caltemp_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 {"rx/agcparams.850", 8, "rx-850", &rx_agcparams_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 {"tx/ramps.900", 512, "tx-900", tx_ramps_handling, 16},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 {"tx/levels.900", 128, "tx-900", &tx_levels_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 {"tx/calchan.900", 128, "tx-900", &tx_calchan_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 {"tx/caltemp.900", 40, "tx-900", &tx_caltemp_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 {"rx/calchan.900", 40, "rx-900", &rx_calchan_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131 {"rx/caltemp.900", 44, "rx-900", &rx_caltemp_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 {"rx/agcparams.900", 8, "rx-900", &rx_agcparams_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 {"tx/ramps.1800", 512, "tx-1800", tx_ramps_handling, 16},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 {"tx/levels.1800", 128, "tx-1800", &tx_levels_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 {"tx/calchan.1800", 128, "tx-1800", &tx_calchan_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 {"tx/caltemp.1800", 40, "tx-1800", &tx_caltemp_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 {"rx/calchan.1800", 40, "rx-1800", &rx_calchan_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 {"rx/caltemp.1800", 44, "rx-1800", &rx_caltemp_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 {"rx/agcparams.1800", 8, "rx-1800", &rx_agcparams_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 {"tx/ramps.1900", 512, "tx-1900", tx_ramps_handling, 16},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 {"tx/levels.1900", 128, "tx-1900", &tx_levels_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 {"tx/calchan.1900", 128, "tx-1900", &tx_calchan_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 {"tx/caltemp.1900", 40, "tx-1900", &tx_caltemp_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 {"rx/calchan.1900", 40, "rx-1900", &rx_calchan_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 {"rx/caltemp.1900", 44, "rx-1900", &rx_caltemp_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 {"rx/agcparams.1900", 8, "rx-1900", &rx_agcparams_handling, 1},
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 {0, 0, 0, 0, 0}
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151 };
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 static
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 try_read_input_file(ip, buf)
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 struct input_file *ip;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 u_char *buf;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157 {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
158 char pathname[MAXPATHLEN];
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
159 int fd;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 struct stat st;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 sprintf(pathname, "%s/%s", input_dir_base, ip->filename);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
163 fd = open(pathname, O_RDONLY);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
164 if (fd < 0)
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
165 return(0);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
166 fstat(fd, &st);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 if (!S_ISREG(st.st_mode)) {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 close(fd);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 fprintf(stderr, "%s is not a regular file, skipping\n",
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 pathname);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 return(0);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 }
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 if (st.st_size != ip->expect_size) {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 close(fd);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 fprintf(stderr,
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 "%s has the wrong length (expected %u bytes), skipping\n",
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 pathname, ip->expect_size);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
178 return(0);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
179 }
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
180 read(fd, buf, ip->expect_size);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
181 close(fd);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
182 return(1);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
183 }
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
184
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
185 static void
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
186 write_outputs(ip, buf)
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
187 struct input_file *ip;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
188 u_char *buf;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
189 {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
190 char pathname[MAXPATHLEN];
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
191 struct output_chunk *op;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
192 unsigned nc;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
193 FILE *of;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
194
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
195 sprintf(pathname, "%s/%s", output_dir_base, ip->outdir);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
196 mkdir_existok(pathname);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
197 op = ip->handling;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
198 for (nc = 0; nc < ip->nchunks; op++, nc++) {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
199 sprintf(pathname, "%s/%s/%s", output_dir_base, ip->outdir,
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
200 op->outfile);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
201 of = fopen(pathname, "w");
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
202 if (!of) {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
203 perror(pathname);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
204 exit(1);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
205 }
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
206 op->conv_func(buf + op->offset, of);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
207 fclose(of);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
208 }
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
209 }
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
210
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
211 main(argc, argv)
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
212 char **argv;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
213 {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
214 struct input_file *ip;
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
215 u_char buf[512];
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
216
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
217 if (argc != 3) {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
218 fprintf(stderr, "usage: %s input-dir output-dir\n", argv[0]);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
219 exit(1);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
220 }
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
221 check_directory_exists(argv[1]);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
222 input_dir_base = argv[1];
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
223 check_directory_exists(argv[2]);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
224 output_dir_base = argv[2];
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
225
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
226 for (ip = input_file_list; ip->filename; ip++) {
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
227 if (try_read_input_file(ip, buf))
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
228 write_outputs(ip, buf);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
229 }
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
230 exit(0);
d41edd329670 fc-cal2text utility written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
231 }