FreeCalypso > hg > freecalypso-tools
annotate ffstools/caltools/fc-cal2bin.c @ 366:9f856f843620
uptools/atcmd: smsend_basic.c renamed to smsend_main.c
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 08 Mar 2018 07:09:37 +0000 |
parents | 0af5009bd52f |
children | 5bcf12be0834 |
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 } |