13#include "ex_fluid_config.h"
19int load_app_state(
char *state_filename ,
size_t *WIDTH ,
size_t *HEIGHT ,
bool *fullscreen ,
char **bgmusic ,
double *drawFPS ,
double *logicFPS ,
N_FLUID *fluid ,
int *threaded )
24 if( access( state_filename , F_OK ) != 0 )
26 n_log(
LOG_INFO ,
"no app state %s to load !" , state_filename );
63 n_log(
LOG_ERR,
"Unable to load config file from %s", state_filename );
68 n_log(
LOG_ERR,
"There were %d errors in %s. Check the logs !", errors, state_filename );
73 for(
int it = 0 ; it < nb ; it++ )
77 if( value ) (*WIDTH) = atoi( value );
79 if( value ) (*HEIGHT) = atoi( value );
81 if( value ) (*fullscreen) = atoi( value );
83 if( value ) (*bgmusic) = strdup( value );
85 if( value ) (*drawFPS) = strtold( value , NULL );
87 if( value ) (*logicFPS) = strtold( value , NULL );
89 if( value ) fluid -> numIters = atoi( value );
91 if( value ) fluid -> density = strtold( value , NULL );
93 if( value ) fluid -> gravity = strtold( value , NULL );
95 if( value ) fluid -> overRelaxation = strtold( value , NULL );
97 if( value ) fluid -> fluid_production_percentage = strtold( value , NULL );
99 if( value ) fluid -> cScale = strtold( value , NULL );
101 if( value ) (*threaded) = atoi( value );
#define __n_assert(__ptr, __ret)
macro to assert things
CONFIG_FILE * load_config_file(char *filename, int *errors)
load a config file
char * get_config_section_value(CONFIG_FILE *cfg_file, char *section_name, int section_position, char *entry, int entry_position)
Function to parse sections and get entries values.
int destroy_config_file(CONFIG_FILE **cfg_file)
Destroy a loaded config file.
int get_nb_config_file_sections(CONFIG_FILE *cfg_file, char *section_name)
Get the number of config file with section_name.
Structure of a config file.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
#define LOG_INFO
informational
Config file reading and writing.
fluid management port from "How to write an Eulerian fluid simulator with 200 lines of code",...
N_STR and string function declaration.