summaryrefslogtreecommitdiffstats
path: root/gnu/usr.sbin/isdn/ulaw2alaw
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1995-02-15 00:46:26 +0000
committerjkh <jkh@FreeBSD.org>1995-02-15 00:46:26 +0000
commit0cb129cc755064f31fb42abf2c721a8605381511 (patch)
tree87521af8f33d69817699aec072374bf2d3734e3e /gnu/usr.sbin/isdn/ulaw2alaw
downloadFreeBSD-src-0cb129cc755064f31fb42abf2c721a8605381511.zip
FreeBSD-src-0cb129cc755064f31fb42abf2c721a8605381511.tar.gz
Import the ISDN userland utilities. Just about ready to start shaking
this baby out in earnest..
Diffstat (limited to 'gnu/usr.sbin/isdn/ulaw2alaw')
-rw-r--r--gnu/usr.sbin/isdn/ulaw2alaw/Makefile5
-rw-r--r--gnu/usr.sbin/isdn/ulaw2alaw/README1
-rw-r--r--gnu/usr.sbin/isdn/ulaw2alaw/con.h162
-rw-r--r--gnu/usr.sbin/isdn/ulaw2alaw/ulaw2alaw.c15
4 files changed, 183 insertions, 0 deletions
diff --git a/gnu/usr.sbin/isdn/ulaw2alaw/Makefile b/gnu/usr.sbin/isdn/ulaw2alaw/Makefile
new file mode 100644
index 0000000..494c541
--- /dev/null
+++ b/gnu/usr.sbin/isdn/ulaw2alaw/Makefile
@@ -0,0 +1,5 @@
+PROG= ulaw2alaw
+CFLAGS+= -DBSD -O
+NOMAN= yes
+
+.include <bsd.prog.mk>
diff --git a/gnu/usr.sbin/isdn/ulaw2alaw/README b/gnu/usr.sbin/isdn/ulaw2alaw/README
new file mode 100644
index 0000000..771e87f
--- /dev/null
+++ b/gnu/usr.sbin/isdn/ulaw2alaw/README
@@ -0,0 +1 @@
+stolen from isdndrv-0.1.1
diff --git a/gnu/usr.sbin/isdn/ulaw2alaw/con.h b/gnu/usr.sbin/isdn/ulaw2alaw/con.h
new file mode 100644
index 0000000..def02c5
--- /dev/null
+++ b/gnu/usr.sbin/isdn/ulaw2alaw/con.h
@@ -0,0 +1,162 @@
+
+static unsigned char ulaw_linear[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 2,
+ 5, 9, 13, 17, 21, 25, 29, 33,
+ 37, 41, 45, 49, 53, 57, 61, 65,
+ 68, 70, 72, 74, 76, 78, 80, 82,
+ 84, 86, 88, 90, 92, 94, 96, 98,
+ 100, 101, 102, 103, 104, 105, 106, 107,
+ 108, 109, 110, 111, 112, 113, 114, 115,
+ 115, 116, 116, 117, 117, 118, 118, 119,
+ 119, 120, 120, 121, 121, 122, 122, 123,
+ 123, 123, 124, 124, 124, 124, 125, 125,
+ 125, 125, 126, 126, 126, 126, 127, 127,
+ 127, 127, 127, 127, 128, 128, 128, 128,
+ 128, 128, 128, 128, 128, 128, 128, 128,
+ 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255,
+ 252, 248, 244, 240, 236, 232, 228, 224,
+ 220, 216, 212, 208, 204, 200, 196, 192,
+ 189, 187, 185, 183, 181, 179, 177, 175,
+ 173, 171, 169, 167, 165, 163, 161, 159,
+ 157, 156, 155, 154, 153, 152, 151, 150,
+ 149, 148, 147, 146, 145, 144, 143, 142,
+ 142, 141, 141, 140, 140, 139, 139, 138,
+ 138, 137, 137, 136, 136, 135, 135, 134,
+ 134, 134, 133, 133, 133, 133, 132, 132,
+ 132, 132, 131, 131, 131, 131, 130, 130,
+ 130, 130, 130, 130, 129, 129, 129, 129,
+ 129, 129, 129, 129, 128, 128, 128, 128,
+};
+
+static unsigned char linear_ulaw[] = {
+ 31, 31, 31, 32, 32, 32, 32, 33,
+ 33, 33, 33, 34, 34, 34, 34, 35,
+ 35, 35, 35, 36, 36, 36, 36, 37,
+ 37, 37, 37, 38, 38, 38, 38, 39,
+ 39, 39, 39, 40, 40, 40, 40, 41,
+ 41, 41, 41, 42, 42, 42, 42, 43,
+ 43, 43, 43, 44, 44, 44, 44, 45,
+ 45, 45, 45, 46, 46, 46, 46, 47,
+ 47, 47, 47, 48, 48, 49, 49, 50,
+ 50, 51, 51, 52, 52, 53, 53, 54,
+ 54, 55, 55, 56, 56, 57, 57, 58,
+ 58, 59, 59, 60, 60, 61, 61, 62,
+ 62, 63, 63, 64, 65, 66, 67, 68,
+ 69, 70, 71, 72, 73, 74, 75, 76,
+ 77, 78, 79, 81, 83, 85, 87, 89,
+ 91, 93, 95, 99, 103, 107, 111, 119,
+ 255, 247, 239, 235, 231, 227, 223, 221,
+ 219, 217, 215, 213, 211, 209, 207, 206,
+ 205, 204, 203, 202, 201, 200, 199, 198,
+ 197, 196, 195, 194, 193, 192, 191, 191,
+ 190, 190, 189, 189, 188, 188, 187, 187,
+ 186, 186, 185, 185, 184, 184, 183, 183,
+ 182, 182, 181, 181, 180, 180, 179, 179,
+ 178, 178, 177, 177, 176, 176, 175, 175,
+ 175, 175, 174, 174, 174, 174, 173, 173,
+ 173, 173, 172, 172, 172, 172, 171, 171,
+ 171, 171, 170, 170, 170, 170, 169, 169,
+ 169, 169, 168, 168, 168, 168, 167, 167,
+ 167, 167, 166, 166, 166, 166, 165, 165,
+ 165, 165, 164, 164, 164, 164, 163, 163,
+ 163, 163, 162, 162, 162, 162, 161, 161,
+ 161, 161, 160, 160, 160, 160, 159, 159,
+};
+
+static unsigned char alaw_linear[] = {
+ 45, 214, 122, 133, 0, 255, 107, 149,
+ 86, 171, 126, 129, 0, 255, 117, 138,
+ 13, 246, 120, 135, 0, 255, 99, 157,
+ 70, 187, 124, 131, 0, 255, 113, 142,
+ 61, 198, 123, 132, 0, 255, 111, 145,
+ 94, 163, 127, 128, 0, 255, 119, 136,
+ 29, 230, 121, 134, 0, 255, 103, 153,
+ 78, 179, 125, 130, 0, 255, 115, 140,
+ 37, 222, 122, 133, 0, 255, 105, 151,
+ 82, 175, 126, 129, 0, 255, 116, 139,
+ 5, 254, 120, 135, 0, 255, 97, 159,
+ 66, 191, 124, 131, 0, 255, 112, 143,
+ 53, 206, 123, 132, 0, 255, 109, 147,
+ 90, 167, 127, 128, 0, 255, 118, 137,
+ 21, 238, 121, 134, 0, 255, 101, 155,
+ 74, 183, 125, 130, 0, 255, 114, 141,
+ 49, 210, 123, 133, 0, 255, 108, 148,
+ 88, 169, 127, 129, 0, 255, 118, 138,
+ 17, 242, 121, 135, 0, 255, 100, 156,
+ 72, 185, 125, 131, 0, 255, 114, 142,
+ 64, 194, 124, 132, 0, 255, 112, 144,
+ 96, 161, 128, 128, 1, 255, 120, 136,
+ 33, 226, 122, 134, 0, 255, 104, 152,
+ 80, 177, 126, 130, 0, 255, 116, 140,
+ 41, 218, 122, 133, 0, 255, 106, 150,
+ 84, 173, 126, 129, 0, 255, 117, 139,
+ 9, 250, 120, 135, 0, 255, 98, 158,
+ 68, 189, 124, 131, 0, 255, 113, 143,
+ 57, 202, 123, 132, 0, 255, 110, 146,
+ 92, 165, 127, 128, 0, 255, 119, 137,
+ 25, 234, 121, 134, 0, 255, 102, 154,
+ 76, 181, 125, 130, 0, 255, 115, 141,
+
+};
+
+
+static unsigned char linear_alaw[] = {
+
+ 252, 172, 172, 172, 172, 80, 80, 80,
+ 80, 208, 208, 208, 208, 16, 16, 16,
+ 16, 144, 144, 144, 144, 112, 112, 112,
+ 112, 240, 240, 240, 240, 48, 48, 48,
+ 48, 176, 176, 176, 176, 64, 64, 64,
+ 64, 192, 192, 192, 192, 0, 0, 0,
+ 0, 128, 128, 128, 128, 96, 96, 96,
+ 96, 224, 224, 224, 224, 32, 32, 32,
+ 160, 160, 88, 88, 216, 216, 24, 24,
+ 152, 152, 120, 120, 248, 248, 56, 56,
+ 184, 184, 72, 72, 200, 200, 8, 8,
+ 136, 136, 104, 104, 232, 232, 40, 40,
+ 168, 86, 214, 22, 150, 118, 246, 54,
+ 182, 70, 198, 6, 134, 102, 230, 38,
+ 166, 222, 158, 254, 190, 206, 142, 238,
+ 210, 242, 194, 226, 218, 250, 202, 234,
+ 235, 203, 251, 219, 227, 195, 243, 211,
+ 175, 239, 143, 207, 191, 255, 159, 223,
+ 167, 39, 231, 103, 135, 7, 199, 71,
+ 183, 55, 247, 119, 151, 23, 215, 87,
+ 87, 169, 169, 41, 41, 233, 233, 105,
+ 105, 137, 137, 9, 9, 201, 201, 73,
+ 73, 185, 185, 57, 57, 249, 249, 121,
+ 121, 153, 153, 25, 25, 217, 217, 89,
+ 89, 89, 161, 161, 161, 161, 33, 33,
+ 33, 33, 225, 225, 225, 225, 97, 97,
+ 97, 97, 129, 129, 129, 129, 1, 1,
+ 1, 1, 193, 193, 193, 193, 65, 65,
+ 65, 65, 177, 177, 177, 177, 49, 49,
+ 49, 49, 241, 241, 241, 241, 113, 113,
+ 113, 113, 145, 145, 145, 145, 17, 17,
+ 17, 17, 209, 209, 209, 209, 81, 253,
+};
+
+inline void translate_bytes(const void *table, void *buff, unsigned long n)
+{
+ __asm__("cld\n"
+ "1:\tlodsb\n\t"
+ "xlatb\n\t"
+ "stosb\n\t"
+ "loop 1b\n\t"
+ ::"b" ((long)table), "c" (n), "D" ((long)buff), "S" ((long)buff)
+ :"bx","cx","di","si","ax");
+}
+
+void translate_ansi(unsigned char table[], unsigned char buff[], unsigned long n)
+{
+register counter;
+
+for(counter=0; counter< n; counter++)
+ buff[counter] = table[buff[counter]];
+}
diff --git a/gnu/usr.sbin/isdn/ulaw2alaw/ulaw2alaw.c b/gnu/usr.sbin/isdn/ulaw2alaw/ulaw2alaw.c
new file mode 100644
index 0000000..afa0f11
--- /dev/null
+++ b/gnu/usr.sbin/isdn/ulaw2alaw/ulaw2alaw.c
@@ -0,0 +1,15 @@
+#include <fcntl.h>
+#include "con.h"
+
+main(int argc, char *argv[])
+{
+ int counter;
+ unsigned char buffer[1024];
+
+
+ while ((counter = read(0, buffer, sizeof(buffer))) > 0) {
+ translate_bytes(ulaw_linear, buffer, counter); /* now linear */
+ translate_bytes(linear_alaw, buffer, counter); /* now alaw */
+ counter != write(1, buffer, counter);
+ }
+}
OpenPOWER on IntegriCloud