annotate ffstools/caltools/fc-cal2bin.c @ 416:30f6d1c32c6f

doc/Flash-boot-defect article removed (no longer relevant) This article is no longer relevant because the issue in question only affected one (1) defective FCDEV3B board which was not and never will be sold.
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 26 Oct 2018 07:11:08 +0000
parents 0af5009bd52f
children 5bcf12be0834
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
292
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
1 /*
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
2 * This utility converts an RF table from ASCII to binary format.
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
3 */
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
4
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
5 #include <sys/types.h>
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
6 #include <sys/file.h>
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
7 #include <stdio.h>
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
8 #include <stdlib.h>
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
9 #include <unistd.h>
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
10
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
11 main(argc, argv)
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
12 char **argv;
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
13 {
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
14 u_char buf[512];
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
15 unsigned size;
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
16 int ofd;
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
17
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
18 if (argc != 3) {
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
19 fprintf(stderr,
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
20 "usage: %s ascii-input-file binary-output-file\n",
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
21 argv[0]);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
22 exit(1);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
23 }
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
24 if (read_rf_table_ext(argv[1], buf, 1, 0, &size))
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
25 exit(1);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
26 ofd = open(argv[2], O_WRONLY|O_CREAT|O_TRUNC, 0666);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
27 if (ofd < 0) {
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
28 perror(argv[2]);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
29 exit(1);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
30 }
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
31 write(ofd, buf, size);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
32 close(ofd);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
33 exit(0);
0af5009bd52f fc-cal2bin written, compiles
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff changeset
34 }