FreeCalypso > hg > freecalypso-tools
annotate ffstools/caltools/fc-cal2bin.c @ 1004:d15d337ac0a9
loadtools/scripts: remove long-deprecated -h gta02 config
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 09 Dec 2023 18:35:30 +0000 |
parents | 5bcf12be0834 |
children |
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 } |
466
5bcf12be0834
ffstools/caltools: null pointer passing fixes
Mychaela Falconia <falcon@freecalypso.org>
parents:
292
diff
changeset
|
24 if (read_rf_table_ext(argv[1], buf, 1, (char **) 0, &size)) |
292
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 } |