changeset 292:0af5009bd52f

fc-cal2bin written, compiles
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 18 Nov 2017 07:38:36 +0000
parents dd97e75620a7
children f8eac2de9a5c
files .hgignore ffstools/caltools/Makefile ffstools/caltools/fc-cal2bin.c
diffstat 3 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat Nov 18 06:47:38 2017 +0000
+++ b/.hgignore	Sat Nov 18 07:38:36 2017 +0000
@@ -6,6 +6,7 @@
 \.srec$
 
 ^ffstools/cal2text/fc-cal2text$
+^ffstools/caltools/fc-cal2bin$
 ^ffstools/tiaud/compile$
 ^ffstools/tiaud/decomp$
 ^ffstools/tiaud/mkvol$
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ffstools/caltools/Makefile	Sat Nov 18 07:38:36 2017 +0000
@@ -0,0 +1,18 @@
+CC=	gcc
+CFLAGS=	-O2
+PROGS=	fc-cal2bin
+INSTBIN=/opt/freecalypso/bin
+
+all:	${PROGS}
+
+LIBRFTAB=	../../librftab/librftab.a
+
+fc-cal2bin:	fc-cal2bin.o ${LIBRFTAB}
+	${CC} ${CFLAGS} -o $@ fc-cal2bin.o ${LIBRFTAB}
+
+install:
+	mkdir -p ${INSTBIN}
+	install -c ${PROGS} ${INSTBIN}
+
+clean:
+	rm -f ${PROGS} *.o *errs *.out
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ffstools/caltools/fc-cal2bin.c	Sat Nov 18 07:38:36 2017 +0000
@@ -0,0 +1,34 @@
+/*
+ * This utility converts an RF table from ASCII to binary format.
+ */
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+main(argc, argv)
+	char **argv;
+{
+	u_char buf[512];
+	unsigned size;
+	int ofd;
+
+	if (argc != 3) {
+		fprintf(stderr,
+			"usage: %s ascii-input-file binary-output-file\n",
+			argv[0]);
+		exit(1);
+	}
+	if (read_rf_table_ext(argv[1], buf, 1, 0, &size))
+		exit(1);
+	ofd = open(argv[2], O_WRONLY|O_CREAT|O_TRUNC, 0666);
+	if (ofd < 0) {
+		perror(argv[2]);
+		exit(1);
+	}
+	write(ofd, buf, size);
+	close(ofd);
+	exit(0);
+}