summaryrefslogtreecommitdiff
path: root/src/lib-config/parse.c
diff options
context:
space:
mode:
authorEmanuele Giaquinta <exg@irssi.org>2009-01-16 17:12:27 +0000
committerexg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564>2009-01-16 17:12:27 +0000
commit4534ef242d82173755fedda1d8b233e89ed05d3f (patch)
tree250c2864fce2c434dc85b8d4ea964c790d1cc7cc /src/lib-config/parse.c
parentd993ce7b06e105aba6196ad8caeb0991d2111c01 (diff)
downloadirssi-4534ef242d82173755fedda1d8b233e89ed05d3f.zip
Use an io channel to write the config file.
git-svn-id: file:///var/www/svn.irssi.org/SVN/irssi/trunk@4990 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/lib-config/parse.c')
-rw-r--r--src/lib-config/parse.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/lib-config/parse.c b/src/lib-config/parse.c
index f0446f0a..22832c07 100644
--- a/src/lib-config/parse.c
+++ b/src/lib-config/parse.c
@@ -269,20 +269,21 @@ void config_parse_init(CONFIG_REC *rec, const char *name)
int config_parse(CONFIG_REC *rec)
{
+ int fd;
+
g_return_val_if_fail(rec != NULL, -1);
g_return_val_if_fail(rec->fname != NULL, -1);
- rec->handle = open(rec->fname, O_RDONLY);
- if (rec->handle == -1)
+ fd = open(rec->fname, O_RDONLY);
+ if (fd == -1)
return config_error(rec, g_strerror(errno));
config_parse_init(rec, rec->fname);
- g_scanner_input_file(rec->scanner, rec->handle);
+ g_scanner_input_file(rec->scanner, fd);
config_parse_loop(rec, rec->mainnode, G_TOKEN_EOF);
g_scanner_destroy(rec->scanner);
- close(rec->handle);
- rec->handle = -1;
+ close(fd);
return rec->last_error == NULL ? 0 : -1;
}
@@ -310,7 +311,6 @@ CONFIG_REC *config_open(const char *fname, int create_mode)
rec = g_new0(CONFIG_REC, 1);
rec->fname = fname == NULL ? NULL : g_strdup(fname);
- rec->handle = -1;
rec->create_mode = create_mode;
rec->mainnode = g_new0(CONFIG_NODE, 1);
rec->mainnode->type = NODE_TYPE_BLOCK;
@@ -327,7 +327,6 @@ void config_close(CONFIG_REC *rec)
config_nodes_remove_all(rec);
g_free(rec->mainnode);
- if (rec->handle != -1) close(rec->handle);
g_hash_table_foreach(rec->cache, (GHFunc) g_free, NULL);
g_hash_table_destroy(rec->cache);
g_hash_table_destroy(rec->cache_nodes);