summaryrefslogtreecommitdiff
path: root/third_party/gsm/tls/ginger.c
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/ginger.c
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/ginger.c')
-rw-r--r--third_party/gsm/tls/ginger.c54
1 files changed, 54 insertions, 0 deletions
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);
+ }
+}