Added SILC Thread Queue API
[crypto.git] / apps / irssi / src / fe-common / core / autorun.c
1 /*
2  autorun.c : irssi
3
4     Copyright (C) 1999-2001 Timo Sirainen
5
6     This program is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     This program is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with this program; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 */
20
21 #include "module.h"
22 #include "signals.h"
23 #include "line-split.h"
24 #include "special-vars.h"
25
26 #include "fe-windows.h"
27
28 void autorun_startup(void)
29 {
30         char tmpbuf[1024], *str, *path;
31         LINEBUF_REC *buffer = NULL;
32         int f, ret, recvlen;
33
34         /* open ~/.irssi/startup and run all commands in it */
35         path = g_strdup_printf("%s/startup", get_irssi_dir());
36         f = open(path, O_RDONLY);
37         g_free(path);
38         if (f == -1) {
39                 /* file not found */
40                 return;
41         }
42
43         do {
44                 recvlen = read(f, tmpbuf, sizeof(tmpbuf));
45
46                 ret = line_split(tmpbuf, recvlen, &str, &buffer);
47                 if (ret > 0 && *str != '#') {
48                         eval_special_string(str, "",
49                                             active_win->active_server,
50                                             active_win->active);
51                 }
52         } while (ret > 0);
53         line_split_free(buffer);
54
55         close(f);
56 }