]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
indent
authorAnthony Minessale <anthony.minessale@gmail.com>
Mon, 4 Jun 2007 14:53:12 +0000 (14:53 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Mon, 4 Jun 2007 14:53:12 +0000 (14:53 +0000)
git-svn-id: http://svn.openzap.org/svn/openzap/trunk@205 a93c3328-9c30-0410-af19-c9cd2b2d52af

33 files changed:
libs/freetdm/src/g711.c
libs/freetdm/src/hashtable.c
libs/freetdm/src/hashtable_itr.c
libs/freetdm/src/include/g711.h
libs/freetdm/src/include/hashtable.h
libs/freetdm/src/include/hashtable_itr.h
libs/freetdm/src/include/hashtable_private.h
libs/freetdm/src/include/libteletone.h
libs/freetdm/src/include/libteletone_detect.h
libs/freetdm/src/include/libteletone_generate.h
libs/freetdm/src/include/openzap.h
libs/freetdm/src/include/sangoma_tdm_api.h
libs/freetdm/src/include/zap_analog.h
libs/freetdm/src/include/zap_isdn.h
libs/freetdm/src/include/zap_skel.h
libs/freetdm/src/include/zap_threadmutex.h
libs/freetdm/src/include/zap_types.h
libs/freetdm/src/include/zap_wanpipe.h
libs/freetdm/src/include/zap_zt.h
libs/freetdm/src/libteletone_detect.c
libs/freetdm/src/priserver.c
libs/freetdm/src/sangoma_pri.c
libs/freetdm/src/testanalog.c
libs/freetdm/src/testapp.c
libs/freetdm/src/testisdn.c
libs/freetdm/src/zap_analog.c
libs/freetdm/src/zap_buffer.c
libs/freetdm/src/zap_io.c
libs/freetdm/src/zap_isdn.c
libs/freetdm/src/zap_skel.c
libs/freetdm/src/zap_threadmutex.c
libs/freetdm/src/zap_wanpipe.c
libs/freetdm/src/zap_zt.c

index 8a5c58b835b6a06c38ce4b13e1cab5ea48e03876..97772c25f5d6b5275bac4261b000b4d3c7f9474e 100644 (file)
 
 /* Copied from the CCITT G.711 specification */
 static const uint8_t ulaw_to_alaw_table[256] =
-{
-     42,  43,  40,  41,  46,  47,  44,  45,  34,  35,  32,  33,  38,  39,  36,  37,
-     58,  59,  56,  57,  62,  63,  60,  61,  50,  51,  48,  49,  54,  55,  52,  53,
-     10,  11,   8,   9,  14,  15,  12,  13,   2,   3,   0,   1,   6,   7,   4,  26,
-     27,  24,  25,  30,  31,  28,  29,  18,  19,  16,  17,  22,  23,  20,  21, 106,
-    104, 105, 110, 111, 108, 109,  98,  99,  96,  97, 102, 103, 100, 101, 122, 120,
-    126, 127, 124, 125, 114, 115, 112, 113, 118, 119, 116, 117,  75,  73,  79,  77,
-     66,  67,  64,  65,  70,  71,  68,  69,  90,  91,  88,  89,  94,  95,  92,  93,
-     82,  82,  83,  83,  80,  80,  81,  81,  86,  86,  87,  87,  84,  84,  85,  85,
-    170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165,
-    186, 187, 184, 185, 190, 191, 188, 189, 178, 179, 176, 177, 182, 183, 180, 181,
-    138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 154,
-    155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149, 234,
-    232, 233, 238, 239, 236, 237, 226, 227, 224, 225, 230, 231, 228, 229, 250, 248,
-    254, 255, 252, 253, 242, 243, 240, 241, 246, 247, 244, 245, 203, 201, 207, 205,
-    194, 195, 192, 193, 198, 199, 196, 197, 218, 219, 216, 217, 222, 223, 220, 221,
-    210, 210, 211, 211, 208, 208, 209, 209, 214, 214, 215, 215, 212, 212, 213, 213
-};
+       {
+               42,  43,  40,  41,  46,  47,  44,  45,  34,  35,  32,  33,  38,  39,  36,  37,
+               58,  59,  56,  57,  62,  63,  60,  61,  50,  51,  48,  49,  54,  55,  52,  53,
+               10,  11,   8,   9,  14,  15,  12,  13,   2,   3,   0,   1,   6,   7,   4,  26,
+               27,  24,  25,  30,  31,  28,  29,  18,  19,  16,  17,  22,  23,  20,  21, 106,
+               104, 105, 110, 111, 108, 109,  98,  99,  96,  97, 102, 103, 100, 101, 122, 120,
+               126, 127, 124, 125, 114, 115, 112, 113, 118, 119, 116, 117,  75,  73,  79,  77,
+               66,  67,  64,  65,  70,  71,  68,  69,  90,  91,  88,  89,  94,  95,  92,  93,
+               82,  82,  83,  83,  80,  80,  81,  81,  86,  86,  87,  87,  84,  84,  85,  85,
+               170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165,
+               186, 187, 184, 185, 190, 191, 188, 189, 178, 179, 176, 177, 182, 183, 180, 181,
+               138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 154,
+               155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149, 234,
+               232, 233, 238, 239, 236, 237, 226, 227, 224, 225, 230, 231, 228, 229, 250, 248,
+               254, 255, 252, 253, 242, 243, 240, 241, 246, 247, 244, 245, 203, 201, 207, 205,
+               194, 195, 192, 193, 198, 199, 196, 197, 218, 219, 216, 217, 222, 223, 220, 221,
+               210, 210, 211, 211, 208, 208, 209, 209, 214, 214, 215, 215, 212, 212, 213, 213
+       };
 
 /* These transcoding tables are copied from the CCITT G.711 specification. To achieve
    optimal results, do not change them. */
 
 static const uint8_t alaw_to_ulaw_table[256] =
-{
-     42,  43,  40,  41,  46,  47,  44,  45,  34,  35,  32,  33,  38,  39,  36,  37,
-     57,  58,  55,  56,  61,  62,  59,  60,  49,  50,  47,  48,  53,  54,  51,  52,
-     10,  11,   8,   9,  14,  15,  12,  13,   2,   3,   0,   1,   6,   7,   4,   5,
-     26,  27,  24,  25,  30,  31,  28,  29,  18,  19,  16,  17,  22,  23,  20,  21,
-     98,  99,  96,  97, 102, 103, 100, 101,  93,  93,  92,  92,  95,  95,  94,  94,
-    116, 118, 112, 114, 124, 126, 120, 122, 106, 107, 104, 105, 110, 111, 108, 109,
-     72,  73,  70,  71,  76,  77,  74,  75,  64,  65,  63,  63,  68,  69,  66,  67,
-     86,  87,  84,  85,  90,  91,  88,  89,  79,  79,  78,  78,  82,  83,  80,  81,
-    170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165,
-    185, 186, 183, 184, 189, 190, 187, 188, 177, 178, 175, 176, 181, 182, 179, 180,
-    138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 133,
-    154, 155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149,
-    226, 227, 224, 225, 230, 231, 228, 229, 221, 221, 220, 220, 223, 223, 222, 222,
-    244, 246, 240, 242, 252, 254, 248, 250, 234, 235, 232, 233, 238, 239, 236, 237,
-    200, 201, 198, 199, 204, 205, 202, 203, 192, 193, 191, 191, 196, 197, 194, 195,
-    214, 215, 212, 213, 218, 219, 216, 217, 207, 207, 206, 206, 210, 211, 208, 209
-};
+       {
+               42,  43,  40,  41,  46,  47,  44,  45,  34,  35,  32,  33,  38,  39,  36,  37,
+               57,  58,  55,  56,  61,  62,  59,  60,  49,  50,  47,  48,  53,  54,  51,  52,
+               10,  11,   8,   9,  14,  15,  12,  13,   2,   3,   0,   1,   6,   7,   4,   5,
+               26,  27,  24,  25,  30,  31,  28,  29,  18,  19,  16,  17,  22,  23,  20,  21,
+               98,  99,  96,  97, 102, 103, 100, 101,  93,  93,  92,  92,  95,  95,  94,  94,
+               116, 118, 112, 114, 124, 126, 120, 122, 106, 107, 104, 105, 110, 111, 108, 109,
+               72,  73,  70,  71,  76,  77,  74,  75,  64,  65,  63,  63,  68,  69,  66,  67,
+               86,  87,  84,  85,  90,  91,  88,  89,  79,  79,  78,  78,  82,  83,  80,  81,
+               170, 171, 168, 169, 174, 175, 172, 173, 162, 163, 160, 161, 166, 167, 164, 165,
+               185, 186, 183, 184, 189, 190, 187, 188, 177, 178, 175, 176, 181, 182, 179, 180,
+               138, 139, 136, 137, 142, 143, 140, 141, 130, 131, 128, 129, 134, 135, 132, 133,
+               154, 155, 152, 153, 158, 159, 156, 157, 146, 147, 144, 145, 150, 151, 148, 149,
+               226, 227, 224, 225, 230, 231, 228, 229, 221, 221, 220, 220, 223, 223, 222, 222,
+               244, 246, 240, 242, 252, 254, 248, 250, 234, 235, 232, 233, 238, 239, 236, 237,
+               200, 201, 198, 199, 204, 205, 202, 203, 192, 193, 191, 191, 196, 197, 194, 195,
+               214, 215, 212, 213, 218, 219, 216, 217, 207, 207, 206, 206, 210, 211, 208, 209
+       };
 
 uint8_t alaw_to_ulaw(uint8_t alaw)
 {
@@ -90,3 +90,15 @@ uint8_t ulaw_to_alaw(uint8_t ulaw)
 }
 /*- End of function --------------------------------------------------------*/
 /*- End of file ------------------------------------------------------------*/
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index fff5e99347a18fcd75f2254baa66b1c877902278..5cc2bb0c40e1d5eacf82b1d0c7da1a5208293f00 100644 (file)
@@ -8,18 +8,18 @@
 #include <math.h>
 
 /*
-Credit for primes table: Aaron Krowne
- http://br.endernet.org/~akrowne/
- http://planetmath.org/encyclopedia/GoodHashTablePrimes.html
+  Credit for primes table: Aaron Krowne
 http://br.endernet.org/~akrowne/
 http://planetmath.org/encyclopedia/GoodHashTablePrimes.html
 */
 static const unsigned int primes[] = {
-53, 97, 193, 389,
-769, 1543, 3079, 6151,
-12289, 24593, 49157, 98317,
-196613, 393241, 786433, 1572869,
-3145739, 6291469, 12582917, 25165843,
-50331653, 100663319, 201326611, 402653189,
-805306457, 1610612741
+       53, 97, 193, 389,
+       769, 1543, 3079, 6151,
+       12289, 24593, 49157, 98317,
+       196613, 393241, 786433, 1572869,
+       3145739, 6291469, 12582917, 25165843,
+       50331653, 100663319, 201326611, 402653189,
+       805306457, 1610612741
 };
 const unsigned int prime_table_length = sizeof(primes)/sizeof(primes[0]);
 const float max_load_factor = 0.65f;
@@ -81,45 +81,45 @@ hashtable_expand(struct hashtable *h)
 
     newtable = (struct entry **)malloc(sizeof(struct entry*) * newsize);
     if (NULL != newtable)
-    {
-        memset(newtable, 0, newsize * sizeof(struct entry *));
-        /* This algorithm is not 'stable'. ie. it reverses the list
-         * when it transfers entries between the tables */
-        for (i = 0; i < h->tablelength; i++) {
-            while (NULL != (e = h->table[i])) {
-                h->table[i] = e->next;
-                index = indexFor(newsize,e->h);
-                e->next = newtable[index];
-                newtable[index] = e;
-            }
-        }
-        free(h->table);
-        h->table = newtable;
-    }
+               {
+                       memset(newtable, 0, newsize * sizeof(struct entry *));
+                       /* This algorithm is not 'stable'. ie. it reverses the list
+                        * when it transfers entries between the tables */
+                       for (i = 0; i < h->tablelength; i++) {
+                               while (NULL != (e = h->table[i])) {
+                                       h->table[i] = e->next;
+                                       index = indexFor(newsize,e->h);
+                                       e->next = newtable[index];
+                                       newtable[index] = e;
+                               }
+                       }
+                       free(h->table);
+                       h->table = newtable;
+               }
     /* Plan B: realloc instead */
     else 
-    {
-        newtable = (struct entry **)
-                   realloc(h->table, newsize * sizeof(struct entry *));
-        if (NULL == newtable) { (h->primeindex)--; return 0; }
-        h->table = newtable;
-        memset(newtable[h->tablelength], 0, newsize - h->tablelength);
-        for (i = 0; i < h->tablelength; i++) {
-            for (pE = &(newtable[i]), e = *pE; e != NULL; e = *pE) {
-                index = indexFor(newsize,e->h);
-                if (index == i)
-                {
-                    pE = &(e->next);
-                }
-                else
-                {
-                    *pE = e->next;
-                    e->next = newtable[index];
-                    newtable[index] = e;
-                }
-            }
-        }
-    }
+               {
+                       newtable = (struct entry **)
+                               realloc(h->table, newsize * sizeof(struct entry *));
+                       if (NULL == newtable) { (h->primeindex)--; return 0; }
+                       h->table = newtable;
+                       memset(newtable[h->tablelength], 0, newsize - h->tablelength);
+                       for (i = 0; i < h->tablelength; i++) {
+                               for (pE = &(newtable[i]), e = *pE; e != NULL; e = *pE) {
+                                       index = indexFor(newsize,e->h);
+                                       if (index == i)
+                                               {
+                                                       pE = &(e->next);
+                                               }
+                                       else
+                                               {
+                                                       *pE = e->next;
+                                                       e->next = newtable[index];
+                                                       newtable[index] = e;
+                                               }
+                               }
+                       }
+               }
     h->tablelength = newsize;
     h->loadlimit   = (unsigned int) ceil(newsize * max_load_factor);
     return -1;
@@ -140,13 +140,13 @@ hashtable_insert(struct hashtable *h, void *k, void *v)
     unsigned int index;
     struct entry *e;
     if (++(h->entrycount) > h->loadlimit)
-    {
-        /* Ignore the return value. If expand fails, we should
-         * still try cramming just this value into the existing table
-         * -- we may not have memory for a larger table, but one more
-         * element may be ok. Next time we insert, we'll try expanding again.*/
-        hashtable_expand(h);
-    }
+               {
+                       /* Ignore the return value. If expand fails, we should
+                        * still try cramming just this value into the existing table
+                        * -- we may not have memory for a larger table, but one more
+                        * element may be ok. Next time we insert, we'll try expanding again.*/
+                       hashtable_expand(h);
+               }
     e = (struct entry *)malloc(sizeof(struct entry));
     if (NULL == e) { --(h->entrycount); return 0; } /*oom*/
     e->h = hash(h,k);
@@ -168,11 +168,11 @@ hashtable_search(struct hashtable *h, void *k)
     index = indexFor(h->tablelength,hashvalue);
     e = h->table[index];
     while (NULL != e)
-    {
-        /* Check hash value to short circuit heavier comparison */
-        if ((hashvalue == e->h) && (h->eqfn(k, e->k))) return e->v;
-        e = e->next;
-    }
+               {
+                       /* Check hash value to short circuit heavier comparison */
+                       if ((hashvalue == e->h) && (h->eqfn(k, e->k))) return e->v;
+                       e = e->next;
+               }
     return NULL;
 }
 
@@ -193,20 +193,20 @@ hashtable_remove(struct hashtable *h, void *k)
     pE = &(h->table[index]);
     e = *pE;
     while (NULL != e)
-    {
-        /* Check hash value to short circuit heavier comparison */
-        if ((hashvalue == e->h) && (h->eqfn(k, e->k)))
-        {
-            *pE = e->next;
-            h->entrycount--;
-            v = e->v;
-            freekey(e->k);
-            free(e);
-            return v;
-        }
-        pE = &(e->next);
-        e = e->next;
-    }
+               {
+                       /* Check hash value to short circuit heavier comparison */
+                       if ((hashvalue == e->h) && (h->eqfn(k, e->k)))
+                               {
+                                       *pE = e->next;
+                                       h->entrycount--;
+                                       v = e->v;
+                                       freekey(e->k);
+                                       free(e);
+                                       return v;
+                               }
+                       pE = &(e->next);
+                       e = e->next;
+               }
     return NULL;
 }
 
@@ -261,4 +261,16 @@ hashtable_destroy(struct hashtable *h, int free_keys, int free_values)
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ */
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index defac691f0375a77776f47ed3d2032ac70bf100e..a60965e911b2a48befeade8f1601c08b8a7b69d7 100644 (file)
@@ -23,14 +23,14 @@ hashtable_iterator(struct hashtable *h)
     if (0 == h->entrycount) return itr;
 
     for (i = 0; i < tablelength; i++)
-    {
-        if (NULL != h->table[i])
-        {
-            itr->e = h->table[i];
-            itr->index = i;
-            break;
-        }
-    }
+               {
+                       if (NULL != h->table[i])
+                               {
+                                       itr->e = h->table[i];
+                                       itr->index = i;
+                                       break;
+                               }
+               }
     return itr;
 }
 
@@ -48,28 +48,28 @@ hashtable_iterator_advance(struct hashtable_itr *itr)
 
     next = itr->e->next;
     if (NULL != next)
-    {
-        itr->parent = itr->e;
-        itr->e = next;
-        return -1;
-    }
+               {
+                       itr->parent = itr->e;
+                       itr->e = next;
+                       return -1;
+               }
     tablelength = itr->h->tablelength;
     itr->parent = NULL;
     if (tablelength <= (j = ++(itr->index)))
-    {
-        itr->e = NULL;
-        return 0;
-    }
+               {
+                       itr->e = NULL;
+                       return 0;
+               }
     table = itr->h->table;
     while (NULL == (next = table[j]))
-    {
-        if (++j >= tablelength)
-        {
-            itr->index = tablelength;
-            itr->e = NULL;
-            return 0;
-        }
-    }
+               {
+                       if (++j >= tablelength)
+                               {
+                                       itr->index = tablelength;
+                                       itr->e = NULL;
+                                       return 0;
+                               }
+               }
     itr->index = j;
     itr->e = next;
     return -1;
@@ -91,10 +91,10 @@ hashtable_iterator_remove(struct hashtable_itr *itr)
 
     /* Do the removal */
     if (NULL == (itr->parent))
-    {
-        /* element is head of a chain */
-        itr->h->table[itr->index] = itr->e->next;
-    } else {
+               {
+                       /* element is head of a chain */
+                       itr->h->table[itr->index] = itr->e->next;
+               } else {
         /* element is mid-chain */
         itr->parent->next = itr->e->next;
     }
@@ -125,19 +125,19 @@ hashtable_iterator_search(struct hashtable_itr *itr,
     e = h->table[index];
     parent = NULL;
     while (NULL != e)
-    {
-        /* Check hash value to short circuit heavier comparison */
-        if ((hashvalue == e->h) && (h->eqfn(k, e->k)))
-        {
-            itr->index = index;
-            itr->e = e;
-            itr->parent = parent;
-            itr->h = h;
-            return -1;
-        }
-        parent = e;
-        e = e->next;
-    }
+               {
+                       /* Check hash value to short circuit heavier comparison */
+                       if ((hashvalue == e->h) && (h->eqfn(k, e->k)))
+                               {
+                                       itr->index = index;
+                                       itr->e = e;
+                                       itr->parent = parent;
+                                       itr->h = h;
+                                       return -1;
+                               }
+                       parent = e;
+                       e = e->next;
+               }
     return 0;
 }
 
@@ -173,4 +173,16 @@ hashtable_iterator_search(struct hashtable_itr *itr,
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ */
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index 8d1f6bf43a9c16bedefd9f93152611a569432e73..2d7e481e4833c0424a6259309a85d74be207fb89 100644 (file)
 /*! \file */
 
 /*! \page g711_page A-law and mu-law handling
-Lookup tables for A-law and u-law look attractive, until you consider the impact
-on the CPU cache. If it causes a substantial area of your processor cache to get
-hit too often, cache sloshing will severely slow things down. The main reason
-these routines are slow in C, is the lack of direct access to the CPU's "find
-the first 1" instruction. A little in-line assembler fixes that, and the
-conversion routines can be faster than lookup tables, in most real world usage.
-A "find the first 1" instruction is available on most modern CPUs, and is a
-much underused feature. 
-
-If an assembly language method of bit searching is not available, these routines
-revert to a method that can be a little slow, so the cache thrashing might not
-seem so bad :(
-
-Feel free to submit patches to add fast "find the first 1" support for your own
-favourite processor.
-
-Look up tables are used for transcoding between A-law and u-law, since it is
-difficult to achieve the precise transcoding procedure laid down in the G.711
-specification by other means.
+  Lookup tables for A-law and u-law look attractive, until you consider the impact
+  on the CPU cache. If it causes a substantial area of your processor cache to get
+  hit too often, cache sloshing will severely slow things down. The main reason
+  these routines are slow in C, is the lack of direct access to the CPU's "find
+  the first 1" instruction. A little in-line assembler fixes that, and the
+  conversion routines can be faster than lookup tables, in most real world usage.
+  A "find the first 1" instruction is available on most modern CPUs, and is a
+  much underused feature. 
+
+  If an assembly language method of bit searching is not available, these routines
+  revert to a method that can be a little slow, so the cache thrashing might not
+  seem so bad :(
+
+  Feel free to submit patches to add fast "find the first 1" support for your own
+  favourite processor.
+
+  Look up tables are used for transcoding between A-law and u-law, since it is
+  difficult to achieve the precise transcoding procedure laid down in the G.711
+  specification by other means.
 */
 
 #if !defined(_G711_H_)
@@ -50,331 +50,331 @@ extern "C" {
 #ifndef __inline__
 #define __inline__ __inline
 #endif
-typedef unsigned __int8 uint8_t;
-typedef __int16 int16_t;
-typedef __int32 int32_t;
-typedef unsigned __int16 uint16_t;
+       typedef unsigned __int8 uint8_t;
+       typedef __int16 int16_t;
+       typedef __int32 int32_t;
+       typedef unsigned __int16 uint16_t;
 #else
 #include <stdint.h>
 #endif
 
 #if defined(__i386__)
-/*! \brief Find the bit position of the highest set bit in a word
-    \param bits The word to be searched
-    \return The bit number of the highest set bit, or -1 if the word is zero. */
-static __inline__ int top_bit(unsigned int bits)
-{
-    int res;
-
-    __asm__ __volatile__(" movl $-1,%%edx;\n"
-                         " bsrl %%eax,%%edx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
-/*- End of function --------------------------------------------------------*/
-
-/*! \brief Find the bit position of the lowest set bit in a word
-    \param bits The word to be searched
-    \return The bit number of the lowest set bit, or -1 if the word is zero. */
-static __inline__ int bottom_bit(unsigned int bits)
-{
-    int res;
-
-    __asm__ __volatile__(" movl $-1,%%edx;\n"
-                         " bsfl %%eax,%%edx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
-/*- End of function --------------------------------------------------------*/
+       /*! \brief Find the bit position of the highest set bit in a word
+         \param bits The word to be searched
+         \return The bit number of the highest set bit, or -1 if the word is zero. */
+       static __inline__ int top_bit(unsigned int bits)
+       {
+               int res;
+
+               __asm__ __volatile__(" movl $-1,%%edx;\n"
+                                                        " bsrl %%eax,%%edx;\n"
+                                                        : "=d" (res)
+                                                        : "a" (bits));
+               return res;
+       }
+       /*- End of function --------------------------------------------------------*/
+
+       /*! \brief Find the bit position of the lowest set bit in a word
+         \param bits The word to be searched
+         \return The bit number of the lowest set bit, or -1 if the word is zero. */
+       static __inline__ int bottom_bit(unsigned int bits)
+       {
+               int res;
+
+               __asm__ __volatile__(" movl $-1,%%edx;\n"
+                                                        " bsfl %%eax,%%edx;\n"
+                                                        : "=d" (res)
+                                                        : "a" (bits));
+               return res;
+       }
+       /*- End of function --------------------------------------------------------*/
 #elif defined(__x86_64__)
-static __inline__ int top_bit(unsigned int bits)
-{
-    int res;
-
-    __asm__ __volatile__(" movq $-1,%%rdx;\n"
-                         " bsrq %%rax,%%rdx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
-/*- End of function --------------------------------------------------------*/
-
-static __inline__ int bottom_bit(unsigned int bits)
-{
-    int res;
-
-    __asm__ __volatile__(" movq $-1,%%rdx;\n"
-                         " bsfq %%rax,%%rdx;\n"
-                         : "=d" (res)
-                         : "a" (bits));
-    return res;
-}
-/*- End of function --------------------------------------------------------*/
+       static __inline__ int top_bit(unsigned int bits)
+       {
+               int res;
+
+               __asm__ __volatile__(" movq $-1,%%rdx;\n"
+                                                        " bsrq %%rax,%%rdx;\n"
+                                                        : "=d" (res)
+                                                        : "a" (bits));
+               return res;
+       }
+       /*- End of function --------------------------------------------------------*/
+
+       static __inline__ int bottom_bit(unsigned int bits)
+       {
+               int res;
+
+               __asm__ __volatile__(" movq $-1,%%rdx;\n"
+                                                        " bsfq %%rax,%%rdx;\n"
+                                                        : "=d" (res)
+                                                        : "a" (bits));
+               return res;
+       }
+       /*- End of function --------------------------------------------------------*/
 #else
-static __inline__ int top_bit(unsigned int bits)
-{
-    int i;
+       static __inline__ int top_bit(unsigned int bits)
+       {
+               int i;
     
-    if (bits == 0)
-        return -1;
-    i = 0;
-    if (bits & 0xFFFF0000)
-    {
-        bits &= 0xFFFF0000;
-        i += 16;
-    }
-    if (bits & 0xFF00FF00)
-    {
-        bits &= 0xFF00FF00;
-        i += 8;
-    }
-    if (bits & 0xF0F0F0F0)
-    {
-        bits &= 0xF0F0F0F0;
-        i += 4;
-    }
-    if (bits & 0xCCCCCCCC)
-    {
-        bits &= 0xCCCCCCCC;
-        i += 2;
-    }
-    if (bits & 0xAAAAAAAA)
-    {
-        bits &= 0xAAAAAAAA;
-        i += 1;
-    }
-    return i;
-}
-/*- End of function --------------------------------------------------------*/
-
-static __inline__ int bottom_bit(unsigned int bits)
-{
-    int i;
+               if (bits == 0)
+                       return -1;
+               i = 0;
+               if (bits & 0xFFFF0000)
+                       {
+                               bits &= 0xFFFF0000;
+                               i += 16;
+                       }
+               if (bits & 0xFF00FF00)
+                       {
+                               bits &= 0xFF00FF00;
+                               i += 8;
+                       }
+               if (bits & 0xF0F0F0F0)
+                       {
+                               bits &= 0xF0F0F0F0;
+                               i += 4;
+                       }
+               if (bits & 0xCCCCCCCC)
+                       {
+                               bits &= 0xCCCCCCCC;
+                               i += 2;
+                       }
+               if (bits & 0xAAAAAAAA)
+                       {
+                               bits &= 0xAAAAAAAA;
+                               i += 1;
+                       }
+               return i;
+       }
+       /*- End of function --------------------------------------------------------*/
+
+       static __inline__ int bottom_bit(unsigned int bits)
+       {
+               int i;
     
-    if (bits == 0)
-        return -1;
-    i = 32;
-    if (bits & 0x0000FFFF)
-    {
-        bits &= 0x0000FFFF;
-        i -= 16;
-    }
-    if (bits & 0x00FF00FF)
-    {
-        bits &= 0x00FF00FF;
-        i -= 8;
-    }
-    if (bits & 0x0F0F0F0F)
-    {
-        bits &= 0x0F0F0F0F;
-        i -= 4;
-    }
-    if (bits & 0x33333333)
-    {
-        bits &= 0x33333333;
-        i -= 2;
-    }
-    if (bits & 0x55555555)
-    {
-        bits &= 0x55555555;
-        i -= 1;
-    }
-    return i;
-}
-/*- End of function --------------------------------------------------------*/
+               if (bits == 0)
+                       return -1;
+               i = 32;
+               if (bits & 0x0000FFFF)
+                       {
+                               bits &= 0x0000FFFF;
+                               i -= 16;
+                       }
+               if (bits & 0x00FF00FF)
+                       {
+                               bits &= 0x00FF00FF;
+                               i -= 8;
+                       }
+               if (bits & 0x0F0F0F0F)
+                       {
+                               bits &= 0x0F0F0F0F;
+                               i -= 4;
+                       }
+               if (bits & 0x33333333)
+                       {
+                               bits &= 0x33333333;
+                               i -= 2;
+                       }
+               if (bits & 0x55555555)
+                       {
+                               bits &= 0x55555555;
+                               i -= 1;
+                       }
+               return i;
+       }
+       /*- End of function --------------------------------------------------------*/
 #endif
 
-/* N.B. It is tempting to use look-up tables for A-law and u-law conversion.
- *      However, you should consider the cache footprint.
- *
- *      A 64K byte table for linear to x-law and a 512 byte table for x-law to
- *      linear sound like peanuts these days, and shouldn't an array lookup be
- *      real fast? No! When the cache sloshes as badly as this one will, a tight
- *      calculation may be better. The messiest part is normally finding the
- *      segment, but a little inline assembly can fix that on an i386, x86_64 and
- *      many other modern processors.
- */
+       /* N.B. It is tempting to use look-up tables for A-law and u-law conversion.
       *      However, you should consider the cache footprint.
       *
       *      A 64K byte table for linear to x-law and a 512 byte table for x-law to
       *      linear sound like peanuts these days, and shouldn't an array lookup be
       *      real fast? No! When the cache sloshes as badly as this one will, a tight
       *      calculation may be better. The messiest part is normally finding the
       *      segment, but a little inline assembly can fix that on an i386, x86_64 and
       *      many other modern processors.
       */
  
-/*
- * Mu-law is basically as follows:
- *
- *      Biased Linear Input Code        Compressed Code
- *      ------------------------        ---------------
- *      00000001wxyza                   000wxyz
- *      0000001wxyzab                   001wxyz
- *      000001wxyzabc                   010wxyz
- *      00001wxyzabcd                   011wxyz
- *      0001wxyzabcde                   100wxyz
- *      001wxyzabcdef                   101wxyz
- *      01wxyzabcdefg                   110wxyz
- *      1wxyzabcdefgh                   111wxyz
- *
- * Each biased linear code has a leading 1 which identifies the segment
- * number. The value of the segment number is equal to 7 minus the number
- * of leading 0's. The quantization interval is directly available as the
- * four bits wxyz.  * The trailing bits (a - h) are ignored.
- *
- * Ordinarily the complement of the resulting code word is used for
- * transmission, and so the code word is complemented before it is returned.
- *
- * For further information see John C. Bellamy's Digital Telephony, 1982,
- * John Wiley & Sons, pps 98-111 and 472-476.
- */
-
-/*#define ULAW_ZEROTRAP*/                 /* turn on the trap as per the MIL-STD */
+       /*
       * Mu-law is basically as follows:
       *
       *      Biased Linear Input Code        Compressed Code
       *      ------------------------        ---------------
       *      00000001wxyza                   000wxyz
       *      0000001wxyzab                   001wxyz
       *      000001wxyzabc                   010wxyz
       *      00001wxyzabcd                   011wxyz
       *      0001wxyzabcde                   100wxyz
       *      001wxyzabcdef                   101wxyz
       *      01wxyzabcdefg                   110wxyz
       *      1wxyzabcdefgh                   111wxyz
       *
       * Each biased linear code has a leading 1 which identifies the segment
       * number. The value of the segment number is equal to 7 minus the number
       * of leading 0's. The quantization interval is directly available as the
       * four bits wxyz.  * The trailing bits (a - h) are ignored.
       *
       * Ordinarily the complement of the resulting code word is used for
       * transmission, and so the code word is complemented before it is returned.
       *
       * For further information see John C. Bellamy's Digital Telephony, 1982,
       * John Wiley & Sons, pps 98-111 and 472-476.
       */
+
+       /*#define ULAW_ZEROTRAP*/                 /* turn on the trap as per the MIL-STD */
 #define ULAW_BIAS        0x84           /* Bias for linear code. */
 
-/*! \brief Encode a linear sample to u-law
-    \param linear The sample to encode.
-    \return The u-law value.
-*/
-static __inline__ uint8_t linear_to_ulaw(int linear)
-{
-    uint8_t u_val;
-    int mask;
-    int seg;
-
-    /* Get the sign and the magnitude of the value. */
-    if (linear < 0)
-    {
-        linear = ULAW_BIAS - linear;
-        mask = 0x7F;
-    }
-    else
-    {
-        linear = ULAW_BIAS + linear;
-        mask = 0xFF;
-    }
-
-    seg = top_bit(linear | 0xFF) - 7;
-
-    /*
-     * Combine the sign, segment, quantization bits,
-     * and complement the code word.
-     */
-    if (seg >= 8)
-        u_val = (uint8_t) (0x7F ^ mask);
-    else
-        u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
+       /*! \brief Encode a linear sample to u-law
+         \param linear The sample to encode.
+         \return The u-law value.
+       */
+       static __inline__ uint8_t linear_to_ulaw(int linear)
+       {
+               uint8_t u_val;
+               int mask;
+               int seg;
+
+               /* Get the sign and the magnitude of the value. */
+               if (linear < 0)
+                       {
+                               linear = ULAW_BIAS - linear;
+                               mask = 0x7F;
+                       }
+               else
+                       {
+                               linear = ULAW_BIAS + linear;
+                               mask = 0xFF;
+                       }
+
+               seg = top_bit(linear | 0xFF) - 7;
+
+               /*
+                * Combine the sign, segment, quantization bits,
+                * and complement the code word.
+                */
+               if (seg >= 8)
+                       u_val = (uint8_t) (0x7F ^ mask);
+               else
+                       u_val = (uint8_t) (((seg << 4) | ((linear >> (seg + 3)) & 0xF)) ^ mask);
 #ifdef ULAW_ZEROTRAP
-    /* Optional ITU trap */
-    if (u_val == 0)
-        u_val = 0x02;
+               /* Optional ITU trap */
+               if (u_val == 0)
+                       u_val = 0x02;
 #endif
-    return  u_val;
-}
-/*- End of function --------------------------------------------------------*/
-
-/*! \brief Decode an u-law sample to a linear value.
-    \param ulaw The u-law sample to decode.
-    \return The linear value.
-*/
-static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
-{
-    int t;
+               return  u_val;
+       }
+       /*- End of function --------------------------------------------------------*/
+
+       /*! \brief Decode an u-law sample to a linear value.
+         \param ulaw The u-law sample to decode.
+         \return The linear value.
+       */
+       static __inline__ int16_t ulaw_to_linear(uint8_t ulaw)
+       {
+               int t;
     
-    /* Complement to obtain normal u-law value. */
-    ulaw = ~ulaw;
-    /*
-     * Extract and bias the quantization bits. Then
-     * shift up by the segment number and subtract out the bias.
-     */
-    t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
-    return  (int16_t) ((ulaw & 0x80)  ?  (ULAW_BIAS - t)  :  (t - ULAW_BIAS));
-}
-/*- End of function --------------------------------------------------------*/
-
-/*
- * A-law is basically as follows:
- *
- *      Linear Input Code        Compressed Code
- *      -----------------        ---------------
- *      0000000wxyza             000wxyz
- *      0000001wxyza             001wxyz
- *      000001wxyzab             010wxyz
- *      00001wxyzabc             011wxyz
- *      0001wxyzabcd             100wxyz
- *      001wxyzabcde             101wxyz
- *      01wxyzabcdef             110wxyz
- *      1wxyzabcdefg             111wxyz
- *
- * For further information see John C. Bellamy's Digital Telephony, 1982,
- * John Wiley & Sons, pps 98-111 and 472-476.
- */
+               /* Complement to obtain normal u-law value. */
+               ulaw = ~ulaw;
+               /*
+                * Extract and bias the quantization bits. Then
+                * shift up by the segment number and subtract out the bias.
+                */
+               t = (((ulaw & 0x0F) << 3) + ULAW_BIAS) << (((int) ulaw & 0x70) >> 4);
+               return  (int16_t) ((ulaw & 0x80)  ?  (ULAW_BIAS - t)  :  (t - ULAW_BIAS));
+       }
+       /*- End of function --------------------------------------------------------*/
+
+       /*
       * A-law is basically as follows:
       *
       *      Linear Input Code        Compressed Code
       *      -----------------        ---------------
       *      0000000wxyza             000wxyz
       *      0000001wxyza             001wxyz
       *      000001wxyzab             010wxyz
       *      00001wxyzabc             011wxyz
       *      0001wxyzabcd             100wxyz
       *      001wxyzabcde             101wxyz
       *      01wxyzabcdef             110wxyz
       *      1wxyzabcdefg             111wxyz
       *
       * For further information see John C. Bellamy's Digital Telephony, 1982,
       * John Wiley & Sons, pps 98-111 and 472-476.
       */
 
 #define ALAW_AMI_MASK       0x55
 
-/*! \brief Encode a linear sample to A-law
-    \param linear The sample to encode.
-    \return The A-law value.
-*/
-static __inline__ uint8_t linear_to_alaw(int linear)
-{
-    int mask;
-    int seg;
+       /*! \brief Encode a linear sample to A-law
+         \param linear The sample to encode.
+         \return The A-law value.
+       */
+       static __inline__ uint8_t linear_to_alaw(int linear)
+       {
+               int mask;
+               int seg;
     
-    if (linear >= 0)
-    {
-        /* Sign (bit 7) bit = 1 */
-        mask = ALAW_AMI_MASK | 0x80;
-    }
-    else
-    {
-        /* Sign (bit 7) bit = 0 */
-        mask = ALAW_AMI_MASK;
-        linear = -linear - 8;
-    }
-
-    /* Convert the scaled magnitude to segment number. */
-    seg = top_bit(linear | 0xFF) - 7;
-    if (seg >= 8)
-    {
-        if (linear >= 0)
-        {
-            /* Out of range. Return maximum value. */
-            return (uint8_t) (0x7F ^ mask);
-        }
-        /* We must be just a tiny step below zero */
-        return (uint8_t) (0x00 ^ mask);
-    }
-    /* Combine the sign, segment, and quantization bits. */
-    return (uint8_t) (((seg << 4) | ((linear >> ((seg)  ?  (seg + 3)  :  4)) & 0x0F)) ^ mask);
-}
-/*- End of function --------------------------------------------------------*/
-
-/*! \brief Decode an A-law sample to a linear value.
-    \param alaw The A-law sample to decode.
-    \return The linear value.
-*/
-static __inline__ int16_t alaw_to_linear(uint8_t alaw)
-{
-    int i;
-    int seg;
-
-    alaw ^= ALAW_AMI_MASK;
-    i = ((alaw & 0x0F) << 4);
-    seg = (((int) alaw & 0x70) >> 4);
-    if (seg)
-        i = (i + 0x108) << (seg - 1);
-    else
-        i += 8;
-    return (int16_t) ((alaw & 0x80)  ?  i  :  -i);
-}
-/*- End of function --------------------------------------------------------*/
-
-/*! \brief Transcode from A-law to u-law, using the procedure defined in G.711.
-    \param alaw The A-law sample to transcode.
-    \return The best matching u-law value.
-*/
-uint8_t alaw_to_ulaw(uint8_t alaw);
-
-/*! \brief Transcode from u-law to A-law, using the procedure defined in G.711.
-    \param alaw The u-law sample to transcode.
-    \return The best matching A-law value.
-*/
-uint8_t ulaw_to_alaw(uint8_t ulaw);
+               if (linear >= 0)
+                       {
+                               /* Sign (bit 7) bit = 1 */
+                               mask = ALAW_AMI_MASK | 0x80;
+                       }
+               else
+                       {
+                               /* Sign (bit 7) bit = 0 */
+                               mask = ALAW_AMI_MASK;
+                               linear = -linear - 8;
+                       }
+
+               /* Convert the scaled magnitude to segment number. */
+               seg = top_bit(linear | 0xFF) - 7;
+               if (seg >= 8)
+                       {
+                               if (linear >= 0)
+                                       {
+                                               /* Out of range. Return maximum value. */
+                                               return (uint8_t) (0x7F ^ mask);
+                                       }
+                               /* We must be just a tiny step below zero */
+                               return (uint8_t) (0x00 ^ mask);
+                       }
+               /* Combine the sign, segment, and quantization bits. */
+               return (uint8_t) (((seg << 4) | ((linear >> ((seg)  ?  (seg + 3)  :  4)) & 0x0F)) ^ mask);
+       }
+       /*- End of function --------------------------------------------------------*/
+
+       /*! \brief Decode an A-law sample to a linear value.
+         \param alaw The A-law sample to decode.
+         \return The linear value.
+       */
+       static __inline__ int16_t alaw_to_linear(uint8_t alaw)
+       {
+               int i;
+               int seg;
+
+               alaw ^= ALAW_AMI_MASK;
+               i = ((alaw & 0x0F) << 4);
+               seg = (((int) alaw & 0x70) >> 4);
+               if (seg)
+                       i = (i + 0x108) << (seg - 1);
+               else
+                       i += 8;
+               return (int16_t) ((alaw & 0x80)  ?  i  :  -i);
+       }
+       /*- End of function --------------------------------------------------------*/
+
+       /*! \brief Transcode from A-law to u-law, using the procedure defined in G.711.
+         \param alaw The A-law sample to transcode.
+         \return The best matching u-law value.
+       */
+       uint8_t alaw_to_ulaw(uint8_t alaw);
+
+       /*! \brief Transcode from u-law to A-law, using the procedure defined in G.711.
+         \param alaw The u-law sample to transcode.
+         \return The best matching A-law value.
+       */
+       uint8_t ulaw_to_alaw(uint8_t ulaw);
 
 #ifdef __cplusplus
 }
@@ -382,3 +382,14 @@ uint8_t ulaw_to_alaw(uint8_t ulaw);
 
 #endif
 /*- End of file ------------------------------------------------------------*/
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index 4019a69ff982628da23ab8ae3fc13c8675781d89..4c3c48f4bfa1b0fc244ce643b25f892a148c242d 100644 (file)
@@ -103,11 +103,11 @@ create_hashtable(unsigned int minsize,
 int 
 hashtable_insert(struct hashtable *h, void *k, void *v);
 
-#define DEFINE_HASHTABLE_INSERT(fnname, keytype, valuetype) \
-int fnname (struct hashtable *h, keytype *k, valuetype *v) \
-{ \
-    return hashtable_insert(h,k,v); \
-}
+#define DEFINE_HASHTABLE_INSERT(fnname, keytype, valuetype)            \
+       int fnname (struct hashtable *h, keytype *k, valuetype *v)      \
+       {                                                                                                                       \
+               return hashtable_insert(h,k,v);                                                 \
+       }
 
 /*****************************************************************************
  * hashtable_search
@@ -122,10 +122,10 @@ void *
 hashtable_search(struct hashtable *h, void *k);
 
 #define DEFINE_HASHTABLE_SEARCH(fnname, keytype, valuetype) \
-valuetype * fnname (struct hashtable *h, keytype *k) \
-{ \
-    return (valuetype *) (hashtable_search(h,k)); \
-}
+       valuetype * fnname (struct hashtable *h, keytype *k)    \
+       {                                                                                                               \
+               return (valuetype *) (hashtable_search(h,k));           \
+       }
 
 /*****************************************************************************
  * hashtable_remove
@@ -140,10 +140,10 @@ void * /* returns value */
 hashtable_remove(struct hashtable *h, void *k);
 
 #define DEFINE_HASHTABLE_REMOVE(fnname, keytype, valuetype) \
-valuetype * fnname (struct hashtable *h, keytype *k) \
-{ \
-    return (valuetype *) (hashtable_remove(h,k)); \
-}
+       valuetype * fnname (struct hashtable *h, keytype *k)    \
+       {                                                                                                               \
+               return (valuetype *) (hashtable_remove(h,k));           \
+       }
 
 
 /*****************************************************************************
@@ -201,4 +201,15 @@ hashtable_destroy(struct hashtable *h, int free_keys, int free_values);
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ */
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index aacf86825ae55d21757851dc564ca70fc92b5ba0..71c0d659ff7918af69baea89943ca1152309a0e3 100644 (file)
@@ -62,17 +62,17 @@ hashtable_iterator_remove(struct hashtable_itr *itr);
 /*****************************************************************************/
 /* search - overwrite the supplied iterator, to point to the entry
  *          matching the supplied key.
           h points to the hashtable to be searched.
+ h points to the hashtable to be searched.
  *          returns zero if not found. */
 int
 hashtable_iterator_search(struct hashtable_itr *itr,
                           struct hashtable *h, void *k);
 
-#define DEFINE_HASHTABLE_ITERATOR_SEARCH(fnname, keytype) \
-int fnname (struct hashtable_itr *i, struct hashtable *h, keytype *k) \
-{ \
-    return (hashtable_iterator_search(i,h,k)); \
-}
+#define DEFINE_HASHTABLE_ITERATOR_SEARCH(fnname, keytype)                              \
+       int fnname (struct hashtable_itr *i, struct hashtable *h, keytype *k) \
+       {                                                                                                                                       \
+               return (hashtable_iterator_search(i,h,k));                                              \
+       }
 
 
 
@@ -109,4 +109,16 @@ int fnname (struct hashtable_itr *i, struct hashtable *h, keytype *k) \
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ */
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index edf59efe18556e2a8824447134eee94f134b82a3..ede652c6549fb7924b6f5479c9501f3ee2fdbb76 100644 (file)
@@ -37,10 +37,10 @@ indexFor(unsigned int tablelength, unsigned int hashvalue) {
 
 /* Only works if tablelength == 2^N */
 /*static inline unsigned int
-indexFor(unsigned int tablelength, unsigned int hashvalue)
-{
-    return (hashvalue & (tablelength - 1u));
-}
+  indexFor(unsigned int tablelength, unsigned int hashvalue)
+  {
+  return (hashvalue & (tablelength - 1u));
+  }
 */
 
 /*****************************************************************************/
@@ -83,4 +83,14 @@ indexFor(unsigned int tablelength, unsigned int hashvalue)
  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
+ */
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index aaf7b0ed4794c4ab9eefb9b5ca53fdd0377b08f4..e81ef5e90d0e391e0c671587ac6d5ab8f098535f 100644 (file)
@@ -78,27 +78,27 @@ extern "C" {
 #define TELETONE_MAX_TONES 6
 #define TELETONE_TONE_RANGE 127
 
-typedef double teletone_process_t;
+       typedef double teletone_process_t;
 
-/*! \file libteletone.h
-    \brief Top level include file
+       /*! \file libteletone.h
+         \brief Top level include file
 
-       This file should be included by applications using the library
-*/
+         This file should be included by applications using the library
+       */
 
-/*! \brief An abstraction to store a tone mapping */
-typedef struct {
-       /*! An array of tone frequencies */
-       teletone_process_t freqs[TELETONE_MAX_TONES];
-} teletone_tone_map_t;
+       /*! \brief An abstraction to store a tone mapping */
+       typedef struct {
+               /*! An array of tone frequencies */
+               teletone_process_t freqs[TELETONE_MAX_TONES];
+       } teletone_tone_map_t;
 
 #if !defined(M_PI)
-/* C99 systems may not define M_PI */
+       /* C99 systems may not define M_PI */
 #define M_PI 3.14159265358979323846264338327
 #endif
 
 #ifdef _MSC_VER
-typedef __int16 int16_t;
+       typedef __int16 int16_t;
 #endif
 
 #include <libteletone_generate.h>
index eda4e49514e06c8f499e697050d8d1a2b194a7cf..15d5e9ddfb3ebcf3043cee6dc39a92716164c35a 100644 (file)
@@ -98,11 +98,11 @@ extern "C" {
 #endif
 #include <libteletone.h>
 
-/*! \file libteletone_detect.h
-    \brief Tone Detection Routines
+       /*! \file libteletone_detect.h
+         \brief Tone Detection Routines
 
-       This module is responsible for tone detection specifics
-*/
+         This module is responsible for tone detection specifics
+       */
 
 #ifndef FALSE
 #define FALSE   0
@@ -111,17 +111,17 @@ extern "C" {
 #endif
 #endif
 
-/* Basic DTMF specs:
- *
- * Minimum tone on = 40ms
- * Minimum tone off = 50ms
- * Maximum digit rate = 10 per second
- * Normal twist <= 8dB accepted
- * Reverse twist <= 4dB accepted
- * S/N >= 15dB will detect OK
- * Attenuation <= 26dB will detect OK
- * Frequency tolerance +- 1.5% will detect, +-3.5% will reject
- */
+       /* Basic DTMF specs:
       *
       * Minimum tone on = 40ms
       * Minimum tone off = 50ms
       * Maximum digit rate = 10 per second
       * Normal twist <= 8dB accepted
       * Reverse twist <= 4dB accepted
       * S/N >= 15dB will detect OK
       * Attenuation <= 26dB will detect OK
       * Frequency tolerance +- 1.5% will detect, +-3.5% will reject
       */
 
 #define DTMF_THRESHOLD              8.0e7
 #define DTMF_NORMAL_TWIST           6.3     /* 8dB */
@@ -134,131 +134,131 @@ extern "C" {
 #define BLOCK_LEN 102
 #define M_TWO_PI 2.0*M_PI
 
-/*! \brief A continer for the elements of a Goertzel Algorithm (The names are from his formula) */
-typedef struct {
-       teletone_process_t v2;
-       teletone_process_t v3;
-       teletone_process_t fac;
-} teletone_goertzel_state_t;
+       /*! \brief A continer for the elements of a Goertzel Algorithm (The names are from his formula) */
+       typedef struct {
+               teletone_process_t v2;
+               teletone_process_t v3;
+               teletone_process_t fac;
+       } teletone_goertzel_state_t;
        
-/*! \brief A container for a DTMF detection state.*/
-typedef struct {
-    int hit1;
-    int hit2;
-    int hit3;
-    int hit4;
-    int mhit;
+       /*! \brief A container for a DTMF detection state.*/
+       typedef struct {
+               int hit1;
+               int hit2;
+               int hit3;
+               int hit4;
+               int mhit;
 
-    teletone_goertzel_state_t row_out[GRID_FACTOR];
-    teletone_goertzel_state_t col_out[GRID_FACTOR];
-    teletone_goertzel_state_t row_out2nd[GRID_FACTOR];
-    teletone_goertzel_state_t col_out2nd[GRID_FACTOR];
-    teletone_process_t energy;
+               teletone_goertzel_state_t row_out[GRID_FACTOR];
+               teletone_goertzel_state_t col_out[GRID_FACTOR];
+               teletone_goertzel_state_t row_out2nd[GRID_FACTOR];
+               teletone_goertzel_state_t col_out2nd[GRID_FACTOR];
+               teletone_process_t energy;
     
-    int current_sample;
-    char digits[TELETONE_MAX_DTMF_DIGITS + 1];
-    int current_digits;
-    int detected_digits;
-    int lost_digits;
-    int digit_hits[16];
-} teletone_dtmf_detect_state_t;
+               int current_sample;
+               char digits[TELETONE_MAX_DTMF_DIGITS + 1];
+               int current_digits;
+               int detected_digits;
+               int lost_digits;
+               int digit_hits[16];
+       } teletone_dtmf_detect_state_t;
 
-/*! \brief An abstraction to store the coefficient of a tone frequency */
-typedef struct {
-    teletone_process_t fac;
-} teletone_detection_descriptor_t;
+       /*! \brief An abstraction to store the coefficient of a tone frequency */
+       typedef struct {
+               teletone_process_t fac;
+       } teletone_detection_descriptor_t;
 
-/*! \brief A container for a single multi-tone detection 
-TELETONE_MAX_TONES dictates the maximum simultaneous tones that can be present
-in a multi-tone representation.
-*/
-typedef struct {
-       int sample_rate;
+       /*! \brief A container for a single multi-tone detection 
+         TELETONE_MAX_TONES dictates the maximum simultaneous tones that can be present
+         in a multi-tone representation.
+       */
+       typedef struct {
+               int sample_rate;
 
-       teletone_detection_descriptor_t tdd[TELETONE_MAX_TONES];
-       teletone_goertzel_state_t gs[TELETONE_MAX_TONES];
-       teletone_goertzel_state_t gs2[TELETONE_MAX_TONES];
-       int tone_count;
+               teletone_detection_descriptor_t tdd[TELETONE_MAX_TONES];
+               teletone_goertzel_state_t gs[TELETONE_MAX_TONES];
+               teletone_goertzel_state_t gs2[TELETONE_MAX_TONES];
+               int tone_count;
 
-       teletone_process_t energy;
-       int current_sample;
+               teletone_process_t energy;
+               int current_sample;
        
-       int min_samples;
-       int total_samples;
+               int min_samples;
+               int total_samples;
 
-       int positives;
-       int negatives;
-       int hits;
+               int positives;
+               int negatives;
+               int hits;
 
-       int positive_factor;
-       int negative_factor;
-       int hit_factor;
+               int positive_factor;
+               int negative_factor;
+               int hit_factor;
 
-} teletone_multi_tone_t;
+       } teletone_multi_tone_t;
 
 
-/*! 
-  \brief Initilize a multi-frequency tone detector
-  \param mt the multi-frequency tone descriptor
-  \param map a representation of the multi-frequency tone
-*/
-void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map);
+       /*! 
+         \brief Initilize a multi-frequency tone detector
+         \param mt the multi-frequency tone descriptor
+         \param map a representation of the multi-frequency tone
+       */
+       void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *map);
 
-/*! 
-  \brief Check a sample buffer for the presence of the mulit-frequency tone described by mt
-  \param mt the multi-frequency tone descriptor
-  \param sample_buffer an array aof 16 bit signed linear samples
-  \param samples the number of samples present in sample_buffer
-  \return true when the tone was detected or false when it is not
-*/
-int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
-                                                               int16_t sample_buffer[],
-                                                               int samples);
+       /*! 
+         \brief Check a sample buffer for the presence of the mulit-frequency tone described by mt
+         \param mt the multi-frequency tone descriptor
+         \param sample_buffer an array aof 16 bit signed linear samples
+         \param samples the number of samples present in sample_buffer
+         \return true when the tone was detected or false when it is not
+       */
+       int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
+                                                                       int16_t sample_buffer[],
+                                                                       int samples);
 
-/*! 
-  \brief Initilize a DTMF detection state object
-  \param dtmf_detect_state the DTMF detection state to initilize
-  \param sample_rate the desired sample rate
-*/
-void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate);
+       /*! 
+         \brief Initilize a DTMF detection state object
+         \param dtmf_detect_state the DTMF detection state to initilize
+         \param sample_rate the desired sample rate
+       */
+       void teletone_dtmf_detect_init (teletone_dtmf_detect_state_t *dtmf_detect_state, int sample_rate);
 
-/*! 
-  \brief Check a sample buffer for the presence of DTMF digits
-  \param dtmf_detect_state the detection state object to check
-  \param sample_buffer an array aof 16 bit signed linear samples
-  \param samples the number of samples present in sample_buffer
-  \return true when DTMF was detected or false when it is not
-*/
-int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
-                                                 int16_t sample_buffer[],
-                                                 int samples);
-/*! 
-  \brief retrieve any collected digits into a string buffer
-  \param dtmf_detect_state the detection state object to check
-  \param buf the string buffer to write to
-  \param max the maximum length of buf
-  \return the number of characters written to buf
-*/
-int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
-                                          char *buf,
-                                          int max);
-
-/*! 
-  \brief Step through the Goertzel Algorithm for each sample in a buffer
-  \param goertzel_state the goertzel state to step the samples through
-  \param sample_buffer an array aof 16 bit signed linear samples
-  \param samples the number of samples present in sample_buffer
-*/
-void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
+       /*! 
+         \brief Check a sample buffer for the presence of DTMF digits
+         \param dtmf_detect_state the detection state object to check
+         \param sample_buffer an array aof 16 bit signed linear samples
+         \param samples the number of samples present in sample_buffer
+         \return true when DTMF was detected or false when it is not
+       */
+       int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
                                                          int16_t sample_buffer[],
                                                          int samples);
+       /*! 
+         \brief retrieve any collected digits into a string buffer
+         \param dtmf_detect_state the detection state object to check
+         \param buf the string buffer to write to
+         \param max the maximum length of buf
+         \return the number of characters written to buf
+       */
+       int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
+                                                  char *buf,
+                                                  int max);
+
+       /*! 
+         \brief Step through the Goertzel Algorithm for each sample in a buffer
+         \param goertzel_state the goertzel state to step the samples through
+         \param sample_buffer an array aof 16 bit signed linear samples
+         \param samples the number of samples present in sample_buffer
+       */
+       void teletone_goertzel_update(teletone_goertzel_state_t *goertzel_state,
+                                                                 int16_t sample_buffer[],
+                                                                 int samples);
 
-/*! 
-  \brief Compute the result of the last applied step of the Goertzel Algorithm
-  \param goertzel_state the goertzel state to retrieve from
-  \return the computed value for consideration in furthur audio tests
-*/
-teletone_process_t teletone_goertzel_result (teletone_goertzel_state_t *goertzel_state);
+       /*! 
+         \brief Compute the result of the last applied step of the Goertzel Algorithm
+         \param goertzel_state the goertzel state to retrieve from
+         \return the computed value for consideration in furthur audio tests
+       */
+       teletone_process_t teletone_goertzel_result (teletone_goertzel_state_t *goertzel_state);
 
 
 
index 3d625e8f52cebba2788f0511af2df43228d062d6..e37778d278026d15488483e531fb7cfc90382525 100644 (file)
@@ -89,113 +89,113 @@ extern "C" {
 
 
 
-/*! \file libteletone_generate.h
-    \brief Tone Generation Routines
-
-       This module is responsible for tone generation specifics
-*/
-
-typedef int16_t teletone_audio_t;
-struct teletone_generation_session;
-typedef int (*tone_handler)(struct teletone_generation_session *ts, teletone_tone_map_t *map);
-
-/*! \brief An abstraction to store a tone generation session */
-struct teletone_generation_session {
-       /*! An array of tone mappings to character mappings */
-       teletone_tone_map_t TONES[TELETONE_TONE_RANGE];
-       /*! The number of channels the output audio should be in */
-       int channels;
-       /*! The Rate in hz of the output audio */
-       int rate;
-       /*! The duration (in samples) of the output audio */
-       int duration;
-       /*! The duration of silence to append after the initial audio is generated */
-       int wait;
-       /*! The duration (in samples) of the output audio (takes prescedence over actual duration value) */
-       int tmp_duration;
-       /*! The duration of silence to append after the initial audio is generated (takes prescedence over actual wait value)*/
-       int tmp_wait;
-       /*! Number of loops to repeat a single instruction*/
-       int loops;
-       /*! Number of loops to repeat the entire set of instructions*/
-       int LOOPS;
-       /*! Number to mutiply total samples by to determine when to begin ascent or decent e.g. 0=beginning 4=(last 25%) */
-       int decay_factor;
-       /*! Direction to perform volume increase/decrease 1/-1*/
-       int decay_direction;
-       /*! Number of samples between increase/decrease of volume */
-       int decay_step;
-       /*! Volume factor of the tone */
-       int volume;
-       /*! Debug on/off */
-       int debug;
-       /*! FILE stream to write debug data to */
-       FILE *debug_stream;
-       /*! Extra user data to attach to the session*/
-       void *user_data;
-       /*! Buffer for storing sample data (dynamic) */
-       teletone_audio_t *buffer;
-       /*! Size of the buffer */
-       int datalen;
-       /*! In-Use size of the buffer */
-       int samples;
-       /*! Callback function called during generation */
-       int dynamic;
-       tone_handler handler;
-};
-
-typedef struct teletone_generation_session teletone_generation_session_t;
-
-
-/*! 
-  \brief Assign a set of tones to a tone_session indexed by a paticular index/character
-  \param ts the tone generation session
-  \param index the index to map the tone to
-  \param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0
-  \return 0
-*/
-int teletone_set_tone(teletone_generation_session_t *ts, int index, ...);
-
-/*! 
-  \brief Assign a set of tones to a single tone map
-  \param map the map to assign the tones to
-  \param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0
-  \return 0
-*/
-int teletone_set_map(teletone_tone_map_t *map, ...);
-
-/*! 
-  \brief Initilize a tone generation session
-  \param ts the tone generation session to initilize
-  \param buflen the size of the buffer(in samples) to dynamically allocate
-  \param handler a callback function to execute when a tone generation instruction is complete
-  \param user_data optional user data to send
-  \return 0
-*/
-int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data);
-
-/*! 
-  \brief Free the buffer allocated by a tone generation session
-  \param ts the tone generation session to destroy
-  \return 0
-*/
-int teletone_destroy_session(teletone_generation_session_t *ts);
-
-/*! 
-  \brief Execute a single tone generation instruction
-  \param ts the tone generation session to consult for parameters
-  \param map the tone mapping to use for the frequencies
-  \return 0
-*/
-int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map);
-
-/*! 
-  \brief Execute a tone generation script and call callbacks after each instruction
-  \param ts the tone generation session to execute on
-  \param cmd the script to execute
-  \return 0
-*/
-int teletone_run(teletone_generation_session_t *ts, char *cmd);
+       /*! \file libteletone_generate.h
+         \brief Tone Generation Routines
+
+         This module is responsible for tone generation specifics
+       */
+
+       typedef int16_t teletone_audio_t;
+       struct teletone_generation_session;
+       typedef int (*tone_handler)(struct teletone_generation_session *ts, teletone_tone_map_t *map);
+
+       /*! \brief An abstraction to store a tone generation session */
+       struct teletone_generation_session {
+               /*! An array of tone mappings to character mappings */
+               teletone_tone_map_t TONES[TELETONE_TONE_RANGE];
+               /*! The number of channels the output audio should be in */
+               int channels;
+               /*! The Rate in hz of the output audio */
+               int rate;
+               /*! The duration (in samples) of the output audio */
+               int duration;
+               /*! The duration of silence to append after the initial audio is generated */
+               int wait;
+               /*! The duration (in samples) of the output audio (takes prescedence over actual duration value) */
+               int tmp_duration;
+               /*! The duration of silence to append after the initial audio is generated (takes prescedence over actual wait value)*/
+               int tmp_wait;
+               /*! Number of loops to repeat a single instruction*/
+               int loops;
+               /*! Number of loops to repeat the entire set of instructions*/
+               int LOOPS;
+               /*! Number to mutiply total samples by to determine when to begin ascent or decent e.g. 0=beginning 4=(last 25%) */
+               int decay_factor;
+               /*! Direction to perform volume increase/decrease 1/-1*/
+               int decay_direction;
+               /*! Number of samples between increase/decrease of volume */
+               int decay_step;
+               /*! Volume factor of the tone */
+               int volume;
+               /*! Debug on/off */
+               int debug;
+               /*! FILE stream to write debug data to */
+               FILE *debug_stream;
+               /*! Extra user data to attach to the session*/
+               void *user_data;
+               /*! Buffer for storing sample data (dynamic) */
+               teletone_audio_t *buffer;
+               /*! Size of the buffer */
+               int datalen;
+               /*! In-Use size of the buffer */
+               int samples;
+               /*! Callback function called during generation */
+               int dynamic;
+               tone_handler handler;
+       };
+
+       typedef struct teletone_generation_session teletone_generation_session_t;
+
+
+       /*! 
+         \brief Assign a set of tones to a tone_session indexed by a paticular index/character
+         \param ts the tone generation session
+         \param index the index to map the tone to
+         \param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0
+         \return 0
+       */
+       int teletone_set_tone(teletone_generation_session_t *ts, int index, ...);
+
+       /*! 
+         \brief Assign a set of tones to a single tone map
+         \param map the map to assign the tones to
+         \param ... up to TELETONE_MAX_TONES frequencies terminated by 0.0
+         \return 0
+       */
+       int teletone_set_map(teletone_tone_map_t *map, ...);
+
+       /*! 
+         \brief Initilize a tone generation session
+         \param ts the tone generation session to initilize
+         \param buflen the size of the buffer(in samples) to dynamically allocate
+         \param handler a callback function to execute when a tone generation instruction is complete
+         \param user_data optional user data to send
+         \return 0
+       */
+       int teletone_init_session(teletone_generation_session_t *ts, int buflen, tone_handler handler, void *user_data);
+
+       /*! 
+         \brief Free the buffer allocated by a tone generation session
+         \param ts the tone generation session to destroy
+         \return 0
+       */
+       int teletone_destroy_session(teletone_generation_session_t *ts);
+
+       /*! 
+         \brief Execute a single tone generation instruction
+         \param ts the tone generation session to consult for parameters
+         \param map the tone mapping to use for the frequencies
+         \return 0
+       */
+       int teletone_mux_tones(teletone_generation_session_t *ts, teletone_tone_map_t *map);
+
+       /*! 
+         \brief Execute a tone generation script and call callbacks after each instruction
+         \param ts the tone generation session to execute on
+         \param cmd the script to execute
+         \return 0
+       */
+       int teletone_run(teletone_generation_session_t *ts, char *cmd);
 
 #ifdef __cplusplus
 }
index 1fdb372087627ca295e1a239e0cfcd21b0501508..53d2106d99eb4047e7c6242724d3b80ad9b0b681 100644 (file)
 
 #define zap_clear_flag_locked(obj, flag) assert(obj->mutex != NULL); zap_mutex_lock(obj->mutex); (obj)->flags &= ~(flag); zap_mutex_unlock(obj->mutex);
 
-#define zap_set_state_locked(obj, s) assert(obj->mutex != NULL); zap_mutex_lock(obj->mutex);\
-       zap_log(ZAP_LOG_DEBUG, "Changing state from %s to %s\n", zap_channel_state2str(obj->state), zap_channel_state2str(s));\
+#define zap_set_state_locked(obj, s) assert(obj->mutex != NULL); zap_mutex_lock(obj->mutex); \
+       zap_log(ZAP_LOG_DEBUG, "Changing state from %s to %s\n", zap_channel_state2str(obj->state), zap_channel_state2str(s)); \
        zap_channel_set_state(obj, s);
 
 
@@ -235,6 +235,8 @@ struct zap_caller_data {
 struct zap_channel {
        uint32_t span_id;
        uint32_t chan_id;
+       uint32_t physical_span_id;
+       uint32_t physical_chan_id;
        zap_chan_type_t type;
        zap_socket_t sockfd;
        zap_channel_flag_t flags;
@@ -263,11 +265,11 @@ struct zap_channel {
        char tokens[ZAP_MAX_TOKENS+1][ZAP_TOKEN_STRLEN];
        uint8_t needed_tones[ZAP_TONEMAP_INVALID];
        uint8_t detected_tones[ZAP_TONEMAP_INVALID];
-       zap_tonemap_t last_detected_tone;
-       
+       zap_tonemap_t last_detected_tone;       
        uint32_t token_count;
        char chan_name[128];
        char chan_number[32];
+       zap_filehandle_t fds[2];
        struct zap_caller_data caller_data;
        struct zap_span *span;
        struct zap_io_interface *zio;
@@ -384,3 +386,14 @@ ZIO_CODEC_FUNCTION(zio_alaw2ulaw);
 
 
 #endif
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index a9ef56add411857c66726b73a805e1ba13c2be84..d4e673cc5e7a5761b3bb081200700b52e82b8035 100644 (file)
@@ -43,10 +43,10 @@ struct iphdr {
        
 #if defined(__LITTLE_ENDIAN_BITFIELD)
        unsigned    ihl:4,
-                                                       version:4;
+               version:4;
 #elif defined (__BIG_ENDIAN_BITFIELD)
        unsigned    version:4,
-                                                       ihl:4;
+               ihl:4;
 #else
 # error  "unknown byteorder!"
 #endif
@@ -108,15 +108,15 @@ static __inline__ int tdmv_api_ioctl(sng_fd_t fd, wanpipe_tdm_api_t *tdm_api_cmd
        memcpy( wan_udp.wan_udphdr_data, (void*)tdm_api_cmd, sizeof(wanpipe_tdm_api_cmd_t));
 
        if (DeviceIoControl(
-                       fd,
-                       IoctlManagementCommand,
-                       (LPVOID)&wan_udp,
-                       sizeof(wan_udp_hdr_t),
-                       (LPVOID)&wan_udp,
-                       sizeof(wan_udp_hdr_t),
-                       (LPDWORD)(&ln),
-                       (LPOVERLAPPED)NULL
-                       ) == FALSE){
+                                               fd,
+                                               IoctlManagementCommand,
+                                               (LPVOID)&wan_udp,
+                                               sizeof(wan_udp_hdr_t),
+                                               (LPVOID)&wan_udp,
+                                               sizeof(wan_udp_hdr_t),
+                                               (LPDWORD)(&ln),
+                                               (LPOVERLAPPED)NULL
+                                               ) == FALSE){
                return 1;
        }
 
@@ -176,15 +176,15 @@ static __inline__ sng_fd_t tdmv_api_open_span_chan(int span, int chan)
        wan_udp.wan_udphdr_data_len = 0;
 
        DeviceIoControl(
-               fd,
-               IoctlManagementCommand,
-               (LPVOID)&wan_udp,
-               sizeof(wan_udp_hdr_t),
-               (LPVOID)&wan_udp,
-               sizeof(wan_udp_hdr_t),
-               (LPDWORD)(&ln),
-               (LPOVERLAPPED)NULL
-               );
+                                       fd,
+                                       IoctlManagementCommand,
+                                       (LPVOID)&wan_udp,
+                                       sizeof(wan_udp_hdr_t),
+                                       (LPVOID)&wan_udp,
+                                       sizeof(wan_udp_hdr_t),
+                                       (LPDWORD)(&ln),
+                                       (LPOVERLAPPED)NULL
+                                       );
 
        if ((wan_udp.wan_udphdr_return_code) || (*(int*)&wan_udp.wan_udphdr_data[0] != 1)){
                /* somone already has this channel, or somthing else is not right. */
@@ -230,21 +230,21 @@ static __inline__ int tdmv_api_wait_socket(sng_fd_t fd, int timeout, int *flags)
        api_poll.timeout = timeout;
 
        if (!DeviceIoControl(
-                       fd,
-                       IoctlApiPoll,
-                       (LPVOID)NULL,
-                       0L,
-                       (LPVOID)&api_poll,
-                       sizeof(API_POLL_STRUCT),
-                       (LPDWORD)(&ln),
-                       (LPOVERLAPPED)NULL)) {
+                                                fd,
+                                                IoctlApiPoll,
+                                                (LPVOID)NULL,
+                                                0L,
+                                                (LPVOID)&api_poll,
+                                                sizeof(API_POLL_STRUCT),
+                                                (LPDWORD)(&ln),
+                                                (LPOVERLAPPED)NULL)) {
                return -1;
        }
 
        *flags = 0;
 
        switch(api_poll.operation_status)
-       {
+               {
                case SANG_STATUS_RX_DATA_AVAILABLE:
                        break;
 
@@ -253,7 +253,7 @@ static __inline__ int tdmv_api_wait_socket(sng_fd_t fd, int timeout, int *flags)
 
                default:
                        return -1;
-       }
+               }
 
        if (api_poll.poll_events_bitmap == 0){
                return -1;
@@ -309,15 +309,15 @@ static __inline__ int tdmv_api_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen
        }
 
        if (!DeviceIoControl(
-                       fd,
-                       IoctlReadCommand,
-                       (LPVOID)NULL,
-                       0L,
-                       (LPVOID)&rx_data,
-                       sizeof(RX_DATA_STRUCT),
-                       (LPDWORD)(&ln),
-                       (LPOVERLAPPED)NULL
-                       )){
+                                                fd,
+                                                IoctlReadCommand,
+                                                (LPVOID)NULL,
+                                                0L,
+                                                (LPVOID)&rx_data,
+                                                sizeof(RX_DATA_STRUCT),
+                                                (LPDWORD)(&ln),
+                                                (LPOVERLAPPED)NULL
+                                                )){
                return -1;
        }
 
@@ -327,18 +327,18 @@ static __inline__ int tdmv_api_readmsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrlen
        user_buf->wp_tdm_api_event_type = pri->operation_status;
 
        switch(pri->operation_status)
-       {
-       case SANG_STATUS_RX_DATA_AVAILABLE:
-               if (pri->data_length > datalen){
+               {
+               case SANG_STATUS_RX_DATA_AVAILABLE:
+                       if (pri->data_length > datalen){
+                               break;
+                       }
+                       memcpy(databuf, rx_data.data, pri->data_length);
+                       rx_len = pri->data_length;
                        break;
-               }
-               memcpy(databuf, rx_data.data, pri->data_length);
-               rx_len = pri->data_length;
-               break;
 
-       default:
-               break;
-       }
+               default:
+                       break;
+               }
 
 #else
        struct msghdr msg;
@@ -386,15 +386,15 @@ static __inline__ int tdmv_api_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrle
        memcpy(local_tx_data.data, databuf, pri->data_length);
 
        if (!DeviceIoControl(
-                       fd,
-                       IoctlWriteCommand,
-                       (LPVOID)&local_tx_data,
-                       (ULONG)sizeof(TX_DATA_STRUCT),
-                       (LPVOID)&local_tx_data,
-                       sizeof(TX_DATA_STRUCT),
-                       (LPDWORD)(&ln),
-                       (LPOVERLAPPED)NULL
-                       )){
+                                                fd,
+                                                IoctlWriteCommand,
+                                                (LPVOID)&local_tx_data,
+                                                (ULONG)sizeof(TX_DATA_STRUCT),
+                                                (LPVOID)&local_tx_data,
+                                                sizeof(TX_DATA_STRUCT),
+                                                (LPDWORD)(&ln),
+                                                (LPOVERLAPPED)NULL
+                                                )){
                return -1;
        }
 
@@ -425,3 +425,15 @@ static __inline__ int tdmv_api_writemsg_tdm(sng_fd_t fd, void *hdrbuf, int hdrle
 }
 
 #endif /* _SANGOMA_TDM_API_H */
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index 82badfcea94bdb56218ad58d5d9c9161b5733ab6..5322463577bf34b7e26fa67ea29ab0182568ff5f 100644 (file)
@@ -46,3 +46,14 @@ zap_status_t zap_analog_start(zap_span_t *span);
 zap_status_t zap_analog_configure_span(zap_span_t *span, char *tonemap, uint32_t digit_timeout, uint32_t max_dialstr, zio_signal_cb_t sig_cb);
 
 #endif
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index 7117304a03eaf3c95dfc1b8a633f4f67ac9b400f..0aea34973d391598c27e65447e85d916d5fd5975 100644 (file)
@@ -47,3 +47,15 @@ zap_status_t zap_isdn_init(void);
 zap_status_t zap_isdn_configure_span(zap_span_t *span, Q921NetUser_t mode, Q931Dialect_t dialect, zio_signal_cb_t sig_cb);
 
 #endif
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index 9fdaadf7b5d22552c7428144147893329eca5675..a8a245837f4274663697035272e50d17f1e0ed77 100644 (file)
@@ -39,3 +39,14 @@ zap_status_t skel_init(zap_software_interface_t **zint);
 zap_status_t skel_destroy(void);
 
 #endif
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index 557f23ea51e64882f8657335ac025c4ec5da001c..1a9061429ebb8340c20b0d7b71d88feb39258869 100644 (file)
@@ -37,3 +37,15 @@ zap_status_t zap_mutex_trylock(zap_mutex_t *mutex);
 zap_status_t zap_mutex_unlock(zap_mutex_t *mutex);
 
 #endif
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index 3bd99d3b0d9182c7ed584dad982bce1b3a1dec96..607fa03366ead1d91d7daee9a9beabb244658db5 100644 (file)
@@ -41,10 +41,12 @@ typedef unsigned __int64 uint64_t;
 typedef unsigned __int32 uint32_t;
 typedef __int32 int32_t;
 typedef intptr_t zap_ssize_t;
+typedef int zap_filehandle_t;
 #else
 #include <stdint.h>
 typedef int zap_socket_t;
 typedef ssize_t zap_ssize_t;
+typedef int zap_filehandle_t;
 #endif
 
 typedef size_t zap_size_t;
@@ -167,8 +169,8 @@ typedef enum {
        ZAP_COMMAND_GET_CODEC,
        ZAP_COMMAND_SET_NATIVE_CODEC,
        ZAP_COMMAND_GET_NATIVE_CODEC,
-       ZAP_COMMAND_ENABLE_TONE_DETECT,
-       ZAP_COMMAND_DISABLE_TONE_DETECT,
+       ZAP_COMMAND_ENABLE_DTMF_DETECT,
+       ZAP_COMMAND_DISABLE_DTMF_DETECT,
        ZAP_COMMAND_SEND_DTMF,
        ZAP_COMMAND_SET_DTMF_ON_PERIOD,
        ZAP_COMMAND_GET_DTMF_ON_PERIOD,
@@ -180,6 +182,8 @@ typedef enum {
        ZAP_COMMAND_ONHOOK,
        ZAP_COMMAND_ENABLE_PROGRESS_DETECT,
        ZAP_COMMAND_DISABLE_PROGRESS_DETECT,
+       ZAP_COMMAND_TRACE_INPUT,
+       ZAP_COMMAND_TRACE_OUTPUT,
        ZAP_COMMAND_COUNT
 } zap_command_t;
 
@@ -322,3 +326,15 @@ typedef struct hashtable_itr zap_hash_itr_t;
 typedef struct key zap_hash_key_t;
 typedef struct value zap_hash_val_t;
 #endif
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index fa78f41f74c21c82f76c8c653a2a64d01d746c9e..0b2f4a9c48d2fe9ad58a6725b98b530321a0cb78 100644 (file)
@@ -39,3 +39,15 @@ zap_status_t wanpipe_init(zap_io_interface_t **zint);
 zap_status_t wanpipe_destroy(void);
 
 #endif
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index 1ad2e65c20e664d930c16e82a025053a7924d2aa..9f3287f6a4f89ea5792477c0f8ad88ba7ae48467 100644 (file)
@@ -229,3 +229,14 @@ zap_status_t zt_init(zap_io_interface_t **zint);
 zap_status_t zt_destroy(void);
 
 #endif
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index 8df7d569a4e386ea7d40a49561e2318b4a483cba..1af9b8fc43ab0598f098d39beaede3e11b97becc 100644 (file)
@@ -208,8 +208,8 @@ void teletone_multi_tone_init(teletone_multi_tone_t *mt, teletone_tone_map_t *ma
 }
 
 int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
-                                          int16_t sample_buffer[],
-                                          int samples)
+                                                               int16_t sample_buffer[],
+                                                               int samples)
 {
        int sample, limit, j, x = 0;
        teletone_process_t v1, famp;
@@ -295,8 +295,8 @@ int teletone_multi_tone_detect (teletone_multi_tone_t *mt,
 
 
 int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
-                 int16_t sample_buffer[],
-                 int samples)
+                                                 int16_t sample_buffer[],
+                                                 int samples)
 {
     teletone_process_t row_energy[GRID_FACTOR];
     teletone_process_t col_energy[GRID_FACTOR];
@@ -426,8 +426,8 @@ int teletone_dtmf_detect (teletone_dtmf_detect_state_t *dtmf_detect_state,
 
 
 int teletone_dtmf_get (teletone_dtmf_detect_state_t *dtmf_detect_state,
-              char *buf,
-              int max)
+                                          char *buf,
+                                          int max)
 {
     if (max > dtmf_detect_state->current_digits) {
         max = dtmf_detect_state->current_digits;
index 5612e19a15b24abe94a5039014cbe5cfd53ddda9..9126a186afa384d443b20cdbc976c96a13391cea 100644 (file)
@@ -137,11 +137,11 @@ static void launch_channel(struct sangoma_pri *spri, int channo)
 
                if (!lead && loops == 300) {
 #if 1
-       if (zap_channel_command(chan, ZAP_COMMAND_SEND_DTMF, dtmf) != ZAP_SUCCESS) {
-               printf("Critical Error: Failed to send dtmf\n");
-               zap_channel_close(&chan);
-               exit(-1);
-       }
+                       if (zap_channel_command(chan, ZAP_COMMAND_SEND_DTMF, dtmf) != ZAP_SUCCESS) {
+                               printf("Critical Error: Failed to send dtmf\n");
+                               zap_channel_close(&chan);
+                               exit(-1);
+                       }
 #endif
 
                }
@@ -314,3 +314,13 @@ int main(int argc, char *argv[])
        return 0;
 }
 
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index b4692216d00bf44fe96ce93c5fd05008a1dc968b..865fe4f4767800432d78e07a18ba31c9909461f4 100644 (file)
 static __inline int gettimeofday(struct timeval *tp, void *nothing)
 {
 #ifdef WITHOUT_MM_LIB
-  SYSTEMTIME st;
-  time_t tt;
-  struct tm tmtm;
-  /* mktime converts local to UTC */
-  GetLocalTime (&st);
-  tmtm.tm_sec = st.wSecond;
-  tmtm.tm_min = st.wMinute;
-  tmtm.tm_hour = st.wHour;
-  tmtm.tm_mday = st.wDay;
-  tmtm.tm_mon = st.wMonth - 1;
-  tmtm.tm_year = st.wYear - 1900;  tmtm.tm_isdst = -1;
-  tt = mktime (&tmtm);
-  tp->tv_sec = tt;
-  tp->tv_usec = st.wMilliseconds * 1000;
+       SYSTEMTIME st;
+       time_t tt;
+       struct tm tmtm;
+       /* mktime converts local to UTC */
+       GetLocalTime (&st);
+       tmtm.tm_sec = st.wSecond;
+       tmtm.tm_min = st.wMinute;
+       tmtm.tm_hour = st.wHour;
+       tmtm.tm_mday = st.wDay;
+       tmtm.tm_mon = st.wMonth - 1;
+       tmtm.tm_year = st.wYear - 1900;  tmtm.tm_isdst = -1;
+       tt = mktime (&tmtm);
+       tp->tv_sec = tt;
+       tp->tv_usec = st.wMilliseconds * 1000;
 #else
-  /**
-   ** The earlier time calculations using GetLocalTime
-   ** had a time resolution of 10ms.The timeGetTime, part
-   ** of multimedia apis offer a better time resolution
-   ** of 1ms.Need to link against winmm.lib for this
-   **/
-  unsigned long Ticks = 0;
-  unsigned long Sec =0;
-  unsigned long Usec = 0;
-  Ticks = timeGetTime();
-
-  Sec = Ticks/1000;
-  Usec = (Ticks - (Sec*1000))*1000;
-  tp->tv_sec = Sec;
-  tp->tv_usec = Usec;
+       /**
+        ** The earlier time calculations using GetLocalTime
+        ** had a time resolution of 10ms.The timeGetTime, part
+        ** of multimedia apis offer a better time resolution
+        ** of 1ms.Need to link against winmm.lib for this
+        **/
+       unsigned long Ticks = 0;
+       unsigned long Sec =0;
+       unsigned long Usec = 0;
+       Ticks = timeGetTime();
+
+       Sec = Ticks/1000;
+       Usec = (Ticks - (Sec*1000))*1000;
+       tp->tv_sec = Sec;
+       tp->tv_usec = Usec;
 #endif /* WITHOUT_MM_LIB */
-  (void)nothing;
-  return 0;
+       (void)nothing;
+       return 0;
 }
 #endif /* WIN32 */
 #endif /* HAVE_GETTIMEOFDAY */
@@ -166,7 +166,7 @@ int sangoma_one_loop(struct sangoma_pri *spri)
        FD_ZERO(&efds);
 
 #ifdef _MSC_VER
-//Windows macro for FD_SET includes a warning C4127: conditional expression is constant
+       //Windows macro for FD_SET includes a warning C4127: conditional expression is constant
 #pragma warning(push)
 #pragma warning(disable:4127)
 #endif
@@ -238,3 +238,14 @@ int sangoma_run_pri(struct sangoma_pri *spri)
 
 }
 
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index e1f17d23fddd9aed974117646de8fb85d68e6e81..cd480e2ba541dd8856fe025d137f9c714f1e7a57 100644 (file)
@@ -100,3 +100,15 @@ int main(int argc, char *argv[])
        zap_global_destroy();
 
 }
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index 12b22b30b32109dd7568425c1172e4aafdeaa8d9..4f00ca600b39e7fe287830e54c72d16dbdca93f4 100644 (file)
@@ -72,3 +72,14 @@ int main(int argc, char *argv[])
        zap_global_destroy();
 
 }
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index d268436eb5bc292d41f57a22320c8bb0e6987133..93af26f752697c4d7361e3cae0432579c94260cf 100644 (file)
@@ -41,3 +41,14 @@ int main(int argc, char *argv[])
        zap_global_destroy();
 
 }
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index ada2ca804e314944c159f731cdb76493b5c52411..e8944f2db6c984c06c76124cd874ebc190c029f0 100644 (file)
@@ -135,7 +135,7 @@ static void *zap_analog_channel_run(zap_thread_t *me, void *obj)
                goto done;
        }
 
-       if (zap_channel_command(chan, ZAP_COMMAND_ENABLE_TONE_DETECT, &tt) != ZAP_SUCCESS) {
+       if (zap_channel_command(chan, ZAP_COMMAND_ENABLE_DTMF_DETECT, &tt) != ZAP_SUCCESS) {
                snprintf(chan->last_error, sizeof(chan->last_error), "error initilizing tone detector!");
                goto done;
        }
@@ -483,6 +483,7 @@ static zap_status_t process_event(zap_span_t *span, zap_event_t *event)
                {
 
                        if (event->channel->state == ZAP_CHANNEL_STATE_DOWN && !zap_test_flag(event->channel, ZAP_CHANNEL_INTHREAD)) {
+                               /*zap_channel_command(event->channel, ZAP_COMMAND_TRACE_INPUT, "/tmp/inbound.ul");*/
                                sig.event_id = ZAP_SIGEVENT_START;
                                zap_set_string(event->channel->caller_data.dnis, event->channel->chan_number);
                                data->sig_cb(&sig);
@@ -585,3 +586,13 @@ zap_status_t zap_analog_start(zap_span_t *span)
        return zap_thread_create_detached(zap_analog_run, span);
 }
 
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index d4edbe6e29e5adc7e0ca4852b8f80c39e4ab9cf3..1db918665d214b8ca383f886659cc376acc548c6 100644 (file)
@@ -197,11 +197,11 @@ zap_size_t zap_buffer_write(zap_buffer_t *buffer, const void *data, zap_size_t d
        freespace = buffer->datalen - buffer->used;
 
        /*
-          if (buffer->data != buffer->head) {
-          memmove(buffer->data, buffer->head, buffer->used);
-          buffer->head = buffer->data;
-          }
-        */
+         if (buffer->data != buffer->head) {
+         memmove(buffer->data, buffer->head, buffer->used);
+         buffer->head = buffer->data;
+         }
+       */
        
        if (freespace < datalen) {
                zap_size_t new_size, new_block_size;
index 3877d5213dfedbd0f44fe476daf9f332fe0c2238..bec1c5a1e84f05a036cc48bd5c66f1da08015711 100644 (file)
@@ -332,6 +332,8 @@ zap_status_t zap_span_add_channel(zap_span_t *span, zap_socket_t sockfd, zap_cha
                new_chan->span_id = span->span_id;
                new_chan->chan_id = span->chan_count;
                new_chan->span = span;
+               new_chan->fds[0] = -1;
+               new_chan->fds[1] = -1;
                zap_mutex_create(&new_chan->mutex);
                zap_buffer_create(&new_chan->digit_buffer, 128, 128, 0);
                zap_set_flag(new_chan, ZAP_CHANNEL_CONFIGURED | ZAP_CHANNEL_READY);
@@ -689,12 +691,18 @@ zap_status_t zap_channel_outgoing_call(zap_channel_t *zchan)
 
 zap_status_t zap_channel_done(zap_channel_t *zchan)
 {
+       int i;
 
        assert(zchan != NULL);
 
        memset(&zchan->caller_data, 0, sizeof(zchan->caller_data));
        zap_clear_flag_locked(zchan, ZAP_CHANNEL_INUSE);
-
+       for (i = 0; i < 2; i++) {
+               if (zchan->fds[i] > -1) {
+                       close(zchan->fds[i]);
+                       zchan->fds[i] = -1;
+               }
+       }
        return ZAP_SUCCESS;
 }
 
@@ -780,6 +788,36 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo
        zap_mutex_lock(zchan->mutex);
 
        switch(command) {
+       case ZAP_COMMAND_TRACE_INPUT:
+               {
+                       char *path = (char *) obj;
+                       if (zchan->fds[0] > 0) {
+                               close(zchan->fds[0]);
+                               zchan->fds[0] = -1;
+                       }
+                       if ((zchan->fds[0] = open(path, O_WRONLY|O_CREAT|O_TRUNC, 755)) > -1) {
+                               GOTO_STATUS(done, ZAP_SUCCESS);
+                       }
+                       
+                       snprintf(zchan->last_error, sizeof(zchan->last_error), "%s", strerror(errno));
+                       GOTO_STATUS(done, ZAP_FAIL);
+               }
+               break;
+       case ZAP_COMMAND_TRACE_OUTPUT:
+               {
+                       char *path = (char *) obj;
+                       if (zchan->fds[1] > 0) {
+                               close(zchan->fds[0]);
+                               zchan->fds[1] = -1;
+                       }
+                       if ((zchan->fds[1] = open(path, O_WRONLY|O_CREAT|O_TRUNC, 755)) > -1) {
+                               GOTO_STATUS(done, ZAP_SUCCESS);
+                       }
+                       
+                       snprintf(zchan->last_error, sizeof(zchan->last_error), "%s", strerror(errno));
+                       GOTO_STATUS(done, ZAP_FAIL);
+               }
+               break;
        case ZAP_COMMAND_SET_INTERVAL:
                {
                        if (!zap_channel_test_feature(zchan, ZAP_CHANNEL_FEATURE_INTERVAL)) {
@@ -863,7 +901,7 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo
                        GOTO_STATUS(done, ZAP_SUCCESS);
                }
                break;
-       case ZAP_COMMAND_ENABLE_TONE_DETECT:
+       case ZAP_COMMAND_ENABLE_DTMF_DETECT:
                {
                        /* if they don't have thier own, use ours */
                        if (!zap_channel_test_feature(zchan, ZAP_CHANNEL_FEATURE_DTMF)) {
@@ -880,7 +918,7 @@ zap_status_t zap_channel_command(zap_channel_t *zchan, zap_command_t command, vo
                        }
                }
                break;
-       case ZAP_COMMAND_DISABLE_TONE_DETECT:
+       case ZAP_COMMAND_DISABLE_DTMF_DETECT:
                {
                        if (!zap_channel_test_feature(zchan, ZAP_CHANNEL_FEATURE_DTMF)) {
                                zap_tone_type_t tt = ZAP_COMMAND_OBJ_INT;
@@ -1216,6 +1254,9 @@ zap_status_t zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *data
        }
 
     status = zchan->zio->read(zchan, data, datalen);
+       if (zchan->fds[0]) {
+               write(zchan->fds[0], data, *datalen);
+       }
 
        if (status == ZAP_SUCCESS && zap_test_flag(zchan, ZAP_CHANNEL_TRANSCODE) && zchan->effective_codec != zchan->native_codec) {
                if (zchan->native_codec == ZAP_CODEC_ULAW && zchan->effective_codec == ZAP_CODEC_SLIN) {
@@ -1391,6 +1432,10 @@ zap_status_t zap_channel_write(zap_channel_t *zchan, void *data, zap_size_t data
                
        } 
 
+       if (zchan->fds[1]) {
+               write(zchan->fds[1], data, *datalen);
+       }
+
     status = zchan->zio->write(zchan, data, datalen);
 
        return status;
@@ -1731,3 +1776,13 @@ void print_bits(uint8_t *b, int bl, char *buf, int blen, int e)
 }
 
 
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index a8e72814605e54630b6484ba5ab4c7b922a8e195..76ad83ca2564fa61d0392fc666793ab023d4597c 100644 (file)
@@ -250,3 +250,14 @@ zap_status_t zap_isdn_configure_span(zap_span_t *span, Q921NetUser_t mode, Q931D
        
        return ZAP_SUCCESS;
 }
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index 4341309649dff2050ee8e2e252e8f076ff8ab11f..c5e9a0e85d5b225e3af5d1697781ff323af77b69 100644 (file)
@@ -108,3 +108,15 @@ zap_status_t skel_destroy(void)
 {
        return ZAP_FAIL;
 }
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
+
index 34e23bec5c5a3dd7b966890d650e096cc35cdc5b..e82d6a39377f8f0607215d94086c5b535a7331f8 100644 (file)
@@ -119,15 +119,15 @@ zap_status_t zap_thread_create_detached_ex(zap_thread_function_t func, void *dat
 
        status = ZAP_SUCCESS;
        goto done;
-failpthread:
+ failpthread:
        pthread_attr_destroy(&thread->attribute);
 #endif
 
-fail:
+ fail:
        if (thread) {
                free(thread);
        }
-done:
+ done:
        return status;
 }
 
@@ -157,16 +157,16 @@ zap_status_t zap_mutex_create(zap_mutex_t **mutex)
 
        goto success;
 
-fail:
-        pthread_mutexattr_destroy(&attr);
-               goto done;
+ fail:
+       pthread_mutexattr_destroy(&attr);
+       goto done;
 
-success:
+ success:
 #endif
        *mutex = check;
        status = ZAP_SUCCESS;
 
-done:
+ done:
        return status;
 }
 
@@ -217,3 +217,14 @@ zap_status_t zap_mutex_unlock(zap_mutex_t *mutex)
 #endif
        return ZAP_SUCCESS;
 }
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index de3da19d59cdb826e5e717e1c7d53e7bdee0fc43..3e9e7501deefee400add1dc81b8a774b04fb7d49 100644 (file)
@@ -72,6 +72,8 @@ static unsigned wp_open_range(zap_span_t *span, unsigned spanno, unsigned start,
                
                if (sockfd != WP_INVALID_SOCKET && zap_span_add_channel(span, sockfd, type, &chan) == ZAP_SUCCESS) {
                        zap_log(ZAP_LOG_INFO, "configuring device s%dc%d as OpenZAP device %d:%d fd:%d\n", spanno, x, chan->span_id, chan->chan_id, sockfd);
+                       chan->physical_span_id = spanno;
+                       chan->physical_chan_id = x;
                        if (type == ZAP_CHAN_TYPE_FXS || type == ZAP_CHAN_TYPE_FXO) {
                                wanpipe_tdm_api_t tdm_api;
 
@@ -532,3 +534,14 @@ zap_status_t wanpipe_destroy(void)
        memset(&wanpipe_interface, 0, sizeof(wanpipe_interface));
        return ZAP_SUCCESS;
 }
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */
index bafc191117ba47c1e8194e5f6d5494d4c225d8f0..49d9edea60a0a438c70a0b83de0f7551aca53413 100644 (file)
@@ -90,6 +90,9 @@ static unsigned zt_open_range(zap_span_t *span, unsigned start, unsigned end, za
                        }
                        zap_log(ZAP_LOG_INFO, "configuring device %s as OpenZAP device %d:%d fd:%d\n", path, chan->span_id, chan->chan_id, sockfd);
 
+                       chan->physical_span_id = ztp.span_no;
+                       chan->physical_chan_id = ztp.chan_no;
+                       
                        if (type == ZAP_CHAN_TYPE_FXS || type == ZAP_CHAN_TYPE_FXO) {
                                if (ztp.g711_type == ZT_G711_ALAW) {
                                        chan->native_codec = chan->effective_codec = ZAP_CODEC_ALAW;
@@ -559,3 +562,14 @@ zap_status_t zt_destroy(void)
        memset(&zt_interface, 0, sizeof(zt_interface));
        return ZAP_SUCCESS;
 }
+
+/* For Emacs:
+ * Local Variables:
+ * mode:c
+ * indent-tabs-mode:t
+ * tab-width:4
+ * c-basic-offset:4
+ * End:
+ * For VIM:
+ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
+ */