All pastes #614009 Raw Edit

Jemand

public text v1 · immutable
·published 2007-07-11 09:06 UTC
rendered paste body
diff --git a/src/config.c b/src/config.c
index c162fde..bf0af34 100644
--- a/src/config.c
+++ b/src/config.c
@@ -68,7 +68,7 @@ getSectionName (void)
 }
 
 static IniDictionary*
-getConfigFile (void)
+getConfigFile (Bool createIfEmpty)
 {
     char          *fileName;
     IniDictionary *iniFile;
@@ -78,6 +78,16 @@ getConfigFile (void)
     if (!fileName)
 	return NULL;
 
+    if (!createIfEmpty)
+    {
+	FILE *fp;
+
+	fp = fopen (fileName, "r");
+	if (!fp)
+	    return NULL;
+	fclose (fp);
+    }
+
     iniFile = ccsIniOpen (fileName);
 
     free (fileName);
@@ -147,6 +157,7 @@ ccsReadGlobalConfig (ConfigOption option,
 
     *value = NULL;
     section = getSectionName();
+    printf("reading from global section %s\n", section);
     ret = ccsIniGetString (iniFile, section, entry, value);
     free (section);
     ccsIniClose (iniFile);
@@ -164,7 +175,8 @@ ccsReadConfig (ConfigOption option,
     char          *section;
     Bool          ret;
 
-    iniFile = getConfigFile();
+    iniFile = getConfigFile (FALSE);
+    printf("opening local config returned %p\n", iniFile);
     if (!iniFile)
 	return ccsReadGlobalConfig (option, value);
 
@@ -191,6 +203,7 @@ ccsReadConfig (ConfigOption option,
 
     *value = NULL;
     section = getSectionName();
+    printf("reading local section %s\n", section);
     ret = ccsIniGetString (iniFile, section, entry, value);
     free (section);
     ccsIniClose (iniFile);
@@ -215,7 +228,7 @@ ccsWriteConfig (ConfigOption option,
     if (ccsReadConfig (option, &curVal) && strcmp (value, curVal) == 0)
 	return TRUE;
 
-    iniFile = getConfigFile();
+    iniFile = getConfigFile (TRUE);
     if (!iniFile)
 	return FALSE;
 
@@ -241,6 +254,7 @@ ccsWriteConfig (ConfigOption option,
     }
 
     section = getSectionName();
+    printf("writing %s to entry %s in section %s of local file\n", value, entry, section);
     ccsIniSetString (iniFile, section, entry, value);
     free (section);