summaryrefslogtreecommitdiff
path: root/third_party/gsm/tls
diff options
context:
space:
mode:
authorBenny Prijono <bennylp@teluu.com>2007-04-07 12:29:46 +0000
committerBenny Prijono <bennylp@teluu.com>2007-04-07 12:29:46 +0000
commit3ade1510e72926d02d7c7d4416257449bc0cd3f3 (patch)
treec51d4960cac0fcd8bf3483a8e77444ac5f9a3177 /third_party/gsm/tls
parentbfd3f58f5b715238fe618d053ddf908a34f1e56c (diff)
Split speex, portaudio, and gsm into third_party directory
git-svn-id: http://svn.pjsip.org/repos/pjproject/branches/split-3rd-party@1168 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'third_party/gsm/tls')
-rw-r--r--third_party/gsm/tls/bitter.c66
-rw-r--r--third_party/gsm/tls/bitter.dta90
-rw-r--r--third_party/gsm/tls/ginger.c54
-rw-r--r--third_party/gsm/tls/sour.c91
-rw-r--r--third_party/gsm/tls/sour1.dta88
-rw-r--r--third_party/gsm/tls/sour2.dta90
-rw-r--r--third_party/gsm/tls/sweet.c66
-rw-r--r--third_party/gsm/tls/taste.c139
-rw-r--r--third_party/gsm/tls/taste.h20
9 files changed, 704 insertions, 0 deletions
diff --git a/third_party/gsm/tls/bitter.c b/third_party/gsm/tls/bitter.c
new file mode 100644
index 00000000..602d8d67
--- /dev/null
+++ b/third_party/gsm/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/third_party/gsm/tls/bitter.dta b/third_party/gsm/tls/bitter.dta
new file mode 100644
index 00000000..d1c42e4d
--- /dev/null
+++ b/third_party/gsm/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/third_party/gsm/tls/ginger.c b/third_party/gsm/tls/ginger.c
new file mode 100644
index 00000000..d830e20f
--- /dev/null
+++ b/third_party/gsm/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 BYTE_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 += BYTE_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/third_party/gsm/tls/sour.c b/third_party/gsm/tls/sour.c
new file mode 100644
index 00000000..b6932e67
--- /dev/null
+++ b/third_party/gsm/tls/sour.c
@@ -0,0 +1,91 @@
+/*
+ * 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,
+ * WAV #49 style.
+ */
+
+#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 BYTE_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 >= BYTE_BITS) {
+ printf("*c++ = sr >> %d;\n",
+ WORD_BITS - n_in);
+ n_in -= BYTE_BITS;
+ }
+ }
+
+ while (n_in >= BYTE_BITS) {
+ printf("*c++ = sr >> %d;\n", WORD_BITS - n_in);
+ n_in -= BYTE_BITS;
+ }
+
+ if (n_in > 0) {
+ fprintf(stderr, "warning: %d bits left over\n", n_in);
+ }
+}
diff --git a/third_party/gsm/tls/sour1.dta b/third_party/gsm/tls/sour1.dta
new file mode 100644
index 00000000..770b24c0
--- /dev/null
+++ b/third_party/gsm/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/third_party/gsm/tls/sour2.dta b/third_party/gsm/tls/sour2.dta
new file mode 100644
index 00000000..f56545c9
--- /dev/null
+++ b/third_party/gsm/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/third_party/gsm/tls/sweet.c b/third_party/gsm/tls/sweet.c
new file mode 100644
index 00000000..6a6fb297
--- /dev/null
+++ b/third_party/gsm/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/third_party/gsm/tls/taste.c b/third_party/gsm/tls/taste.c
new file mode 100644
index 00000000..4bc84adc
--- /dev/null
+++ b/third_party/gsm/tls/taste.c
@@ -0,0 +1,139 @@
+/*
+ * 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 (fgets(buf, sizeof buf, stdin)) {
+
+ char * nl;
+
+ if (nl = strchr(buf, '\n'))
+ *nl = '\0';
+
+ 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/third_party/gsm/tls/taste.h b/third_party/gsm/tls/taste.h
new file mode 100644
index 00000000..2fc85efd
--- /dev/null
+++ b/third_party/gsm/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 */