root/src/ftmod/ftmod_pika/ftdm_pika.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. PIKA_STR2ENUM_P
  2. PIKA_STR2ENUM_P
  3. PIKA_STR2ENUM_P
  4. PIKA_STR2ENUM_P

   1 /*
   2  * Copyright (c) 2007, Anthony Minessale II
   3  * All rights reserved.
   4  * 
   5  * Redistribution and use in source and binary forms, with or without
   6  * modification, are permitted provided that the following conditions
   7  * are met:
   8  * 
   9  * * Redistributions of source code must retain the above copyright
  10  * notice, this list of conditions and the following disclaimer.
  11  * 
  12  * * Redistributions in binary form must reproduce the above copyright
  13  * notice, this list of conditions and the following disclaimer in the
  14  * documentation and/or other materials provided with the distribution.
  15  * 
  16  * * Neither the name of the original author; nor the names of any contributors
  17  * may be used to endorse or promote products derived from this software
  18  * without specific prior written permission.
  19  * 
  20  * 
  21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24  * A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER
  25  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32  */
  33 
  34 #ifndef FTDM_PIKA_H
  35 #define FTDM_PIKA_H
  36 #include "freetdm.h"
  37 #include "pikahmpapi.h"
  38 
  39 
  40 
  41 #define PIKA_STR2ENUM_P(_FUNC1, _FUNC2, _TYPE) _TYPE _FUNC1 (const char *name); const char * _FUNC2 (_TYPE type);
  42 #define PIKA_STR2ENUM(_FUNC1, _FUNC2, _TYPE, _STRINGS, _MAX)    \
  43         _TYPE _FUNC1 (const char *name)                                                         \
  44         {                                                                                                               \
  45                 int i;                                                                                          \
  46                 _TYPE t = _MAX ;                                                                        \
  47                                                                                                                         \
  48                 for (i = 0; i < _MAX ; i++) {                                           \
  49                         if (!strcasecmp(name, _STRINGS[i])) {                   \
  50                                 t = (_TYPE) i;                                                          \
  51                                 break;                                                                          \
  52                         }                                                                                               \
  53                 }                                                                                                       \
  54                                                                                                                         \
  55                 return t;                                                                                       \
  56         }                                                                                                               \
  57         const char * _FUNC2 (_TYPE type)                                                \
  58         {                                                                                                               \
  59                 if (type > _MAX) {                                                                      \
  60                         type = _MAX;                                                                    \
  61                 }                                                                                                       \
  62                 return _STRINGS[(int)type];                                                     \
  63         }
  64 
  65 
  66 typedef enum {
  67         PIKA_SPAN_FRAMING_T1_D4,
  68         PIKA_SPAN_FRAMING_T1_ESF,
  69         PIKA_SPAN_FRAMING_E1_BASIC,
  70         PIKA_SPAN_FRAMING_E1_CRC4,
  71         PIKA_SPAN_INVALID
  72 } PIKA_TSpanFraming;
  73 #define PIKA_SPAN_STRINGS "T1_D4", "T1_ESF", "E1_BASIC", "E1_CRC4"
  74 PIKA_STR2ENUM_P(pika_str2span, pika_span2str, PIKA_TSpanFraming)
  75 
  76 typedef enum {
  77         PIKA_SPAN_ENCODING_T1_AMI_ZS_NONE,
  78         PIKA_SPAN_ENCODING_T1_AMI_ZS_GTE,
  79         PIKA_SPAN_ENCODING_T1_AMI_ZS_BELL,
  80         PIKA_SPAN_ENCODING_T1_AMI_ZS_JAM8,
  81         PIKA_SPAN_ENCODING_T1_B8ZS,
  82         PIKA_SPAN_ENCODING_E1_AMI,
  83         PIKA_SPAN_ENCODING_E1_HDB3,
  84         PIKA_SPAN_ENCODING_INVALID
  85 } PIKA_TSpanEncoding;
  86 #define PIKA_SPAN_ENCODING_STRINGS "T1_AMI_ZS_NONE", "T1_AMI_ZS_GTE", "T1_AMI_ZS_BELL", "T1_AMI_ZS_JAM8", "T1_B8ZS", "E1_AMI", "E1_HDB3"
  87 PIKA_STR2ENUM_P(pika_str2span_encoding, pika_span_encoding2str, PIKA_TSpanEncoding)
  88 
  89 typedef enum {
  90         PIKA_SPAN_LOOP_LENGTH_SHORT_HAUL,
  91         PIKA_SPAN_LOOP_LENGTH_LONG_HAUL,
  92         PIKA_SPAN_LOOP_INVALID
  93 } PIKA_TSpanLoopLength;
  94 #define PIKA_LL_STRINGS "SHORT_HAUL", "LONG_HAUL"
  95 PIKA_STR2ENUM_P(pika_str2loop_length, pika_loop_length2str, PIKA_TSpanLoopLength)
  96 
  97 typedef enum {
  98         PIKA_SPAN_LBO_T1_LONG_0_DB,
  99         PIKA_SPAN_LBO_T1_LONG_7_DB,
 100         PIKA_SPAN_LBO_T1_LONG_15_DB,
 101         PIKA_SPAN_LBO_T1_LONG_22_DB,
 102         PIKA_SPAN_LBO_T1_SHORT_133_FT,
 103         PIKA_SPAN_LBO_T1_SHORT_266_FT,
 104         PIKA_SPAN_LBO_T1_SHORT_399_FT,
 105         PIKA_SPAN_LBO_T1_SHORT_533_FT,
 106         PIKA_SPAN_LBO_T1_SHORT_655_FT,
 107         PIKA_SPAN_LBO_E1_WAVEFORM_120_OHM,
 108         PIKA_SPAN_LBO_INVALID
 109 } PIKA_TSpanBuildOut;
 110 #define PIKA_LBO_STRINGS "T1_LONG_0_DB", "T1_LONG_7_DB", "T1_LONG_15_DB", "T1_LONG_22_DB", "T1_SHORT_133_FT", "T1_SHORT_266_FT", "T1_SHORT_399_FT", "T1_SHORT_533_FT", "T1_SHORT_655_FT", "E1_WAVEFORM_120_OHM"
 111 PIKA_STR2ENUM_P(pika_str2lbo, pika_lbo2str, PIKA_TSpanBuildOut)
 112 
 113 typedef enum {
 114         PIKA_SPAN_COMPAND_MODE_MU_LAW = 1,
 115         PIKA_SPAN_COMPAND_MODE_A_LAW,
 116         PIKA_SPAN_COMPAND_MODE_INVALID
 117 } PIKA_TSpanCompandMode;
 118 #define PIKA_SPAN_COMPAND_MODE_STRINGS "MU_LAW", "A_LAW"
 119 PIKA_STR2ENUM_P(pika_str2compand_mode, pika_compand_mode2str, PIKA_TSpanCompandMode)
 120 
 121 #endif
 122 
 123 /* For Emacs:
 124  * Local Variables:
 125  * mode:c
 126  * indent-tabs-mode:t
 127  * tab-width:4
 128  * c-basic-offset:4
 129  * End:
 130  * For VIM:
 131  * vim:set softtabstop=4 shiftwidth=4 tabstop=4:
 132  */

/* [<][>][^][v][top][bottom][index][help] */