예제 #1
0
ULONG InitPrefs(STRPTR filename, BOOL use, BOOL save)
{
    D(bug("[serial prefs] InitPrefs\n"));
    mempool = CreatePool(MEMF_PUBLIC | MEMF_CLEAR, 2048, 2048);
    if (!mempool) 
    {
	ShowMsg("Out of memory!");
	return 0;
    }

    if (!LoadPrefs(filename))
    {
    	if (!DefaultPrefs())
	{
	    CleanupPrefs();
	    ShowMsg("Panic! Cannot setup default prefs!");
	    return 0;
	}
    }
    
    restore_prefs = serialprefs;
    
    if (use || save)
    {
    	SavePrefs((CONST STRPTR) CONFIGNAME_ENV);
    }
    
    if (save)
    {
    	SavePrefs((CONST STRPTR) CONFIGNAME_ENVARC);
    }
    
    if (use || save) CleanupPrefs();

    return 1;
}
예제 #2
0
//----------------------------------------------------------------------------------------------------------------------
void InitializePrefs(void)
{
FILE *Fp;
gchar Skip[30],PrefDir[MAX_FNAME_LENGTH];

DefaultPrefs(); CreateDir();
if ((Fp=fopen(".lamps_prefs","r")))
   {
   if (fscanf(Fp,"%s %s\n",Skip,PrefDir) == 2) strcpy(SetupDir,PrefDir);
   if (fscanf(Fp,"%s %s\n",Skip,PrefDir) == 2) strcpy(ListFDir,PrefDir);
   if (fscanf(Fp,"%s %s\n",Skip,PrefDir) == 2) strcpy(BanDir,PrefDir);
   if (fscanf(Fp,"%s %s\n",Skip,PrefDir) == 2) strcpy(SpecDir,PrefDir);
   if (fscanf(Fp,"%s %s\n",Skip,PrefDir) == 2) strcpy(BatDir,PrefDir);
   if (fscanf(Fp,"%s %s\n",Skip,PrefDir) == 2) strcpy(CalDir,PrefDir);
   if (fscanf(Fp,"%s %s\n",Skip,PrefDir) == 2) strcpy(LogDir,PrefDir);
   if (fscanf(Fp,"%s %s\n",Skip,PrefDir) == 2) strcpy(MacroDir,PrefDir);
   if (fscanf(Fp,"%s %d\n",Skip,&Theme1d) != 2) Theme1d=-1;                 //-1 for Random theme, see InitializeColours
   if (fscanf(Fp,"%s %d\n",Skip,&Theme2d) != 2) Theme2d=-1;                 //-1 for Random theme, see InitializeColours
   fclose(Fp);
   }
else Prefs(NULL,NULL);
CreateDir();                                                                                        //Create directories
InitializeColours();
}