Exemplo n.º 1
0
/*
 * capset_set_fcp_forwardall - sets the fcp-controlled call forward all feature
 *
 */
static void capset_set_fcp_forwardall (cc_boolean state)
{
   CONFIG_DEBUG(DEB_F_PREFIX"FCP Setting CALLFWD Capability to [%d]", DEB_F_PREFIX_ARGS(JNI, "capset_set_fcp_forwardall"), (unsigned int)state);

   capability_idleset[CCAPI_CALL_CAP_CALLFWD]       = state;
   capability_set[OFFHOOK][CCAPI_CALL_CAP_CALLFWD]  = state;
}
Exemplo n.º 2
0
/*
 *  Function: config_get_string()
 *
 *  Description: Get any arbitrary config entry as a string
 *
 *  Parameters: id - The id of the config string to get
 *              buffer - Empty buffer where string will be copied
 *              buffer_len -  length of the buffer where string will be copied
 *
 *  Returns: None
 */
void
config_get_string (int id, char *buffer, int buffer_len)
{
    const var_t *entry;
    char *buf_start;

    /*
     * Set the result to be empty in case we can't find anything
     */
    buffer[0] = 0;
    if ((id >= 0) && (id < CFGID_PROTOCOL_MAX)) {
        entry = &prot_cfg_table[id];
        if (entry->length > buffer_len) {
            CONFIG_ERROR(CFG_F_PREFIX"insufficient buffer: %d\n", "config_get_string",
                    id);
        } else {
            buf_start = buffer;
            entry->print_func(entry, buffer, buffer_len);
            CONFIG_DEBUG(DEB_F_PREFIX"CFGID %d: get str: %s = %s\n", DEB_F_PREFIX_ARGS(CONFIG_API, "config_get_string"), id, entry->name,
                         buf_start);
        }
    } else {
        CONFIG_ERROR(CFG_F_PREFIX"Invalid ID: %d\n", "config_get_string", id);
    }
}
Exemplo n.º 3
0
/*
 * capset_set_fcp_redial - sets the fcp-controlled redial feature
 *
 */
static void capset_set_fcp_redial (cc_boolean state)
{
   CONFIG_DEBUG(DEB_F_PREFIX"FCP Setting REDIAL capability to [%d]", DEB_F_PREFIX_ARGS(JNI, "capset_set_fcp_redial"), (unsigned int)state);

   capability_idleset[CCAPI_CALL_CAP_REDIAL]        = state;
   capability_set[OFFHOOK][CCAPI_CALL_CAP_REDIAL]   = state;
   capability_set[ONHOOK][CCAPI_CALL_CAP_REDIAL]    = state;
}
Exemplo n.º 4
0
/*
 * Some logical upper limit to avoid long print out in case
 * of large length value
 */
void
print_config_value (int id, char *get_set, const char *entry_name,
                    void *buffer, int length)
{
    long  long_val  = 0;
    int   int_val   = 0;
    short short_val = 0;
    char  char_val  = 0;
    char  str[MAX_CONFIG_VAL_PRINT_LEN];
    char *in_ptr;
    char *str_ptr;

    if (length == sizeof(char)) {
        char_val = *(char *) buffer;
        long_val = (long) char_val;
        CONFIG_DEBUG(DEB_F_PREFIX"CFGID %d: %s: %s = %ld\n", DEB_F_PREFIX_ARGS(CONFIG_API, "print_config_value"), id, get_set, entry_name,
                     long_val);
    } else if (length == sizeof(short)) {
        short_val = *(short *) buffer;
        long_val = (long) short_val;
        CONFIG_DEBUG(DEB_F_PREFIX"CFGID %d: %s: %s = %ld\n", DEB_F_PREFIX_ARGS(CONFIG_API, "print_config_value"), id, get_set, entry_name,
                     long_val);
    } else if (length == sizeof(int)) {
        int_val = *(int *) buffer;
        long_val = (long) int_val;
        CONFIG_DEBUG(DEB_F_PREFIX"CFGID %d: %s: %s = %ld\n", DEB_F_PREFIX_ARGS(CONFIG_API, "print_config_value"), id, get_set, entry_name,
                     long_val);
    } else if (length == sizeof(long)) {
        long_val = *(long *) buffer;
        CONFIG_DEBUG(DEB_F_PREFIX"CFGID %d: %s: %s = %ld\n", DEB_F_PREFIX_ARGS(CONFIG_API, "print_config_value"), id, get_set, entry_name,
                     long_val);
    } else if (length < MAX_CONFIG_VAL_PRINT_LEN / 2) {

        in_ptr = (char *) buffer;
        str_ptr = &str[0];
        while (length--) {
            sprintf(str_ptr++, "%02x", *in_ptr++);
            str_ptr++;
        }
        *str_ptr = '\0';
        CONFIG_DEBUG(DEB_F_PREFIX"CFGID %d: %s: %s = %s\n", DEB_F_PREFIX_ARGS(CONFIG_API, "print_config_value"), id, get_set, entry_name, str);
    } else {
        CONFIG_ERROR(CFG_F_PREFIX"cfg_id = %d length too long -> %d\n", "print_config_value",
                id, length);
    }
}
Exemplo n.º 5
0
/*
 *  Function: config_set_string()
 *
 *  Parameters: id - The id of the config string to set
 *              buffer - The new value for the string
 *
 *  Description: Set any arbitrary config entry as a string
 *
 *  Returns: None
 */
void
config_set_string (int id, char *buffer)
{
    const var_t *entry;

    if ((id >= 0) && (id < CFGID_PROTOCOL_MAX)) {
        entry = &prot_cfg_table[id];
        if (entry->parse_func(entry, buffer)) {
            /* Parse function returned an error */
            CONFIG_ERROR(CFG_F_PREFIX"Parse function failed. ID: %d %s:%s\n", "config_set_string", id, entry->name, buffer);
        } else {
            CONFIG_DEBUG(DEB_F_PREFIX"CFGID %d: %s set str to %s\n", DEB_F_PREFIX_ARGS(CONFIG_API, "config_set_string"), id, entry->name,
                         buffer);
        }
    } else {
        CONFIG_ERROR(CFG_F_PREFIX"Invalid ID: %d\n", "config_set_string", id);
    }
}
Exemplo n.º 6
0
/*
 * capset_init - initialize the internal capability data structures to defaults
 *
 */
static void capset_init ()
{
   // initialize the 4 tables related to capability set to false
   memset(capability_idleset, 0, sizeof(capability_idleset));
   memset(capability_set, 0, sizeof(capability_set));

   // ----------------------------------------------------------------------
   // FCP based capabilities
   // ----------------------------------------------------------------------

   CONFIG_DEBUG(DEB_F_PREFIX"FCP Initializing Capabilities to default", DEB_F_PREFIX_ARGS(JNI, "capset_init"));

   // ----------------------------------------------------------------------
   // Non-FCP-based Capabilities
   // ----------------------------------------------------------------------

   // Now, set all the non-FCP based capabilities to appropriate default settings
   // (some of which may be enabled by default)

   capability_idleset[CCAPI_CALL_CAP_NEWCALL]                    = TRUE;

   // call-state based settings
   // offhook
   capability_set[OFFHOOK][CCAPI_CALL_CAP_ENDCALL]               = TRUE;

   // onhook
   capability_set[ONHOOK][CCAPI_CALL_CAP_NEWCALL] = TRUE;

   // ringout
   capability_set[RINGOUT][CCAPI_CALL_CAP_ENDCALL] = TRUE;

   // ringing
   capability_set[RINGIN][CCAPI_CALL_CAP_ANSWER] = TRUE;

   // proceed
   capability_set[PROCEED][CCAPI_CALL_CAP_ENDCALL] = TRUE;

   // connected
   capability_set[CONNECTED][CCAPI_CALL_CAP_ENDCALL] = TRUE;
   capability_set[CONNECTED][CCAPI_CALL_CAP_HOLD] = TRUE;
   capability_set[CONNECTED][CCAPI_CALL_CAP_TRANSFER] = TRUE;
   capability_set[CONNECTED][CCAPI_CALL_CAP_CONFERENCE] = TRUE;
   capability_set[CONNECTED][CCAPI_CALL_CAP_SELECT] = TRUE;

   // hold
   capability_set[HOLD][CCAPI_CALL_CAP_RESUME] = TRUE;
   capability_set[REMHOLD][CCAPI_CALL_CAP_RESUME] = TRUE;

   // busy
   capability_set[BUSY][CCAPI_CALL_CAP_ENDCALL] = TRUE;

   // reorder
   capability_set[REORDER][CCAPI_CALL_CAP_ENDCALL] = TRUE;

   // dialing
   capability_set[DIALING][CCAPI_CALL_CAP_ENDCALL] = TRUE;
   capability_set[DIALING][CCAPI_CALL_CAP_DIAL] = TRUE;
   capability_set[DIALING][CCAPI_CALL_CAP_SENDDIGIT] = TRUE;
   capability_set[DIALING][CCAPI_CALL_CAP_BACKSPACE] = TRUE;

   // holdrevert
   capability_set[HOLDREVERT][CCAPI_CALL_CAP_ANSWER] = TRUE;

   // preservation
   capability_set[PRESERVATION][CCAPI_CALL_CAP_ENDCALL] = TRUE;

   // waiting for digits
   capability_set[WAITINGFORDIGITS][CCAPI_CALL_CAP_SENDDIGIT] = TRUE;
   capability_set[WAITINGFORDIGITS][CCAPI_CALL_CAP_BACKSPACE] = TRUE;
}
Exemplo n.º 7
0
  //--------------------------------------
  //  ParseStrainFile
  //--------------------------------------
  bool StrainConfigFile::Parse( const std::string & sBuf )
  {
    bool *vInitializationCheck;
    vInitializationCheck = new bool[ StrainOpt::eNumKeywords ]; 
    
    for ( Int i = 0; i < StrainOpt::eNumKeywords; i ++ )
      vInitializationCheck[i] = false;

    std::vector< std::vector< std::string> > vsTokens;
    GeneralLib::Tokenize( vsTokens, sBuf, " \t\n");
    for(Size_Type i = 0; i < vsTokens.size(); i ++)
    {
      Size_Type iFirstToken;
      
      if ( vsTokens[i].size() == 0 )
      {
        iFirstToken = StrainOpt::eComment;
      }
      else if ( vsTokens[i][0].find_first_of( StrainOpt::Keywords[ StrainOpt::eComment ] )
                == 0 ) // if first token is comment
      {
        iFirstToken = StrainOpt::eComment;
      }
      else
      {
        // Identify the keyword in the beginning of the line (i.e., vertex? texture?
        for( iFirstToken = 0;
             iFirstToken < StrainOpt::eNumKeywords; iFirstToken ++)
        {
          if( strcmp( StrainOpt::Keywords[iFirstToken], vsTokens[i][0].c_str()) == 0 )
            break;
        }
        CONFIG_DEBUG( std::cout << i + 1 << " " << StrainOpt::Keywords[iFirstToken] << " "
                      << vsTokens[i][0].c_str() << " Token " << iFirstToken << endl ); 
      }
      
      switch( iFirstToken )   // look at first token of each line
      {
        case StrainOpt::eComment:  
          break;
        case StrainOpt::eStrainSearchType:
          SearchType = StrainOpt::ProcessSearchType( vsTokens[i], i );
          break;
        case StrainOpt::eStrainType:
          StrainType = StrainOpt::ProcessStrainType( vsTokens[i], i );
          break;
        case StrainOpt::eOptimizationMethod:
          OptimizationMethod = StrainOpt::ProcessOptMethod( vsTokens[i], i );
          break;
        case StrainOpt::eStrainStepSize:
          StrainSteps = StrainOpt::ParseMatrix( vsTokens, i );
          i += 2; // need to skip the matrix
          break;
        case StrainOpt::eMaxStrainStep:
          nMaxSteps =  InitFileIO::ExtractInt( vsTokens[i], i );
          break;
        case StrainOpt::eConvergenceMethod:
          boost::tie( ConvergenceMethod, fConvergenceThresh )
            = StrainOpt::ProcessConvergenceMethod( vsTokens[i], i );
          break;
          
        default:
          {
            cerr << "[StrainConfig] Error: syntax not recognized:  Line " <<  i  << endl;
            exit(0);
            return false;
          }
      }
      vInitializationCheck[ iFirstToken ] = true;
    }

    bool bMissingTokens = false;
    for ( Int i = 0; i < StrainOpt::eNumKeywords; i ++ )
      if( ! vInitializationCheck[ i ] )
      {
        cerr << "[StrainConfig] Missing variable: \'" << StrainOpt::Keywords[i] << "\' not optional"  << endl;
        bMissingTokens = true;
      }
    
    delete [] vInitializationCheck;
    if ( bMissingTokens )
      RUNTIME_ASSERT(0, "[StrainConfig] Failed to parse Strain config file\n" );
    
    return true;
  }