/*...sini_file_logic:0:*/ static void ini_file_logic(const char *argv0) { const char *os_fn; if ( ini_fn != NULL ) { if ( (os_fn = get_os_fn(ini_fn)) == NULL ) fatal("bad user initialisation filename %s", ini_fn); if ( read_ini_file(os_fn) ) return; warning("can't find user initialisation file %s", os_fn); } if ( (os_fn = get_ae_fn(argv0)) == NULL ) fatal("bad default initialisation file name %s", argv0); if ( read_ini_file(os_fn) ) return; os_fn = get_ae_fn("ae"); if ( read_ini_file(os_fn) ) return; fatal("can't find default or AE's initialisation file"); }
static void read_config_file(void) { int result ; // search for existing file. // 1. look in current directory // 2. if not found, search location of executable // 3. if not found, generate default file in location of executable // printf("seek local ini=%s\n", local_ini_name) ; result = read_ini_file(local_ini_name) ; if (result == 0) { return ; } // If search for local file failed, try location of executable, // if that isn't the local directory. // If global INI filename isn't present, give up on search. // This will usually mean that we are running under WinNT 4.0, // and the executable is already in the current directory. // Just write the file in the current directory. // printf("ininame=%s\n", ininame) ; // getchar() ; if (ininame[0] == 0) { strcpy(ini_path, local_ini_name) ; } // If global INI filename IS present, try to load it else { result = read_ini_file(ininame) ; if (result == 0) { return ; } strcpy(ini_path, ininame) ; } // If we couldn't open any existing INI files, // generate default file in appropriate location. result = write_default_ini_file(ini_path) ; if (result != 0) { // perror(ini_path) ; sprintf (tempstr, "path [%s]\n", ini_path); nputs (0xA, tempstr); sprintf (tempstr, "FindFirst: %s\n", get_system_message ()); nputs (0xA, tempstr); } // try to read again, after writing defaults read_ini_file(ini_path) ; }
// Read a .ini file from FILENAME IniSetup(const char*filename) :_filename(filename) { read_ini_file(); }