* #31630: added libgsm
diff --git a/jni/libgsm/tls/bitter.c b/jni/libgsm/tls/bitter.c
new file mode 100644
index 0000000..602d8d6
--- /dev/null
+++ b/jni/libgsm/tls/bitter.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+ * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+ * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+ */
+
+/*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/bitter.c,v 1.1 1992/10/28 00:28:39 jutta Exp $*/
+
+/* Generate code to pack a bit array from a name:#bits description */
+
+#include	<stdio.h>
+#include	"taste.h"
+#include	"proto.h"
+
+void write_code P2((s_spex, n_spex), struct spex * s_spex, int n_spex)
+{
+	struct spex	* sp = s_spex;
+	int		bits = 8;
+	int		vars;
+
+	if (!n_spex) return;
+
+	vars = sp->varsize;
+
+	while (n_spex) {
+
+		if (bits == 8) printf("\t*c++ =   ");
+		else printf("\t       | ");
+
+		if (vars == bits) {
+	
+			printf( (bits==8? "%s & 0x%lX;\n" : "(%s & 0x%lX);\n"),
+				sp->var, 
+				~(0xfffffffe << (bits - 1)));
+			if (!-- n_spex) break;
+			sp++;
+
+			vars = sp->varsize;
+			bits = 8;
+
+		} else if (vars < bits) {
+
+			printf( "((%s & 0x%lX) << %d)",
+				sp->var,
+				~(0xfffffffe << (vars - 1)),
+				bits - vars);
+			bits -= vars;
+			if (!--n_spex) {
+				puts(";");
+				break;
+			}
+			else putchar('\n');
+			sp++;
+			vars = sp->varsize;
+
+		} else {
+			printf("((%s >> %d) & 0x%X);\n",
+				sp->var, 
+				vars - bits,
+				~(0xfffffffe << (bits - 1)));
+			
+			vars -= bits;
+			bits = 8;
+		}
+	}
+}
diff --git a/jni/libgsm/tls/bitter.dta b/jni/libgsm/tls/bitter.dta
new file mode 100644
index 0000000..d1c42e4
--- /dev/null
+++ b/jni/libgsm/tls/bitter.dta
@@ -0,0 +1,90 @@
+;
+; Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+; Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+; details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+;
+;
+; Variable     Size
+
+GSM_MAGIC	4
+
+LARc[0]		6
+LARc[1]		6
+LARc[2]		5
+LARc[3]		5
+LARc[4]		4
+LARc[5]		4
+LARc[6]		3
+LARc[7]		3
+
+Nc[0]		7
+bc[0]		2
+Mc[0]		2
+xmaxc[0]	6
+xmc[0]		3
+xmc[1]		3
+xmc[2]		3
+xmc[3]		3
+xmc[4]		3
+xmc[5]		3
+xmc[6]		3
+xmc[7]		3
+xmc[8]		3
+xmc[9]		3
+xmc[10]		3
+xmc[11]		3
+xmc[12]		3
+
+Nc[1]		7
+bc[1]		2
+Mc[1]		2
+xmaxc[1]	6
+xmc[13]		3
+xmc[14]		3
+xmc[15]		3
+xmc[16]		3
+xmc[17]		3
+xmc[18]		3
+xmc[19]		3
+xmc[20]		3
+xmc[21]		3
+xmc[22]		3
+xmc[23]		3
+xmc[24]		3
+xmc[25]		3
+
+Nc[2]		7
+bc[2]		2
+Mc[2]		2
+xmaxc[2]	6
+xmc[26]		3
+xmc[27]		3
+xmc[28]		3
+xmc[29]		3
+xmc[30]		3
+xmc[31]		3
+xmc[32]		3
+xmc[33]		3
+xmc[34]		3
+xmc[35]		3
+xmc[36]		3
+xmc[37]		3
+xmc[38]		3
+
+Nc[3]		7
+bc[3]		2
+Mc[3]		2
+xmaxc[3]	6
+xmc[39]		3
+xmc[40]		3
+xmc[41]		3
+xmc[42]		3
+xmc[43]		3
+xmc[44]		3
+xmc[45]		3
+xmc[46]		3
+xmc[47]		3
+xmc[48]		3
+xmc[49]		3
+xmc[50]		3
+xmc[51]		3
diff --git a/jni/libgsm/tls/ginger.c b/jni/libgsm/tls/ginger.c
new file mode 100644
index 0000000..579e4cf
--- /dev/null
+++ b/jni/libgsm/tls/ginger.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright 1996 by Jutta Degener and Carsten Bormann, Technische
+ * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+ * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+ */
+
+/*$Header*/
+
+/* Generate code to pack a bit array from a name:#bits description */
+
+#include	<stdio.h>
+#include	"taste.h"
+#include	"proto.h"
+#include	<limits.h>
+
+/* This module is the opposite of sour.   Sweet was already taken,
+ * that's why it's called ginger.  (Add one point if that reminds
+ * you of Gary Larson.)
+ */
+
+#define WORD_BITS	16	/* sizeof(uword) * CHAR_BIT on the 
+				 * target architecture---if this isn't 16,
+				 * you're in trouble with this library anyway.
+				 */
+
+#define CHAR_BITS	 8	/* CHAR_BIT on the target architecture---
+				 * if this isn't 8, you're in *deep* trouble.
+				 */
+
+void write_code P2((s_spex, n_spex), struct spex * s_spex, int n_spex)
+{
+	struct spex	* sp = s_spex;
+	int		  n_in = 0;
+
+	printf("uword sr = 0;\n");
+
+	for (; n_spex > 0; n_spex--, sp++) {
+
+		while (n_in < sp->varsize) {
+			if (n_in) printf("sr |= (uword)*c++ << %d;\n", n_in);
+			else printf("sr = *c++;\n");
+			n_in += CHAR_BITS;
+		}
+
+		printf("%s = sr & %#x;  sr >>= %d;\n",
+			sp->var, ~(~0U << sp->varsize), sp->varsize);
+
+		n_in -= sp->varsize;
+	}
+
+	if (n_in > 0) {
+		fprintf(stderr, "%d bits left over\n", n_in);
+	}
+}
diff --git a/jni/libgsm/tls/sour.c b/jni/libgsm/tls/sour.c
new file mode 100644
index 0000000..1eae53e
--- /dev/null
+++ b/jni/libgsm/tls/sour.c
@@ -0,0 +1,89 @@
+/*
+ * Copyright 1996 by Jutta Degener and Carsten Bormann, Technische
+ * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+ * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+ */
+
+/*$Header*/
+
+/* Generate code to pack a bit array from a name:#bits description */
+
+#include	<stdio.h>
+#include	"taste.h"
+#include	"proto.h"
+#include	<limits.h>
+
+/* This module goes back to one Jeff Chilton used for his implementation
+ * of the #49 WAV GSM format.  (In his original patch 8, it replaced
+ * bitter.c.)
+ *
+ * In Microsoft's WAV #49 version of the GSM format, two 32 1/2
+ * byte GSM frames are packed together to make one WAV frame, and
+ * the GSM parameters are packed into bytes right-to-left rather
+ * than left-to-right.
+ *
+ * That is, where toast's GSM format writes
+ *
+ * 	aaaaaabb bbbbcccc cdddddee ...
+ *	___1____ ___2____ ___3____
+ *
+ *  for parameters a (6 bits), b (6 bits), c (5 bits), d (5 bits), e ..
+ *  the WAV format has
+ *
+ * 	bbaaaaaa ccccbbbb eedddddc ...
+ *	___1____ ___2____ ___3____
+ *
+ *  (This format looks a lot prettier if one pictures octets coming
+ *  in through a fifo queue from the left, rather than waiting in the
+ *  right-hand remainder of a C array.)
+ */
+
+#define WORD_BITS	16	/* sizeof(uword) * CHAR_BIT on the 
+				 * target architecture---if this isn't 16,
+				 * you're in trouble with this library anyway.
+				 */
+
+#define CHAR_BITS	 8	/* CHAR_BIT on the target architecture---
+				 * if this isn't 8, you're in *deep* trouble.
+				 */
+
+void write_code P2((s_spex, n_spex), struct spex * s_spex, int n_spex)
+{
+	struct spex	* sp = s_spex;
+	int		  n_in = 0;
+
+	printf("uword sr = 0;\n");
+
+	for (; n_spex > 0; n_spex--, sp++) {
+
+		/*	insert       old 
+		 *	new var	     value     unused
+		 *	here  
+		 *
+		 *	[____________xxxxxx**********]
+		 *
+		 *	<----- n_in ------>
+		 */
+		printf("sr = sr >> %d | %s << %d;\n",
+			sp->varsize,
+			sp->var, 
+			WORD_BITS - sp->varsize);
+
+		n_in += sp->varsize;
+
+		while (n_in >= CHAR_BIT) {
+			printf("*c++ = sr >> %d;\n",
+				WORD_BITS - n_in);
+			n_in -= CHAR_BIT;
+		}
+	}
+
+	while (n_in >= CHAR_BIT) {
+		printf("*c++ = sr >> %d;\n", WORD_BITS - n_in);
+		n_in -= CHAR_BIT;
+	}
+
+	if (n_in > 0) {
+		fprintf(stderr, "warning: %d bits left over\n", n_in);
+	}
+}
diff --git a/jni/libgsm/tls/sour1.dta b/jni/libgsm/tls/sour1.dta
new file mode 100644
index 0000000..770b24c
--- /dev/null
+++ b/jni/libgsm/tls/sour1.dta
@@ -0,0 +1,88 @@
+;
+; Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+; Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+; details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+;
+;
+; Variable     Size
+
+LARc[0]		6
+LARc[1]		6
+LARc[2]		5
+LARc[3]		5
+LARc[4]		4
+LARc[5]		4
+LARc[6]		3
+LARc[7]		3
+
+Nc[0]		7
+bc[0]		2
+Mc[0]		2
+xmaxc[0]	6
+xmc[0]		3
+xmc[1]		3
+xmc[2]		3
+xmc[3]		3
+xmc[4]		3
+xmc[5]		3
+xmc[6]		3
+xmc[7]		3
+xmc[8]		3
+xmc[9]		3
+xmc[10]		3
+xmc[11]		3
+xmc[12]		3
+
+Nc[1]		7
+bc[1]		2
+Mc[1]		2
+xmaxc[1]	6
+xmc[13]		3
+xmc[14]		3
+xmc[15]		3
+xmc[16]		3
+xmc[17]		3
+xmc[18]		3
+xmc[19]		3
+xmc[20]		3
+xmc[21]		3
+xmc[22]		3
+xmc[23]		3
+xmc[24]		3
+xmc[25]		3
+
+Nc[2]		7
+bc[2]		2
+Mc[2]		2
+xmaxc[2]	6
+xmc[26]		3
+xmc[27]		3
+xmc[28]		3
+xmc[29]		3
+xmc[30]		3
+xmc[31]		3
+xmc[32]		3
+xmc[33]		3
+xmc[34]		3
+xmc[35]		3
+xmc[36]		3
+xmc[37]		3
+xmc[38]		3
+
+Nc[3]		7
+bc[3]		2
+Mc[3]		2
+xmaxc[3]	6
+xmc[39]		3
+xmc[40]		3
+xmc[41]		3
+xmc[42]		3
+xmc[43]		3
+xmc[44]		3
+xmc[45]		3
+xmc[46]		3
+xmc[47]		3
+xmc[48]		3
+xmc[49]		3
+xmc[50]		3
+xmc[51]		3
diff --git a/jni/libgsm/tls/sour2.dta b/jni/libgsm/tls/sour2.dta
new file mode 100644
index 0000000..f56545c
--- /dev/null
+++ b/jni/libgsm/tls/sour2.dta
@@ -0,0 +1,90 @@
+;
+; Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+; Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+; details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+;
+;
+; Variable     Size
+
+g->chain	4
+
+LARc[0]		6
+LARc[1]		6
+LARc[2]		5
+LARc[3]		5
+LARc[4]		4
+LARc[5]		4
+LARc[6]		3
+LARc[7]		3
+
+Nc[0]		7
+bc[0]		2
+Mc[0]		2
+xmaxc[0]	6
+xmc[0]		3
+xmc[1]		3
+xmc[2]		3
+xmc[3]		3
+xmc[4]		3
+xmc[5]		3
+xmc[6]		3
+xmc[7]		3
+xmc[8]		3
+xmc[9]		3
+xmc[10]		3
+xmc[11]		3
+xmc[12]		3
+
+Nc[1]		7
+bc[1]		2
+Mc[1]		2
+xmaxc[1]	6
+xmc[13]		3
+xmc[14]		3
+xmc[15]		3
+xmc[16]		3
+xmc[17]		3
+xmc[18]		3
+xmc[19]		3
+xmc[20]		3
+xmc[21]		3
+xmc[22]		3
+xmc[23]		3
+xmc[24]		3
+xmc[25]		3
+
+Nc[2]		7
+bc[2]		2
+Mc[2]		2
+xmaxc[2]	6
+xmc[26]		3
+xmc[27]		3
+xmc[28]		3
+xmc[29]		3
+xmc[30]		3
+xmc[31]		3
+xmc[32]		3
+xmc[33]		3
+xmc[34]		3
+xmc[35]		3
+xmc[36]		3
+xmc[37]		3
+xmc[38]		3
+
+Nc[3]		7
+bc[3]		2
+Mc[3]		2
+xmaxc[3]	6
+xmc[39]		3
+xmc[40]		3
+xmc[41]		3
+xmc[42]		3
+xmc[43]		3
+xmc[44]		3
+xmc[45]		3
+xmc[46]		3
+xmc[47]		3
+xmc[48]		3
+xmc[49]		3
+xmc[50]		3
+xmc[51]		3
diff --git a/jni/libgsm/tls/sweet.c b/jni/libgsm/tls/sweet.c
new file mode 100644
index 0000000..6a6fb29
--- /dev/null
+++ b/jni/libgsm/tls/sweet.c
@@ -0,0 +1,66 @@
+ /*
+  * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+  * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+  * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+  */
+
+/*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/sweet.c,v 1.2 1996/07/02 10:15:53 jutta Exp $*/
+ 
+/* Generate code to unpack a bit array from name:#bits description */
+
+#include	<stdio.h>
+#include	"taste.h"
+#include	"proto.h"
+
+void write_code P2((s_spex, n_spex), struct spex * s_spex, int n_spex)
+{
+	struct spex	* sp = s_spex;
+	int		bits = 8;
+	int		vars;
+
+	if (!n_spex) return;
+
+	vars = sp->varsize;
+
+	while (n_spex) {
+
+		if (vars == sp->varsize) {
+			printf("\t%s  = ", sp->var);
+		} else printf("\t%s |= ", sp->var);
+
+		if (vars == bits) {
+	
+			if (bits == 8) printf( "*c++;\n" );
+			else printf( "*c++ & 0x%lX;\n",
+				~(0xfffffffe << (bits - 1)) );
+
+			if (!-- n_spex) break;
+			sp++;
+			vars = sp->varsize;
+			bits = 8;
+
+		} else if (vars < bits) {
+
+			printf( "(*c >> %d) & 0x%lX;\n", 
+				bits - vars,
+				~(0xfffffffe << (vars - 1)));
+
+			bits -= vars;
+			if (!--n_spex) break;
+			sp++;
+			vars = sp->varsize;
+
+		} else {
+			/*   vars > bits.  We're eating lower-all of c,
+			 *   but we must shift it.
+			 */
+			printf(	"(*c++ & 0x%X) << %d;\n",
+				~(0xfffffffe << (bits - 1)),
+				vars - bits );
+
+			vars -= bits;
+			bits = 8;
+		}
+	}
+}
+
diff --git a/jni/libgsm/tls/taste.c b/jni/libgsm/tls/taste.c
new file mode 100644
index 0000000..640ff16
--- /dev/null
+++ b/jni/libgsm/tls/taste.c
@@ -0,0 +1,134 @@
+/*
+ * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+ * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+ * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+ */
+
+/*$Header: /tmp_amd/presto/export/kbs/jutta/src/gsm/RCS/taste.c,v 1.1 1992/10/28 00:28:39 jutta Exp $*/
+
+#include	<stdio.h>
+#include	<string.h>
+#include	<memory.h>
+
+#include	"config.h"
+
+#ifdef	HAS_STDLIB_H
+#	include	<stdlib.h>
+#else
+#include "proto.h"
+#	ifdef	HAS_MALLOC_H
+#	include <malloc.h>
+#	else
+		extern char	* malloc P((char *)), * realloc P((char *,int));
+#	endif
+	extern int exit P((int));
+#endif
+
+#include "proto.h"
+
+/*
+ * common code to sweet.c and bitter.c: read the name:#bits description.
+ */
+
+#include	"taste.h"
+
+static struct spex  * s_spex;
+static int n_spex, m_spex;
+
+extern void	write_code P((struct spex *, int));
+
+char * strsave P1((str), char * str)		/* strdup() + errors */
+{
+	int    n = strlen(str) + 1;
+	char * s = malloc(n);
+	if (!s) {
+		fprintf(stderr, "Failed to malloc %d bytes, abort\n",
+			strlen(str) + 1);
+		exit(1);
+	}
+	return memcpy(s, str, n);
+}
+
+struct spex * new_spex P0()
+{
+	if (n_spex >= m_spex) {
+		m_spex += 500;
+		if (!(s_spex = (struct spex *)(n_spex
+			? realloc((char *)s_spex, m_spex * sizeof(*s_spex))
+			: malloc( m_spex * sizeof(*s_spex))))) {
+			fprintf(stderr, "Failed to malloc %d bytes, abort\n",
+				m_spex * sizeof(*s_spex));
+			exit(1);
+		}
+	}
+	return s_spex + n_spex;
+}
+
+char * strtek P2((str, sep), char * str, char * sep) {
+
+	static char     * S = (char *)0;
+	char		* c, * base;
+
+	if (str) S = str;
+
+	if (!S || !*S) return (char *)0;
+
+	/*  Skip delimiters.
+	 */
+	while (*S) {
+		for (c = sep; *c && *c != *S; c++) ;
+		if (*c) *S++ = 0;
+		else break;
+	}
+
+	base = S;
+
+	/*   Skip non-delimiters.
+	 */
+	for (base = S; *S; S++) {
+
+		for (c = sep; *c; c++)
+			if (*c == *S) {
+				*S++ = 0;
+				return base;
+			}
+	}
+
+	return base == S ? (char *)0 : base;
+}
+
+int read_spex P0()
+{
+	char buf[200];
+	char * s, *t;
+	struct spex	* sp = s_spex;	
+
+	while (gets(buf)) {
+
+		if (!*buf || *buf == ';') continue;
+		s = strtek(buf, " \t");
+		if (!s) {
+			fprintf(stderr, "? %s\n", buf);
+			continue;
+		}
+		sp = new_spex();
+		sp->var = strsave(s);
+		s = strtek((char*)0, " \t");
+		if (!s) {
+			fprintf(stderr, "varsize?\n");
+			continue;
+		}
+		sp->varsize = strtol(s, (char *)0, 0);
+		n_spex++;
+	}
+
+	return sp - s_spex;
+}
+
+int main P0()
+{
+	read_spex();
+	write_code(s_spex, n_spex);
+
+	exit(0);
+}
diff --git a/jni/libgsm/tls/taste.h b/jni/libgsm/tls/taste.h
new file mode 100644
index 0000000..2fc85ef
--- /dev/null
+++ b/jni/libgsm/tls/taste.h
@@ -0,0 +1,20 @@
+/*
+ * Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
+ * Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
+ * details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
+ */
+ 
+/*
+ * common code to sweet.c and bitter.c
+ */
+
+#ifndef	TASTE_H
+#define	TASTE_H
+
+struct spex {
+
+	char	* var;
+	int	varsize;
+} ;
+
+#endif	/* TASTE_H */