-// Radiant function table
-// use to access what Radiant provides
-_QERFuncTable_1 g_FuncTable;
-_QERQglTable g_QglTable;
-
-#define CONFIG_SECTION "Configuration"
-
-#if defined( __linux__ ) || defined( __APPLE__ )
-
-static bool read_var( const char *filename, const char *section, const char *key, char *value ){
- char line[1024], *ptr;
- FILE *rc;
-
- rc = fopen( filename, "rt" );
-
- if ( rc == NULL ) {
- return false;
- }
-
- while ( fgets( line, 1024, rc ) != 0 )
- {
- // First we find the section
- if ( line[0] != '[' ) {
- continue;
- }
-
- ptr = strchr( line, ']' );
- *ptr = '\0';
-
- if ( strcmp( &line[1], section ) == 0 ) {
- while ( fgets( line, 1024, rc ) != 0 )
- {
- ptr = strchr( line, '=' );
-
- if ( ptr == NULL ) {
- // reached the end of the section
- fclose( rc );
- return false;
- }
- *ptr = '\0';
-
- if ( strcmp( line, key ) == 0 ) {
- strcpy( value, ptr + 1 );
- fclose( rc );
-
- while ( value[strlen( value ) - 1] == 10 ||
- value[strlen( value ) - 1] == 13 ||
- value[strlen( value ) - 1] == 32 )
- value[strlen( value ) - 1] = 0;
- return true;
- }
- }
- }
- }
-
- fclose( rc );
- return false;
-}
-
-static bool save_var( const char *filename, const char *section, const char *key, const char *value ){
- char line[1024], *ptr;
- FILE *old_rc = NULL, *rc;
- bool found;
-
- rc = fopen( filename, "rb" );
-
- if ( rc != NULL ) {
- guint32 len;
- void *buf;
-
- char *tmpname = g_strdup_printf( "%s.tmp", filename );
- old_rc = fopen( tmpname, "w+b" );
- g_free( tmpname );
-
- fseek( rc, 0, SEEK_END );
- len = ftell( rc );
- rewind( rc );
- buf = g_malloc( len );
- fread( buf, len, 1, rc );
- fwrite( buf, len, 1, old_rc );
- g_free( buf );
- fclose( rc );
- rewind( old_rc );
- }
-
- rc = fopen( filename, "wb" );
-
- if ( rc == NULL ) {
- return false;
- }
-
- // First we need to find the section
- found = false;
- if ( old_rc != NULL ) {
- while ( fgets( line, 1024, old_rc ) != NULL )
- {
- fputs( line, rc );
-
- if ( line[0] == '[' ) {
- ptr = strchr( line, ']' );
- *ptr = '\0';