projects
/
systembsd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
39df684
)
exit func for config, close()s and free()s
author
kremlin
<ian@kremlin.cc>
Fri, 20 Jun 2014 02:59:38 +0000
(21:59 -0500)
committer
kremlin
<ian@kremlin.cc>
Fri, 20 Jun 2014 02:59:38 +0000
(21:59 -0500)
src/config.c
patch
|
blob
|
blame
|
history
diff --git
a/src/config.c
b/src/config.c
index 5d8534614cc0bad884eb3146b89d2cb60330a205..2b5ec0610cfa1d58d0fbff659c11e562ec21d245 100644
(file)
--- a/
src/config.c
+++ b/
src/config.c
@@
-3,6
+3,7
@@
#include <gio/gio.h>
static GKeyFile *config;
#include <gio/gio.h>
static GKeyFile *config;
+static int config_descr;
static const gchar *CONFIG_KEYS[] = {
"PrettyHostname",
static const gchar *CONFIG_KEYS[] = {
"PrettyHostname",
@@
-55,7
+56,6
@@
gboolean config_init() {
return FALSE;
}
return FALSE;
}
- int config_descr;
config_descr = g_open(config_path, O_CREAT, 644);
gchar *posix_hostname;
config_descr = g_open(config_path, O_CREAT, 644);
gchar *posix_hostname;
@@
-86,10
+86,22
@@
gboolean config_init() {
if(!g_access(config_path, W_OK)) {
g_printf("%s\n", "no write permissions for /etc/! exiting..");
return FALSE;
if(!g_access(config_path, W_OK)) {
g_printf("%s\n", "no write permissions for /etc/! exiting..");
return FALSE;
- } else if(g_key_file_load_from_file(config, config_path, G_KEY_FILE_KEEP_COMMENTS, NULL))
+ } else if(g_key_file_load_from_file(config, config_path, G_KEY_FILE_KEEP_COMMENTS, NULL)) {
+ config_descr = g_open(config_path, O_RDWR, 644);
return TRUE;
return TRUE;
+ }
g_printf("could not read config at %s! exiting..", config_path);
return FALSE;
}
}
g_printf("could not read config at %s! exiting..", config_path);
return FALSE;
}
}
+
+void clean_config() {
+
+ if(config)
+ g_free(config);
+
+ if(config_descr)
+ g_close(config_descr, NULL);
+
+}