annotate miscprog/pircalextr.c @ 275:cbd944ebeff0

Pirelli PCB RE: traced out Calypso FDP and flash reset input
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 24 Mar 2018 20:38:24 +0000
parents e3bbb8cfbbc0
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
218
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This program extracts the RF calibration tables from a dump of Pirelli's
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 * factory sector and saves them in FreeCalypso ASCII format.
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4 */
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/types.h>
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <sys/file.h>
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <sys/stat.h>
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <stdio.h>
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10 #include <stdint.h>
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 #include <endian.h>
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 #include <stdlib.h>
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 #include <unistd.h>
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 u_char factbuf[0x2000];
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17 read_factory_struct(filename)
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 char *filename;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 int fd;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 struct stat st;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 fd = open(filename, O_RDONLY);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if (fd < 0) {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 perror(filename);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 exit(1);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 fstat(fd, &st);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 if (!S_ISREG(st.st_mode)) {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 fprintf(stderr, "error: %s is not a regular file\n", filename);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 exit(1);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 if (st.st_size != 0x10000) {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 fprintf(stderr,
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
35 "error: %s is of the wrong size (64 KiB expected)\n",
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
36 filename);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
37 exit(1);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
38 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
39 read(fd, factbuf, sizeof factbuf);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
40 close(fd);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
41 return(0);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
42 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
43
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
44 unsigned
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
45 get_u32(bin)
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
46 u_char *bin;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
47 {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
48 return le32toh(*(uint32_t *)bin);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
49 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
50
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
51 unsigned
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
52 get_u16(bin)
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
53 u_char *bin;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
54 {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
55 return le16toh(*(uint16_t *)bin);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
56 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
57
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
58 get_s16(bin)
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
59 u_char *bin;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
60 {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
61 int i;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
62
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
63 i = le16toh(*(uint16_t *)bin);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
64 if (i >= 32768)
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
65 i -= 65536;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
66 return(i);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
67 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
68
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
69 void
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
70 write_tx_levels_table(bin, outf)
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
71 u_char *bin;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
72 FILE *outf;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
73 {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
74 int i;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
75 u_char *p = bin;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
76
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
77 fputs("rf_table tx-levels\n\n", outf);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
78 fputs("# Fields in each entry: apc, ramp_index, chan_cal_index\n\n",
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
79 outf);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
80 for (i = 0; i < 32; i++) {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
81 fprintf(outf, "%5u %3u %3u\t# entry %d\n",
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
82 get_u16(p), p[2], p[3], i);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
83 p += 4;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
84 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
85 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
86
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
87 void
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
88 write_tx_calchan_table(bin, outf)
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
89 u_char *bin;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
90 FILE *outf;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
91 {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
92 int i, j;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
93 u_char *p = bin;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
94
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
95 fputs("rf_table tx-calchan\n", outf);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
96 for (i = 0; i < 4; i++) {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
97 fprintf(outf, "\n# Channel calibration table %d:\n\n", i);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
98 for (j = 0; j < 8; j++) {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
99 fprintf(outf, "%5u %6d\n", get_u16(p), get_s16(p + 2));
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
100 p += 4;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
101 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
102 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
103 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
104
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
105 void
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
106 write_rx_calchan_table(bin, outf)
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
107 u_char *bin;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
108 FILE *outf;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
109 {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
110 int i;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
111 u_char *p = bin;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
112
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
113 fputs("rf_table rx-calchan\n\n", outf);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
114 for (i = 0; i < 10; i++) {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
115 fprintf(outf, "%5u %6d\n", get_u16(p), get_s16(p + 2));
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
116 p += 4;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
117 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
118 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
119
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
120 void
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
121 write_rx_agcparams_table(bin, outf)
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
122 u_char *bin;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
123 FILE *outf;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
124 {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
125 fputs("rf_table rx-agc-params\n\n", outf);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
126 fprintf(outf, "%5u\t# g_magic\n", get_u16(bin));
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
127 fprintf(outf, "%5u\t# lna_att\n", get_u16(bin + 2));
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
128 fprintf(outf, "%5u\t# lna_switch_thr_low\n", get_u16(bin + 4));
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
129 fprintf(outf, "%5u\t# lna_switch_thr_high\n", get_u16(bin + 6));
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
130 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
131
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
132 struct calmap {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
133 unsigned offset;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
134 char *outfile;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
135 void (*fmtfunc)();
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
136 } pirelli_cal_map[] = {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
137 {0x092C, "tx-levels.900", write_tx_levels_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
138 {0x09AD, "tx-calchan.900", write_tx_calchan_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
139 {0x0C2F, "tx-levels.1800", write_tx_levels_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
140 {0x0CB0, "tx-calchan.1800", write_tx_calchan_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
141 {0x0F32, "tx-levels.1900", write_tx_levels_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
142 {0x0FB3, "tx-calchan.1900", write_tx_calchan_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
143 {0x10AF, "rx-calchan.900", write_rx_calchan_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
144 {0x10D8, "rx-agcparams.900", write_rx_agcparams_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
145 {0x10E1, "rx-calchan.1800", write_rx_calchan_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
146 {0x110A, "rx-agcparams.1800", write_rx_agcparams_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
147 {0x1113, "rx-calchan.1900", write_rx_calchan_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
148 {0x113C, "rx-agcparams.1900", write_rx_agcparams_table},
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
149 {0, 0, 0}
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
150 };
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
151
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
152 main(argc, argv)
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
153 char **argv;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
154 {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
155 struct calmap *tp;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
156 FILE *of;
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
157
219
e3bbb8cfbbc0 pircalextr: added second argument for output directory
Mychaela Falconia <falcon@freecalypso.org>
parents: 218
diff changeset
158 if (argc != 3) {
e3bbb8cfbbc0 pircalextr: added second argument for output directory
Mychaela Falconia <falcon@freecalypso.org>
parents: 218
diff changeset
159 fprintf(stderr, "usage: %s fact.bin outdir\n", argv[0]);
218
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
160 exit(1);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
161 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
162 read_factory_struct(argv[1]);
219
e3bbb8cfbbc0 pircalextr: added second argument for output directory
Mychaela Falconia <falcon@freecalypso.org>
parents: 218
diff changeset
163 if (chdir(argv[2]) < 0) {
e3bbb8cfbbc0 pircalextr: added second argument for output directory
Mychaela Falconia <falcon@freecalypso.org>
parents: 218
diff changeset
164 perror(argv[2]);
e3bbb8cfbbc0 pircalextr: added second argument for output directory
Mychaela Falconia <falcon@freecalypso.org>
parents: 218
diff changeset
165 exit(1);
e3bbb8cfbbc0 pircalextr: added second argument for output directory
Mychaela Falconia <falcon@freecalypso.org>
parents: 218
diff changeset
166 }
218
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
167 for (tp = pirelli_cal_map; tp->outfile; tp++) {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
168 of = fopen(tp->outfile, "w");
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
169 if (!of) {
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
170 perror(tp->outfile);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
171 exit(1);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
172 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
173 tp->fmtfunc(factbuf + tp->offset, of);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
174 fclose(of);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
175 }
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
176 exit(0);
b6a95d35fabc pircalextr program written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
177 }