[Pommed-commits] r275 - trunk/gpomme

Julien Blache jblache at alioth.debian.org
Fri Feb 23 13:20:01 CET 2007


Author: jblache
Date: 2007-02-23 13:20:01 +0100 (Fri, 23 Feb 2007)
New Revision: 275

Modified:
   trunk/gpomme/conffile.c
   trunk/gpomme/conffile.h
Log:
Add config_write().


Modified: trunk/gpomme/conffile.c
===================================================================
--- trunk/gpomme/conffile.c	2007-02-23 11:54:43 UTC (rev 274)
+++ trunk/gpomme/conffile.c	2007-02-23 12:20:01 UTC (rev 275)
@@ -22,6 +22,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include <errno.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <pwd.h>
@@ -31,11 +32,6 @@
 #include "gpomme.h"
 #include "theme.h"
 
-/*
- * TODO
- *  - print config with cfg_print()
- */
-
 #define CONFFILE        "/.gpommerc"
 
 static cfg_opt_t cfg_opts[] =
@@ -46,6 +42,7 @@
   };
 
 
+cfg_t *cfg;
 static char *conffile;
 
 
@@ -82,7 +79,6 @@
 config_load(void)
 {
   struct passwd *pw;
-  cfg_t *cfg;
 
   int ret;
 
@@ -151,7 +147,29 @@
 	}
     }
 
-  cfg_free(cfg);
+  return 0;
+}
 
+int
+config_write(void)
+{
+  FILE *fp;
+
+  fp = fopen(conffile, "w");
+  if (fp == NULL)
+    {
+      fprintf(stderr, "Could not write to config file: %s\n", strerror(errno));
+
+      return -1;
+    }
+
+  fprintf(fp, "# gpomme config file\n");
+  fprintf(fp, "#  - theme : name of the theme to use\n");
+  fprintf(fp, "#  - timeout : time before the window hides\n\n");
+
+  cfg_print(cfg, fp);
+
+  fclose(fp);
+
   return 0;
 }

Modified: trunk/gpomme/conffile.h
===================================================================
--- trunk/gpomme/conffile.h	2007-02-23 11:54:43 UTC (rev 274)
+++ trunk/gpomme/conffile.h	2007-02-23 12:20:01 UTC (rev 275)
@@ -8,4 +8,7 @@
 int
 config_load(void);
 
+int
+config_write(void);
+
 #endif /* !__CONFFILE_H__ */




More information about the Pommed-commits mailing list