////////////////////////////////////////////////////////////////////////////////////////////////////
// read the whole ini file
////////////////////////////////////////////////////////////////////////////////////////////////////
STRING* str_file_data = "";
var _fHandle_user_config_i = NULL;
void get_user_settings(STRING* local_filename)
{
_fHandle_user_config_i = file_open_read(local_filename);
if(_fHandle_user_config_i){ //read config file
int eof = 0;
while(eof != -1){
eof = file_str_read(_fHandle_user_config_i, str_file_data);
var_for_name(str_file_data);
}
}
file_close(_fHandle_user_config_i);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// read single/predefinded variables
////////////////////////////////////////////////////////////////////////////////////////////////////
//predefinded variables
char result_chr[32];
int version_;
void read_ini(STRING* local_filename)
{
STRING* path_to_ini = "#256";
//set path
str_cpy(path_to_ini,work_dir);
str_cat(path_to_ini,"\\");
str_cat(path_to_ini,local_filename);
// section, key, default value, predefined string,size, file
GetPrivateProfileString("header", "game_name", "can't read string", result_chr, 32, _chr(path_to_ini));
// var = section, key, default value, file
version_ = GetPrivateProfileInt("header", "version", 0, _chr(path_to_ini));
}
////////////////////////////////////////////////////////////////////////////////////////////////////
// write single/predefinded variables
////////////////////////////////////////////////////////////////////////////////////////////////////
void write_ini(STRING* local_filename, STRING* section, STRING* variable)
{
STRING* path_to_ini = "#256";
STRING* variable_value = "#32";
str_cpy(path_to_ini,work_dir);
str_cat(path_to_ini,"\\");
str_cat(path_to_ini,local_filename);
str_cpy(variable_value,variable);
var_for_name(variable_value);
str_clip(variable_value,(str_len(variable)+3));
WritePrivateProfileString(section, variable, _chr(variable_value), _chr(path_to_ini));
}