FreeCalypso > hg > freecalypso-tools
comparison ffstools/caltools/fc-cal2bin.c @ 292:0af5009bd52f
fc-cal2bin written, compiles
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 18 Nov 2017 07:38:36 +0000 |
parents | |
children | 5bcf12be0834 |
comparison
equal
deleted
inserted
replaced
291:dd97e75620a7 | 292:0af5009bd52f |
---|---|
1 /* | |
2 * This utility converts an RF table from ASCII to binary format. | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <sys/file.h> | |
7 #include <stdio.h> | |
8 #include <stdlib.h> | |
9 #include <unistd.h> | |
10 | |
11 main(argc, argv) | |
12 char **argv; | |
13 { | |
14 u_char buf[512]; | |
15 unsigned size; | |
16 int ofd; | |
17 | |
18 if (argc != 3) { | |
19 fprintf(stderr, | |
20 "usage: %s ascii-input-file binary-output-file\n", | |
21 argv[0]); | |
22 exit(1); | |
23 } | |
24 if (read_rf_table_ext(argv[1], buf, 1, 0, &size)) | |
25 exit(1); | |
26 ofd = open(argv[2], O_WRONLY|O_CREAT|O_TRUNC, 0666); | |
27 if (ofd < 0) { | |
28 perror(argv[2]); | |
29 exit(1); | |
30 } | |
31 write(ofd, buf, size); | |
32 close(ofd); | |
33 exit(0); | |
34 } |