Beispiel #1
0
static void print_sig_config()
{
	config_number("g^xy length", g_xy_length);
	config_key(hasher_name);
	config_number("Ni length", ni_length);
	config_number("Nr length", nr_length);
}
Beispiel #2
0
real config_real( hash_t section, hash_t key )
{
	config_key_t* key_val = config_key( section, key, false );
	if( key_val && ( key_val->type >= CONFIGVALUE_STRING_VAR ) )
		_expand_string_val( section, key_val );
	return key_val ? key_val->rval : 0;
}
Beispiel #3
0
static void print_sig_config(void)
{
	config_number("g^xy length", g_xy_length);
	config_key(prf->key);
	config_number("Ni length", ni_length);
	config_number("Nr length", nr_length);
}
Beispiel #4
0
static void print_psk_config(void)
{
	config_number("g^xy length", g_xy_length);
	config_key(hasher_name);
	config_number("Ni length", ni_length);
	config_number("Nr length", nr_length);
	config_number("pre-shared-key length", psk_length);
}
Beispiel #5
0
static void ikev2_config()
{
	config_number("g^ir length", g_ir_length);
	config_key(hasher_name);
	config_number("Ni length",ni_length);
	config_number("Nr length",nr_length);
	config_number("DKM length",dkm_length);
	config_number("Child SA DKM length",child_sa_dkm_length);
}
Beispiel #6
0
redmine::result redmine::action::config(redmine::cl::args &args,
                                        redmine::options &options) {
  if (0 == args.count()) {
    fprintf(stderr,
            "usage: redmine config <action> [args]\n"
            "actions:\n"
            "        new <name>\n"
            "        browser [<path>]\n"
            "        editor [<path>]\n"
            "        profile [<name>]\n"
            "        key [<key>]\n"
            "        url [<url>]\n"
            "        port [<port>]\n"
            "        use-ssl [true|false]\n"
            "        verify-ssl [true|false]\n");
    return FAILURE;
  }

  if (!strcmp("new", args[0])) {
    return config_new(++args, options);
  }

  if (!strcmp("browser", args[0])) {
    return config_browser(++args, options);
  }

  if (!strcmp("editor", args[0])) {
    return config_editor(++args, options);
  }

  if (!strcmp("profile", args[0])) {
    return config_profile(++args, options);
  }

  if (!strcmp("key", args[0])) {
    return config_key(++args, options);
  }

  if (!strcmp("url", args[0])) {
    return config_url(++args, options);
  }

  if (!strcmp("port", args[0])) {
    return config_port(++args, options);
  }

  if (!strcmp("use-ssl", args[0])) {
    return config_use_ssl(++args, options);
  }

  if (!strcmp("verify-ssl", args[0])) {
    return config_verify_ssl(++args, options);
  }

  fprintf(stderr, "invalid argument: %s\n", args[0]);
  return INVALID_ARGUMENT;
}
Beispiel #7
0
void on_conf_key(GtkButton *button, gpointer user_data)
{
	dialog_buttons *btn = (dialog_buttons *)user_data;
	int key = btn->index;

	if (key == -1) return;
	
	config_key(current_pad, key);
	key_tree_manager->update();
}
Beispiel #8
0
		void modify_selected()
		{
			int key, pad, keysym;
			if (get_selected(pad, key, keysym))
			{
				remove_selected();
				config_key(pad,key);
				update();
			}
		}
Beispiel #9
0
void config_set_bool( hash_t section, hash_t key, bool value )
{
	config_key_t* key_val = config_key( section, key, true );
	if( !FOUNDATION_VALIDATE( key_val ) ) return;
	key_val->bval = value;
	key_val->ival = ( value ? 1 : 0 );
	key_val->rval = ( value ? REAL_C( 1.0 ) : REAL_C( 0.0 ) );
	if( key_val->expanded != key_val->sval )
		string_deallocate( key_val->expanded );
	if( ( key_val->type != CONFIGVALUE_STRING_CONST ) && ( key_val->type != CONFIGVALUE_STRING_CONST_VAR ) )
		string_deallocate( key_val->sval );
	key_val->sval = 0;
	key_val->expanded = 0;
	key_val->type = CONFIGVALUE_BOOL;
}
Beispiel #10
0
void config_set_int( hash_t section, hash_t key, int64_t value )
{
	config_key_t* key_val = config_key( section, key, true );
	if( !FOUNDATION_VALIDATE( key_val ) ) return;
	key_val->bval = value ? true : false;
	key_val->ival = value;
	key_val->rval = (real)value;
	if( key_val->expanded != key_val->sval )
		string_deallocate( key_val->expanded );
	if( ( key_val->type != CONFIGVALUE_STRING_CONST ) && ( key_val->type != CONFIGVALUE_STRING_CONST_VAR ) )
		string_deallocate( key_val->sval );
	key_val->sval = 0;
	key_val->expanded = 0;
	key_val->type = CONFIGVALUE_INT;
}
Beispiel #11
0
void config_set_real( hash_t section, hash_t key, real value )
{
	config_key_t* key_val = config_key( section, key, true );
	if( !FOUNDATION_VALIDATE( key_val ) ) return;
	key_val->bval = !math_realzero( value );
	key_val->ival = (int64_t)value;
	key_val->rval = value;
	if( key_val->expanded != key_val->sval )
		string_deallocate( key_val->expanded );
	if( ( key_val->type != CONFIGVALUE_STRING_CONST ) && ( key_val->type != CONFIGVALUE_STRING_CONST_VAR ) )
		string_deallocate( key_val->sval );
	key_val->sval = 0;
	key_val->expanded = 0;
	key_val->type = CONFIGVALUE_REAL;
}
Beispiel #12
0
void config_set_string( hash_t section, hash_t key, const char* value )
{
	config_key_t* key_val = config_key( section, key, true );
	if( !FOUNDATION_VALIDATE( key_val ) ) return;
	if( key_val->expanded != key_val->sval )
		string_deallocate( key_val->expanded );
	if( ( key_val->type != CONFIGVALUE_STRING_CONST ) && ( key_val->type != CONFIGVALUE_STRING_CONST_VAR ) )
		string_deallocate( key_val->sval );

	key_val->sval = string_clone( value );
	key_val->expanded = 0;
	key_val->type = ( ( string_find_string( key_val->sval, "$(", 0 ) != STRING_NPOS ) ? CONFIGVALUE_STRING_VAR : CONFIGVALUE_STRING );

	if( key_val->type == CONFIGVALUE_STRING )
	{
		bool is_true = string_equal( key_val->sval, "true" );
		key_val->bval = ( string_equal( key_val->sval, "false" ) || string_equal( key_val->sval, "0" ) || !string_length( key_val->sval ) ) ? false : true;
		key_val->ival = is_true ? 1 : _config_string_to_int( key_val->sval );
		key_val->rval = is_true ? REAL_C(1.0) : _config_string_to_real( key_val->sval );
	}
}
Beispiel #13
0
void config_set_string_constant( hash_t section, hash_t key, const char* value )
{
	config_key_t* key_val = config_key( section, key, true );
	if( !FOUNDATION_VALIDATE( key_val ) ) return;
	if( !FOUNDATION_VALIDATE( value ) ) return;
	if( key_val->expanded != key_val->sval )
		string_deallocate( key_val->expanded );
	if( ( key_val->type != CONFIGVALUE_STRING_CONST ) && ( key_val->type != CONFIGVALUE_STRING_CONST_VAR ) )
		string_deallocate( key_val->sval );
	//key_val->sval = (char*)value;
	memcpy( &key_val->sval, &value, sizeof( char* ) ); //Yeah yeah, we're storing a const pointer in a non-const var
	key_val->expanded = 0;
	key_val->type = ( ( string_find_string( key_val->sval, "$(", 0 ) != STRING_NPOS ) ? CONFIGVALUE_STRING_CONST_VAR : CONFIGVALUE_STRING_CONST );

	if( key_val->type == CONFIGVALUE_STRING_CONST )
	{
		bool is_true = string_equal( key_val->sval, "true" );
		key_val->bval = ( string_equal( key_val->sval, "false" ) || string_equal( key_val->sval, "0" ) || !string_length( key_val->sval ) ) ? false : true;
		key_val->ival = is_true ? 1 : _config_string_to_int( key_val->sval );
		key_val->rval = is_true ? REAL_C(1.0) : _config_string_to_real( key_val->sval );
	}
}
Beispiel #14
0
const char* config_string( hash_t section, hash_t key )
{
	config_key_t* key_val = config_key( section, key, false );
	if( !key_val )
		return "";
	//Convert to string
	/*lint --e{788} We use default for remaining enums */
	switch( key_val->type )
	{
		case CONFIGVALUE_BOOL:  return key_val->bval ? "true" : "false";
		case CONFIGVALUE_INT:   if( !key_val->sval ) key_val->sval = string_from_int( key_val->ival, 0, 0 ); return key_val->sval;
		case CONFIGVALUE_REAL:  if( !key_val->sval ) key_val->sval = string_from_real( key_val->rval, 4, 0, '0' ); return key_val->sval;
		default: break;
	}
	//String value of some form
	if( !key_val->sval )
		return "";
	if( key_val->type >= CONFIGVALUE_STRING_VAR )
	{
		_expand_string_val( section, key_val );
		return key_val->expanded;
	}
	return key_val->sval;
}
Beispiel #15
0
void config_load(void)
{
    fs_file fh;

    if ((fh = fs_open(USER_CONFIG_FILE, "r")))
    {
        char *line, *key, *val;

        while (read_line(&line, fh))
        {
            if (scan_key_and_value(&key, &val, line))
            {
                int i;

                /* Look up an integer option by that name. */

                for (i = 0; i < ARRAYSIZE(option_d); i++)
                {
                    if (strcmp(key, option_d[i].name) == 0)
                    {
                        /* Translate some strings to integers. */

                        if (i == CONFIG_MOUSE_CAMERA_1      ||
                            i == CONFIG_MOUSE_CAMERA_2      ||
                            i == CONFIG_MOUSE_CAMERA_3      ||
                            i == CONFIG_MOUSE_CAMERA_TOGGLE ||
                            i == CONFIG_MOUSE_CAMERA_L      ||
                            i == CONFIG_MOUSE_CAMERA_R)
                        {
                            config_mouse(val, i);
                        }
                        else if (i == CONFIG_KEY_FORWARD       ||
                                 i == CONFIG_KEY_BACKWARD      ||
                                 i == CONFIG_KEY_LEFT          ||
                                 i == CONFIG_KEY_RIGHT         ||
                                 i == CONFIG_KEY_CAMERA_1      ||
                                 i == CONFIG_KEY_CAMERA_2      ||
                                 i == CONFIG_KEY_CAMERA_3      ||
                                 i == CONFIG_KEY_CAMERA_TOGGLE ||
                                 i == CONFIG_KEY_CAMERA_R      ||
                                 i == CONFIG_KEY_CAMERA_L      ||
                                 i == CONFIG_KEY_PAUSE         ||
                                 i == CONFIG_KEY_RESTART       ||
                                 i == CONFIG_KEY_SCORE_NEXT    ||
                                 i == CONFIG_KEY_ROTATE_FAST)
                        {
                            config_key(val, i);
                        }
                        else
                            config_set_d(i, atoi(val));

                        /* Stop looking. */

                        break;
                    }
                }

                /* Look up a string option by that name.*/

                for (i = 0; i < ARRAYSIZE(option_s); i++)
                {
                    if (strcmp(key, option_s[i].name) == 0)
                    {
                        config_set_s(i, val);
                        break;
                    }
                }
            }
            free(line);
        }
        fs_close(fh);

        dirty = 0;
    }
}
Beispiel #16
0
void Dialog::OnButtonClicked(wxCommandEvent &event)
{
    // Affichage d'un message à chaque clic sur le bouton
    wxButton *bt_tmp = (wxButton *)event.GetEventObject(); // get the button object
    int bt_id = bt_tmp->GetId() - wxID_HIGHEST - 1;        // get the real ID
    int gamepad_id = m_tab_gamepad->GetSelection();        // get the tab ID (equivalent to the gamepad id)
    if (bt_id >= 0 && bt_id <= PAD_R_LEFT) {               // if the button ID is a gamepad button
        bt_tmp->Disable();                                 // switch the button state to "Disable"
        config_key(gamepad_id, bt_id);
        bt_tmp->Enable();                 // switch the button state to "Enable"
    } else if (bt_id == Gamepad_config) { // If the button ID is equals to the Gamepad_config button ID
        GamepadConfiguration gamepad_config(gamepad_id, this);

        gamepad_config.InitGamepadConfiguration();
        gamepad_config.ShowModal();
    } else if (bt_id == JoyL_config) { // If the button ID is equals to the JoyL_config button ID
        JoystickConfiguration joystick_config(gamepad_id, true, this);

        joystick_config.InitJoystickConfiguration();
        joystick_config.ShowModal();
    } else if (bt_id == JoyR_config) { // If the button ID is equals to the JoyR_config button ID
        JoystickConfiguration joystick_config(gamepad_id, false, this);

        joystick_config.InitJoystickConfiguration();
        joystick_config.ShowModal();
    } else if (bt_id == Set_all) { // If the button ID is equals to the Set_all button ID
        for (int i = 0; i < MAX_KEYS; ++i) {
            bt_tmp = m_bt_gamepad[gamepad_id][i];
            switch (i) {
                case PAD_L_UP: // Left joystick (Up) ↑
                    m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_up);
                    break;
                case PAD_L_RIGHT: // Left joystick (Right) →
                    m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_right);
                    break;
                case PAD_L_DOWN: // Left joystick (Down) ↓
                    m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_bottom);
                    break;
                case PAD_L_LEFT: // Left joystick (Left) ←
                    m_pan_tabs[gamepad_id]->ShowImg(img_l_arrow_left);
                    break;
                case PAD_R_UP: // Right joystick (Up) ↑
                    m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_up);
                    break;
                case PAD_R_RIGHT: // Right joystick (Right) →
                    m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_right);
                    break;
                case PAD_R_DOWN: // Right joystick (Down) ↓
                    m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_bottom);
                    break;
                case PAD_R_LEFT: // Right joystick (Left) ←
                    m_pan_tabs[gamepad_id]->ShowImg(img_r_arrow_left);
                    break;
                default:
                    m_pan_tabs[gamepad_id]->ShowImg(i);
                    break;
            }
            m_pan_tabs[gamepad_id]->Refresh();
            m_pan_tabs[gamepad_id]->Update();
            config_key(gamepad_id, i);
            switch (i) {
                case PAD_L_UP: // Left joystick (Up) ↑
                    m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_up);
                    break;
                case PAD_L_RIGHT: // Left joystick (Right) →
                    m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_right);
                    break;
                case PAD_L_DOWN: // Left joystick (Down) ↓
                    m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_bottom);
                    break;
                case PAD_L_LEFT: // Left joystick (Left) ←
                    m_pan_tabs[gamepad_id]->HideImg(img_l_arrow_left);
                    break;
                case PAD_R_UP: // Right joystick (Up) ↑
                    m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_up);
                    break;
                case PAD_R_RIGHT: // Right joystick (Right) →
                    m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_right);
                    break;
                case PAD_R_DOWN: // Right joystick (Down) ↓
                    m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_bottom);
                    break;
                case PAD_R_LEFT: // Right joystick (Left) ←
                    m_pan_tabs[gamepad_id]->HideImg(img_r_arrow_left);
                    break;
                default:
                    m_pan_tabs[gamepad_id]->HideImg(i);
                    break;
            }
            m_pan_tabs[gamepad_id]->Refresh();
            m_pan_tabs[gamepad_id]->Update();
            usleep(500000); // give enough time to the user to release the button
        }
    } else if (bt_id == Ok) {     // If the button ID is equals to the Ok button ID
        SaveConfig();             // Save the configuration
        Close();                  // Close the window
    } else if (bt_id == Apply) {  // If the button ID is equals to the Apply button ID
        SaveConfig();             // Save the configuration
    } else if (bt_id == Cancel) { // If the button ID is equals to the cancel button ID
        Close();                  // Close the window
    }
}
Beispiel #17
0
void config_parse( stream_t* stream, hash_t filter_section, bool overwrite )
{
	char* buffer;
	hash_t section = 0;
	hash_t key = 0;
	unsigned int line = 0;

#if BUILD_ENABLE_DEBUG_CONFIG
	log_debugf( HASH_CONFIG, "Parsing config stream: %s", stream_path( stream ) );
#endif
	buffer = memory_allocate_zero( 1024ULL, 0, MEMORY_TEMPORARY );
	while( !stream_eos( stream ) )
	{
		++line;
		stream_read_line_buffer( stream, buffer, 1024, '\n' );
		string_strip( buffer, " \t\n\r" );
		if( !string_length( buffer ) || ( buffer[0] == ';' ) || ( buffer[0] == '#' ) )
			continue;
		if( buffer[0] == '[' )
		{
			//Section declaration
			unsigned int endpos = string_rfind( buffer, ']', string_length( buffer ) - 1 );
			if( ( endpos == STRING_NPOS ) || ( endpos < 1 ) )
			{
				log_warnf( HASH_CONFIG, WARNING_BAD_DATA, "Invalid section declaration on line %d in config stream '%s'", line, stream_path( stream ) );
				continue;
			}
			buffer[endpos] = 0;
			section = hash( buffer + 1, endpos - 1 );
#if BUILD_ENABLE_DEBUG_CONFIG
			log_debugf( HASH_CONFIG, "  config: section set to '%s' (0x%llx)", buffer + 1, section );
#endif
		}
		else if( !filter_section || ( filter_section == section ) )
		{
			//name=value declaration
			char* name;
			char* value;
			unsigned int separator = string_find( buffer, '=', 0 );
			if( separator == STRING_NPOS )
			{
				log_warnf( HASH_CONFIG, WARNING_BAD_DATA, "Invalid value declaration on line %d in config stream '%s', missing assignment operator '=': %s", line, stream_path( stream ), buffer );
				continue;
			}
			
			name = string_strip_substr( buffer, " \t", separator );
			value = string_strip( buffer + separator + 1, " \t" );
			if( !string_length( name ) )
			{
				log_warnf( HASH_CONFIG, WARNING_BAD_DATA, "Invalid value declaration on line %d in config stream '%s', empty name string", line, stream_path( stream ) );
				continue;
			}

			key = hash( name, string_length( name ) );

			if( overwrite || !config_key( section, key, false ) )
			{
#if BUILD_ENABLE_DEBUG_CONFIG
				log_debugf( HASH_CONFIG, "  config: %s (0x%llx) = %s", name, key, value );
#endif

				if( !string_length( value ) )
					config_set_string( section, key, "" );
				else if( string_equal( value, "false" ) )
					config_set_bool( section, key, false );
				else if( string_equal( value, "true" ) )
					config_set_bool( section, key, true );
				else if( ( string_find( value, '.', 0 ) != STRING_NPOS ) && ( string_find_first_not_of( value, "0123456789.", 0 ) == STRING_NPOS ) && ( string_find( value, '.', string_find( value, '.', 0 ) + 1 ) == STRING_NPOS ) ) //Exactly one "."
					config_set_real( section, key, string_to_real( value ) );
				else if( string_find_first_not_of( value, "0123456789", 0 ) == STRING_NPOS )
					config_set_int( section, key, string_to_int64( value ) );
				else
					config_set_string( section, key, value );
			}
		}
	}
	memory_deallocate( buffer );
}