diff librftab/smallconv.c @ 720:b73c21a2148f

reorg: smallconv.c moved from ffstools/cal2text to librftab This module contains write_afcdac_ascii() and write_stdmap_ascii() functions; the plan is to make them available to other programs, particularly the upcoming addition of RF table dump to tiffs.
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 25 Aug 2020 06:28:44 +0000
parents ffstools/cal2text/smallconv.c@d41edd329670
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/librftab/smallconv.c	Tue Aug 25 06:28:44 2020 +0000
@@ -0,0 +1,36 @@
+/*
+ * /gsm/rf/afcdac and /gsm/rf/stdmap each store a single 16-bit value,
+ * and are not tables in the rftw/rftr sense, hence the code in rftablewr.c
+ * does not handle these two.  However, in fc-cal2text we would like to
+ * handle their conversion from binary to ASCII the same way as the bigger
+ * tables, hence the two functions in this module.
+ */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <endian.h>
+
+void
+write_afcdac_ascii(bin, outf)
+	uint16_t *bin;
+	FILE *outf;
+{
+	int i;
+
+	i = le16toh(*bin);
+	if (i >= 32768)
+		i -= 65536;
+	fprintf(outf, "%d\n", i);
+}
+
+void
+write_stdmap_ascii(bin, outf)
+	uint16_t *bin;
+	FILE *outf;
+{
+	int i;
+
+	i = le16toh(*bin);
+	fprintf(outf, "0x%04X\n", i);
+}