diff options
author | Emanuele Giaquinta <exg@irssi.org> | 2008-03-09 11:08:44 +0000 |
---|---|---|
committer | exg <exg@dbcabf3a-b0e7-0310-adc4-f8d773084564> | 2008-03-09 11:08:44 +0000 |
commit | a3021ccf5f41890e4204e413c76843c324752419 (patch) | |
tree | ef7db22b84be1a8195fa5a8bc2d6b0921a3cbb34 /src/fe-common/core/autorun.c | |
parent | 2b0ebef9112d1546672722d1f559cfccb867f191 (diff) | |
download | irssi-a3021ccf5f41890e4204e413c76843c324752419.zip |
Use GIOChannel API to read a file linewise.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4736 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src/fe-common/core/autorun.c')
-rw-r--r-- | src/fe-common/core/autorun.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/fe-common/core/autorun.c b/src/fe-common/core/autorun.c index f114ac23..d9b21f54 100644 --- a/src/fe-common/core/autorun.c +++ b/src/fe-common/core/autorun.c @@ -20,37 +20,36 @@ #include "module.h" #include "signals.h" -#include "line-split.h" #include "special-vars.h" #include "fe-windows.h" void autorun_startup(void) { - char tmpbuf[1024], *str, *path; - LINEBUF_REC *buffer = NULL; - int f, ret, recvlen; + char *path; + GIOChannel *handle; + GString *buf; + gsize tpos; /* open ~/.irssi/startup and run all commands in it */ path = g_strdup_printf("%s/startup", get_irssi_dir()); - f = open(path, O_RDONLY); + handle = g_io_channel_new_file(path, "r", NULL); g_free(path); - if (f == -1) { + if (handle == NULL) { /* file not found */ return; } - do { - recvlen = read(f, tmpbuf, sizeof(tmpbuf)); - - ret = line_split(tmpbuf, recvlen, &str, &buffer); - if (ret > 0 && *str != '#') { - eval_special_string(str, "", + buf = g_string_sized_new(512); + while (g_io_channel_read_line_string(handle, buf, &tpos, NULL) == G_IO_STATUS_NORMAL) { + buf->str[tpos] = '\0'; + if (buf->str[0] != '#') { + eval_special_string(buf->str, "", active_win->active_server, active_win->active); } - } while (ret > 0); - line_split_free(buffer); + } + g_string_free(buf, TRUE); - close(f); + g_io_channel_close(handle); } |